diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-21 11:57:32 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-11-21 11:57:32 +0000 |
commit | 031bc868293539714157e3d93cc338b011f5661d (patch) | |
tree | 624843cfddada855a6a80380e817bb188596c441 /crates/ra_analysis/src/descriptors/module/imp.rs | |
parent | 713c3ea30b38199e05e1f70094d85177f16915f8 (diff) | |
parent | 5a61b218f8869532ccb6be9dccff9e7d8641bf49 (diff) |
Merge #236
236: WIP: Module name resolution r=matklad a=matklad
work towards #231
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis/src/descriptors/module/imp.rs')
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/imp.rs | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/crates/ra_analysis/src/descriptors/module/imp.rs b/crates/ra_analysis/src/descriptors/module/imp.rs index defe87216..d4dce861f 100644 --- a/crates/ra_analysis/src/descriptors/module/imp.rs +++ b/crates/ra_analysis/src/descriptors/module/imp.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::{ | 3 | use ra_syntax::{ |
4 | ast::{self, ModuleItemOwner, NameOwner}, | 4 | ast::{self, NameOwner}, |
5 | SmolStr, | 5 | SmolStr, |
6 | }; | 6 | }; |
7 | use relative_path::RelativePathBuf; | 7 | use relative_path::RelativePathBuf; |
@@ -15,7 +15,7 @@ use crate::{ | |||
15 | }; | 15 | }; |
16 | 16 | ||
17 | use super::{ | 17 | use super::{ |
18 | LinkData, LinkId, ModuleData, ModuleId, ModuleScope, ModuleSource, ModuleSourceNode, | 18 | LinkData, LinkId, ModuleData, ModuleId, ModuleSource, ModuleSourceNode, |
19 | ModuleTree, Problem, | 19 | ModuleTree, Problem, |
20 | }; | 20 | }; |
21 | 21 | ||
@@ -81,23 +81,6 @@ pub(crate) fn modules<'a>( | |||
81 | }) | 81 | }) |
82 | } | 82 | } |
83 | 83 | ||
84 | pub(crate) fn module_scope( | ||
85 | db: &impl DescriptorDatabase, | ||
86 | source_root_id: SourceRootId, | ||
87 | module_id: ModuleId, | ||
88 | ) -> Cancelable<Arc<ModuleScope>> { | ||
89 | let tree = db._module_tree(source_root_id)?; | ||
90 | let source = module_id.source(&tree).resolve(db); | ||
91 | let res = match source { | ||
92 | ModuleSourceNode::SourceFile(it) => ModuleScope::new(it.borrowed().items()), | ||
93 | ModuleSourceNode::Module(it) => match it.borrowed().item_list() { | ||
94 | Some(items) => ModuleScope::new(items.items()), | ||
95 | None => ModuleScope::new(std::iter::empty()), | ||
96 | }, | ||
97 | }; | ||
98 | Ok(Arc::new(res)) | ||
99 | } | ||
100 | |||
101 | pub(crate) fn module_tree( | 84 | pub(crate) fn module_tree( |
102 | db: &impl DescriptorDatabase, | 85 | db: &impl DescriptorDatabase, |
103 | source_root: SourceRootId, | 86 | source_root: SourceRootId, |