diff options
author | Aleksey Kladov <[email protected]> | 2019-01-02 15:08:14 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-02 15:08:14 +0000 |
commit | a94530afb354d2f9a3e3864c678aa496c8de6a23 (patch) | |
tree | f8591449a13c9272fd1038c771cdff1de3349847 /crates/ra_analysis/src/imp.rs | |
parent | 29d8bfb9c909847cb37ff6e564ea0e61744277ad (diff) |
move world-symbols to file_symbols
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 8071554a7..9ac52b5c3 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -3,7 +3,6 @@ use std::{ | |||
3 | sync::Arc, | 3 | sync::Arc, |
4 | }; | 4 | }; |
5 | 5 | ||
6 | use rayon::prelude::*; | ||
7 | use salsa::{Database, ParallelDatabase}; | 6 | use salsa::{Database, ParallelDatabase}; |
8 | 7 | ||
9 | use hir::{ | 8 | use hir::{ |
@@ -25,7 +24,7 @@ use crate::{ | |||
25 | completion::{CompletionItem, completions}, | 24 | completion::{CompletionItem, completions}, |
26 | CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit, | 25 | CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit, |
27 | Query, ReferenceResolution, RootChange, SourceChange, SourceFileEdit, | 26 | Query, ReferenceResolution, RootChange, SourceChange, SourceFileEdit, |
28 | symbol_index::{LibrarySymbolsQuery, SymbolIndex, SymbolsDatabase, FileSymbol}, | 27 | symbol_index::{LibrarySymbolsQuery, FileSymbol}, |
29 | }; | 28 | }; |
30 | 29 | ||
31 | #[derive(Debug, Default)] | 30 | #[derive(Debug, Default)] |
@@ -149,39 +148,6 @@ impl AnalysisImpl { | |||
149 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { | 148 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { |
150 | self.db.file_lines(file_id) | 149 | self.db.file_lines(file_id) |
151 | } | 150 | } |
152 | pub fn world_symbols(&self, query: Query) -> Cancelable<Vec<(FileId, FileSymbol)>> { | ||
153 | /// Need to wrap Snapshot to provide `Clone` impl for `map_with` | ||
154 | struct Snap(salsa::Snapshot<db::RootDatabase>); | ||
155 | impl Clone for Snap { | ||
156 | fn clone(&self) -> Snap { | ||
157 | Snap(self.0.snapshot()) | ||
158 | } | ||
159 | } | ||
160 | |||
161 | let buf: Vec<Arc<SymbolIndex>> = if query.libs { | ||
162 | let snap = Snap(self.db.snapshot()); | ||
163 | self.db | ||
164 | .library_roots() | ||
165 | .par_iter() | ||
166 | .map_with(snap, |db, &lib_id| db.0.library_symbols(lib_id)) | ||
167 | .collect() | ||
168 | } else { | ||
169 | let mut files = Vec::new(); | ||
170 | for &root in self.db.local_roots().iter() { | ||
171 | let sr = self.db.source_root(root); | ||
172 | files.extend(sr.files.values().map(|&it| it)) | ||
173 | } | ||
174 | |||
175 | let snap = Snap(self.db.snapshot()); | ||
176 | files | ||
177 | .par_iter() | ||
178 | .map_with(snap, |db, &file_id| db.0.file_symbols(file_id)) | ||
179 | .filter_map(|it| it.ok()) | ||
180 | .collect() | ||
181 | }; | ||
182 | Ok(query.search(&buf)) | ||
183 | } | ||
184 | |||
185 | pub(crate) fn module_path(&self, position: FilePosition) -> Cancelable<Option<String>> { | 151 | pub(crate) fn module_path(&self, position: FilePosition) -> Cancelable<Option<String>> { |
186 | let descr = match source_binder::module_from_position(&*self.db, position)? { | 152 | let descr = match source_binder::module_from_position(&*self.db, position)? { |
187 | None => return Ok(None), | 153 | None => return Ok(None), |
@@ -555,7 +521,7 @@ impl AnalysisImpl { | |||
555 | let mut query = Query::new(name.to_string()); | 521 | let mut query = Query::new(name.to_string()); |
556 | query.exact(); | 522 | query.exact(); |
557 | query.limit(4); | 523 | query.limit(4); |
558 | self.world_symbols(query) | 524 | crate::symbol_index::world_symbols(&*self.db, query) |
559 | } | 525 | } |
560 | } | 526 | } |
561 | 527 | ||