diff options
author | Aleksey Kladov <[email protected]> | 2020-02-29 15:57:56 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-02-29 15:57:56 +0000 |
commit | a6a623dfbb40b79cac7857165114fa11a25e4e1f (patch) | |
tree | b32c98b5c186a6d495d53d6e5b375a47ee0a0955 /crates/ra_hir | |
parent | 099a8f37f5fd41f7afe26039b063973617133153 (diff) |
Small cleanup
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 24 |
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 | ||
140 | impl 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 | |||
148 | pub(crate) trait ToIdByKey: Sized + AstNode + 'static { | 154 | pub(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>; |