aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-15 07:45:57 +0000
committerGitHub <[email protected]>2019-11-15 07:45:57 +0000
commit31d01efb069065449e53cfd7d0935c4b9fecf1e3 (patch)
tree00b30d62bb7cb34532fe0dbfe2ba6de64f8fde0f /crates/ra_hir_def
parent3ad11973ac7596323f085a9fcb9530e47f021c41 (diff)
parenta28907af8ca93077601053cf168ac2429855c394 (diff)
Merge #2251
2251: Privatize modules r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/nameres.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index d3ecabb9b..5fc592150 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -87,7 +87,7 @@ pub struct CrateDefMap {
87 prelude: Option<ModuleId>, 87 prelude: Option<ModuleId>,
88 extern_prelude: FxHashMap<Name, ModuleDefId>, 88 extern_prelude: FxHashMap<Name, ModuleDefId>,
89 root: CrateModuleId, 89 root: CrateModuleId,
90 pub modules: Arena<CrateModuleId, ModuleData>, 90 modules: Arena<CrateModuleId, ModuleData>,
91 91
92 /// Some macros are not well-behavior, which leads to infinite loop 92 /// Some macros are not well-behavior, which leads to infinite loop
93 /// e.g. macro_rules! foo { ($ty:ty) => { foo!($ty); } } 93 /// e.g. macro_rules! foo { ($ty:ty) => { foo!($ty); } }
@@ -258,6 +258,17 @@ impl CrateDefMap {
258 let res = self.resolve_path_fp_with_macro(db, ResolveMode::Other, original_module, path); 258 let res = self.resolve_path_fp_with_macro(db, ResolveMode::Other, original_module, path);
259 (res.resolved_def, res.segment_index) 259 (res.resolved_def, res.segment_index)
260 } 260 }
261
262 pub fn modules(&self) -> impl Iterator<Item = CrateModuleId> + '_ {
263 self.modules.iter().map(|(id, _data)| id)
264 }
265
266 pub fn modules_for_file(&self, file_id: FileId) -> impl Iterator<Item = CrateModuleId> + '_ {
267 self.modules
268 .iter()
269 .filter(move |(_id, data)| data.definition == Some(file_id))
270 .map(|(id, _data)| id)
271 }
261} 272}
262 273
263mod diagnostics { 274mod diagnostics {