diff options
author | Aleksey Kladov <[email protected]> | 2020-03-02 18:00:38 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-03-02 18:00:38 +0000 |
commit | 2716a1fa3f8a7410248724a6ce5d4c28837db682 (patch) | |
tree | ad1faf323e4cb1478e1e34e2ed9fe858c5be80e5 /crates/ra_ide/src/goto_definition.rs | |
parent | 96eca8a1abd79840b9040250db9d1e65ec663b0e (diff) |
More principled approach for gotodef for field shorhand
Callers can now decide for themselves if they should prefer field or
local definition. By default, it's the local.
Diffstat (limited to 'crates/ra_ide/src/goto_definition.rs')
-rw-r--r-- | crates/ra_ide/src/goto_definition.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index e67585203..76ee232a3 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs | |||
@@ -76,6 +76,8 @@ pub(crate) fn reference_definition( | |||
76 | 76 | ||
77 | let name_kind = classify_name_ref(sema, name_ref); | 77 | let name_kind = classify_name_ref(sema, name_ref); |
78 | if let Some(def) = name_kind { | 78 | if let Some(def) = name_kind { |
79 | let def = def.definition(); | ||
80 | |||
79 | return match def.try_to_nav(sema.db) { | 81 | return match def.try_to_nav(sema.db) { |
80 | Some(nav) => ReferenceResult::Exact(nav), | 82 | Some(nav) => ReferenceResult::Exact(nav), |
81 | None => ReferenceResult::Approximate(Vec::new()), | 83 | None => ReferenceResult::Approximate(Vec::new()), |
@@ -795,8 +797,8 @@ mod tests { | |||
795 | Foo { x<|> }; | 797 | Foo { x<|> }; |
796 | } | 798 | } |
797 | ", | 799 | ", |
798 | "x RECORD_FIELD_DEF FileId(1) [13; 19) [13; 14)", | 800 | "x BIND_PAT FileId(1) [42; 43)", |
799 | "x: i32|x", | 801 | "x", |
800 | ) | 802 | ) |
801 | } | 803 | } |
802 | } | 804 | } |