From 444d67ae1802d2832b3bcdc0ff593b014477b37b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 9 Mar 2021 17:42:05 +0300 Subject: Cleanup --- crates/ide_completion/src/item.rs | 7 ++----- crates/ide_completion/src/render.rs | 8 +++++--- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/ide_completion') diff --git a/crates/ide_completion/src/item.rs b/crates/ide_completion/src/item.rs index 9b039e3e5..b6bc11da2 100644 --- a/crates/ide_completion/src/item.rs +++ b/crates/ide_completion/src/item.rs @@ -430,11 +430,8 @@ impl Builder { self.import_to_add = import_to_add; self } - pub(crate) fn set_ref_match( - mut self, - ref_match: Option<(Mutability, CompletionScore)>, - ) -> Builder { - self.ref_match = ref_match; + pub(crate) fn ref_match(mut self, ref_match: (Mutability, CompletionScore)) -> Builder { + self.ref_match = Some(ref_match); self } } diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs index fae5685e2..0a6ac8804 100644 --- a/crates/ide_completion/src/render.rs +++ b/crates/ide_completion/src/render.rs @@ -246,7 +246,6 @@ impl<'a> Render<'a> { } }; - let mut ref_match = None; if let ScopeDef::Local(local) = resolution { if let Some((active_name, active_type)) = self.ctx.active_name_and_type() { let ty = local.ty(self.ctx.db()); @@ -255,7 +254,11 @@ impl<'a> Render<'a> { { item = item.set_score(score); } - ref_match = refed_type_matches(&active_type, &active_name, &ty, &local_name); + if let Some(ref_match) = + refed_type_matches(&active_type, &active_name, &ty, &local_name) + { + item = item.ref_match(ref_match); + } } } @@ -285,7 +288,6 @@ impl<'a> Render<'a> { Some( item.kind(kind) .add_import(import_to_add) - .set_ref_match(ref_match) .set_documentation(self.docs(resolution)) .set_deprecated(self.is_deprecated(resolution)) .build(), -- cgit v1.2.3 From abc0ed36bdf4975dc9c5fb2ddd3f960ad2db5494 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 9 Mar 2021 17:44:27 +0300 Subject: Cleanup --- crates/ide_completion/src/item.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ide_completion') diff --git a/crates/ide_completion/src/item.rs b/crates/ide_completion/src/item.rs index b6bc11da2..b16f0775a 100644 --- a/crates/ide_completion/src/item.rs +++ b/crates/ide_completion/src/item.rs @@ -208,7 +208,7 @@ impl CompletionItem { lookup: None, kind: None, text_edit: None, - deprecated: None, + deprecated: false, trigger_call_info: None, score: None, ref_match: None, @@ -308,7 +308,7 @@ pub(crate) struct Builder { lookup: Option, kind: Option, text_edit: Option, - deprecated: Option, + deprecated: bool, trigger_call_info: Option, score: Option, ref_match: Option<(Mutability, CompletionScore)>, @@ -355,7 +355,7 @@ impl Builder { lookup, kind: self.kind, completion_kind: self.completion_kind, - deprecated: self.deprecated.unwrap_or(false), + deprecated: self.deprecated, trigger_call_info: self.trigger_call_info.unwrap_or(false), score: self.score, ref_match: self.ref_match, @@ -415,7 +415,7 @@ impl Builder { self } pub(crate) fn set_deprecated(mut self, deprecated: bool) -> Builder { - self.deprecated = Some(deprecated); + self.deprecated = deprecated; self } pub(crate) fn set_score(mut self, score: CompletionScore) -> Builder { -- cgit v1.2.3