mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-31 23:38:45 +00:00
Update crates/ide/src/references.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
parent
6001e7dfb1
commit
bd0eeb3f04
1 changed files with 4 additions and 13 deletions
|
@ -116,19 +116,10 @@ pub(crate) fn find_all_refs(
|
||||||
|
|
||||||
fn retain_import_usages(usages: &mut UsageSearchResult, sema: &Semantics<'_, RootDatabase>) {
|
fn retain_import_usages(usages: &mut UsageSearchResult, sema: &Semantics<'_, RootDatabase>) {
|
||||||
for (file_id, refs) in &mut usages.references {
|
for (file_id, refs) in &mut usages.references {
|
||||||
refs.retain(|x| {
|
refs.retain(|it| {
|
||||||
let file_sema = sema.parse(file_id.clone()).syntax().clone();
|
match if.name.as_name_ref() {
|
||||||
|
Some(name_ref) => name_ref.syntax().ancestors().any(|it| !matches(it.kind(), USE)),
|
||||||
let maybe_node = file_sema.child_or_token_at_range(x.range.clone());
|
None => true,
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue