diff options
author | Aleksey Kladov <[email protected]> | 2019-12-07 17:24:52 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-07 18:44:43 +0000 |
commit | dda9587e75f4fd1740d16531038023ff582ef43f (patch) | |
tree | 56a377d2ff6b3dcbb8e2f25ccc876c718b48d37a /crates/ra_hir/src | |
parent | d75f768c13752dfa5ea9189a0b4dfb9b460993e6 (diff) |
Track source of type parameters
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model/src.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 78a454082..8f04ebd23 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -9,8 +9,8 @@ use hir_def::{ | |||
9 | use ra_syntax::ast; | 9 | use ra_syntax::ast; |
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{ |
12 | db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, Import, MacroDef, | 12 | db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, GenericParam, ImplBlock, |
13 | Module, Static, Struct, StructField, Trait, TypeAlias, Union, | 13 | Import, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | pub use hir_expand::InFile; | 16 | pub use hir_expand::InFile; |
@@ -129,3 +129,11 @@ impl HasSource for Import { | |||
129 | src.with_value(ptr.map_left(|it| it.to_node(&root)).map_right(|it| it.to_node(&root))) | 129 | src.with_value(ptr.map_left(|it| it.to_node(&root)).map_right(|it| it.to_node(&root))) |
130 | } | 130 | } |
131 | } | 131 | } |
132 | |||
133 | impl HasSource for GenericParam { | ||
134 | type Ast = Either<ast::TraitDef, ast::TypeParam>; | ||
135 | fn source(self, db: &impl DefDatabase) -> InFile<Self::Ast> { | ||
136 | let child_source = self.id.parent.child_source(db); | ||
137 | child_source.map(|it| it[self.id.local_id].clone()) | ||
138 | } | ||
139 | } | ||