diff options
author | Aleksey Kladov <[email protected]> | 2019-12-09 17:42:45 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-09 18:46:35 +0000 |
commit | b683cbd93db65f5421ef9b7617a2abfe93928af0 (patch) | |
tree | b972b060d4c23397bfa06466bd2261301e8228ec | |
parent | 7ac4ea7fec018f76eed5b5c10fc96ba3d9b969be (diff) |
Report correct original range in goto_definition
-rw-r--r-- | crates/ra_ide/src/goto_definition.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index b93d6a931..cfe62037f 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs | |||
@@ -19,25 +19,23 @@ pub(crate) fn goto_definition( | |||
19 | position: FilePosition, | 19 | position: FilePosition, |
20 | ) -> Option<RangeInfo<Vec<NavigationTarget>>> { | 20 | ) -> Option<RangeInfo<Vec<NavigationTarget>>> { |
21 | let file = db.parse_or_expand(position.file_id.into())?; | 21 | let file = db.parse_or_expand(position.file_id.into())?; |
22 | let token = file.token_at_offset(position.offset).filter(|it| !it.kind().is_trivia()).next()?; | 22 | let original_token = |
23 | let token = descend_into_macros(db, position.file_id, token); | 23 | file.token_at_offset(position.offset).filter(|it| !it.kind().is_trivia()).next()?; |
24 | let token = descend_into_macros(db, position.file_id, original_token.clone()); | ||
24 | 25 | ||
25 | let res = match_ast! { | 26 | let nav_targets = match_ast! { |
26 | match (token.value.parent()) { | 27 | match (token.value.parent()) { |
27 | ast::NameRef(name_ref) => { | 28 | ast::NameRef(name_ref) => { |
28 | let navs = reference_definition(db, token.with_value(&name_ref)).to_vec(); | 29 | reference_definition(db, token.with_value(&name_ref)).to_vec() |
29 | RangeInfo::new(name_ref.syntax().text_range(), navs.to_vec()) | ||
30 | }, | 30 | }, |
31 | ast::Name(name) => { | 31 | ast::Name(name) => { |
32 | let navs = name_definition(db, token.with_value(&name))?; | 32 | name_definition(db, token.with_value(&name))? |
33 | RangeInfo::new(name.syntax().text_range(), navs) | ||
34 | |||
35 | }, | 33 | }, |
36 | _ => return None, | 34 | _ => return None, |
37 | } | 35 | } |
38 | }; | 36 | }; |
39 | 37 | ||
40 | Some(res) | 38 | Some(RangeInfo::new(original_token.text_range(), nav_targets)) |
41 | } | 39 | } |
42 | 40 | ||
43 | #[derive(Debug)] | 41 | #[derive(Debug)] |