aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-12-14 17:46:39 +0000
committerEdwin Cheng <[email protected]>2019-12-14 17:46:39 +0000
commitb53587c7bdd67c63bd33a745fdaeb22a847b6c2f (patch)
treec4a73cb4d89ff6dce084f3b2af640e272b163319
parent61360fdfec981eadef1eefb595c8b32c951771e8 (diff)
Re-export Origin to replace ExpansionOrigin
-rw-r--r--crates/ra_hir/src/lib.rs3
-rw-r--r--crates/ra_hir_expand/src/lib.rs20
-rw-r--r--crates/ra_ide/src/expand.rs4
-rw-r--r--crates/ra_mbe/src/lib.rs1
4 files changed, 11 insertions, 17 deletions
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 2bf729b6d..8b9562722 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -58,7 +58,6 @@ pub use hir_def::{
58 type_ref::Mutability, 58 type_ref::Mutability,
59}; 59};
60pub use hir_expand::{ 60pub use hir_expand::{
61 name::Name, ExpansionOrigin, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, 61 name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, MacroFile, Origin,
62 MacroFile,
63}; 62};
64pub use hir_ty::{display::HirDisplay, CallableDef}; 63pub use hir_ty::{display::HirDisplay, CallableDef};
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs
index d1a43fe6c..cb4e1950b 100644
--- a/crates/ra_hir_expand/src/lib.rs
+++ b/crates/ra_hir_expand/src/lib.rs
@@ -214,11 +214,7 @@ pub struct ExpansionInfo {
214 exp_map: Arc<mbe::TokenMap>, 214 exp_map: Arc<mbe::TokenMap>,
215} 215}
216 216
217#[derive(Debug, Clone, PartialEq, Eq)] 217pub use mbe::Origin;
218pub enum ExpansionOrigin {
219 Call,
220 Def,
221}
222 218
223impl ExpansionInfo { 219impl ExpansionInfo {
224 pub fn call_node(&self) -> Option<InFile<SyntaxNode>> { 220 pub fn call_node(&self) -> Option<InFile<SyntaxNode>> {
@@ -241,17 +237,15 @@ impl ExpansionInfo {
241 pub fn map_token_up( 237 pub fn map_token_up(
242 &self, 238 &self,
243 token: InFile<&SyntaxToken>, 239 token: InFile<&SyntaxToken>,
244 ) -> Option<(InFile<SyntaxToken>, ExpansionOrigin)> { 240 ) -> Option<(InFile<SyntaxToken>, Origin)> {
245 let token_id = self.exp_map.token_by_range(token.value.text_range())?; 241 let token_id = self.exp_map.token_by_range(token.value.text_range())?;
246 242
247 let (token_id, origin) = self.macro_def.0.map_id_up(token_id); 243 let (token_id, origin) = self.macro_def.0.map_id_up(token_id);
248 let (token_map, tt, origin) = match origin { 244 let (token_map, tt) = match origin {
249 mbe::Origin::Call => (&self.macro_arg.1, self.arg.clone(), ExpansionOrigin::Call), 245 mbe::Origin::Call => (&self.macro_arg.1, self.arg.clone()),
250 mbe::Origin::Def => ( 246 mbe::Origin::Def => {
251 &self.macro_def.1, 247 (&self.macro_def.1, self.def.as_ref().map(|tt| tt.syntax().clone()))
252 self.def.as_ref().map(|tt| tt.syntax().clone()), 248 }
253 ExpansionOrigin::Def,
254 ),
255 }; 249 };
256 250
257 let range = token_map.range_by_token(token_id)?; 251 let range = token_map.range_by_token(token_id)?;
diff --git a/crates/ra_ide/src/expand.rs b/crates/ra_ide/src/expand.rs
index 327393dbb..258478bc1 100644
--- a/crates/ra_ide/src/expand.rs
+++ b/crates/ra_ide/src/expand.rs
@@ -1,7 +1,7 @@
1//! Utilities to work with files, produced by macros. 1//! Utilities to work with files, produced by macros.
2use std::iter::successors; 2use std::iter::successors;
3 3
4use hir::{ExpansionOrigin, InFile}; 4use hir::{InFile, Origin};
5use ra_db::FileId; 5use ra_db::FileId;
6use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxToken, TextRange}; 6use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxToken, TextRange};
7 7
@@ -45,7 +45,7 @@ pub(crate) fn original_range_by_kind(
45 45
46 if first.file_id != last.file_id 46 if first.file_id != last.file_id
47 || first_origin != last_origin 47 || first_origin != last_origin
48 || (kind == OriginalRangeKind::CallToken && first_origin != ExpansionOrigin::Call) 48 || (kind == OriginalRangeKind::CallToken && first_origin != Origin::Call)
49 { 49 {
50 return None; 50 return None;
51 } 51 }
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index 0d2d43bef..ce2deadf6 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -104,6 +104,7 @@ impl Shift {
104 } 104 }
105} 105}
106 106
107#[derive(Debug, Eq, PartialEq)]
107pub enum Origin { 108pub enum Origin {
108 Def, 109 Def,
109 Call, 110 Call,