aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-05 10:20:11 +0000
committerAleksey Kladov <[email protected]>2018-12-05 10:20:11 +0000
commitdb456749a85e87cdbe3f87b85bf44446d9d5694b (patch)
tree615c68873a325a02be8e21e1bd4dcb9ce8ab6a1e
parent4344264024d374bb9cdc6f388f13c90b48c6c22e (diff)
make stuff private
-rw-r--r--crates/ra_hir/src/module/mod.rs15
-rw-r--r--crates/ra_hir/src/source_binder.rs6
2 files changed, 8 insertions, 13 deletions
diff --git a/crates/ra_hir/src/module/mod.rs b/crates/ra_hir/src/module/mod.rs
index 9ab7dbff5..580c737c3 100644
--- a/crates/ra_hir/src/module/mod.rs
+++ b/crates/ra_hir/src/module/mod.rs
@@ -153,17 +153,10 @@ impl ModuleTree {
153 self.mods.iter().map(|(id, _)| id) 153 self.mods.iter().map(|(id, _)| id)
154 } 154 }
155 155
156 fn modules_for_source(&self, source: ModuleSource) -> Vec<ModuleId> { 156 pub(crate) fn modules_with_sources<'a>(
157 self.mods 157 &'a self,
158 .iter() 158 ) -> impl Iterator<Item = (ModuleId, ModuleSource)> + 'a {
159 .filter(|(_idx, it)| it.source == source) 159 self.mods.iter().map(|(id, m)| (id, m.source))
160 .map(|(idx, _)| idx)
161 .collect()
162 }
163
164 //TODO: move to source binders?
165 pub(crate) fn any_module_for_source(&self, source: ModuleSource) -> Option<ModuleId> {
166 self.modules_for_source(source).pop()
167 } 160 }
168} 161}
169 162
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index dbf0a4de8..479155805 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -61,8 +61,10 @@ fn module_from_source(
61) -> Cancelable<Option<Module>> { 61) -> Cancelable<Option<Module>> {
62 let source_root_id = db.file_source_root(module_source.file_id()); 62 let source_root_id = db.file_source_root(module_source.file_id());
63 let module_tree = db.module_tree(source_root_id)?; 63 let module_tree = db.module_tree(source_root_id)?;
64 64 let m = module_tree
65 let module_id = ctry!(module_tree.any_module_for_source(module_source)); 65 .modules_with_sources()
66 .find(|(_id, src)| src == &module_source);
67 let module_id = ctry!(m).0;
66 Ok(Some(Module::new(db, source_root_id, module_id)?)) 68 Ok(Some(Module::new(db, source_root_id, module_id)?))
67} 69}
68 70