diff options
author | Aleksey Kladov <[email protected]> | 2018-11-20 21:31:12 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-11-20 21:31:12 +0000 |
commit | 9bb11aee44f377fdf2ce7bed5c09ccbcf30f9b57 (patch) | |
tree | 881bfa5cf8479690ed3c127b8a27457885a00736 /crates/ra_analysis/src/descriptors/module/mod.rs | |
parent | aab71bff8eb89fb65f4aba8e90df2ae586ecb0a6 (diff) |
populate resolve from unresolved imports
Diffstat (limited to 'crates/ra_analysis/src/descriptors/module/mod.rs')
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/mod.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs index f49e7f909..2d0bfa64c 100644 --- a/crates/ra_analysis/src/descriptors/module/mod.rs +++ b/crates/ra_analysis/src/descriptors/module/mod.rs | |||
@@ -103,9 +103,11 @@ impl ModuleDescriptor { | |||
103 | 103 | ||
104 | /// The root of the tree this module is part of | 104 | /// The root of the tree this module is part of |
105 | pub fn crate_root(&self) -> ModuleDescriptor { | 105 | pub fn crate_root(&self) -> ModuleDescriptor { |
106 | generate(Some(self.clone()), |it| it.parent()) | 106 | let root_id = self.module_id.crate_root(&self.tree); |
107 | .last() | 107 | ModuleDescriptor { |
108 | .unwrap() | 108 | module_id: root_id, |
109 | ..self.clone() | ||
110 | } | ||
109 | } | 111 | } |
110 | 112 | ||
111 | /// `name` is `None` for the crate's root module | 113 | /// `name` is `None` for the crate's root module |
@@ -205,6 +207,11 @@ impl ModuleId { | |||
205 | let link = self.parent_link(tree)?; | 207 | let link = self.parent_link(tree)?; |
206 | Some(tree.link(link).owner) | 208 | Some(tree.link(link).owner) |
207 | } | 209 | } |
210 | fn crate_root(self, tree: &ModuleTree) -> ModuleId { | ||
211 | generate(Some(self), move |it| it.parent(tree)) | ||
212 | .last() | ||
213 | .unwrap() | ||
214 | } | ||
208 | fn child(self, tree: &ModuleTree, name: &str) -> Option<ModuleId> { | 215 | fn child(self, tree: &ModuleTree, name: &str) -> Option<ModuleId> { |
209 | let link = tree | 216 | let link = tree |
210 | .module(self) | 217 | .module(self) |