diff options
Diffstat (limited to 'crates/ra_hir_def/src/item_scope.rs')
-rw-r--r-- | crates/ra_hir_def/src/item_scope.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index a96b5cfd2..b5c07ed5f 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs | |||
@@ -10,6 +10,7 @@ use crate::{per_ns::PerNs, AdtId, BuiltinType, ImplId, MacroDefId, ModuleDefId, | |||
10 | #[derive(Debug, Default, PartialEq, Eq)] | 10 | #[derive(Debug, Default, PartialEq, Eq)] |
11 | pub struct ItemScope { | 11 | pub struct ItemScope { |
12 | visible: FxHashMap<Name, Resolution>, | 12 | visible: FxHashMap<Name, Resolution>, |
13 | defs: Vec<ModuleDefId>, | ||
13 | impls: Vec<ImplId>, | 14 | impls: Vec<ImplId>, |
14 | /// Macros visible in current module in legacy textual scope | 15 | /// Macros visible in current module in legacy textual scope |
15 | /// | 16 | /// |
@@ -53,11 +54,7 @@ impl ItemScope { | |||
53 | } | 54 | } |
54 | 55 | ||
55 | pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ { | 56 | pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ { |
56 | self.entries() | 57 | self.defs.iter().copied() |
57 | .filter_map(|(_name, res)| if !res.import { Some(res.def) } else { None }) | ||
58 | .flat_map(|per_ns| { | ||
59 | per_ns.take_types().into_iter().chain(per_ns.take_values().into_iter()) | ||
60 | }) | ||
61 | } | 58 | } |
62 | 59 | ||
63 | pub fn impls(&self) -> impl Iterator<Item = ImplId> + ExactSizeIterator + '_ { | 60 | pub fn impls(&self) -> impl Iterator<Item = ImplId> + ExactSizeIterator + '_ { |
@@ -100,6 +97,10 @@ impl ItemScope { | |||
100 | }) | 97 | }) |
101 | } | 98 | } |
102 | 99 | ||
100 | pub(crate) fn define_def(&mut self, def: ModuleDefId) { | ||
101 | self.defs.push(def) | ||
102 | } | ||
103 | |||
103 | pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<MacroDefId> { | 104 | pub(crate) fn get_legacy_macro(&self, name: &Name) -> Option<MacroDefId> { |
104 | self.legacy_macros.get(name).copied() | 105 | self.legacy_macros.get(name).copied() |
105 | } | 106 | } |