aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/source_binder.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 4353e25ac..439a4d5db 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -101,15 +101,7 @@ impl SourceBinder {
101 } 101 }
102 102
103 fn child_by_source(&mut self, db: &impl HirDatabase, container: ChildContainer) -> &DynMap { 103 fn child_by_source(&mut self, db: &impl HirDatabase, container: ChildContainer) -> &DynMap {
104 self.child_by_source_cache.entry(container).or_insert_with(|| match container { 104 self.child_by_source_cache.entry(container).or_insert_with(|| container.child_by_source(db))
105 ChildContainer::DefWithBodyId(it) => it.child_by_source(db),
106 ChildContainer::ModuleId(it) => it.child_by_source(db),
107 ChildContainer::TraitId(it) => it.child_by_source(db),
108 ChildContainer::ImplId(it) => it.child_by_source(db),
109 ChildContainer::EnumId(it) => it.child_by_source(db),
110 ChildContainer::VariantId(it) => it.child_by_source(db),
111 ChildContainer::GenericDefId(it) => it.child_by_source(db),
112 })
113 } 105 }
114} 106}
115 107
@@ -145,6 +137,20 @@ impl_froms! {
145 GenericDefId 137 GenericDefId
146} 138}
147 139
140impl ChildContainer {
141 fn child_by_source(self, db: &impl HirDatabase) -> DynMap {
142 match self {
143 ChildContainer::DefWithBodyId(it) => it.child_by_source(db),
144 ChildContainer::ModuleId(it) => it.child_by_source(db),
145 ChildContainer::TraitId(it) => it.child_by_source(db),
146 ChildContainer::ImplId(it) => it.child_by_source(db),
147 ChildContainer::EnumId(it) => it.child_by_source(db),
148 ChildContainer::VariantId(it) => it.child_by_source(db),
149 ChildContainer::GenericDefId(it) => it.child_by_source(db),
150 }
151 }
152}
153
148pub(crate) trait ToIdByKey: Sized + AstNode + 'static { 154pub(crate) trait ToIdByKey: Sized + AstNode + 'static {
149 type ID: Sized + Copy + 'static; 155 type ID: Sized + Copy + 'static;
150 const KEY: Key<Self, Self::ID>; 156 const KEY: Key<Self, Self::ID>;