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_mbe | |
parent | 786cae520ad62c9a0a13f5ab18e5bd7e5b0c9825 (diff) |
Goto definition works inside macros
Diffstat (limited to 'crates/ra_mbe')
-rw-r--r-- | crates/ra_mbe/src/syntax_bridge.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index 3f57ce3b5..37382d2df 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs | |||
@@ -77,6 +77,12 @@ pub fn token_tree_to_syntax_node( | |||
77 | } | 77 | } |
78 | 78 | ||
79 | impl TokenMap { | 79 | impl TokenMap { |
80 | pub fn token_by_offset(&self, relative_offset: TextUnit) -> Option<tt::TokenId> { | ||
81 | let (idx, _) = | ||
82 | self.tokens.iter().enumerate().find(|(_, range)| range.contains(relative_offset))?; | ||
83 | Some(tt::TokenId(idx as u32)) | ||
84 | } | ||
85 | |||
80 | pub fn relative_range_of(&self, tt: tt::TokenId) -> Option<TextRange> { | 86 | pub fn relative_range_of(&self, tt: tt::TokenId) -> Option<TextRange> { |
81 | let idx = tt.0 as usize; | 87 | let idx = tt.0 as usize; |
82 | self.tokens.get(idx).copied() | 88 | self.tokens.get(idx).copied() |