From dda9587e75f4fd1740d16531038023ff582ef43f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 7 Dec 2019 18:24:52 +0100 Subject: Track source of type parameters --- crates/ra_hir/src/code_model/src.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src') 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::{ use ra_syntax::ast; use crate::{ - db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplBlock, Import, MacroDef, - Module, Static, Struct, StructField, Trait, TypeAlias, Union, + db::DefDatabase, Const, Enum, EnumVariant, FieldSource, Function, GenericParam, ImplBlock, + Import, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union, }; pub use hir_expand::InFile; @@ -129,3 +129,11 @@ impl HasSource for Import { src.with_value(ptr.map_left(|it| it.to_node(&root)).map_right(|it| it.to_node(&root))) } } + +impl HasSource for GenericParam { + type Ast = Either; + fn source(self, db: &impl DefDatabase) -> InFile { + let child_source = self.id.parent.child_source(db); + child_source.map(|it| it[self.id.local_id].clone()) + } +} -- cgit v1.2.3