diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/src/descriptors/mod.rs | 14 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/imp.rs | 2 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/mod.rs | 12 | ||||
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 11 |
4 files changed, 19 insertions, 20 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 | ||
21 | salsa::query_group! { | 21 | salsa::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; | |||
8 | use ra_syntax::{ | 8 | use 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 | }; |
13 | use relative_path::RelativePathBuf; | 13 | use 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, |
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 1bbf0cb6d..61296215c 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -21,7 +21,7 @@ use crate::{ | |||
21 | db::{self, FileSyntaxQuery, SyntaxDatabase}, | 21 | db::{self, FileSyntaxQuery, SyntaxDatabase}, |
22 | descriptors::{ | 22 | descriptors::{ |
23 | function::{FnDescriptor, FnId}, | 23 | function::{FnDescriptor, FnId}, |
24 | module::{ModuleDescriptor, ModuleSource, ModuleTree, Problem}, | 24 | module::{ModuleDescriptor, Problem}, |
25 | DeclarationDescriptor, DescriptorDatabase, | 25 | DeclarationDescriptor, DescriptorDatabase, |
26 | }, | 26 | }, |
27 | input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, | 27 | input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, |
@@ -216,10 +216,6 @@ impl AnalysisImpl { | |||
216 | .sweep(salsa::SweepStrategy::default().discard_values()); | 216 | .sweep(salsa::SweepStrategy::default().discard_values()); |
217 | Ok(query.search(&buf)) | 217 | Ok(query.search(&buf)) |
218 | } | 218 | } |
219 | fn module_tree(&self, file_id: FileId) -> Cancelable<Arc<ModuleTree>> { | ||
220 | let source_root = self.db.file_source_root(file_id); | ||
221 | self.db.module_tree(source_root) | ||
222 | } | ||
223 | /// This return `Vec`: a module may be inclucded from several places. | 219 | /// This return `Vec`: a module may be inclucded from several places. |
224 | /// We don't handle this case yet though, so the Vec has length at most one. | 220 | /// We don't handle this case yet though, so the Vec has length at most one. |
225 | pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<(FileId, FileSymbol)>> { | 221 | pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<(FileId, FileSymbol)>> { |
@@ -354,7 +350,6 @@ impl AnalysisImpl { | |||
354 | } | 350 | } |
355 | 351 | ||
356 | pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { | 352 | pub fn diagnostics(&self, file_id: FileId) -> Cancelable<Vec<Diagnostic>> { |
357 | let module_tree = self.module_tree(file_id)?; | ||
358 | let syntax = self.db.file_syntax(file_id); | 353 | let syntax = self.db.file_syntax(file_id); |
359 | 354 | ||
360 | let mut res = ra_editor::diagnostics(&syntax) | 355 | let mut res = ra_editor::diagnostics(&syntax) |
@@ -365,8 +360,8 @@ impl AnalysisImpl { | |||
365 | fix: None, | 360 | fix: None, |
366 | }) | 361 | }) |
367 | .collect::<Vec<_>>(); | 362 | .collect::<Vec<_>>(); |
368 | if let Some(m) = module_tree.any_module_for_source(ModuleSource::SourceFile(file_id)) { | 363 | if let Some(m) = ModuleDescriptor::guess_from_file_id(&*self.db, file_id)? { |
369 | for (name_node, problem) in m.problems(&module_tree, &*self.db) { | 364 | for (name_node, problem) in m.problems(&*self.db) { |
370 | let diag = match problem { | 365 | let diag = match problem { |
371 | Problem::UnresolvedModule { candidate } => { | 366 | Problem::UnresolvedModule { candidate } => { |
372 | let create_file = FileSystemEdit::CreateFile { | 367 | let create_file = FileSystemEdit::CreateFile { |