diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-26 16:29:20 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-26 16:29:20 +0000 |
commit | 4ecaad98e074c42dbf637a11afcb630aafffd7b3 (patch) | |
tree | 50832b85e65752b040affcc8d34dc5cd8c2625b9 /crates/ide_completion/src/render | |
parent | 20e32fc946010f8c46728d6cb8bab1b96b3f48b9 (diff) | |
parent | 0e31ae2cef92f973a6ee3def3f1feaa94dcb7a4f (diff) |
Merge #8056
8056: completion relevance consider if types can be unified r=JoshMcguigan a=JoshMcguigan
This PR improves completion relevance scoring for generic types, in cases where the types could unify.
### Before

### After

changelog feature improve completions
Co-authored-by: Josh Mcguigan <[email protected]>
Diffstat (limited to 'crates/ide_completion/src/render')
-rw-r--r-- | crates/ide_completion/src/render/enum_variant.rs | 4 | ||||
-rw-r--r-- | crates/ide_completion/src/render/function.rs | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/crates/ide_completion/src/render/enum_variant.rs b/crates/ide_completion/src/render/enum_variant.rs index 374247b05..832f5ced1 100644 --- a/crates/ide_completion/src/render/enum_variant.rs +++ b/crates/ide_completion/src/render/enum_variant.rs | |||
@@ -6,7 +6,7 @@ use itertools::Itertools; | |||
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | item::{CompletionItem, CompletionKind, ImportEdit}, | 8 | item::{CompletionItem, CompletionKind, ImportEdit}, |
9 | render::{builder_ext::Params, compute_exact_type_match, compute_ref_match, RenderContext}, | 9 | render::{builder_ext::Params, compute_ref_match, compute_type_match, RenderContext}, |
10 | CompletionRelevance, | 10 | CompletionRelevance, |
11 | }; | 11 | }; |
12 | 12 | ||
@@ -77,7 +77,7 @@ impl<'a> EnumRender<'a> { | |||
77 | 77 | ||
78 | let ty = self.variant.parent_enum(self.ctx.completion.db).ty(self.ctx.completion.db); | 78 | let ty = self.variant.parent_enum(self.ctx.completion.db).ty(self.ctx.completion.db); |
79 | item.set_relevance(CompletionRelevance { | 79 | item.set_relevance(CompletionRelevance { |
80 | exact_type_match: compute_exact_type_match(self.ctx.completion, &ty), | 80 | type_match: compute_type_match(self.ctx.completion, &ty), |
81 | ..CompletionRelevance::default() | 81 | ..CompletionRelevance::default() |
82 | }); | 82 | }); |
83 | 83 | ||
diff --git a/crates/ide_completion/src/render/function.rs b/crates/ide_completion/src/render/function.rs index b1eba20e8..d681e2c91 100644 --- a/crates/ide_completion/src/render/function.rs +++ b/crates/ide_completion/src/render/function.rs | |||
@@ -8,7 +8,7 @@ use syntax::ast::Fn; | |||
8 | use crate::{ | 8 | use crate::{ |
9 | item::{CompletionItem, CompletionItemKind, CompletionKind, CompletionRelevance, ImportEdit}, | 9 | item::{CompletionItem, CompletionItemKind, CompletionKind, CompletionRelevance, ImportEdit}, |
10 | render::{ | 10 | render::{ |
11 | builder_ext::Params, compute_exact_name_match, compute_exact_type_match, compute_ref_match, | 11 | builder_ext::Params, compute_exact_name_match, compute_ref_match, compute_type_match, |
12 | RenderContext, | 12 | RenderContext, |
13 | }, | 13 | }, |
14 | }; | 14 | }; |
@@ -73,7 +73,7 @@ impl<'a> FunctionRender<'a> { | |||
73 | 73 | ||
74 | let ret_type = self.func.ret_type(self.ctx.db()); | 74 | let ret_type = self.func.ret_type(self.ctx.db()); |
75 | item.set_relevance(CompletionRelevance { | 75 | item.set_relevance(CompletionRelevance { |
76 | exact_type_match: compute_exact_type_match(self.ctx.completion, &ret_type), | 76 | type_match: compute_type_match(self.ctx.completion, &ret_type), |
77 | exact_name_match: compute_exact_name_match(self.ctx.completion, self.name.clone()), | 77 | exact_name_match: compute_exact_name_match(self.ctx.completion, self.name.clone()), |
78 | ..CompletionRelevance::default() | 78 | ..CompletionRelevance::default() |
79 | }); | 79 | }); |