diff options
author | Edwin Cheng <[email protected]> | 2019-12-08 08:16:52 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-12-08 08:16:52 +0000 |
commit | 509fedd9d2f228c6dca762cbf06c31af34ac0c75 (patch) | |
tree | 973ccea0049ee917a7f901a7e0238f7ef6c984bc /crates/ra_hir/src | |
parent | 9e551d5452232d1d44e4bba754392beaa3a7628f (diff) |
Remove MacroFileKind
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index b80aaeb90..c5a920688 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -21,7 +21,6 @@ use hir_def::{ | |||
21 | }; | 21 | }; |
22 | use hir_expand::{ | 22 | use hir_expand::{ |
23 | hygiene::Hygiene, name::AsName, AstId, HirFileId, InFile, MacroCallId, MacroCallKind, | 23 | hygiene::Hygiene, name::AsName, AstId, HirFileId, InFile, MacroCallId, MacroCallKind, |
24 | MacroFileKind, | ||
25 | }; | 24 | }; |
26 | use ra_syntax::{ | 25 | use ra_syntax::{ |
27 | ast::{self, AstNode}, | 26 | ast::{self, AstNode}, |
@@ -142,7 +141,6 @@ pub struct ReferenceDescriptor { | |||
142 | 141 | ||
143 | #[derive(Debug)] | 142 | #[derive(Debug)] |
144 | pub struct Expansion { | 143 | pub struct Expansion { |
145 | macro_file_kind: MacroFileKind, | ||
146 | macro_call_id: MacroCallId, | 144 | macro_call_id: MacroCallId, |
147 | } | 145 | } |
148 | 146 | ||
@@ -157,7 +155,7 @@ impl Expansion { | |||
157 | } | 155 | } |
158 | 156 | ||
159 | pub fn file_id(&self) -> HirFileId { | 157 | pub fn file_id(&self) -> HirFileId { |
160 | self.macro_call_id.as_file(self.macro_file_kind) | 158 | self.macro_call_id.as_file() |
161 | } | 159 | } |
162 | } | 160 | } |
163 | 161 | ||
@@ -456,10 +454,7 @@ impl SourceAnalyzer { | |||
456 | macro_call.file_id, | 454 | macro_call.file_id, |
457 | db.ast_id_map(macro_call.file_id).ast_id(macro_call.value), | 455 | db.ast_id_map(macro_call.file_id).ast_id(macro_call.value), |
458 | ); | 456 | ); |
459 | Some(Expansion { | 457 | Some(Expansion { macro_call_id: def.as_call_id(db, MacroCallKind::FnLike(ast_id)) }) |
460 | macro_call_id: def.as_call_id(db, MacroCallKind::FnLike(ast_id)), | ||
461 | macro_file_kind: to_macro_file_kind(macro_call.value), | ||
462 | }) | ||
463 | } | 458 | } |
464 | } | 459 | } |
465 | 460 | ||
@@ -543,35 +538,3 @@ fn adjust( | |||
543 | }) | 538 | }) |
544 | .map(|(_ptr, scope)| *scope) | 539 | .map(|(_ptr, scope)| *scope) |
545 | } | 540 | } |
546 | |||
547 | /// Given a `ast::MacroCall`, return what `MacroKindFile` it belongs to. | ||
548 | /// FIXME: Not completed | ||
549 | fn to_macro_file_kind(macro_call: &ast::MacroCall) -> MacroFileKind { | ||
550 | let syn = macro_call.syntax(); | ||
551 | let parent = match syn.parent() { | ||
552 | Some(it) => it, | ||
553 | None => { | ||
554 | // FIXME: | ||
555 | // If it is root, which means the parent HirFile | ||
556 | // MacroKindFile must be non-items | ||
557 | // return expr now. | ||
558 | return MacroFileKind::Expr; | ||
559 | } | ||
560 | }; | ||
561 | |||
562 | match parent.kind() { | ||
563 | MACRO_ITEMS | SOURCE_FILE => MacroFileKind::Items, | ||
564 | LET_STMT => { | ||
565 | // FIXME: Handle Pattern | ||
566 | MacroFileKind::Expr | ||
567 | } | ||
568 | EXPR_STMT => MacroFileKind::Statements, | ||
569 | BLOCK => MacroFileKind::Statements, | ||
570 | ARG_LIST => MacroFileKind::Expr, | ||
571 | TRY_EXPR => MacroFileKind::Expr, | ||
572 | _ => { | ||
573 | // Unknown , Just guess it is `Items` | ||
574 | MacroFileKind::Items | ||
575 | } | ||
576 | } | ||
577 | } | ||