diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-25 08:09:26 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-25 08:09:26 +0000 |
commit | 8a73a8937d67db97072a11a40f0c3ed963e18e1b (patch) | |
tree | 7bfffa2750b044f47b67d7b9e89c14c1a1089505 /crates/ra_hir_def | |
parent | 6ad1a0711631d8017791a6dfe85bbe205d6c7414 (diff) | |
parent | d606521723d2635a21e6dd821b314f8e3127cbf9 (diff) |
Merge #3707
3707: Add ItemScope::visibility_of r=matklad a=edwin0cheng
~This PR implements `HasVisibility` for various constructs and change `Definition::search_scope` to use `Visibility` directly instead of depends on ad-hoc string parsing.~
This PR added `visibility_of` in `ItemScope` and `Module` and use it directly directly instead of depends on ad-hoc string parsing.
And also add a FIXME to indicate that there is a bug which do not search child-submodules in other files recursively in `Definition::search_scope`.
I will submit another PR to fix that bug after this is merged.
cc @flodiebold
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/item_scope.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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 { | |||
68 | self.impls.iter().copied() | 68 | self.impls.iter().copied() |
69 | } | 69 | } |
70 | 70 | ||
71 | pub fn visbility_of(&self, def: ModuleDefId) -> Option<Visibility> { | ||
72 | self.name_of(ItemInNs::Types(def)) | ||
73 | .or_else(|| self.name_of(ItemInNs::Values(def))) | ||
74 | .map(|(_, v)| v) | ||
75 | } | ||
76 | |||
71 | /// Iterate over all module scoped macros | 77 | /// Iterate over all module scoped macros |
72 | pub(crate) fn macros<'a>(&'a self) -> impl Iterator<Item = (&'a Name, MacroDefId)> + 'a { | 78 | pub(crate) fn macros<'a>(&'a self) -> impl Iterator<Item = (&'a Name, MacroDefId)> + 'a { |
73 | self.visible.iter().filter_map(|(name, def)| def.take_macros().map(|macro_| (name, macro_))) | 79 | self.visible.iter().filter_map(|(name, def)| def.take_macros().map(|macro_| (name, macro_))) |