aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/render/enum_variant.rs
diff options
context:
space:
mode:
authorJosh Mcguigan <[email protected]>2021-03-16 02:26:59 +0000
committerJosh Mcguigan <[email protected]>2021-03-16 02:40:42 +0000
commit405bbb3aa46ecbfa5124969739695565d9841b9c (patch)
treed72f4691d4ebb199953fa2ffb52ed3a8b1501a73 /crates/ide_completion/src/render/enum_variant.rs
parentc0a2b4e826e1da20d3cfa8c279fcdffa24f32a7d (diff)
completions: centralize calculation of relevance and ref matches
Diffstat (limited to 'crates/ide_completion/src/render/enum_variant.rs')
-rw-r--r--crates/ide_completion/src/render/enum_variant.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/ide_completion/src/render/enum_variant.rs b/crates/ide_completion/src/render/enum_variant.rs
index e8cfcc0c7..374247b05 100644
--- a/crates/ide_completion/src/render/enum_variant.rs
+++ b/crates/ide_completion/src/render/enum_variant.rs
@@ -6,7 +6,8 @@ use itertools::Itertools;
6 6
7use crate::{ 7use crate::{
8 item::{CompletionItem, CompletionKind, ImportEdit}, 8 item::{CompletionItem, CompletionKind, ImportEdit},
9 render::{builder_ext::Params, RenderContext}, 9 render::{builder_ext::Params, compute_exact_type_match, compute_ref_match, RenderContext},
10 CompletionRelevance,
10}; 11};
11 12
12pub(crate) fn render_variant<'a>( 13pub(crate) fn render_variant<'a>(
@@ -74,6 +75,16 @@ impl<'a> EnumRender<'a> {
74 item.lookup_by(self.short_qualified_name); 75 item.lookup_by(self.short_qualified_name);
75 } 76 }
76 77
78 let ty = self.variant.parent_enum(self.ctx.completion.db).ty(self.ctx.completion.db);
79 item.set_relevance(CompletionRelevance {
80 exact_type_match: compute_exact_type_match(self.ctx.completion, &ty),
81 ..CompletionRelevance::default()
82 });
83
84 if let Some(ref_match) = compute_ref_match(self.ctx.completion, &ty) {
85 item.ref_match(ref_match);
86 }
87
77 item.build() 88 item.build()
78 } 89 }
79 90