aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2020-03-22 11:52:45 +0000
committerEdwin Cheng <[email protected]>2020-03-22 11:52:45 +0000
commitf647faac60660d9022b9d677c894d65e98c8ae5f (patch)
tree67163adec856c535f8f8003895984552ea2a1763 /crates
parent532e178f8e1fd3e20d1a22256d93cad2ba9954a9 (diff)
Refactor search
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide_db/src/search.rs20
1 files changed, 4 insertions, 16 deletions
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs
index cf78d3e41..117454695 100644
--- a/crates/ra_ide_db/src/search.rs
+++ b/crates/ra_ide_db/src/search.rs
@@ -10,9 +10,7 @@ use hir::{DefWithBody, HasSource, ModuleSource, Semantics};
10use once_cell::unsync::Lazy; 10use once_cell::unsync::Lazy;
11use ra_db::{FileId, FileRange, SourceDatabaseExt}; 11use ra_db::{FileId, FileRange, SourceDatabaseExt};
12use ra_prof::profile; 12use ra_prof::profile;
13use ra_syntax::{ 13use ra_syntax::{ast, match_ast, AstNode, TextRange, TextUnit};
14 algo::find_node_at_offset, ast, match_ast, AstNode, TextRange, TextUnit, TokenAtOffset,
15};
16use rustc_hash::FxHashMap; 14use rustc_hash::FxHashMap;
17use test_utils::tested_by; 15use test_utils::tested_by;
18 16
@@ -219,21 +217,11 @@ impl Definition {
219 continue; 217 continue;
220 } 218 }
221 219
222 let name_ref = 220 let name_ref: ast::NameRef =
223 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(&tree, offset) { 221 if let Some(name_ref) = sema.find_node_at_offset_with_descend(&tree, offset) {
224 name_ref 222 name_ref
225 } else { 223 } else {
226 // Handle macro token cases 224 continue;
227 let token = match tree.token_at_offset(offset) {
228 TokenAtOffset::None => continue,
229 TokenAtOffset::Single(t) => t,
230 TokenAtOffset::Between(_, t) => t,
231 };
232 let expanded = sema.descend_into_macros(token);
233 match ast::NameRef::cast(expanded.parent()) {
234 Some(name_ref) => name_ref,
235 _ => continue,
236 }
237 }; 225 };
238 226
239 // FIXME: reuse sb 227 // FIXME: reuse sb