mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
Small cleanup
This commit is contained in:
parent
099a8f37f5
commit
a6a623dfbb
1 changed files with 15 additions and 9 deletions
|
@ -101,15 +101,7 @@ impl SourceBinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn child_by_source(&mut self, db: &impl HirDatabase, container: ChildContainer) -> &DynMap {
|
fn child_by_source(&mut self, db: &impl HirDatabase, container: ChildContainer) -> &DynMap {
|
||||||
self.child_by_source_cache.entry(container).or_insert_with(|| match container {
|
self.child_by_source_cache.entry(container).or_insert_with(|| container.child_by_source(db))
|
||||||
ChildContainer::DefWithBodyId(it) => it.child_by_source(db),
|
|
||||||
ChildContainer::ModuleId(it) => it.child_by_source(db),
|
|
||||||
ChildContainer::TraitId(it) => it.child_by_source(db),
|
|
||||||
ChildContainer::ImplId(it) => it.child_by_source(db),
|
|
||||||
ChildContainer::EnumId(it) => it.child_by_source(db),
|
|
||||||
ChildContainer::VariantId(it) => it.child_by_source(db),
|
|
||||||
ChildContainer::GenericDefId(it) => it.child_by_source(db),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +137,20 @@ impl_froms! {
|
||||||
GenericDefId
|
GenericDefId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ChildContainer {
|
||||||
|
fn child_by_source(self, db: &impl HirDatabase) -> DynMap {
|
||||||
|
match self {
|
||||||
|
ChildContainer::DefWithBodyId(it) => it.child_by_source(db),
|
||||||
|
ChildContainer::ModuleId(it) => it.child_by_source(db),
|
||||||
|
ChildContainer::TraitId(it) => it.child_by_source(db),
|
||||||
|
ChildContainer::ImplId(it) => it.child_by_source(db),
|
||||||
|
ChildContainer::EnumId(it) => it.child_by_source(db),
|
||||||
|
ChildContainer::VariantId(it) => it.child_by_source(db),
|
||||||
|
ChildContainer::GenericDefId(it) => it.child_by_source(db),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) trait ToIdByKey: Sized + AstNode + 'static {
|
pub(crate) trait ToIdByKey: Sized + AstNode + 'static {
|
||||||
type ID: Sized + Copy + 'static;
|
type ID: Sized + Copy + 'static;
|
||||||
const KEY: Key<Self, Self::ID>;
|
const KEY: Key<Self, Self::ID>;
|
||||||
|
|
Loading…
Reference in a new issue