aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/completion/src/completions/trait_impl.rs49
1 files changed, 26 insertions, 23 deletions
diff --git a/crates/completion/src/completions/trait_impl.rs b/crates/completion/src/completions/trait_impl.rs
index 43b3d939f..54bb897e9 100644
--- a/crates/completion/src/completions/trait_impl.rs
+++ b/crates/completion/src/completions/trait_impl.rs
@@ -156,20 +156,21 @@ fn add_function_impl(
156 }; 156 };
157 let range = TextRange::new(fn_def_node.text_range().start(), ctx.source_range().end()); 157 let range = TextRange::new(fn_def_node.text_range().start(), ctx.source_range().end());
158 158
159 #[allow(deprecated)] 159 if let Some(src) = func.source(ctx.db) {
160 let function_decl = function_declaration(&func.source_old(ctx.db).value); 160 let function_decl = function_declaration(&src.value);
161 match ctx.config.snippet_cap { 161 match ctx.config.snippet_cap {
162 Some(cap) => { 162 Some(cap) => {
163 let snippet = format!("{} {{\n $0\n}}", function_decl); 163 let snippet = format!("{} {{\n $0\n}}", function_decl);
164 builder.snippet_edit(cap, TextEdit::replace(range, snippet)) 164 builder.snippet_edit(cap, TextEdit::replace(range, snippet))
165 } 165 }
166 None => { 166 None => {
167 let header = format!("{} {{", function_decl); 167 let header = format!("{} {{", function_decl);
168 builder.text_edit(TextEdit::replace(range, header)) 168 builder.text_edit(TextEdit::replace(range, header))
169 }
169 } 170 }
171 .kind(completion_kind)
172 .add_to(acc);
170 } 173 }
171 .kind(completion_kind)
172 .add_to(acc);
173} 174}
174 175
175fn add_type_alias_impl( 176fn add_type_alias_impl(
@@ -201,17 +202,19 @@ fn add_const_impl(
201 let const_name = const_.name(ctx.db).map(|n| n.to_string()); 202 let const_name = const_.name(ctx.db).map(|n| n.to_string());
202 203
203 if let Some(const_name) = const_name { 204 if let Some(const_name) = const_name {
204 #[allow(deprecated)] 205 if let Some(source) = const_.source(ctx.db) {
205 let snippet = make_const_compl_syntax(&const_.source_old(ctx.db).value); 206 let snippet = make_const_compl_syntax(&source.value);
206 207
207 let range = TextRange::new(const_def_node.text_range().start(), ctx.source_range().end()); 208 let range =
208 209 TextRange::new(const_def_node.text_range().start(), ctx.source_range().end());
209 CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()) 210
210 .text_edit(TextEdit::replace(range, snippet)) 211 CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone())
211 .lookup_by(const_name) 212 .text_edit(TextEdit::replace(range, snippet))
212 .kind(CompletionItemKind::Const) 213 .lookup_by(const_name)
213 .set_documentation(const_.docs(ctx.db)) 214 .kind(CompletionItemKind::Const)
214 .add_to(acc); 215 .set_documentation(const_.docs(ctx.db))
216 .add_to(acc);
217 }
215 } 218 }
216} 219}
217 220