diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 75a467fb3..f0ed8e2b2 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -16,7 +16,7 @@ use ra_syntax::{ | |||
16 | ast::{self, AstNode}, | 16 | ast::{self, AstNode}, |
17 | match_ast, AstPtr, | 17 | match_ast, AstPtr, |
18 | SyntaxKind::*, | 18 | SyntaxKind::*, |
19 | SyntaxNode, SyntaxNodePtr, TextRange, TextUnit, | 19 | SyntaxNode, SyntaxNodePtr, SyntaxToken, TextRange, TextUnit, |
20 | }; | 20 | }; |
21 | 21 | ||
22 | use crate::{ | 22 | use crate::{ |
@@ -131,11 +131,16 @@ pub struct Expansion { | |||
131 | } | 131 | } |
132 | 132 | ||
133 | impl Expansion { | 133 | impl Expansion { |
134 | pub fn translate_offset(&self, db: &impl HirDatabase, offset: TextUnit) -> Option<TextUnit> { | 134 | pub fn map_token_down( |
135 | &self, | ||
136 | db: &impl HirDatabase, | ||
137 | token: Source<&SyntaxToken>, | ||
138 | ) -> Option<Source<SyntaxToken>> { | ||
135 | let exp_info = self.file_id().expansion_info(db)?; | 139 | let exp_info = self.file_id().expansion_info(db)?; |
136 | exp_info.translate_offset(offset) | 140 | exp_info.map_token_down(token) |
137 | } | 141 | } |
138 | pub fn file_id(&self) -> HirFileId { | 142 | |
143 | fn file_id(&self) -> HirFileId { | ||
139 | self.macro_call_id.as_file(MacroFileKind::Items) | 144 | self.macro_call_id.as_file(MacroFileKind::Items) |
140 | } | 145 | } |
141 | } | 146 | } |