aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/descriptors
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/descriptors')
-rw-r--r--crates/ra_analysis/src/descriptors/mod.rs14
-rw-r--r--crates/ra_analysis/src/descriptors/module/imp.rs2
-rw-r--r--crates/ra_analysis/src/descriptors/module/mod.rs12
3 files changed, 16 insertions, 12 deletions
diff --git a/crates/ra_analysis/src/descriptors/mod.rs b/crates/ra_analysis/src/descriptors/mod.rs
index f47ac49c5..a8489f89c 100644
--- a/crates/ra_analysis/src/descriptors/mod.rs
+++ b/crates/ra_analysis/src/descriptors/mod.rs
@@ -20,19 +20,19 @@ use crate::{
20 20
21salsa::query_group! { 21salsa::query_group! {
22 pub(crate) trait DescriptorDatabase: SyntaxDatabase + IdDatabase { 22 pub(crate) trait DescriptorDatabase: SyntaxDatabase + IdDatabase {
23 fn module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> { 23 fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> {
24 type FnScopesQuery;
25 use fn function::imp::fn_scopes;
26 }
27
28 fn _module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
24 type ModuleTreeQuery; 29 type ModuleTreeQuery;
25 use fn module::imp::module_tree; 30 use fn module::imp::module_tree;
26 } 31 }
27 fn module_scope(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<ModuleScope>> { 32 fn _module_scope(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<ModuleScope>> {
28 type ModuleScopeQuery; 33 type ModuleScopeQuery;
29 use fn module::imp::module_scope; 34 use fn module::imp::module_scope;
30 } 35 }
31 fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> {
32 type FnScopesQuery;
33 use fn function::imp::fn_scopes;
34 }
35
36 fn _fn_syntax(fn_id: FnId) -> FnDefNode { 36 fn _fn_syntax(fn_id: FnId) -> FnDefNode {
37 type FnSyntaxQuery; 37 type FnSyntaxQuery;
38 // Don't retain syntax trees in memory 38 // Don't retain syntax trees in memory
diff --git a/crates/ra_analysis/src/descriptors/module/imp.rs b/crates/ra_analysis/src/descriptors/module/imp.rs
index ec0885938..defe87216 100644
--- a/crates/ra_analysis/src/descriptors/module/imp.rs
+++ b/crates/ra_analysis/src/descriptors/module/imp.rs
@@ -86,7 +86,7 @@ pub(crate) fn module_scope(
86 source_root_id: SourceRootId, 86 source_root_id: SourceRootId,
87 module_id: ModuleId, 87 module_id: ModuleId,
88) -> Cancelable<Arc<ModuleScope>> { 88) -> Cancelable<Arc<ModuleScope>> {
89 let tree = db.module_tree(source_root_id)?; 89 let tree = db._module_tree(source_root_id)?;
90 let source = module_id.source(&tree).resolve(db); 90 let source = module_id.source(&tree).resolve(db);
91 let res = match source { 91 let res = match source {
92 ModuleSourceNode::SourceFile(it) => ModuleScope::new(it.borrowed().items()), 92 ModuleSourceNode::SourceFile(it) => ModuleScope::new(it.borrowed().items()),
diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs
index a894025ed..ff7afe16e 100644
--- a/crates/ra_analysis/src/descriptors/module/mod.rs
+++ b/crates/ra_analysis/src/descriptors/module/mod.rs
@@ -8,7 +8,7 @@ use ra_editor::find_node_at_offset;
8use ra_syntax::{ 8use ra_syntax::{
9 algo::generate, 9 algo::generate,
10 ast::{self, AstNode, NameOwner}, 10 ast::{self, AstNode, NameOwner},
11 SmolStr, SyntaxNode, SyntaxNodeRef, 11 SmolStr, SyntaxNode,
12}; 12};
13use relative_path::RelativePathBuf; 13use relative_path::RelativePathBuf;
14 14
@@ -62,7 +62,7 @@ impl ModuleDescriptor {
62 module_source: ModuleSource, 62 module_source: ModuleSource,
63 ) -> Cancelable<Option<ModuleDescriptor>> { 63 ) -> Cancelable<Option<ModuleDescriptor>> {
64 let source_root_id = db.file_source_root(file_id); 64 let source_root_id = db.file_source_root(file_id);
65 let module_tree = db.module_tree(source_root_id)?; 65 let module_tree = db._module_tree(source_root_id)?;
66 66
67 let res = match module_tree.any_module_for_source(module_source) { 67 let res = match module_tree.any_module_for_source(module_source) {
68 None => None, 68 None => None,
@@ -124,7 +124,11 @@ impl ModuleDescriptor {
124 124
125 /// Returns a `ModuleScope`: a set of items, visible in this module. 125 /// Returns a `ModuleScope`: a set of items, visible in this module.
126 pub fn scope(&self, db: &impl DescriptorDatabase) -> Cancelable<Arc<ModuleScope>> { 126 pub fn scope(&self, db: &impl DescriptorDatabase) -> Cancelable<Arc<ModuleScope>> {
127 db.module_scope(self.source_root_id, self.module_id) 127 db._module_scope(self.source_root_id, self.module_id)
128 }
129
130 pub fn problems(&self, db: &impl DescriptorDatabase) -> Vec<(SyntaxNode, Problem)> {
131 self.module_id.problems(&self.tree, db)
128 } 132 }
129} 133}
130 134
@@ -209,7 +213,7 @@ impl ModuleId {
209 .find(|it| it.name == name)?; 213 .find(|it| it.name == name)?;
210 Some(*link.points_to.first()?) 214 Some(*link.points_to.first()?)
211 } 215 }
212 pub(crate) fn problems( 216 fn problems(
213 self, 217 self,
214 tree: &ModuleTree, 218 tree: &ModuleTree,
215 db: &impl SyntaxDatabase, 219 db: &impl SyntaxDatabase,