mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 20:43:21 +00:00
make stuff private
This commit is contained in:
parent
4344264024
commit
db456749a8
2 changed files with 8 additions and 13 deletions
|
@ -153,17 +153,10 @@ impl ModuleTree {
|
|||
self.mods.iter().map(|(id, _)| id)
|
||||
}
|
||||
|
||||
fn modules_for_source(&self, source: ModuleSource) -> Vec<ModuleId> {
|
||||
self.mods
|
||||
.iter()
|
||||
.filter(|(_idx, it)| it.source == 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()
|
||||
pub(crate) fn modules_with_sources<'a>(
|
||||
&'a self,
|
||||
) -> impl Iterator<Item = (ModuleId, ModuleSource)> + 'a {
|
||||
self.mods.iter().map(|(id, m)| (id, m.source))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,8 +61,10 @@ fn module_from_source(
|
|||
) -> Cancelable<Option<Module>> {
|
||||
let source_root_id = db.file_source_root(module_source.file_id());
|
||||
let module_tree = db.module_tree(source_root_id)?;
|
||||
|
||||
let module_id = ctry!(module_tree.any_module_for_source(module_source));
|
||||
let m = module_tree
|
||||
.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)?))
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue