This commit is contained in:
Aleksey Kladov 2018-10-24 16:36:28 +03:00
parent 44c8ddf885
commit 8ada1a2689
2 changed files with 4 additions and 6 deletions

View file

@ -152,11 +152,9 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>(
}
pub fn resolve_local_name(
file: &File,
offset: TextUnit,
name_ref: ast::NameRef,
) -> Option<(SmolStr, TextRange)> {
let fn_def = find_node_at_offset::<ast::FnDef>(file.syntax(), offset)?;
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()?;