@@ -192,6 +192,7 @@ fn traverse(
192
192
let mut bindings_shadow_count: FxHashMap < Name , u32 > = FxHashMap :: default ( ) ;
193
193
194
194
let mut current_macro_call: Option < ast:: MacroCall > = None ;
195
+ let mut current_attr_macro_call = None ;
195
196
let mut current_macro: Option < ast:: Macro > = None ;
196
197
let mut macro_highlighter = MacroHighlighter :: default ( ) ;
197
198
let mut inside_attribute = false ;
@@ -227,6 +228,19 @@ fn traverse(
227
228
}
228
229
_ => ( ) ,
229
230
}
231
+ match event. clone ( ) . map ( |it| it. into_node ( ) . and_then ( ast:: Item :: cast) ) {
232
+ WalkEvent :: Enter ( Some ( item) ) => {
233
+ if sema. is_attr_macro_call ( & item) {
234
+ current_attr_macro_call = Some ( item) ;
235
+ }
236
+ }
237
+ WalkEvent :: Leave ( Some ( item) ) => {
238
+ if current_attr_macro_call == Some ( item) {
239
+ current_attr_macro_call = None ;
240
+ }
241
+ }
242
+ _ => ( ) ,
243
+ }
230
244
231
245
match event. clone ( ) . map ( |it| it. into_node ( ) . and_then ( ast:: Macro :: cast) ) {
232
246
WalkEvent :: Enter ( Some ( mac) ) => {
@@ -286,6 +300,22 @@ fn traverse(
286
300
}
287
301
None => token. into ( ) ,
288
302
}
303
+ } else if current_attr_macro_call. is_some ( ) {
304
+ let token = match element. clone ( ) . into_token ( ) {
305
+ Some ( it) => it,
306
+ _ => continue ,
307
+ } ;
308
+ let token = sema. descend_into_macros ( token. clone ( ) ) ;
309
+ match token. parent ( ) {
310
+ Some ( parent) => {
311
+ // We only care Name and Name_ref
312
+ match ( token. kind ( ) , parent. kind ( ) ) {
313
+ ( IDENT , NAME ) | ( IDENT , NAME_REF ) => parent. into ( ) ,
314
+ _ => token. into ( ) ,
315
+ }
316
+ }
317
+ None => token. into ( ) ,
318
+ }
289
319
} else {
290
320
element. clone ( )
291
321
} ;
0 commit comments