mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Track source of type parameters
This commit is contained in:
parent
d75f768c13
commit
dda9587e75
2 changed files with 82 additions and 23 deletions
|
@ -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<ast::TraitDef, ast::TypeParam>;
|
||||
fn source(self, db: &impl DefDatabase) -> InFile<Self::Ast> {
|
||||
let child_source = self.id.parent.child_source(db);
|
||||
child_source.map(|it| it[self.id.local_id].clone())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue