fix: ensure that highlight_related works for macro_expr

This commit is contained in:
roife 2024-07-10 01:23:27 +08:00
parent ae6e8d56d4
commit d94dcfa841
2 changed files with 13 additions and 6 deletions

View file

@ -14,7 +14,6 @@ use ide_db::{
FileId, RootDatabase,
};
use itertools::Itertools;
use span::FileRange;
use syntax::{
ast::{self, HasLoopBody, Label},
match_ast, AstNode, AstToken,

View file

@ -575,12 +575,20 @@ impl<'a> WalkExpandedExprCtx<'a> {
}
if let ast::Expr::MacroExpr(expr) = expr {
if let Some(expanded) = expr
.macro_call()
.and_then(|call| self.sema.expand(&call))
.and_then(ast::MacroStmts::cast)
if let Some(expanded) =
expr.macro_call().and_then(|call| self.sema.expand(&call))
{
self.handle_expanded(expanded, cb);
match_ast! {
match expanded {
ast::MacroStmts(it) => {
self.handle_expanded(it, cb);
},
ast::Expr(it) => {
self.walk(&it, cb);
},
_ => {}
}
}
}
}
}