Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit bd0eeb3

Browse files
enomadoVeykril
andauthored
Update crates/ide/src/references.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
1 parent 6001e7d commit bd0eeb3

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

crates/ide/src/references.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,10 @@ pub(crate) fn find_all_refs(
116116

117117
fn retain_import_usages(usages: &mut UsageSearchResult, sema: &Semantics<'_, RootDatabase>) {
118118
for (file_id, refs) in &mut usages.references {
119-
refs.retain(|x| {
120-
let file_sema = sema.parse(file_id.clone()).syntax().clone();
121-
122-
let maybe_node = file_sema.child_or_token_at_range(x.range.clone());
123-
124-
if let Some(node) = maybe_node {
125-
let res = match node {
126-
syntax::NodeOrToken::Node(x) => !matches!(x.kind(), USE),
127-
syntax::NodeOrToken::Token(_) => true,
128-
};
129-
res
130-
} else {
131-
true
119+
refs.retain(|it| {
120+
match if.name.as_name_ref() {
121+
Some(name_ref) => name_ref.syntax().ancestors().any(|it| !matches(it.kind(), USE)),
122+
None => true,
132123
}
133124
});
134125
}

0 commit comments

Comments
 (0)