mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
remove some hacks from nameresolution for macros
This commit is contained in:
parent
780e1a365b
commit
caefa6982b
7 changed files with 68 additions and 66 deletions
|
@ -827,25 +827,25 @@ where
|
|||
ast::ExprKind::IndexExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
|
||||
ast::ExprKind::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
|
||||
ast::ExprKind::MacroCall(e) => {
|
||||
// very hacky.FIXME change to use the macro resolution
|
||||
let path = e.path().and_then(Path::from_ast);
|
||||
|
||||
let ast_id = self
|
||||
.db
|
||||
.ast_id_map(self.current_file_id)
|
||||
.ast_id(e)
|
||||
.with_file_id(self.current_file_id);
|
||||
|
||||
if let Some(def) = self.resolver.resolve_macro_call(self.db, path) {
|
||||
let call_id = MacroCallLoc { def, ast_id }.id(self.db);
|
||||
let file_id = call_id.as_file(MacroFileKind::Expr);
|
||||
if let Some(node) = self.db.parse_or_expand(file_id) {
|
||||
if let Some(expr) = ast::Expr::cast(&*node) {
|
||||
log::debug!("macro expansion {}", expr.syntax().debug_dump());
|
||||
let old_file_id = std::mem::replace(&mut self.current_file_id, file_id);
|
||||
let id = self.collect_expr(&expr);
|
||||
self.current_file_id = old_file_id;
|
||||
return id;
|
||||
if let Some(path) = e.path().and_then(Path::from_ast) {
|
||||
if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) {
|
||||
let call_id = MacroCallLoc { def: def.id, ast_id }.id(self.db);
|
||||
let file_id = call_id.as_file(MacroFileKind::Expr);
|
||||
if let Some(node) = self.db.parse_or_expand(file_id) {
|
||||
if let Some(expr) = ast::Expr::cast(&*node) {
|
||||
log::debug!("macro expansion {}", expr.syntax().debug_dump());
|
||||
let old_file_id =
|
||||
std::mem::replace(&mut self.current_file_id, file_id);
|
||||
let id = self.collect_expr(&expr);
|
||||
self.current_file_id = old_file_id;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue