mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Simplify event processing
This commit is contained in:
parent
3c12d38a32
commit
86a7ac2d31
6 changed files with 128 additions and 104 deletions
|
@ -245,11 +245,13 @@ pub fn resolve_local_name<'a>(name_ref: ast::NameRef, scopes: &'a FnScopes) -> O
|
|||
use std::collections::HashSet;
|
||||
|
||||
let mut shadowed = HashSet::new();
|
||||
scopes.scope_chain(name_ref.syntax())
|
||||
let ret = scopes.scope_chain(name_ref.syntax())
|
||||
.flat_map(|scope| scopes.entries(scope).iter())
|
||||
.filter(|entry| shadowed.insert(entry.name()))
|
||||
.filter(|entry| entry.name() == name_ref.text())
|
||||
.nth(0)
|
||||
.nth(0);
|
||||
eprintln!("ret = {:?}", ret);
|
||||
ret
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -357,7 +359,6 @@ mod tests {
|
|||
let scopes = FnScopes::new(fn_def);
|
||||
|
||||
let local_name = resolve_local_name(name_ref, &scopes).unwrap().ast().name().unwrap();
|
||||
|
||||
let expected_name = find_node_at_offset::<ast::Name>(file.syntax(), expected_offset.into()).unwrap();
|
||||
assert_eq!(local_name.syntax().range(), expected_name.syntax().range());
|
||||
}
|
||||
|
@ -394,4 +395,4 @@ mod tests {
|
|||
}",
|
||||
46);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue