From bd0eeb3f041cc57dad3ac40ed6cfcc08f1055638 Mon Sep 17 00:00:00 2001 From: Stanislav Date: Wed, 7 Sep 2022 03:01:06 +0300 Subject: [PATCH] Update crates/ide/src/references.rs Co-authored-by: Lukas Wirth --- crates/ide/src/references.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index 53a7a3a217..d4c431f75f 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs @@ -116,19 +116,10 @@ pub(crate) fn find_all_refs( fn retain_import_usages(usages: &mut UsageSearchResult, sema: &Semantics<'_, RootDatabase>) { for (file_id, refs) in &mut usages.references { - refs.retain(|x| { - let file_sema = sema.parse(file_id.clone()).syntax().clone(); - - let maybe_node = file_sema.child_or_token_at_range(x.range.clone()); - - if let Some(node) = maybe_node { - let res = match node { - syntax::NodeOrToken::Node(x) => !matches!(x.kind(), USE), - syntax::NodeOrToken::Token(_) => true, - }; - res - } else { - true + refs.retain(|it| { + match if.name.as_name_ref() { + Some(name_ref) => name_ref.syntax().ancestors().any(|it| !matches(it.kind(), USE)), + None => true, } }); }