Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-completion/src/item.rs')
-rw-r--r--crates/ide-completion/src/item.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/ide-completion/src/item.rs b/crates/ide-completion/src/item.rs
index 4774fe9db7..2b10dccb80 100644
--- a/crates/ide-completion/src/item.rs
+++ b/crates/ide-completion/src/item.rs
@@ -6,7 +6,7 @@ use hir::{Documentation, Mutability};
use ide_db::{imports::import_assets::LocatedImport, SnippetCap, SymbolKind};
use smallvec::SmallVec;
use stdx::{impl_from, never};
-use syntax::{SmolStr, TextRange};
+use syntax::{SmolStr, TextRange, TextSize};
use text_edit::TextEdit;
use crate::{
@@ -68,7 +68,7 @@ pub struct CompletionItem {
/// Indicates that a reference or mutable reference to this variable is a
/// possible match.
- ref_match: Option<Mutability>,
+ ref_match: Option<(Mutability, TextSize)>,
/// The import data to add to completion's edits.
import_to_add: SmallVec<[LocatedImport; 1]>,
@@ -104,8 +104,8 @@ impl fmt::Debug for CompletionItem {
s.field("relevance", &self.relevance);
}
- if let Some(mutability) = &self.ref_match {
- s.field("ref_match", &format!("&{}", mutability.as_keyword_for_ref()));
+ if let Some((mutability, offset)) = &self.ref_match {
+ s.field("ref_match", &format!("&{}@{offset:?}", mutability.as_keyword_for_ref()));
}
if self.trigger_call_info {
s.field("trigger_call_info", &true);
@@ -395,14 +395,14 @@ impl CompletionItem {
self.trigger_call_info
}
- pub fn ref_match(&self) -> Option<(Mutability, CompletionRelevance)> {
+ pub fn ref_match(&self) -> Option<(Mutability, TextSize, CompletionRelevance)> {
// Relevance of the ref match should be the same as the original
// match, but with exact type match set because self.ref_match
// is only set if there is an exact type match.
let mut relevance = self.relevance;
relevance.type_match = Some(CompletionRelevanceTypeMatch::Exact);
- self.ref_match.map(|mutability| (mutability, relevance))
+ self.ref_match.map(|(mutability, offset)| (mutability, offset, relevance))
}
pub fn imports_to_add(&self) -> &[LocatedImport] {
@@ -428,7 +428,7 @@ pub(crate) struct Builder {
deprecated: bool,
trigger_call_info: bool,
relevance: CompletionRelevance,
- ref_match: Option<Mutability>,
+ ref_match: Option<(Mutability, TextSize)>,
}
impl Builder {
@@ -548,8 +548,8 @@ impl Builder {
self.imports_to_add.push(import_to_add);
self
}
- pub(crate) fn ref_match(&mut self, mutability: Mutability) -> &mut Builder {
- self.ref_match = Some(mutability);
+ pub(crate) fn ref_match(&mut self, mutability: Mutability, offset: TextSize) -> &mut Builder {
+ self.ref_match = Some((mutability, offset));
self
}
}