From 9c7a2aef30cb35347af646dea5a5611af1224676 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 15 Nov 2019 10:26:31 +0300 Subject: Refactor Module::from_source to properly descend from root file --- crates/ra_hir_def/src/nameres.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index d3ecabb9b..1331fbe30 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs @@ -258,6 +258,13 @@ impl CrateDefMap { let res = self.resolve_path_fp_with_macro(db, ResolveMode::Other, original_module, path); (res.resolved_def, res.segment_index) } + + pub fn modules_for_file(&self, file_id: FileId) -> impl Iterator + '_ { + self.modules + .iter() + .filter(move |(_id, data)| data.definition == Some(file_id)) + .map(|(id, _data)| id) + } } mod diagnostics { -- cgit v1.2.3