diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-15 13:42:12 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-15 13:42:12 +0000 |
commit | 3962b0d53c8da6e3f95f54395d266cb99562bd47 (patch) | |
tree | f2330e5ffdc8206b7a08e2f74fc204f78363dabf /crates/ide_completion | |
parent | b245e8d115ef63673bd475a56be96ed654aaa4d7 (diff) | |
parent | 67d59aeb7cc442ce629dbd3976f57000fa73df51 (diff) |
Merge #8027
8027: Completion context remove exact match method in favor of fields r=JoshMcguigan a=JoshMcguigan
This is a minor cleanup PR following #8008. It removes the `expected_name_and_type` method on completion context in favor of using the fields.
I thought this method was used in more places, or else it may have just made sense to make this change directly in #8008 :shrug:
Co-authored-by: Josh Mcguigan <[email protected]>
Diffstat (limited to 'crates/ide_completion')
-rw-r--r-- | crates/ide_completion/src/render.rs | 16 |
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> { | |||
322 | fn compute_relevance(ctx: &RenderContext, ty: &Type, name: &str) -> CompletionRelevance { | 316 | fn 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 | } |