diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-16 14:07:44 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-16 14:07:44 +0000 |
commit | 1adc3525873d2588987f2c29143536ce952d6ab2 (patch) | |
tree | ba86bbb6e4e82fb1a85ab6a830173c00f2415d5e /crates/ra_mbe | |
parent | 786cae520ad62c9a0a13f5ab18e5bd7e5b0c9825 (diff) | |
parent | 2eaa8c94a8a6b5cd86139c5e010ae95268b28658 (diff) |
Merge #2273
2273: goto in macro calls r=matklad a=matklad
![goto](https://user-images.githubusercontent.com/1711539/68984944-2a50ba80-0824-11ea-896c-c0ea8edcd0d6.gif)
This builds on the awesome infrastructure created by @edwin0cheng
Co-authored-by: Aleksey Kladov <[email protected]>
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() |