mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +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)
|
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()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue