diff options
author | Aleksey Kladov <[email protected]> | 2019-11-16 13:49:26 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-16 14:00:54 +0000 |
commit | 2eaa8c94a8a6b5cd86139c5e010ae95268b28658 (patch) | |
tree | ba86bbb6e4e82fb1a85ab6a830173c00f2415d5e /crates/ra_hir_expand | |
parent | 786cae520ad62c9a0a13f5ab18e5bd7e5b0c9825 (diff) |
Goto definition works inside macros
Diffstat (limited to 'crates/ra_hir_expand')
-rw-r--r-- | crates/ra_hir_expand/src/lib.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 26531cb05..6bfbb2f79 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs | |||
@@ -160,6 +160,15 @@ pub struct ExpansionInfo { | |||
160 | } | 160 | } |
161 | 161 | ||
162 | impl ExpansionInfo { | 162 | impl ExpansionInfo { |
163 | pub fn translate_offset(&self, offset: TextUnit) -> Option<TextUnit> { | ||
164 | let offset = offset.checked_sub(self.arg_start.1)?; | ||
165 | let token_id = self.macro_arg.1.token_by_offset(offset)?; | ||
166 | let token_id = tt::TokenId(token_id.0 + self.shift); | ||
167 | |||
168 | let (r, _) = self.exp_map.ranges.iter().find(|(_, tid)| *tid == token_id)?; | ||
169 | Some(r.start()) | ||
170 | } | ||
171 | |||
163 | pub fn find_range(&self, from: TextRange) -> Option<(HirFileId, TextRange)> { | 172 | pub fn find_range(&self, from: TextRange) -> Option<(HirFileId, TextRange)> { |
164 | let token_id = look_in_rev_map(&self.exp_map, from)?; | 173 | let token_id = look_in_rev_map(&self.exp_map, from)?; |
165 | 174 | ||