aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/generics.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-07 18:52:09 +0000
committerAleksey Kladov <[email protected]>2019-12-07 18:52:09 +0000
commit7d2080a0311cab62388f416beeb360695dbc5ded (patch)
tree5c3f5ff8ad9fb4cf0cc53abe8476e275525814ec /crates/ra_hir_def/src/generics.rs
parentd1a01aa2f8ca9eff9ba2321f2f113623742e212c (diff)
Classify name works for TypeParams
Diffstat (limited to 'crates/ra_hir_def/src/generics.rs')
-rw-r--r--crates/ra_hir_def/src/generics.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs
index 0df5a20f5..159f9034b 100644
--- a/crates/ra_hir_def/src/generics.rs
+++ b/crates/ra_hir_def/src/generics.rs
@@ -14,11 +14,14 @@ use ra_db::FileId;
14use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner}; 14use ra_syntax::ast::{self, NameOwner, TypeBoundsOwner, TypeParamsOwner};
15 15
16use crate::{ 16use crate::{
17 child_by_source::ChildBySource,
17 db::DefDatabase, 18 db::DefDatabase,
19 dyn_map::DynMap,
20 keys,
18 src::HasChildSource, 21 src::HasChildSource,
19 src::HasSource, 22 src::HasSource,
20 type_ref::{TypeBound, TypeRef}, 23 type_ref::{TypeBound, TypeRef},
21 AdtId, AstItemDef, GenericDefId, LocalGenericParamId, Lookup, 24 AdtId, AstItemDef, GenericDefId, GenericParamId, LocalGenericParamId, Lookup,
22}; 25};
23 26
24/// Data about a generic parameter (to a function, struct, impl, ...). 27/// Data about a generic parameter (to a function, struct, impl, ...).
@@ -183,3 +186,18 @@ impl HasChildSource for GenericDefId {
183 sm 186 sm
184 } 187 }
185} 188}
189
190impl ChildBySource for GenericDefId {
191 fn child_by_source(&self, db: &impl DefDatabase) -> DynMap {
192 let mut res = DynMap::default();
193 let arena_map = self.child_source(db);
194 let arena_map = arena_map.as_ref();
195 for (local_id, src) in arena_map.value.iter() {
196 let id = GenericParamId { parent: *self, local_id };
197 if let Either::Right(type_param) = src {
198 res[keys::TYPE_PARAM].insert(arena_map.with_value(type_param.clone()), id)
199 }
200 }
201 res
202 }
203}