aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_editor/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_editor/src/lib.rs')
-rw-r--r--crates/ra_editor/src/lib.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs
index fcb3e12e6..2a801f7da 100644
--- a/crates/ra_editor/src/lib.rs
+++ b/crates/ra_editor/src/lib.rs
@@ -19,7 +19,7 @@ mod scope;
19mod test_utils; 19mod test_utils;
20 20
21use ra_syntax::{ 21use ra_syntax::{
22 File, TextUnit, TextRange, SyntaxNodeRef, 22 File, TextUnit, TextRange, SmolStr, SyntaxNodeRef,
23 ast::{self, AstNode, NameOwner}, 23 ast::{self, AstNode, NameOwner},
24 algo::find_leaf_at_offset, 24 algo::find_leaf_at_offset,
25 SyntaxKind::{self, *}, 25 SyntaxKind::{self, *},
@@ -164,12 +164,12 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>(
164 .next() 164 .next()
165} 165}
166 166
167pub fn resolve_local_name<'a>(file: &'a File, offset: TextUnit, name_ref: ast::NameRef) -> Option<ast::Name<'a>> { 167pub fn resolve_local_name(file: &File, offset: TextUnit, name_ref: ast::NameRef) -> Option<(SmolStr, TextRange)> {
168 let fn_def = find_node_at_offset::<ast::FnDef>(file.syntax(), offset)?; 168 let fn_def = find_node_at_offset::<ast::FnDef>(file.syntax(), offset)?;
169 let scopes = scope::FnScopes::new(fn_def); 169 let scopes = scope::FnScopes::new(fn_def);
170 170 let scope_entry = scope::resolve_local_name(name_ref, &scopes)?;
171 // TODO: This doesn't work because of scopes lifetime 171 let name = scope_entry.ast().name()?;
172 scope::resolve_local_name(name_ref, &scopes) 172 Some((scope_entry.name(), name.syntax().range()))
173} 173}
174 174
175#[cfg(test)] 175#[cfg(test)]