@@ -22,6 +22,7 @@ pub mod span;
22
22
pub mod files;
23
23
mod fixup;
24
24
25
+ use attrs:: collect_attrs;
25
26
use triomphe:: Arc ;
26
27
27
28
use std:: { fmt, hash:: Hash } ;
@@ -32,7 +33,7 @@ use base_db::{
32
33
} ;
33
34
use either:: Either ;
34
35
use syntax:: {
35
- ast:: { self , AstNode , HasDocComments } ,
36
+ ast:: { self , AstNode } ,
36
37
SyntaxNode , SyntaxToken , TextRange , TextSize ,
37
38
} ;
38
39
@@ -438,9 +439,9 @@ impl MacroCallLoc {
438
439
MacroCallKind :: Derive { ast_id, derive_attr_index, .. } => {
439
440
// FIXME: handle `cfg_attr`
440
441
ast_id. with_value ( ast_id. to_node ( db) ) . map ( |it| {
441
- it . doc_comments_and_attrs ( )
442
+ collect_attrs ( & it )
442
443
. nth ( derive_attr_index. ast_index ( ) )
443
- . and_then ( |it| match it {
444
+ . and_then ( |it| match it. 1 {
444
445
Either :: Left ( attr) => Some ( attr. syntax ( ) . clone ( ) ) ,
445
446
Either :: Right ( _) => None ,
446
447
} )
@@ -451,9 +452,9 @@ impl MacroCallLoc {
451
452
if self . def . is_attribute_derive ( ) {
452
453
// FIXME: handle `cfg_attr`
453
454
ast_id. with_value ( ast_id. to_node ( db) ) . map ( |it| {
454
- it . doc_comments_and_attrs ( )
455
+ collect_attrs ( & it )
455
456
. nth ( invoc_attr_index. ast_index ( ) )
456
- . and_then ( |it| match it {
457
+ . and_then ( |it| match it. 1 {
457
458
Either :: Left ( attr) => Some ( attr. syntax ( ) . clone ( ) ) ,
458
459
Either :: Right ( _) => None ,
459
460
} )
@@ -549,24 +550,24 @@ impl MacroCallKind {
549
550
MacroCallKind :: Derive { ast_id, derive_attr_index, .. } => {
550
551
// FIXME: should be the range of the macro name, not the whole derive
551
552
// FIXME: handle `cfg_attr`
552
- ast_id
553
- . to_node ( db)
554
- . doc_comments_and_attrs ( )
553
+ collect_attrs ( & ast_id. to_node ( db) )
555
554
. nth ( derive_attr_index. ast_index ( ) )
556
555
. expect ( "missing derive" )
556
+ . 1
557
557
. expect_left ( "derive is a doc comment?" )
558
558
. syntax ( )
559
559
. text_range ( )
560
560
}
561
561
// FIXME: handle `cfg_attr`
562
- MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => ast_id
563
- . to_node ( db)
564
- . doc_comments_and_attrs ( )
565
- . nth ( invoc_attr_index. ast_index ( ) )
566
- . expect ( "missing attribute" )
567
- . expect_left ( "attribute macro is a doc comment?" )
568
- . syntax ( )
569
- . text_range ( ) ,
562
+ MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => {
563
+ collect_attrs ( & ast_id. to_node ( db) )
564
+ . nth ( invoc_attr_index. ast_index ( ) )
565
+ . expect ( "missing attribute" )
566
+ . 1
567
+ . expect_left ( "attribute macro is a doc comment?" )
568
+ . syntax ( )
569
+ . text_range ( )
570
+ }
570
571
} ;
571
572
572
573
FileRange { range, file_id }
@@ -737,11 +738,9 @@ impl ExpansionInfo {
737
738
let attr_input_or_mac_def = def. or_else ( || match loc. kind {
738
739
MacroCallKind :: Attr { ast_id, invoc_attr_index, .. } => {
739
740
// FIXME: handle `cfg_attr`
740
- let tt = ast_id
741
- . to_node ( db)
742
- . doc_comments_and_attrs ( )
741
+ let tt = collect_attrs ( & ast_id. to_node ( db) )
743
742
. nth ( invoc_attr_index. ast_index ( ) )
744
- . and_then ( Either :: left) ?
743
+ . and_then ( |x| Either :: left ( x . 1 ) ) ?
745
744
. token_tree ( ) ?;
746
745
Some ( InFile :: new ( ast_id. file_id , tt) )
747
746
}
0 commit comments