From f647faac60660d9022b9d677c894d65e98c8ae5f Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sun, 22 Mar 2020 19:52:45 +0800 Subject: [PATCH] Refactor search --- crates/ra_ide_db/src/search.rs | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs index cf78d3e41ed..11745469595 100644 --- a/crates/ra_ide_db/src/search.rs +++ b/crates/ra_ide_db/src/search.rs @@ -10,9 +10,7 @@ use once_cell::unsync::Lazy; use ra_db::{FileId, FileRange, SourceDatabaseExt}; use ra_prof::profile; -use ra_syntax::{ - algo::find_node_at_offset, ast, match_ast, AstNode, TextRange, TextUnit, TokenAtOffset, -}; +use ra_syntax::{ast, match_ast, AstNode, TextRange, TextUnit}; use rustc_hash::FxHashMap; use test_utils::tested_by; @@ -219,21 +217,11 @@ pub fn find_usages( continue; } - let name_ref = - if let Some(name_ref) = find_node_at_offset::(&tree, offset) { + let name_ref: ast::NameRef = + if let Some(name_ref) = sema.find_node_at_offset_with_descend(&tree, offset) { name_ref } else { - // Handle macro token cases - let token = match tree.token_at_offset(offset) { - TokenAtOffset::None => continue, - TokenAtOffset::Single(t) => t, - TokenAtOffset::Between(_, t) => t, - }; - let expanded = sema.descend_into_macros(token); - match ast::NameRef::cast(expanded.parent()) { - Some(name_ref) => name_ref, - _ => continue, - } + continue; }; // FIXME: reuse sb