From 1d4c767879913271bf01912f12c7f8f176c7755d Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Fri, 5 Oct 2018 15:21:40 -0400 Subject: WIP: This doesn't currently work but I also don't think it's the right abstraction --- crates/ra_analysis/src/imp.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'crates/ra_analysis/src') diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 90184a4b9..05c91fb83 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -9,7 +9,7 @@ use std::{ }; use relative_path::RelativePath; -use ra_editor::{self, FileSymbol, LineIndex, find_node_at_offset, LocalEdit}; +use ra_editor::{self, FileSymbol, LineIndex, find_node_at_offset, LocalEdit, resolve_local_name}; use ra_syntax::{ TextUnit, TextRange, SmolStr, File, AstNode, SyntaxKind::*, @@ -197,7 +197,21 @@ impl AnalysisImpl { let file = root.syntax(file_id); let syntax = file.syntax(); if let Some(name_ref) = find_node_at_offset::(syntax, offset) { - return self.index_resolve(name_ref, token); + + // First try to resolve the symbol locally + if let Some(name) = resolve_local_name(&file, offset, name_ref) { + let vec: Vec<(FileId, FileSymbol)>::new(); + vec.push((file_id, FileSymbol { + name: name.text(), + node_range: name.syntax().range(), + kind : NAME + })); + + return vec; + } else { + // If that fails try the index based approach. + return self.index_resolve(name_ref, token); + } } if let Some(name) = find_node_at_offset::(syntax, offset) { if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { -- cgit v1.2.3