diff options
Diffstat (limited to 'crates/ide_completion/src')
-rw-r--r-- | crates/ide_completion/src/render.rs | 13 | ||||
-rw-r--r-- | crates/ide_completion/src/render/function.rs | 26 |
2 files changed, 21 insertions, 18 deletions
diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs index f24ef7e49..d3db55c35 100644 --- a/crates/ide_completion/src/render.rs +++ b/crates/ide_completion/src/render.rs | |||
@@ -135,16 +135,17 @@ fn render_field_( | |||
135 | ctx.source_range(), | 135 | ctx.source_range(), |
136 | receiver.map_or_else(|| name.clone(), |receiver| format!("{}.{}", receiver, name)), | 136 | receiver.map_or_else(|| name.clone(), |receiver| format!("{}.{}", receiver, name)), |
137 | ); | 137 | ); |
138 | item.kind(SymbolKind::Field) | ||
139 | .detail(ty.display(ctx.db()).to_string()) | ||
140 | .set_documentation(field.docs(ctx.db())) | ||
141 | .set_deprecated(is_deprecated); | ||
142 | 138 | ||
143 | item.set_relevance(CompletionRelevance { | 139 | item.set_relevance(CompletionRelevance { |
144 | type_match: compute_type_match(ctx.completion, ty), | 140 | type_match: compute_type_match(ctx.completion, ty), |
145 | exact_name_match: compute_exact_name_match(ctx.completion, &name), | 141 | exact_name_match: compute_exact_name_match(ctx.completion, &name), |
146 | ..CompletionRelevance::default() | 142 | ..CompletionRelevance::default() |
147 | }); | 143 | }); |
144 | item.kind(SymbolKind::Field) | ||
145 | .detail(ty.display(ctx.db()).to_string()) | ||
146 | .set_documentation(field.docs(ctx.db())) | ||
147 | .set_deprecated(is_deprecated) | ||
148 | .lookup_by(name); | ||
148 | 149 | ||
149 | if let Some(_ref_match) = compute_ref_match(ctx.completion, ty) { | 150 | if let Some(_ref_match) = compute_ref_match(ctx.completion, ty) { |
150 | // FIXME | 151 | // FIXME |
@@ -167,7 +168,9 @@ fn render_tuple_field_( | |||
167 | receiver.map_or_else(|| field.to_string(), |receiver| format!("{}.{}", receiver, field)), | 168 | receiver.map_or_else(|| field.to_string(), |receiver| format!("{}.{}", receiver, field)), |
168 | ); | 169 | ); |
169 | 170 | ||
170 | item.kind(SymbolKind::Field).detail(ty.display(ctx.db()).to_string()); | 171 | item.kind(SymbolKind::Field) |
172 | .detail(ty.display(ctx.db()).to_string()) | ||
173 | .lookup_by(field.to_string()); | ||
171 | 174 | ||
172 | item.build() | 175 | item.build() |
173 | } | 176 | } |
diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs index 1abeed96d..1357b9f4a 100644 --- a/crates/ide_completion/src/render/function.rs +++ b/crates/ide_completion/src/render/function.rs | |||
@@ -58,29 +58,29 @@ impl<'a> FunctionRender<'a> { | |||
58 | Some(FunctionRender { ctx, name, receiver, func: fn_, ast_node, is_method }) | 58 | Some(FunctionRender { ctx, name, receiver, func: fn_, ast_node, is_method }) |
59 | } | 59 | } |
60 | 60 | ||
61 | fn render(mut self, import_to_add: Option<ImportEdit>) -> CompletionItem { | 61 | fn render(self, import_to_add: Option<ImportEdit>) -> CompletionItem { |
62 | let params = self.params(); | 62 | let params = self.params(); |
63 | if let Some(receiver) = &self.receiver { | 63 | let call = if let Some(receiver) = &self.receiver { |
64 | self.name = format!("{}.{}", receiver, &self.name) | 64 | format!("{}.{}", receiver, &self.name) |
65 | } | 65 | } else { |
66 | let mut item = CompletionItem::new( | 66 | self.name.clone() |
67 | CompletionKind::Reference, | 67 | }; |
68 | self.ctx.source_range(), | 68 | let mut item = |
69 | self.name.clone(), | 69 | CompletionItem::new(CompletionKind::Reference, self.ctx.source_range(), call.clone()); |
70 | ); | ||
71 | item.kind(self.kind()) | 70 | item.kind(self.kind()) |
72 | .set_documentation(self.ctx.docs(self.func)) | 71 | .set_documentation(self.ctx.docs(self.func)) |
73 | .set_deprecated( | 72 | .set_deprecated( |
74 | self.ctx.is_deprecated(self.func) || self.ctx.is_deprecated_assoc_item(self.func), | 73 | self.ctx.is_deprecated(self.func) || self.ctx.is_deprecated_assoc_item(self.func), |
75 | ) | 74 | ) |
76 | .detail(self.detail()) | 75 | .detail(self.detail()) |
77 | .add_call_parens(self.ctx.completion, self.name.clone(), params) | 76 | .add_call_parens(self.ctx.completion, call.clone(), params) |
78 | .add_import(import_to_add); | 77 | .add_import(import_to_add) |
78 | .lookup_by(self.name); | ||
79 | 79 | ||
80 | let ret_type = self.func.ret_type(self.ctx.db()); | 80 | let ret_type = self.func.ret_type(self.ctx.db()); |
81 | item.set_relevance(CompletionRelevance { | 81 | item.set_relevance(CompletionRelevance { |
82 | type_match: compute_type_match(self.ctx.completion, &ret_type), | 82 | type_match: compute_type_match(self.ctx.completion, &ret_type), |
83 | exact_name_match: compute_exact_name_match(self.ctx.completion, &self.name), | 83 | exact_name_match: compute_exact_name_match(self.ctx.completion, &call), |
84 | ..CompletionRelevance::default() | 84 | ..CompletionRelevance::default() |
85 | }); | 85 | }); |
86 | 86 | ||
@@ -263,7 +263,7 @@ fn bar(s: &S) { | |||
263 | ); | 263 | ); |
264 | 264 | ||
265 | check_edit( | 265 | check_edit( |
266 | "self.foo", | 266 | "foo", |
267 | r#" | 267 | r#" |
268 | struct S {} | 268 | struct S {} |
269 | impl S { | 269 | impl S { |