aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/completions/trait_impl.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion/src/completions/trait_impl.rs')
-rw-r--r--crates/ide_completion/src/completions/trait_impl.rs27
1 files changed, 12 insertions, 15 deletions
diff --git a/crates/ide_completion/src/completions/trait_impl.rs b/crates/ide_completion/src/completions/trait_impl.rs
index 031f42d4a..5a7361f8e 100644
--- a/crates/ide_completion/src/completions/trait_impl.rs
+++ b/crates/ide_completion/src/completions/trait_impl.rs
@@ -145,8 +145,8 @@ fn add_function_impl(
145 format!("fn {}(..)", fn_name) 145 format!("fn {}(..)", fn_name)
146 }; 146 };
147 147
148 let mut builder = CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label); 148 let mut item = CompletionItem::new(CompletionKind::Magic, ctx.source_range(), label);
149 builder.lookup_by(fn_name).set_documentation(func.docs(ctx.db)); 149 item.lookup_by(fn_name).set_documentation(func.docs(ctx.db));
150 150
151 let completion_kind = if func.self_param(ctx.db).is_some() { 151 let completion_kind = if func.self_param(ctx.db).is_some() {
152 CompletionItemKind::Method 152 CompletionItemKind::Method
@@ -160,15 +160,15 @@ fn add_function_impl(
160 match ctx.config.snippet_cap { 160 match ctx.config.snippet_cap {
161 Some(cap) => { 161 Some(cap) => {
162 let snippet = format!("{} {{\n $0\n}}", function_decl); 162 let snippet = format!("{} {{\n $0\n}}", function_decl);
163 builder.snippet_edit(cap, TextEdit::replace(range, snippet)); 163 item.snippet_edit(cap, TextEdit::replace(range, snippet));
164 } 164 }
165 None => { 165 None => {
166 let header = format!("{} {{", function_decl); 166 let header = format!("{} {{", function_decl);
167 builder.text_edit(TextEdit::replace(range, header)); 167 item.text_edit(TextEdit::replace(range, header));
168 } 168 }
169 }; 169 };
170 builder.kind(completion_kind); 170 item.kind(completion_kind);
171 builder.add_to(acc); 171 item.add_to(acc);
172 } 172 }
173} 173}
174 174
@@ -184,14 +184,12 @@ fn add_type_alias_impl(
184 184
185 let range = TextRange::new(type_def_node.text_range().start(), ctx.source_range().end()); 185 let range = TextRange::new(type_def_node.text_range().start(), ctx.source_range().end());
186 186
187 let mut builder = 187 let mut item = CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone());
188 CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()); 188 item.text_edit(TextEdit::replace(range, snippet))
189 builder
190 .text_edit(TextEdit::replace(range, snippet))
191 .lookup_by(alias_name) 189 .lookup_by(alias_name)
192 .kind(SymbolKind::TypeAlias) 190 .kind(SymbolKind::TypeAlias)
193 .set_documentation(type_alias.docs(ctx.db)); 191 .set_documentation(type_alias.docs(ctx.db));
194 builder.add_to(acc); 192 item.add_to(acc);
195} 193}
196 194
197fn add_const_impl( 195fn add_const_impl(
@@ -209,14 +207,13 @@ fn add_const_impl(
209 let range = 207 let range =
210 TextRange::new(const_def_node.text_range().start(), ctx.source_range().end()); 208 TextRange::new(const_def_node.text_range().start(), ctx.source_range().end());
211 209
212 let mut builder = 210 let mut item =
213 CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone()); 211 CompletionItem::new(CompletionKind::Magic, ctx.source_range(), snippet.clone());
214 builder 212 item.text_edit(TextEdit::replace(range, snippet))
215 .text_edit(TextEdit::replace(range, snippet))
216 .lookup_by(const_name) 213 .lookup_by(const_name)
217 .kind(SymbolKind::Const) 214 .kind(SymbolKind::Const)
218 .set_documentation(const_.docs(ctx.db)); 215 .set_documentation(const_.docs(ctx.db));
219 builder.add_to(acc); 216 item.add_to(acc);
220 } 217 }
221 } 218 }
222} 219}