aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/imp.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r--crates/ra_analysis/src/imp.rs39
1 files changed, 19 insertions, 20 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index 54f38b285..46169d863 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -10,7 +10,7 @@ use ra_syntax::{
10 SyntaxKind::*, 10 SyntaxKind::*,
11 SyntaxNodeRef, TextRange, TextUnit, 11 SyntaxNodeRef, TextRange, TextUnit,
12}; 12};
13use ra_db::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE, SyntaxDatabase}; 13use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase};
14use rayon::prelude::*; 14use rayon::prelude::*;
15use salsa::{Database, ParallelDatabase}; 15use salsa::{Database, ParallelDatabase};
16use hir::{ 16use hir::{
@@ -56,7 +56,7 @@ impl AnalysisHostImpl {
56 self.db.query_mut(ra_db::FileTextQuery).set(file_id, text) 56 self.db.query_mut(ra_db::FileTextQuery).set(file_id, text)
57 } 57 }
58 if !change.libraries_added.is_empty() { 58 if !change.libraries_added.is_empty() {
59 let mut libraries = Vec::clone(&self.db.libraries()); 59 let mut libraries = Vec::clone(&self.db.library_roots());
60 for library in change.libraries_added { 60 for library in change.libraries_added {
61 libraries.push(library.root_id); 61 libraries.push(library.root_id);
62 self.db 62 self.db
@@ -65,7 +65,7 @@ impl AnalysisHostImpl {
65 self.apply_root_change(library.root_id, library.root_change); 65 self.apply_root_change(library.root_id, library.root_change);
66 } 66 }
67 self.db 67 self.db
68 .query_mut(ra_db::LibrariesQuery) 68 .query_mut(ra_db::LibraryRootsQuery)
69 .set((), Arc::new(libraries)); 69 .set((), Arc::new(libraries));
70 } 70 }
71 if let Some(crate_graph) = change.crate_graph { 71 if let Some(crate_graph) = change.crate_graph {
@@ -142,27 +142,26 @@ impl AnalysisImpl {
142 self.db.file_lines(file_id) 142 self.db.file_lines(file_id)
143 } 143 }
144 pub fn world_symbols(&self, query: Query) -> Cancelable<Vec<(FileId, FileSymbol)>> { 144 pub fn world_symbols(&self, query: Query) -> Cancelable<Vec<(FileId, FileSymbol)>> {
145 /// Need to wrap Snapshot to provide `Clone` impl for `map_with`
146 struct Snap(salsa::Snapshot<db::RootDatabase>);
147 impl Clone for Snap {
148 fn clone(&self) -> Snap {
149 Snap(self.0.snapshot())
150 }
151 }
152
145 let buf: Vec<Arc<SymbolIndex>> = if query.libs { 153 let buf: Vec<Arc<SymbolIndex>> = if query.libs {
154 let snap = Snap(self.db.snapshot());
146 self.db 155 self.db
147 .libraries() 156 .library_roots()
148 .iter() 157 .par_iter()
149 .map(|&lib_id| self.db.library_symbols(lib_id)) 158 .map_with(snap, |db, &lib_id| db.0.library_symbols(lib_id))
150 .collect() 159 .collect()
151 } else { 160 } else {
152 let files: Vec<FileId> = self 161 let mut files = Vec::new();
153 .db 162 for &root in self.db.local_roots().iter() {
154 .source_root(WORKSPACE) 163 let sr = self.db.source_root(root);
155 .files 164 files.extend(sr.files.values().map(|&it| it))
156 .values()
157 .map(|&it| it)
158 .collect();
159
160 /// Need to wrap Snapshot to provide `Clone` impl for `map_with`
161 struct Snap(salsa::Snapshot<db::RootDatabase>);
162 impl Clone for Snap {
163 fn clone(&self) -> Snap {
164 Snap(self.0.snapshot())
165 }
166 } 165 }
167 166
168 let snap = Snap(self.db.snapshot()); 167 let snap = Snap(self.db.snapshot());