Remove unnecessary special local handling in search
This commit is contained in:
parent
38e9a110d4
commit
e158dc7246
@ -319,10 +319,6 @@ impl Definition {
|
|||||||
sema,
|
sema,
|
||||||
scope: None,
|
scope: None,
|
||||||
include_self_kw_refs: None,
|
include_self_kw_refs: None,
|
||||||
local_repr: match self {
|
|
||||||
Definition::Local(local) => Some(local),
|
|
||||||
_ => None,
|
|
||||||
},
|
|
||||||
search_self_mod: false,
|
search_self_mod: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -337,9 +333,6 @@ pub struct FindUsages<'a> {
|
|||||||
assoc_item_container: Option<hir::AssocItemContainer>,
|
assoc_item_container: Option<hir::AssocItemContainer>,
|
||||||
/// whether to search for the `Self` type of the definition
|
/// whether to search for the `Self` type of the definition
|
||||||
include_self_kw_refs: Option<hir::Type>,
|
include_self_kw_refs: Option<hir::Type>,
|
||||||
/// the local representative for the local definition we are searching for
|
|
||||||
/// (this is required for finding all local declarations in a or-pattern)
|
|
||||||
local_repr: Option<hir::Local>,
|
|
||||||
/// whether to search for the `self` module
|
/// whether to search for the `self` module
|
||||||
search_self_mod: bool,
|
search_self_mod: bool,
|
||||||
}
|
}
|
||||||
@ -644,19 +637,6 @@ impl<'a> FindUsages<'a> {
|
|||||||
sink: &mut dyn FnMut(FileId, FileReference) -> bool,
|
sink: &mut dyn FnMut(FileId, FileReference) -> bool,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match NameRefClass::classify(self.sema, name_ref) {
|
match NameRefClass::classify(self.sema, name_ref) {
|
||||||
Some(NameRefClass::Definition(def @ Definition::Local(local)))
|
|
||||||
if matches!(
|
|
||||||
self.local_repr, Some(repr) if repr == local
|
|
||||||
) =>
|
|
||||||
{
|
|
||||||
let FileRange { file_id, range } = self.sema.original_range(name_ref.syntax());
|
|
||||||
let reference = FileReference {
|
|
||||||
range,
|
|
||||||
name: ast::NameLike::NameRef(name_ref.clone()),
|
|
||||||
category: ReferenceCategory::new(&def, name_ref),
|
|
||||||
};
|
|
||||||
sink(file_id, reference)
|
|
||||||
}
|
|
||||||
Some(NameRefClass::Definition(def))
|
Some(NameRefClass::Definition(def))
|
||||||
if self.def == def
|
if self.def == def
|
||||||
// is our def a trait assoc item? then we want to find all assoc items from trait impls of our trait
|
// is our def a trait assoc item? then we want to find all assoc items from trait impls of our trait
|
||||||
@ -701,14 +681,16 @@ impl<'a> FindUsages<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(NameRefClass::FieldShorthand { local_ref: local, field_ref: field }) => {
|
Some(NameRefClass::FieldShorthand { local_ref: local, field_ref: field }) => {
|
||||||
let field = Definition::Field(field);
|
|
||||||
let FileRange { file_id, range } = self.sema.original_range(name_ref.syntax());
|
let FileRange { file_id, range } = self.sema.original_range(name_ref.syntax());
|
||||||
|
|
||||||
|
let field = Definition::Field(field);
|
||||||
|
let local = Definition::Local(local);
|
||||||
let access = match self.def {
|
let access = match self.def {
|
||||||
Definition::Field(_) if field == self.def => {
|
Definition::Field(_) if field == self.def => {
|
||||||
ReferenceCategory::new(&field, name_ref)
|
ReferenceCategory::new(&field, name_ref)
|
||||||
}
|
}
|
||||||
Definition::Local(_) if matches!(self.local_repr, Some(repr) if repr == local) => {
|
Definition::Local(_) if local == self.def => {
|
||||||
ReferenceCategory::new(&Definition::Local(local), name_ref)
|
ReferenceCategory::new(&local, name_ref)
|
||||||
}
|
}
|
||||||
_ => return false,
|
_ => return false,
|
||||||
};
|
};
|
||||||
@ -752,21 +734,6 @@ impl<'a> FindUsages<'a> {
|
|||||||
};
|
};
|
||||||
sink(file_id, reference)
|
sink(file_id, reference)
|
||||||
}
|
}
|
||||||
Some(NameClass::Definition(def @ Definition::Local(local))) if def != self.def => {
|
|
||||||
if matches!(
|
|
||||||
self.local_repr,
|
|
||||||
Some(repr) if local == repr
|
|
||||||
) {
|
|
||||||
let FileRange { file_id, range } = self.sema.original_range(name.syntax());
|
|
||||||
let reference = FileReference {
|
|
||||||
range,
|
|
||||||
name: ast::NameLike::Name(name.clone()),
|
|
||||||
category: None,
|
|
||||||
};
|
|
||||||
return sink(file_id, reference);
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
Some(NameClass::Definition(def)) if def != self.def => {
|
Some(NameClass::Definition(def)) if def != self.def => {
|
||||||
match (&self.assoc_item_container, self.def) {
|
match (&self.assoc_item_container, self.def) {
|
||||||
// for type aliases we always want to reference the trait def and all the trait impl counterparts
|
// for type aliases we always want to reference the trait def and all the trait impl counterparts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user