aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_analysis/src/imp.rs6
-rw-r--r--crates/ra_editor/src/lib.rs4
2 files changed, 4 insertions, 6 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index c15873328..83a0dc445 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -207,7 +207,7 @@ impl AnalysisImpl {
207 let syntax = file.syntax(); 207 let syntax = file.syntax();
208 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { 208 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) {
209 // First try to resolve the symbol locally 209 // First try to resolve the symbol locally
210 return if let Some((name, range)) = resolve_local_name(&file, offset, name_ref) { 210 return if let Some((name, range)) = resolve_local_name(name_ref) {
211 let mut vec = vec![]; 211 let mut vec = vec![];
212 vec.push(( 212 vec.push((
213 file_id, 213 file_id,
@@ -262,7 +262,7 @@ impl AnalysisImpl {
262 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) { 262 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, offset) {
263 263
264 // We are only handing local references for now 264 // We are only handing local references for now
265 if let Some(resolved) = resolve_local_name(&file, offset, name_ref) { 265 if let Some(resolved) = resolve_local_name(name_ref) {
266 266
267 ret.push((file_id, resolved.1)); 267 ret.push((file_id, resolved.1));
268 268
@@ -270,7 +270,7 @@ impl AnalysisImpl {
270 270
271 let refs : Vec<_> = fn_def.syntax().descendants() 271 let refs : Vec<_> = fn_def.syntax().descendants()
272 .filter_map(ast::NameRef::cast) 272 .filter_map(ast::NameRef::cast)
273 .filter(|n: &ast::NameRef| resolve_local_name(&file, n.syntax().range().start(), *n) == Some(resolved.clone())) 273 .filter(|&n: &ast::NameRef| resolve_local_name(n) == Some(resolved.clone()))
274 .collect(); 274 .collect();
275 275
276 for r in refs { 276 for r in refs {
diff --git a/crates/ra_editor/src/lib.rs b/crates/ra_editor/src/lib.rs
index 417080d90..94e9a18e4 100644
--- a/crates/ra_editor/src/lib.rs
+++ b/crates/ra_editor/src/lib.rs
@@ -152,11 +152,9 @@ pub fn find_node_at_offset<'a, N: AstNode<'a>>(
152} 152}
153 153
154pub fn resolve_local_name( 154pub fn resolve_local_name(
155 file: &File,
156 offset: TextUnit,
157 name_ref: ast::NameRef, 155 name_ref: ast::NameRef,
158) -> Option<(SmolStr, TextRange)> { 156) -> Option<(SmolStr, TextRange)> {
159 let fn_def = find_node_at_offset::<ast::FnDef>(file.syntax(), offset)?; 157 let fn_def = name_ref.syntax().ancestors().find_map(ast::FnDef::cast)?;
160 let scopes = scope::FnScopes::new(fn_def); 158 let scopes = scope::FnScopes::new(fn_def);
161 let scope_entry = scope::resolve_local_name(name_ref, &scopes)?; 159 let scope_entry = scope::resolve_local_name(name_ref, &scopes)?;
162 let name = scope_entry.ast().name()?; 160 let name = scope_entry.ast().name()?;