aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-22 14:04:31 +0000
committerAleksey Kladov <[email protected]>2019-12-22 14:04:31 +0000
commitfe38fffaa90f656abbeff7b8a167afc45cc492a9 (patch)
treef1578f7d34fa304677483a8df13942e1326bc1b5 /crates/ra_hir_def
parent9f616ed65a3cd3088a006ab9f116c2b9a2235cb6 (diff)
Minor rename
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r--crates/ra_hir_def/src/item_scope.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs
index 9e082c5f7..eab3e2fff 100644
--- a/crates/ra_hir_def/src/item_scope.rs
+++ b/crates/ra_hir_def/src/item_scope.rs
@@ -9,7 +9,7 @@ use crate::{per_ns::PerNs, BuiltinType, ImplId, MacroDefId, ModuleDefId, TraitId
9 9
10#[derive(Debug, Default, PartialEq, Eq)] 10#[derive(Debug, Default, PartialEq, Eq)]
11pub struct ItemScope { 11pub struct ItemScope {
12 items: FxHashMap<Name, Resolution>, 12 visible: FxHashMap<Name, Resolution>,
13 impls: Vec<ImplId>, 13 impls: Vec<ImplId>,
14 /// Macros visible in current module in legacy textual scope 14 /// Macros visible in current module in legacy textual scope
15 /// 15 ///
@@ -49,7 +49,7 @@ pub(crate) enum BuiltinShadowMode {
49impl ItemScope { 49impl ItemScope {
50 pub fn entries<'a>(&'a self) -> impl Iterator<Item = (&'a Name, &'a Resolution)> + 'a { 50 pub fn entries<'a>(&'a self) -> impl Iterator<Item = (&'a Name, &'a Resolution)> + 'a {
51 //FIXME: shadowing 51 //FIXME: shadowing
52 self.items.iter().chain(BUILTIN_SCOPE.iter()) 52 self.visible.iter().chain(BUILTIN_SCOPE.iter())
53 } 53 }
54 54
55 pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ { 55 pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ {
@@ -66,7 +66,7 @@ impl ItemScope {
66 66
67 /// Iterate over all module scoped macros 67 /// Iterate over all module scoped macros
68 pub(crate) fn macros<'a>(&'a self) -> impl Iterator<Item = (&'a Name, MacroDefId)> + 'a { 68 pub(crate) fn macros<'a>(&'a self) -> impl Iterator<Item = (&'a Name, MacroDefId)> + 'a {
69 self.items 69 self.visible
70 .iter() 70 .iter()
71 .filter_map(|(name, res)| res.def.take_macros().map(|macro_| (name, macro_))) 71 .filter_map(|(name, res)| res.def.take_macros().map(|macro_| (name, macro_)))
72 } 72 }
@@ -79,9 +79,9 @@ impl ItemScope {
79 /// Get a name from current module scope, legacy macros are not included 79 /// Get a name from current module scope, legacy macros are not included
80 pub(crate) fn get(&self, name: &Name, shadow: BuiltinShadowMode) -> Option<&Resolution> { 80 pub(crate) fn get(&self, name: &Name, shadow: BuiltinShadowMode) -> Option<&Resolution> {
81 match shadow { 81 match shadow {
82 BuiltinShadowMode::Module => self.items.get(name).or_else(|| BUILTIN_SCOPE.get(name)), 82 BuiltinShadowMode::Module => self.visible.get(name).or_else(|| BUILTIN_SCOPE.get(name)),
83 BuiltinShadowMode::Other => { 83 BuiltinShadowMode::Other => {
84 let item = self.items.get(name); 84 let item = self.visible.get(name);
85 if let Some(res) = item { 85 if let Some(res) = item {
86 if let Some(ModuleDefId::ModuleId(_)) = res.def.take_types() { 86 if let Some(ModuleDefId::ModuleId(_)) = res.def.take_types() {
87 return BUILTIN_SCOPE.get(name).or(item); 87 return BUILTIN_SCOPE.get(name).or(item);
@@ -94,7 +94,7 @@ impl ItemScope {
94 } 94 }
95 95
96 pub(crate) fn traits<'a>(&'a self) -> impl Iterator<Item = TraitId> + 'a { 96 pub(crate) fn traits<'a>(&'a self) -> impl Iterator<Item = TraitId> + 'a {
97 self.items.values().filter_map(|r| match r.def.take_types() { 97 self.visible.values().filter_map(|r| match r.def.take_types() {
98 Some(ModuleDefId::TraitId(t)) => Some(t), 98 Some(ModuleDefId::TraitId(t)) => Some(t),
99 _ => None, 99 _ => None,
100 }) 100 })
@@ -114,7 +114,7 @@ impl ItemScope {
114 114
115 pub(crate) fn push_res(&mut self, name: Name, res: &Resolution, import: bool) -> bool { 115 pub(crate) fn push_res(&mut self, name: Name, res: &Resolution, import: bool) -> bool {
116 let mut changed = false; 116 let mut changed = false;
117 let existing = self.items.entry(name.clone()).or_default(); 117 let existing = self.visible.entry(name.clone()).or_default();
118 118
119 if existing.def.types.is_none() && res.def.types.is_some() { 119 if existing.def.types.is_none() && res.def.types.is_some() {
120 existing.def.types = res.def.types; 120 existing.def.types = res.def.types;
@@ -139,7 +139,7 @@ impl ItemScope {
139 } 139 }
140 140
141 pub(crate) fn collect_resolutions(&self) -> Vec<(Name, Resolution)> { 141 pub(crate) fn collect_resolutions(&self) -> Vec<(Name, Resolution)> {
142 self.items.iter().map(|(name, res)| (name.clone(), res.clone())).collect() 142 self.visible.iter().map(|(name, res)| (name.clone(), res.clone())).collect()
143 } 143 }
144 144
145 pub(crate) fn collect_legacy_macros(&self) -> FxHashMap<Name, MacroDefId> { 145 pub(crate) fn collect_legacy_macros(&self) -> FxHashMap<Name, MacroDefId> {