Introduce modules_from_source fn
This commit is contained in:
parent
6502bd2c96
commit
cd878658d3
1 changed files with 6 additions and 6 deletions
|
@ -25,15 +25,19 @@ pub(crate) struct ModuleTree {
|
|||
}
|
||||
|
||||
impl ModuleTree {
|
||||
pub(crate) fn modules_for_file(&self, file_id: FileId) -> Vec<ModuleId> {
|
||||
pub(crate) fn modules_for_source(&self, source: ModuleSource) -> Vec<ModuleId> {
|
||||
self.mods
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_idx, it)| it.source.is_file(file_id))
|
||||
.filter(|(_idx, it)| it.source == source)
|
||||
.map(|(idx, _)| ModuleId(idx as u32))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub(crate) fn modules_for_file(&self, file_id: FileId) -> Vec<ModuleId> {
|
||||
self.modules_for_source(ModuleSource::File(file_id))
|
||||
}
|
||||
|
||||
pub(crate) fn any_module_for_file(&self, file_id: FileId) -> Option<ModuleId> {
|
||||
self.modules_for_file(file_id).pop()
|
||||
}
|
||||
|
@ -178,10 +182,6 @@ impl ModuleSource {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_file(self, file_id: FileId) -> bool {
|
||||
self.as_file() == Some(file_id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Hash, Debug, PartialEq, Eq)]
|
||||
|
|
Loading…
Add table
Reference in a new issue