aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-17 17:17:21 +0000
committerGitHub <[email protected]>2019-11-17 17:17:21 +0000
commit076921c5c7fd5a880a20e0a022520469447f7b49 (patch)
tree4a57f22e985709c4206fb95fda04367a8e90b5a3 /crates/ra_hir/src
parent4dfd1553280887dc95cd622ec89000c7f5ec037e (diff)
parentfd52d721e1ed9794048d63e546f43805d24d7ab8 (diff)
Merge #2289
2289: More correct expansion mapping r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/source_binder.rs13
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
22use crate::{ 22use crate::{
@@ -131,11 +131,16 @@ pub struct Expansion {
131} 131}
132 132
133impl Expansion { 133impl 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}