aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-07 17:54:18 +0000
committerAleksey Kladov <[email protected]>2019-12-07 18:44:43 +0000
commitd1a01aa2f8ca9eff9ba2321f2f113623742e212c (patch)
tree91421fd3cd4befa235f2a393246967c4c2272938 /crates/ra_ide/src
parent1692f07393dba4f5c122df1a609d5b18751bf406 (diff)
Gotodef for TypeParameters
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/goto_definition.rs25
1 files changed, 18 insertions, 7 deletions
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(
64 64
65 let name_kind = classify_name_ref(db, name_ref).map(|d| d.kind); 65 let name_kind = classify_name_ref(db, name_ref).map(|d| d.kind);
66 match name_kind { 66 match name_kind {
67 Some(Macro(mac)) => return Exact(mac.to_nav(db)), 67 Some(Macro(it)) => return Exact(it.to_nav(db)),
68 Some(Field(field)) => return Exact(field.to_nav(db)), 68 Some(Field(it)) => return Exact(it.to_nav(db)),
69 Some(AssocItem(assoc)) => return Exact(assoc.to_nav(db)), 69 Some(GenericParam(it)) => return Exact(it.to_nav(db)),
70 Some(AssocItem(it)) => return Exact(it.to_nav(db)),
71 Some(Local(it)) => return Exact(it.to_nav(db)),
70 Some(Def(def)) => match NavigationTarget::from_def(db, def) { 72 Some(Def(def)) => match NavigationTarget::from_def(db, def) {
71 Some(nav) => return Exact(nav), 73 Some(nav) => return Exact(nav),
72 None => return Approximate(vec![]), 74 None => return Approximate(vec![]),
@@ -77,10 +79,6 @@ pub(crate) fn reference_definition(
77 // us to the actual type 79 // us to the actual type
78 return Exact(imp.to_nav(db)); 80 return Exact(imp.to_nav(db));
79 } 81 }
80 Some(Local(local)) => return Exact(local.to_nav(db)),
81 Some(GenericParam(_)) => {
82 // FIXME: go to the generic param def
83 }
84 None => {} 82 None => {}
85 }; 83 };
86 84
@@ -723,4 +721,17 @@ mod tests {
723 "foo FN_DEF FileId(1) [359; 376) [362; 365)", 721 "foo FN_DEF FileId(1) [359; 376) [362; 365)",
724 ); 722 );
725 } 723 }
724
725 #[test]
726 fn goto_for_type_param() {
727 check_goto(
728 "
729 //- /lib.rs
730 struct Foo<T> {
731 t: <|>T,
732 }
733 ",
734 "T TYPE_PARAM FileId(1) [11; 12)",
735 );
736 }
726} 737}