aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/db.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/db.rs')
-rw-r--r--crates/ra_analysis/src/db.rs12
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;
10use salsa; 10use salsa;
11 11
12use crate::{ 12use 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
37pub(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
36impl salsa::ParallelDatabase for RootDatabase { 45impl 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}
117fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { 126fn 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}