From 2b6f1ab0e2303dce8e6e424514fd2a9e74566c89 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 18 Nov 2019 16:08:41 +0300 Subject: Collapse TokenMap and RevTokenMap --- crates/ra_hir_expand/src/db.rs | 8 +++----- crates/ra_hir_expand/src/lib.rs | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'crates/ra_hir_expand/src') diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index 9de7c1ea8..3c11c8a22 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -59,10 +59,8 @@ pub trait AstDatabase: SourceDatabase { fn intern_macro(&self, macro_call: MacroCallLoc) -> MacroCallId; fn macro_arg(&self, id: MacroCallId) -> Option>; fn macro_def(&self, id: MacroDefId) -> Option>; - fn parse_macro( - &self, - macro_file: MacroFile, - ) -> Option<(Parse, Arc)>; + fn parse_macro(&self, macro_file: MacroFile) + -> Option<(Parse, Arc)>; fn macro_expand(&self, macro_call: MacroCallId) -> Result, String>; } @@ -136,7 +134,7 @@ pub(crate) fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Optio pub(crate) fn parse_macro( db: &dyn AstDatabase, macro_file: MacroFile, -) -> Option<(Parse, Arc)> { +) -> Option<(Parse, Arc)> { let _p = profile("parse_macro_query"); let macro_call_id = macro_file.macro_call_id; diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 73ec1688c..cfe7e6d15 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -159,7 +159,7 @@ pub struct ExpansionInfo { macro_def: Arc<(db::TokenExpander, mbe::TokenMap)>, macro_arg: Arc<(tt::Subtree, mbe::TokenMap)>, - exp_map: Arc, + exp_map: Arc, } impl ExpansionInfo { @@ -186,7 +186,7 @@ impl ExpansionInfo { mbe::Origin::Def => (&self.macro_def.1, &self.def), }; - let range = token_map.relative_range_of(token_id)?; + let range = token_map.range_by_token(token_id)?; let token = algo::find_covering_element( tt.ast.syntax(), range + tt.ast.syntax().text_range().start(), -- cgit v1.2.3