mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-16 23:24:03 +00:00
typo and draft
This commit is contained in:
parent
bd0eeb3f04
commit
92d54f9b30
1 changed files with 23 additions and 3 deletions
|
@ -115,12 +115,32 @@ 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 {
|
// 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 {
|
||||||
refs.retain(|it| {
|
refs.retain(|it| {
|
||||||
match if.name.as_name_ref() {
|
match it.name.as_name_ref() {
|
||||||
Some(name_ref) => name_ref.syntax().ancestors().any(|it| !matches(it.kind(), USE)),
|
Some(name_ref) => name_ref.syntax().ancestors().any(|it_ref| {
|
||||||
|
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…
Reference in a new issue