diff options
author | Aleksey Kladov <[email protected]> | 2019-02-08 11:09:57 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-08 11:34:30 +0000 |
commit | e4a6343e47a7dc87192b762b3b2ebd100240d194 (patch) | |
tree | 44f92482abb828755b6ad483fb50eb9ec673ee38 /crates/ra_ide_api/src | |
parent | 5173c6295b9c48e6990d6fb6467fc35cd0dfc902 (diff) |
move index_resolve to symbol index
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/call_info.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 3 | ||||
-rw-r--r-- | crates/ra_ide_api/src/imp.rs | 12 | ||||
-rw-r--r-- | crates/ra_ide_api/src/symbol_index.rs | 8 |
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 | }; |
4 | use ra_ide_api_light::{self, LocalEdit, Severity}; | 4 | use ra_ide_api_light::{self, LocalEdit, Severity}; |
5 | use ra_syntax::ast; | ||
6 | use ra_db::SourceDatabase; | 5 | use ra_db::SourceDatabase; |
7 | 6 | ||
8 | use crate::{ | 7 | use 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 | ||
14 | impl db::RootDatabase { | 12 | impl 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 | ||
88 | impl SourceChange { | 78 | impl 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 | ||
112 | pub(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)] |
113 | pub(crate) struct SymbolIndex { | 121 | pub(crate) struct SymbolIndex { |
114 | symbols: Vec<FileSymbol>, | 122 | symbols: Vec<FileSymbol>, |