aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_completion')
-rw-r--r--crates/ide_completion/src/render.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs
index 3e1bff4d6..670563e50 100644
--- a/crates/ide_completion/src/render.rs
+++ b/crates/ide_completion/src/render.rs
@@ -118,12 +118,6 @@ impl<'a> RenderContext<'a> {
118 fn docs(&self, node: impl HasAttrs) -> Option<Documentation> { 118 fn docs(&self, node: impl HasAttrs) -> Option<Documentation> {
119 node.docs(self.db()) 119 node.docs(self.db())
120 } 120 }
121
122 // FIXME delete this method in favor of directly using the fields
123 // on CompletionContext
124 fn expected_name_and_type(&self) -> Option<(String, Type)> {
125 Some((self.completion.expected_name.clone()?, self.completion.expected_type.clone()?))
126 }
127} 121}
128 122
129/// Generic renderer for completion items. 123/// Generic renderer for completion items.
@@ -249,8 +243,8 @@ impl<'a> Render<'a> {
249 relevance.is_local = true; 243 relevance.is_local = true;
250 item.set_relevance(relevance); 244 item.set_relevance(relevance);
251 245
252 if let Some((_expected_name, expected_type)) = self.ctx.expected_name_and_type() { 246 if let Some(expected_type) = self.ctx.completion.expected_type.as_ref() {
253 if ty != expected_type { 247 if &ty != expected_type {
254 if let Some(ty_without_ref) = expected_type.remove_ref() { 248 if let Some(ty_without_ref) = expected_type.remove_ref() {
255 if relevance_type_match(self.ctx.db().upcast(), &ty, &ty_without_ref) { 249 if relevance_type_match(self.ctx.db().upcast(), &ty, &ty_without_ref) {
256 cov_mark::hit!(suggest_ref); 250 cov_mark::hit!(suggest_ref);
@@ -322,10 +316,8 @@ impl<'a> Render<'a> {
322fn compute_relevance(ctx: &RenderContext, ty: &Type, name: &str) -> CompletionRelevance { 316fn compute_relevance(ctx: &RenderContext, ty: &Type, name: &str) -> CompletionRelevance {
323 let mut res = CompletionRelevance::default(); 317 let mut res = CompletionRelevance::default();
324 318
325 if let Some((expected_name, expected_type)) = ctx.expected_name_and_type() { 319 res.exact_type_match = Some(ty) == ctx.completion.expected_type.as_ref();
326 res.exact_type_match = ty == &expected_type; 320 res.exact_name_match = Some(name) == ctx.completion.expected_name.as_deref();
327 res.exact_name_match = name == &expected_name;
328 }
329 321
330 res 322 res
331} 323}