From bcfb3700ce5249d79368eda974b738617a83f894 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Wed, 25 Mar 2020 04:45:42 +0800 Subject: Add ItemScope::visibility_of --- crates/ra_hir_def/src/item_scope.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/ra_hir_def/src') diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index 5e943b780..ef1aaba6f 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs @@ -68,6 +68,12 @@ impl ItemScope { self.impls.iter().copied() } + pub fn visbility_of(&self, def: ModuleDefId) -> Option { + self.name_of(ItemInNs::Types(def)) + .or_else(|| self.name_of(ItemInNs::Values(def))) + .map(|(_, v)| v) + } + /// Iterate over all module scoped macros pub(crate) fn macros<'a>(&'a self) -> impl Iterator + 'a { self.visible.iter().filter_map(|(name, def)| def.take_macros().map(|macro_| (name, macro_))) -- cgit v1.2.3