mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
move resolve local name
This commit is contained in:
parent
b67295134b
commit
c02be1502c
7 changed files with 31 additions and 94 deletions
|
@ -151,15 +151,7 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>(
|
|||
leaf.ancestors().filter_map(N::cast).next()
|
||||
}
|
||||
|
||||
pub fn resolve_local_name(
|
||||
name_ref: ast::NameRef,
|
||||
) -> Option<(SmolStr, TextRange)> {
|
||||
let fn_def = name_ref.syntax().ancestors().find_map(ast::FnDef::cast)?;
|
||||
let scopes = scope::FnScopes::new(fn_def);
|
||||
let scope_entry = scope::resolve_local_name(name_ref, &scopes)?;
|
||||
let name = scope_entry.ast().name()?;
|
||||
Some((scope_entry.name(), name.syntax().range()))
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue