diff options
author | Aleksey Kladov <[email protected]> | 2018-10-20 20:29:26 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-20 20:29:26 +0100 |
commit | 71cbdddf1c6b6c34c05aea01b92bb8a105b32c71 (patch) | |
tree | 1b7a83d15a344afa81e3b1169ffcd10fe2defc92 /crates/ra_analysis/src/roots.rs | |
parent | e74bf6e56e45a26002ef2a77fb3ac27f523277fb (diff) |
make file-symbols query cancelable
Diffstat (limited to 'crates/ra_analysis/src/roots.rs')
-rw-r--r-- | crates/ra_analysis/src/roots.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/crates/ra_analysis/src/roots.rs b/crates/ra_analysis/src/roots.rs index e950a75e2..123c4acfa 100644 --- a/crates/ra_analysis/src/roots.rs +++ b/crates/ra_analysis/src/roots.rs | |||
@@ -22,7 +22,7 @@ pub(crate) trait SourceRoot { | |||
22 | fn module_tree(&self) -> Cancelable<Arc<ModuleTreeDescriptor>>; | 22 | fn module_tree(&self) -> Cancelable<Arc<ModuleTreeDescriptor>>; |
23 | fn lines(&self, file_id: FileId) -> Arc<LineIndex>; | 23 | fn lines(&self, file_id: FileId) -> Arc<LineIndex>; |
24 | fn syntax(&self, file_id: FileId) -> File; | 24 | fn syntax(&self, file_id: FileId) -> File; |
25 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>); | 25 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()>; |
26 | } | 26 | } |
27 | 27 | ||
28 | #[derive(Default, Debug, Clone)] | 28 | #[derive(Default, Debug, Clone)] |
@@ -77,14 +77,12 @@ impl SourceRoot for WritableSourceRoot { | |||
77 | fn syntax(&self, file_id: FileId) -> File { | 77 | fn syntax(&self, file_id: FileId) -> File { |
78 | self.db.file_syntax(file_id) | 78 | self.db.file_syntax(file_id) |
79 | } | 79 | } |
80 | fn symbols<'a>(&'a self, acc: &mut Vec<Arc<SymbolIndex>>) { | 80 | fn symbols<'a>(&'a self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> { |
81 | let db = &self.db; | 81 | for &file_id in self.db.file_set().files.iter() { |
82 | let symbols = db.file_set(); | 82 | let symbols = self.db.file_symbols(file_id)?; |
83 | let symbols = symbols | 83 | acc.push(symbols) |
84 | .files | 84 | } |
85 | .iter() | 85 | Ok(()) |
86 | .map(|&file_id| db.file_symbols(file_id)); | ||
87 | acc.extend(symbols); | ||
88 | } | 86 | } |
89 | } | 87 | } |
90 | 88 | ||
@@ -180,7 +178,8 @@ impl SourceRoot for ReadonlySourceRoot { | |||
180 | fn syntax(&self, file_id: FileId) -> File { | 178 | fn syntax(&self, file_id: FileId) -> File { |
181 | self.data(file_id).syntax().clone() | 179 | self.data(file_id).syntax().clone() |
182 | } | 180 | } |
183 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) { | 181 | fn symbols(&self, acc: &mut Vec<Arc<SymbolIndex>>) -> Cancelable<()> { |
184 | acc.push(Arc::clone(&self.symbol_index)) | 182 | acc.push(Arc::clone(&self.symbol_index)); |
183 | Ok(()) | ||
185 | } | 184 | } |
186 | } | 185 | } |