mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
pretty solition works
This commit is contained in:
parent
92d54f9b30
commit
eba54c2fc9
1 changed files with 6 additions and 24 deletions
|
@ -79,7 +79,7 @@ pub(crate) fn find_all_refs(
|
||||||
retain_adt_literal_usages(&mut usages, def, sema);
|
retain_adt_literal_usages(&mut usages, def, sema);
|
||||||
}
|
}
|
||||||
|
|
||||||
retain_import_usages(&mut usages, sema);
|
retain_import_usages(&mut usages);
|
||||||
|
|
||||||
let references = usages
|
let references = usages
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -114,33 +114,15 @@ pub(crate) fn find_all_refs(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retain_import_usages(usages: &mut UsageSearchResult, sema: &Semantics<'_, RootDatabase>) {
|
fn retain_import_usages(usages: &mut UsageSearchResult) {
|
||||||
// todo use this https://github.com/rust-lang/rust-analyzer/blob/master/crates/rust-analyzer/src/config.rs#L432
|
// todo use this https://github.com/rust-lang/rust-analyzer/blob/master/crates/rust-analyzer/src/config.rs#L432
|
||||||
|
|
||||||
for (_file_id, refs) in &mut usages.references {
|
for (_file_id, refs) in &mut usages.references {
|
||||||
refs.retain(|it| {
|
refs.retain(|it| match it.name.as_name_ref() {
|
||||||
match it.name.as_name_ref() {
|
Some(name_ref) => {
|
||||||
Some(name_ref) => name_ref.syntax().ancestors().any(|it_ref| {
|
!name_ref.syntax().ancestors().any(|it_ref| matches!(it_ref.kind(), USE))
|
||||||
dbg!(&it_ref);
|
|
||||||
!matches!(it_ref.kind(), USE)
|
|
||||||
}),
|
|
||||||
None => true,
|
|
||||||
}
|
}
|
||||||
|
None => true,
|
||||||
// this works:
|
|
||||||
// let file_sema = sema.parse(file_id.clone()).syntax().clone();
|
|
||||||
|
|
||||||
// let maybe_node = file_sema.child_or_token_at_range(it.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
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue