aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_ide_api/src/call_info.rs2
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs3
-rw-r--r--crates/ra_ide_api/src/imp.rs12
-rw-r--r--crates/ra_ide_api/src/symbol_index.rs8
4 files changed, 11 insertions, 14 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
index 2eb388e0e..a59ab7853 100644
--- a/crates/ra_ide_api/src/call_info.rs
+++ b/crates/ra_ide_api/src/call_info.rs
@@ -20,7 +20,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
20 let name_ref = calling_node.name_ref()?; 20 let name_ref = calling_node.name_ref()?;
21 21
22 // Resolve the function's NameRef (NOTE: this isn't entirely accurate). 22 // Resolve the function's NameRef (NOTE: this isn't entirely accurate).
23 let file_symbols = db.index_resolve(name_ref); 23 let file_symbols = crate::symbol_index::index_resolve(db, name_ref);
24 let symbol = file_symbols 24 let symbol = file_symbols
25 .into_iter() 25 .into_iter()
26 .find(|it| it.ptr.kind() == FN_DEF)?; 26 .find(|it| it.ptr.kind() == FN_DEF)?;
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index 681f36623..69f2d2bf6 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -118,8 +118,7 @@ pub(crate) fn reference_definition(
118 } 118 }
119 } 119 }
120 // If that fails try the index based approach. 120 // If that fails try the index based approach.
121 let navs = db 121 let navs = crate::symbol_index::index_resolve(db, name_ref)
122 .index_resolve(name_ref)
123 .into_iter() 122 .into_iter()
124 .map(NavigationTarget::from_symbol) 123 .map(NavigationTarget::from_symbol)
125 .collect(); 124 .collect();
diff --git a/crates/ra_ide_api/src/imp.rs b/crates/ra_ide_api/src/imp.rs
index 435cc7d4b..a351c9373 100644
--- a/crates/ra_ide_api/src/imp.rs
+++ b/crates/ra_ide_api/src/imp.rs
@@ -2,13 +2,11 @@ use hir::{
2 self, Problem, source_binder 2 self, Problem, source_binder
3}; 3};
4use ra_ide_api_light::{self, LocalEdit, Severity}; 4use ra_ide_api_light::{self, LocalEdit, Severity};
5use ra_syntax::ast;
6use ra_db::SourceDatabase; 5use ra_db::SourceDatabase;
7 6
8use crate::{ 7use crate::{
9 db, Diagnostic, FileId, FilePosition, FileSystemEdit, 8 db, Diagnostic, FileId, FilePosition, FileSystemEdit,
10 Query, SourceChange, SourceFileEdit, 9 SourceChange, SourceFileEdit,
11 symbol_index::FileSymbol,
12}; 10};
13 11
14impl db::RootDatabase { 12impl db::RootDatabase {
@@ -75,14 +73,6 @@ impl db::RootDatabase {
75 }; 73 };
76 res 74 res
77 } 75 }
78
79 pub(crate) fn index_resolve(&self, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
80 let name = name_ref.text();
81 let mut query = Query::new(name.to_string());
82 query.exact();
83 query.limit(4);
84 crate::symbol_index::world_symbols(self, query)
85 }
86} 76}
87 77
88impl SourceChange { 78impl SourceChange {
diff --git a/crates/ra_ide_api/src/symbol_index.rs b/crates/ra_ide_api/src/symbol_index.rs
index 9f939c650..3d0b2369e 100644
--- a/crates/ra_ide_api/src/symbol_index.rs
+++ b/crates/ra_ide_api/src/symbol_index.rs
@@ -109,6 +109,14 @@ pub(crate) fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol>
109 query.search(&buf) 109 query.search(&buf)
110} 110}
111 111
112pub(crate) fn index_resolve(db: &RootDatabase, name_ref: &ast::NameRef) -> Vec<FileSymbol> {
113 let name = name_ref.text();
114 let mut query = Query::new(name.to_string());
115 query.exact();
116 query.limit(4);
117 crate::symbol_index::world_symbols(db, query)
118}
119
112#[derive(Default, Debug)] 120#[derive(Default, Debug)]
113pub(crate) struct SymbolIndex { 121pub(crate) struct SymbolIndex {
114 symbols: Vec<FileSymbol>, 122 symbols: Vec<FileSymbol>,