aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/source_binder.rs41
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};
22use hir_expand::{ 22use 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};
26use ra_syntax::{ 25use 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)]
144pub struct Expansion { 143pub 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
549fn 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}