From cd878658d3072ee0741cd04c16d330e7d5907f94 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 4 Nov 2018 20:07:25 +0300 Subject: Introduce modules_from_source fn --- crates/ra_analysis/src/descriptors/module/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'crates/ra_analysis/src/descriptors/module') diff --git a/crates/ra_analysis/src/descriptors/module/mod.rs b/crates/ra_analysis/src/descriptors/module/mod.rs index e22489fc1..4e871d16d 100644 --- a/crates/ra_analysis/src/descriptors/module/mod.rs +++ b/crates/ra_analysis/src/descriptors/module/mod.rs @@ -25,15 +25,19 @@ pub(crate) struct ModuleTree { } impl ModuleTree { - pub(crate) fn modules_for_file(&self, file_id: FileId) -> Vec { + pub(crate) fn modules_for_source(&self, source: ModuleSource) -> Vec { 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 { + self.modules_for_source(ModuleSource::File(file_id)) + } + pub(crate) fn any_module_for_file(&self, file_id: FileId) -> Option { 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)] -- cgit v1.2.3