mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
completions: centralize calculation of relevance and ref matches
This commit is contained in:
parent
c0a2b4e826
commit
405bbb3aa4
3 changed files with 174 additions and 52 deletions
|
@ -6,7 +6,8 @@ use itertools::Itertools;
|
|||
|
||||
use crate::{
|
||||
item::{CompletionItem, CompletionKind, ImportEdit},
|
||||
render::{builder_ext::Params, RenderContext},
|
||||
render::{builder_ext::Params, compute_exact_type_match, compute_ref_match, RenderContext},
|
||||
CompletionRelevance,
|
||||
};
|
||||
|
||||
pub(crate) fn render_variant<'a>(
|
||||
|
@ -74,6 +75,16 @@ impl<'a> EnumRender<'a> {
|
|||
item.lookup_by(self.short_qualified_name);
|
||||
}
|
||||
|
||||
let ty = self.variant.parent_enum(self.ctx.completion.db).ty(self.ctx.completion.db);
|
||||
item.set_relevance(CompletionRelevance {
|
||||
exact_type_match: compute_exact_type_match(self.ctx.completion, &ty),
|
||||
..CompletionRelevance::default()
|
||||
});
|
||||
|
||||
if let Some(ref_match) = compute_ref_match(self.ctx.completion, &ty) {
|
||||
item.ref_match(ref_match);
|
||||
}
|
||||
|
||||
item.build()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue