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/db.rs | |
parent | e74bf6e56e45a26002ef2a77fb3ac27f523277fb (diff) |
make file-symbols query cancelable
Diffstat (limited to 'crates/ra_analysis/src/db.rs')
-rw-r--r-- | crates/ra_analysis/src/db.rs | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index cce959669..d621b3b22 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs | |||
@@ -1,17 +1,19 @@ | |||
1 | use crate::{ | 1 | use std::{ |
2 | module_map::{ModuleDescriptorQuery, ModuleTreeQuery, ModulesDatabase}, | 2 | fmt, |
3 | symbol_index::SymbolIndex, | 3 | hash::{Hash, Hasher}, |
4 | FileId, FileResolverImp, | 4 | sync::Arc, |
5 | }; | 5 | }; |
6 | |||
6 | use ra_editor::LineIndex; | 7 | use ra_editor::LineIndex; |
7 | use ra_syntax::File; | 8 | use ra_syntax::File; |
8 | use rustc_hash::FxHashSet; | 9 | use rustc_hash::FxHashSet; |
9 | use salsa; | 10 | use salsa; |
10 | 11 | ||
11 | use std::{ | 12 | use crate::{ |
12 | fmt, | 13 | Cancelable, |
13 | hash::{Hash, Hasher}, | 14 | module_map::{ModuleDescriptorQuery, ModuleTreeQuery, ModulesDatabase}, |
14 | sync::Arc, | 15 | symbol_index::SymbolIndex, |
16 | FileId, FileResolverImp, | ||
15 | }; | 17 | }; |
16 | 18 | ||
17 | #[derive(Default)] | 19 | #[derive(Default)] |
@@ -98,7 +100,7 @@ salsa::query_group! { | |||
98 | fn file_lines(file_id: FileId) -> Arc<LineIndex> { | 100 | fn file_lines(file_id: FileId) -> Arc<LineIndex> { |
99 | type FileLinesQuery; | 101 | type FileLinesQuery; |
100 | } | 102 | } |
101 | fn file_symbols(file_id: FileId) -> Arc<SymbolIndex> { | 103 | fn file_symbols(file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { |
102 | type FileSymbolsQuery; | 104 | type FileSymbolsQuery; |
103 | } | 105 | } |
104 | } | 106 | } |
@@ -112,7 +114,7 @@ fn file_lines(db: &impl SyntaxDatabase, file_id: FileId) -> Arc<LineIndex> { | |||
112 | let text = db.file_text(file_id); | 114 | let text = db.file_text(file_id); |
113 | Arc::new(LineIndex::new(&*text)) | 115 | Arc::new(LineIndex::new(&*text)) |
114 | } | 116 | } |
115 | fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Arc<SymbolIndex> { | 117 | fn file_symbols(db: &impl SyntaxDatabase, file_id: FileId) -> Cancelable<Arc<SymbolIndex>> { |
116 | let syntax = db.file_syntax(file_id); | 118 | let syntax = db.file_syntax(file_id); |
117 | Arc::new(SymbolIndex::for_file(file_id, syntax)) | 119 | Ok(Arc::new(SymbolIndex::for_file(file_id, syntax))) |
118 | } | 120 | } |