mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Gotodef for TypeParameters
This commit is contained in:
parent
1692f07393
commit
d1a01aa2f8
1 changed files with 18 additions and 7 deletions
|
@ -64,9 +64,11 @@ pub(crate) fn reference_definition(
|
|||
|
||||
let name_kind = classify_name_ref(db, name_ref).map(|d| d.kind);
|
||||
match name_kind {
|
||||
Some(Macro(mac)) => return Exact(mac.to_nav(db)),
|
||||
Some(Field(field)) => return Exact(field.to_nav(db)),
|
||||
Some(AssocItem(assoc)) => return Exact(assoc.to_nav(db)),
|
||||
Some(Macro(it)) => return Exact(it.to_nav(db)),
|
||||
Some(Field(it)) => return Exact(it.to_nav(db)),
|
||||
Some(GenericParam(it)) => return Exact(it.to_nav(db)),
|
||||
Some(AssocItem(it)) => return Exact(it.to_nav(db)),
|
||||
Some(Local(it)) => return Exact(it.to_nav(db)),
|
||||
Some(Def(def)) => match NavigationTarget::from_def(db, def) {
|
||||
Some(nav) => return Exact(nav),
|
||||
None => return Approximate(vec![]),
|
||||
|
@ -77,10 +79,6 @@ pub(crate) fn reference_definition(
|
|||
// us to the actual type
|
||||
return Exact(imp.to_nav(db));
|
||||
}
|
||||
Some(Local(local)) => return Exact(local.to_nav(db)),
|
||||
Some(GenericParam(_)) => {
|
||||
// FIXME: go to the generic param def
|
||||
}
|
||||
None => {}
|
||||
};
|
||||
|
||||
|
@ -723,4 +721,17 @@ mod tests {
|
|||
"foo FN_DEF FileId(1) [359; 376) [362; 365)",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn goto_for_type_param() {
|
||||
check_goto(
|
||||
"
|
||||
//- /lib.rs
|
||||
struct Foo<T> {
|
||||
t: <|>T,
|
||||
}
|
||||
",
|
||||
"T TYPE_PARAM FileId(1) [11; 12)",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue