diff options
author | Aleksey Kladov <[email protected]> | 2018-11-27 22:38:39 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-11-27 22:38:39 +0000 |
commit | 4c9933c01657349438f9170c2ef7d6352144b224 (patch) | |
tree | 47b9b3ecde0c9bbfcc8a9ba4fd063a743eaf9c64 | |
parent | 806ea03b64455a0c10fd8a8d6d98ed4e7ac15058 (diff) |
check_canceled is a method
-rw-r--r-- | crates/ra_analysis/src/db.rs | 17 | ||||
-rw-r--r-- | crates/ra_analysis/src/hir/module/imp.rs | 3 | ||||
-rw-r--r-- | crates/ra_analysis/src/hir/module/nameres.rs | 2 | ||||
-rw-r--r-- | crates/ra_analysis/src/input.rs | 2 |
4 files changed, 9 insertions, 15 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index 78bbfcf2d..d7fffc188 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs | |||
@@ -6,7 +6,6 @@ use ra_syntax::{SourceFileNode, SyntaxNode}; | |||
6 | use salsa::{self, Database}; | 6 | use salsa::{self, Database}; |
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | db, | ||
10 | hir, | 9 | hir, |
11 | symbol_index::SymbolIndex, | 10 | symbol_index::SymbolIndex, |
12 | syntax_ptr::SyntaxPtr, | 11 | syntax_ptr::SyntaxPtr, |
@@ -59,14 +58,6 @@ impl Default for RootDatabase { | |||
59 | } | 58 | } |
60 | } | 59 | } |
61 | 60 | ||
62 | pub(crate) fn check_canceled(db: &impl salsa::Database) -> Cancelable<()> { | ||
63 | if db.salsa_runtime().is_current_revision_canceled() { | ||
64 | Err(Canceled) | ||
65 | } else { | ||
66 | Ok(()) | ||
67 | } | ||
68 | } | ||
69 | |||
70 | impl salsa::ParallelDatabase for RootDatabase { | 61 | impl salsa::ParallelDatabase for RootDatabase { |
71 | fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { | 62 | fn snapshot(&self) -> salsa::Snapshot<RootDatabase> { |
72 | salsa::Snapshot::new(RootDatabase { | 63 | salsa::Snapshot::new(RootDatabase { |
@@ -80,7 +71,11 @@ impl salsa::ParallelDatabase for RootDatabase { | |||
80 | pub(crate) trait BaseDatabase: salsa::Database { | 71 | pub(crate) trait BaseDatabase: salsa::Database { |
81 | fn id_maps(&self) -> &IdMaps; | 72 | fn id_maps(&self) -> &IdMaps; |
82 | fn check_canceled(&self) -> Cancelable<()> { | 73 | fn check_canceled(&self) -> Cancelable<()> { |
83 | check_canceled(self) | 74 | if self.salsa_runtime().is_current_revision_canceled() { |
75 | Err(Canceled) | ||
76 | } else { | ||
77 | Ok(()) | ||
78 | } | ||
84 | } | 79 | } |
85 | } | 80 | } |
86 | 81 | ||
@@ -171,7 +166,7 @@ fn file_lines(db: &impl SyntaxDatabase, file_id: FileId) -> Arc<LineIndex> { | |||
171 | Arc::new(LineIndex::new(&*text)) | 166 | Arc::new(LineIndex::new(&*text)) |
172 | } | 167 | } |
173 | fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { | 168 | fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { |
174 | db::check_canceled(db)?; | 169 | db.check_canceled()?; |
175 | let syntax = db.file_syntax(file_id); | 170 | let syntax = db.file_syntax(file_id); |
176 | Ok(Arc::new(SymbolIndex::for_file(file_id, syntax))) | 171 | Ok(Arc::new(SymbolIndex::for_file(file_id, syntax))) |
177 | } | 172 | } |
diff --git a/crates/ra_analysis/src/hir/module/imp.rs b/crates/ra_analysis/src/hir/module/imp.rs index 3b1baff76..d51ca2d59 100644 --- a/crates/ra_analysis/src/hir/module/imp.rs +++ b/crates/ra_analysis/src/hir/module/imp.rs | |||
@@ -8,7 +8,6 @@ use relative_path::RelativePathBuf; | |||
8 | use rustc_hash::{FxHashMap, FxHashSet}; | 8 | use rustc_hash::{FxHashMap, FxHashSet}; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | db, | ||
12 | hir::HirDatabase, | 11 | hir::HirDatabase, |
13 | input::{SourceRoot, SourceRootId}, | 12 | input::{SourceRoot, SourceRootId}, |
14 | Cancelable, FileId, FileResolverImp, | 13 | Cancelable, FileId, FileResolverImp, |
@@ -52,7 +51,7 @@ pub(crate) fn module_tree( | |||
52 | db: &impl HirDatabase, | 51 | db: &impl HirDatabase, |
53 | source_root: SourceRootId, | 52 | source_root: SourceRootId, |
54 | ) -> Cancelable<Arc<ModuleTree>> { | 53 | ) -> Cancelable<Arc<ModuleTree>> { |
55 | db::check_canceled(db)?; | 54 | db.check_canceled()?; |
56 | let res = create_module_tree(db, source_root)?; | 55 | let res = create_module_tree(db, source_root)?; |
57 | Ok(Arc::new(res)) | 56 | Ok(Arc::new(res)) |
58 | } | 57 | } |
diff --git a/crates/ra_analysis/src/hir/module/nameres.rs b/crates/ra_analysis/src/hir/module/nameres.rs index 2ff5e0537..d38940085 100644 --- a/crates/ra_analysis/src/hir/module/nameres.rs +++ b/crates/ra_analysis/src/hir/module/nameres.rs | |||
@@ -248,7 +248,7 @@ where | |||
248 | } | 248 | } |
249 | 249 | ||
250 | for &module_id in self.input.keys() { | 250 | for &module_id in self.input.keys() { |
251 | crate::db::check_canceled(self.db)?; | 251 | self.db.check_canceled()?; |
252 | self.resolve_imports(module_id); | 252 | self.resolve_imports(module_id); |
253 | } | 253 | } |
254 | Ok(self.result) | 254 | Ok(self.result) |
diff --git a/crates/ra_analysis/src/input.rs b/crates/ra_analysis/src/input.rs index a78b6e397..60086d1ae 100644 --- a/crates/ra_analysis/src/input.rs +++ b/crates/ra_analysis/src/input.rs | |||
@@ -33,7 +33,7 @@ impl CrateGraph { | |||
33 | pub trait FileResolver: fmt::Debug + Send + Sync + 'static { | 33 | pub trait FileResolver: fmt::Debug + Send + Sync + 'static { |
34 | fn file_stem(&self, file_id: FileId) -> String; | 34 | fn file_stem(&self, file_id: FileId) -> String; |
35 | fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId>; | 35 | fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId>; |
36 | fn debug_path(&self, _file_id: FileId) -> Option<std::path::PathBuf> { | 36 | fn debug_path(&self, _1file_id: FileId) -> Option<std::path::PathBuf> { |
37 | None | 37 | None |
38 | } | 38 | } |
39 | } | 39 | } |