From d1a01aa2f8ca9eff9ba2321f2f113623742e212c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 7 Dec 2019 18:54:18 +0100 Subject: Gotodef for TypeParameters --- crates/ra_ide/src/goto_definition.rs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index d3c198813..64c0cbad4 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs @@ -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 TYPE_PARAM FileId(1) [11; 12)", + ); + } } -- cgit v1.2.3