diff options
author | Edwin Cheng <[email protected]> | 2019-12-14 17:46:39 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-12-14 17:46:39 +0000 |
commit | b53587c7bdd67c63bd33a745fdaeb22a847b6c2f (patch) | |
tree | c4a73cb4d89ff6dce084f3b2af640e272b163319 /crates/ra_hir_expand/src | |
parent | 61360fdfec981eadef1eefb595c8b32c951771e8 (diff) |
Re-export Origin to replace ExpansionOrigin
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r-- | crates/ra_hir_expand/src/lib.rs | 20 |
1 files changed, 7 insertions, 13 deletions
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)] | 217 | pub use mbe::Origin; |
218 | pub enum ExpansionOrigin { | ||
219 | Call, | ||
220 | Def, | ||
221 | } | ||
222 | 218 | ||
223 | impl ExpansionInfo { | 219 | impl 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)?; |