store macro kind in HirFileId

This commit is contained in:
Aleksey Kladov 2019-05-14 01:12:07 +03:00
parent ee0ab7c00b
commit 101b3abfd7
4 changed files with 38 additions and 21 deletions

View file

@ -6,11 +6,11 @@ use rustc_hash::FxHashMap;
use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap};
use ra_syntax::{
SyntaxNodePtr, AstPtr, AstNode,
ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind,ArrayExprKind, TypeAscriptionOwner}
ast::{self, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind,ArrayExprKind, TypeAscriptionOwner},
};
use crate::{
Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc,
Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind,
name::AsName,
type_ref::{Mutability, TypeRef},
};
@ -833,8 +833,11 @@ where
if let Some(tt) = self.db.macro_expand(call_id).ok() {
if let Some(expr) = mbe::token_tree_to_expr(&tt).ok() {
log::debug!("macro expansion {}", expr.syntax().debug_dump());
let old_file_id =
std::mem::replace(&mut self.current_file_id, call_id.into());
let old_file_id = std::mem::replace(
&mut self.current_file_id,
//BUG
call_id.as_file(MacroFileKind::Items),
);
let id = self.collect_expr(&expr);
self.current_file_id = old_file_id;
return id;