aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/roots.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/roots.rs')
-rw-r--r--crates/ra_analysis/src/roots.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs
index 19c84df65..123c4acfa 100644
--- a/crates/ra_analysis/src/roots.rs
+++ b/crates/ra_analysis/src/roots.rs
@@ -8,6 +8,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
8use salsa::Database; 8use salsa::Database;
9 9
10use crate::{ 10use crate::{
11 Cancelable,
11 db::{self, FilesDatabase, SyntaxDatabase}, 12 db::{self, FilesDatabase, SyntaxDatabase},
12 descriptors::{ModuleDescriptor, ModuleTreeDescriptor}, 13 descriptors::{ModuleDescriptor, ModuleTreeDescriptor},
13 imp::FileResolverImp, 14 imp::FileResolverImp,
@@ -18,10 +19,10 @@ use crate::{
18 19
19pub(crate) trait SourceRoot { 20pub(crate) trait SourceRoot {
20 fn contains(&self, file_id: FileId) -> bool; 21 fn contains(&self, file_id: FileId) -> bool;
21 fn module_tree(&self) -> Arc<ModuleTreeDescriptor>; 22 fn module_tree(&self) -> Cancelable<Arc<ModuleTreeDescriptor>>;
22 fn lines(&self, file_id: FileId) -> Arc<LineIndex>; 23 fn lines(&self, file_id: FileId) -> Arc<LineIndex>;
23 fn syntax(&self, file_id: FileId) -> File; 24 fn syntax(&self, file_id: FileId) -> File;
24 fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>); 25 fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()>;
25} 26}
26 27
27#[derive(Default, Debug, Clone)] 28#[derive(Default, Debug, Clone)]
@@ -64,7 +65,7 @@ impl WritableSourceRoot {
64} 65}
65 66
66impl SourceRoot for WritableSourceRoot { 67impl SourceRoot for WritableSourceRoot {
67 fn module_tree(&self) -> Arc<ModuleTreeDescriptor> { 68 fn module_tree(&self) -> Cancelable<Arc<ModuleTreeDescriptor>> {
68 self.db.module_tree() 69 self.db.module_tree()
69 } 70 }
70 fn contains(&self, file_id: FileId) -> bool { 71 fn contains(&self, file_id: FileId) -> bool {
@@ -76,14 +77,12 @@ impl SourceRoot for WritableSourceRoot {
76 fn syntax(&self, file_id: FileId) -> File { 77 fn syntax(&self, file_id: FileId) -> File {
77 self.db.file_syntax(file_id) 78 self.db.file_syntax(file_id)
78 } 79 }
79 fn symbols<'a>(&'a self, acc: &mut Vec<Arc<SymbolIndex>>) { 80 fn symbols<'a>(&'a self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> {
80 let db = &self.db; 81 for &file_id in self.db.file_set().files.iter() {
81 let symbols = db.file_set(); 82 let symbols = self.db.file_symbols(file_id)?;
82 let symbols = symbols 83 acc.push(symbols)
83 .files 84 }
84 .iter() 85 Ok(())
85 .map(|&file_id| db.file_symbols(file_id));
86 acc.extend(symbols);
87 } 86 }
88} 87}
89 88
@@ -167,8 +166,8 @@ impl ReadonlySourceRoot {
167} 166}
168 167
169impl SourceRoot for ReadonlySourceRoot { 168impl SourceRoot for ReadonlySourceRoot {
170 fn module_tree(&self) -> Arc<ModuleTreeDescriptor> { 169 fn module_tree(&self) -> Cancelable<Arc<ModuleTreeDescriptor>> {
171 Arc::clone(&self.module_tree) 170 Ok(Arc::clone(&self.module_tree))
172 } 171 }
173 fn contains(&self, file_id: FileId) -> bool { 172 fn contains(&self, file_id: FileId) -> bool {
174 self.file_map.contains_key(&file_id) 173 self.file_map.contains_key(&file_id)
@@ -179,7 +178,8 @@ impl SourceRoot for ReadonlySourceRoot {
179 fn syntax(&self, file_id: FileId) -> File { 178 fn syntax(&self, file_id: FileId) -> File {
180 self.data(file_id).syntax().clone() 179 self.data(file_id).syntax().clone()
181 } 180 }
182 fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) { 181 fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> {
183 acc.push(Arc::clone(&self.symbol_index)) 182 acc.push(Arc::clone(&self.symbol_index));
183 Ok(())
184 } 184 }
185} 185}