diff options
Diffstat (limited to 'crates/ra_analysis/src/db.rs')
-rw-r--r-- | crates/ra_analysis/src/db.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index d621b3b22..09d74b9e7 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs | |||
@@ -10,7 +10,8 @@ use rustc_hash::FxHashSet; | |||
10 | use salsa; | 10 | use salsa; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | Cancelable, | 13 | db, |
14 | Cancelable, Canceled, | ||
14 | module_map::{ModuleDescriptorQuery, ModuleTreeQuery, ModulesDatabase}, | 15 | module_map::{ModuleDescriptorQuery, ModuleTreeQuery, ModulesDatabase}, |
15 | symbol_index::SymbolIndex, | 16 | symbol_index::SymbolIndex, |
16 | FileId, FileResolverImp, | 17 | FileId, FileResolverImp, |
@@ -33,6 +34,14 @@ impl salsa::Database for RootDatabase { | |||
33 | } | 34 | } |
34 | } | 35 | } |
35 | 36 | ||
37 | pub(crate) fn check_canceled(db: &impl salsa::Database) -> Cancelable<()> { | ||
38 | if db.salsa_runtime().is_current_revision_canceled() { | ||
39 | Err(Canceled) | ||
40 | } else { | ||
41 | Ok(()) | ||
42 | } | ||
43 | } | ||
44 | |||
36 | impl salsa::ParallelDatabase for RootDatabase { | 45 | impl salsa::ParallelDatabase for RootDatabase { |
37 | fn fork(&self) -> Self { | 46 | fn fork(&self) -> Self { |
38 | RootDatabase { | 47 | RootDatabase { |
@@ -115,6 +124,7 @@ fn file_lines(db: &impl SyntaxDatabase, file_id: FileId) -> Arc<LineIndex> { | |||
115 | Arc::new(LineIndex::new(&*text)) | 124 | Arc::new(LineIndex::new(&*text)) |
116 | } | 125 | } |
117 | fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { | 126 | fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { |
127 | db::check_canceled(db)?; | ||
118 | let syntax = db.file_syntax(file_id); | 128 | let syntax = db.file_syntax(file_id); |
119 | Ok(Arc::new(SymbolIndex::for_file(file_id, syntax))) | 129 | Ok(Arc::new(SymbolIndex::for_file(file_id, syntax))) |
120 | } | 130 | } |