aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/module_map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/module_map.rs')
-rw-r--r--crates/ra_analysis/src/module_map.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/ra_analysis/src/module_map.rs b/crates/ra_analysis/src/module_map.rs
index b15432498..0c413becd 100644
--- a/crates/ra_analysis/src/module_map.rs
+++ b/crates/ra_analysis/src/module_map.rs
@@ -1,4 +1,5 @@
1use crate::{ 1use crate::{
2 Cancelable,
2 db::SyntaxDatabase, 3 db::SyntaxDatabase,
3 descriptors::{ModuleDescriptor, ModuleTreeDescriptor}, 4 descriptors::{ModuleDescriptor, ModuleTreeDescriptor},
4 FileId, 5 FileId,
@@ -8,30 +9,30 @@ use std::sync::Arc;
8 9
9salsa::query_group! { 10salsa::query_group! {
10 pub(crate) trait ModulesDatabase: SyntaxDatabase { 11 pub(crate) trait ModulesDatabase: SyntaxDatabase {
11 fn module_tree() -> Arc<ModuleTreeDescriptor> { 12 fn module_tree() -> Cancelable<Arc<ModuleTreeDescriptor>> {
12 type ModuleTreeQuery; 13 type ModuleTreeQuery;
13 } 14 }
14 fn module_descriptor(file_id: FileId) -> Arc<ModuleDescriptor> { 15 fn module_descriptor(file_id: FileId) -> Cancelable<Arc<ModuleDescriptor>> {
15 type ModuleDescriptorQuery; 16 type ModuleDescriptorQuery;
16 } 17 }
17 } 18 }
18} 19}
19 20
20fn module_descriptor(db: &impl ModulesDatabase, file_id: FileId) -> Arc<ModuleDescriptor> { 21fn module_descriptor(db: &impl ModulesDatabase, file_id: FileId) -> Cancelable<Arc<ModuleDescriptor>> {
21 let file = db.file_syntax(file_id); 22 let file = db.file_syntax(file_id);
22 Arc::new(ModuleDescriptor::new(file.ast())) 23 Ok(Arc::new(ModuleDescriptor::new(file.ast())))
23} 24}
24 25
25fn module_tree(db: &impl ModulesDatabase) -> Arc<ModuleTreeDescriptor> { 26fn module_tree(db: &impl ModulesDatabase) -> Cancelable<Arc<ModuleTreeDescriptor>> {
26 let file_set = db.file_set(); 27 let file_set = db.file_set();
27 let mut files = Vec::new(); 28 let mut files = Vec::new();
28 for &file_id in file_set.files.iter() { 29 for &file_id in file_set.files.iter() {
29 let module_descr = db.module_descriptor(file_id); 30 let module_descr = db.module_descriptor(file_id)?;
30 files.push((file_id, module_descr)); 31 files.push((file_id, module_descr));
31 } 32 }
32 let res = ModuleTreeDescriptor::new( 33 let res = ModuleTreeDescriptor::new(
33 files.iter().map(|(file_id, descr)| (*file_id, &**descr)), 34 files.iter().map(|(file_id, descr)| (*file_id, &**descr)),
34 &file_set.resolver, 35 &file_set.resolver,
35 ); 36 );
36 Arc::new(res) 37 Ok(Arc::new(res))
37} 38}