aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src')
-rw-r--r--crates/ra_analysis/src/descriptors/mod.rs4
-rw-r--r--crates/ra_analysis/src/descriptors/module/imp.rs29
2 files changed, 20 insertions, 13 deletions
diff --git a/crates/ra_analysis/src/descriptors/mod.rs b/crates/ra_analysis/src/descriptors/mod.rs
index eaeef54c1..775949a88 100644
--- a/crates/ra_analysis/src/descriptors/mod.rs
+++ b/crates/ra_analysis/src/descriptors/mod.rs
@@ -11,7 +11,7 @@ use ra_syntax::{
11use crate::{ 11use crate::{
12 db::SyntaxDatabase, 12 db::SyntaxDatabase,
13 descriptors::function::{resolve_local_name, FnId, FnScopes}, 13 descriptors::function::{resolve_local_name, FnId, FnScopes},
14 descriptors::module::{ModuleId, ModuleScope, ModuleTree}, 14 descriptors::module::{ModuleId, ModuleScope, ModuleTree, ModuleSource},
15 input::SourceRootId, 15 input::SourceRootId,
16 syntax_ptr::LocalSyntaxPtr, 16 syntax_ptr::LocalSyntaxPtr,
17 Cancelable, FileId, 17 Cancelable, FileId,
@@ -23,7 +23,7 @@ salsa::query_group! {
23 type ModuleTreeQuery; 23 type ModuleTreeQuery;
24 use fn module::imp::module_tree; 24 use fn module::imp::module_tree;
25 } 25 }
26 fn submodules(file_id: FileId) -> Cancelable<Arc<Vec<SmolStr>>> { 26 fn submodules(source: ModuleSource) -> Cancelable<Arc<Vec<module::imp::Submodule>>> {
27 type SubmodulesQuery; 27 type SubmodulesQuery;
28 use fn module::imp::submodules; 28 use fn module::imp::submodules;
29 } 29 }
diff --git a/crates/ra_analysis/src/descriptors/module/imp.rs b/crates/ra_analysis/src/descriptors/module/imp.rs
index 3a010ecf5..b9cd81739 100644
--- a/crates/ra_analysis/src/descriptors/module/imp.rs
+++ b/crates/ra_analysis/src/descriptors/module/imp.rs
@@ -19,14 +19,25 @@ use super::{
19 ModuleTree, Problem, 19 ModuleTree, Problem,
20}; 20};
21 21
22#[derive(Clone, Hash, PartialEq, Eq, Debug)]
23pub(crate) struct Submodule {
24 name: SmolStr
25}
26
22pub(crate) fn submodules( 27pub(crate) fn submodules(
23 db: &impl DescriptorDatabase, 28 db: &impl DescriptorDatabase,
24 file_id: FileId, 29 source: ModuleSource,
25) -> Cancelable<Arc<Vec<SmolStr>>> { 30) -> Cancelable<Arc<Vec<Submodule>>> {
26 db::check_canceled(db)?; 31 db::check_canceled(db)?;
32 let file_id = match source {
33 ModuleSource::File(it) => it,
34 _ => unimplemented!(),
35 };
27 let file = db.file_syntax(file_id); 36 let file = db.file_syntax(file_id);
28 let root = file.ast(); 37 let root = file.ast();
29 let submodules = modules(root).map(|(name, _)| name).collect(); 38 let submodules = modules(root)
39 .map(|(name, _)| Submodule { name })
40 .collect();
30 Ok(Arc::new(submodules)) 41 Ok(Arc::new(submodules))
31} 42}
32 43
@@ -66,11 +77,6 @@ pub(crate) fn module_tree(
66 Ok(Arc::new(res)) 77 Ok(Arc::new(res))
67} 78}
68 79
69#[derive(Clone, Hash, PartialEq, Eq, Debug)]
70pub struct Submodule {
71 pub name: SmolStr,
72}
73
74fn create_module_tree<'a>( 80fn create_module_tree<'a>(
75 db: &impl DescriptorDatabase, 81 db: &impl DescriptorDatabase,
76 source_root: SourceRootId, 82 source_root: SourceRootId,
@@ -118,10 +124,11 @@ fn build_subtree(
118 parent, 124 parent,
119 children: Vec::new(), 125 children: Vec::new(),
120 }); 126 });
121 for name in db.submodules(file_id)?.iter() { 127 for sub in db.submodules(ModuleSource::File(file_id))?.iter() {
122 let (points_to, problem) = resolve_submodule(file_id, name, &source_root.file_resolver); 128 let name = sub.name.clone();
129 let (points_to, problem) = resolve_submodule(file_id, &name, &source_root.file_resolver);
123 let link = tree.push_link(LinkData { 130 let link = tree.push_link(LinkData {
124 name: name.clone(), 131 name,
125 owner: id, 132 owner: id,
126 points_to: Vec::new(), 133 points_to: Vec::new(),
127 problem: None, 134 problem: None,