make stuff private

This commit is contained in:
Aleksey Kladov 2018-12-05 13:20:11 +03:00
parent 4344264024
commit db456749a8
2 changed files with 8 additions and 13 deletions

View file

@ -153,17 +153,10 @@ impl ModuleTree {
self.mods.iter().map(|(id, _)| id) self.mods.iter().map(|(id, _)| id)
} }
fn modules_for_source(&self, source: ModuleSource) -> Vec<ModuleId> { pub(crate) fn modules_with_sources<'a>(
self.mods &'a self,
.iter() ) -> impl Iterator<Item = (ModuleId, ModuleSource)> + 'a {
.filter(|(_idx, it)| it.source == source) self.mods.iter().map(|(id, m)| (id, m.source))
.map(|(idx, _)| idx)
.collect()
}
//TODO: move to source binders?
pub(crate) fn any_module_for_source(&self, source: ModuleSource) -> Option<ModuleId> {
self.modules_for_source(source).pop()
} }
} }

View file

@ -61,8 +61,10 @@ fn module_from_source(
) -> Cancelable<Option<Module>> { ) -> Cancelable<Option<Module>> {
let source_root_id = db.file_source_root(module_source.file_id()); let source_root_id = db.file_source_root(module_source.file_id());
let module_tree = db.module_tree(source_root_id)?; let module_tree = db.module_tree(source_root_id)?;
let m = module_tree
let module_id = ctry!(module_tree.any_module_for_source(module_source)); .modules_with_sources()
.find(|(_id, src)| src == &module_source);
let module_id = ctry!(m).0;
Ok(Some(Module::new(db, source_root_id, module_id)?)) Ok(Some(Module::new(db, source_root_id, module_id)?))
} }