@@ -692,72 +692,182 @@ final class AttributeTests: ParserTestCase {
692
692
func testMacroRoleNames( ) {
693
693
assertParse (
694
694
"""
695
- @attached(member, names: named(deinit ))
695
+ @attached(member, names: named(1️⃣deinit ))
696
696
macro m()
697
- """
697
+ """ ,
698
+ substructure: DeclReferenceExprSyntax ( baseName: . keyword( . `deinit`) ) ,
699
+ substructureAfterMarker: " 1️⃣ "
698
700
)
699
701
700
702
assertParse (
701
703
"""
702
- @attached(member, names: named(init ))
704
+ @attached(member, names: named(1️⃣init ))
703
705
macro m()
704
- """
706
+ """ ,
707
+ substructure: DeclReferenceExprSyntax ( baseName: . keyword( . `init`) ) ,
708
+ substructureAfterMarker: " 1️⃣ "
705
709
)
706
710
707
711
assertParse (
708
712
"""
709
- @attached(member, names: named(init (a:b:)))
713
+ @attached(member, names: named(1️⃣init (a:b:)))
710
714
macro m()
711
- """
715
+ """ ,
716
+ substructure: DeclReferenceExprSyntax (
717
+ baseName: . keyword( . `init`) ,
718
+ argumentNames: DeclNameArgumentsSyntax (
719
+ arguments: [
720
+ DeclNameArgumentSyntax ( name: . identifier( " a " ) ) ,
721
+ DeclNameArgumentSyntax ( name: . identifier( " b " ) ) ,
722
+ ]
723
+ )
724
+ ) ,
725
+ substructureAfterMarker: " 1️⃣ "
712
726
)
713
727
714
728
assertParse (
715
729
"""
716
- @attached(member, names: named(subscript ))
730
+ @attached(member, names: named(1️⃣subscript ))
717
731
macro m()
718
- """
732
+ """ ,
733
+ substructure: DeclReferenceExprSyntax ( baseName: . keyword( . `subscript`) ) ,
734
+ substructureAfterMarker: " 1️⃣ "
719
735
)
720
736
721
737
assertParse (
722
738
"""
723
- @attached(declaration, names: named(subscript (a:b:)))
739
+ @attached(declaration, names: named(1️⃣subscript (a:b:)))
724
740
macro m()
725
- """
741
+ """ ,
742
+ substructure: DeclReferenceExprSyntax (
743
+ baseName: . keyword( . `subscript`) ,
744
+ argumentNames: DeclNameArgumentsSyntax (
745
+ arguments: [
746
+ DeclNameArgumentSyntax ( name: . identifier( " a " ) ) ,
747
+ DeclNameArgumentSyntax ( name: . identifier( " b " ) ) ,
748
+ ]
749
+ )
750
+ ) ,
751
+ substructureAfterMarker: " 1️⃣ "
726
752
)
727
753
728
754
assertParse (
729
755
"""
730
- @freestanding(declaration, names: named(deinit ))
756
+ @freestanding(declaration, names: named(1️⃣deinit ))
731
757
macro m()
732
- """
758
+ """ ,
759
+ substructure: DeclReferenceExprSyntax ( baseName: . keyword( . `deinit`) ) ,
760
+ substructureAfterMarker: " 1️⃣ "
733
761
)
734
762
735
763
assertParse (
736
764
"""
737
- @freestanding(declaration, names: named(init ))
765
+ @freestanding(declaration, names: named(1️⃣init ))
738
766
macro m()
739
- """
767
+ """ ,
768
+ substructure: DeclReferenceExprSyntax ( baseName: . keyword( . `init`) ) ,
769
+ substructureAfterMarker: " 1️⃣ "
740
770
)
741
771
742
772
assertParse (
743
773
"""
744
- @freestanding(declaration, names: named(init (a:b:)))
774
+ @freestanding(declaration, names: named(1️⃣init (a:b:)))
745
775
macro m()
746
- """
776
+ """ ,
777
+ substructure: DeclReferenceExprSyntax (
778
+ baseName: . keyword( . `init`) ,
779
+ argumentNames: DeclNameArgumentsSyntax (
780
+ arguments: [
781
+ DeclNameArgumentSyntax ( name: . identifier( " a " ) ) ,
782
+ DeclNameArgumentSyntax ( name: . identifier( " b " ) ) ,
783
+ ]
784
+ )
785
+ ) ,
786
+ substructureAfterMarker: " 1️⃣ "
747
787
)
748
788
749
789
assertParse (
750
790
"""
751
- @freestanding(member, names: named(subscript ))
791
+ @freestanding(member, names: named(1️⃣subscript ))
752
792
macro m()
793
+ """ ,
794
+ substructure: DeclReferenceExprSyntax ( baseName: . keyword( . `subscript`) ) ,
795
+ substructureAfterMarker: " 1️⃣ "
796
+ )
797
+
798
+ assertParse (
753
799
"""
800
+ @freestanding(member, names: named(1️⃣subscript(a:b:)))
801
+ macro m()
802
+ """ ,
803
+ substructure: DeclReferenceExprSyntax (
804
+ baseName: . keyword( . `subscript`) ,
805
+ argumentNames: DeclNameArgumentsSyntax (
806
+ arguments: [
807
+ DeclNameArgumentSyntax ( name: . identifier( " a " ) ) ,
808
+ DeclNameArgumentSyntax ( name: . identifier( " b " ) ) ,
809
+ ]
810
+ )
811
+ ) ,
812
+ substructureAfterMarker: " 1️⃣ "
754
813
)
755
814
756
815
assertParse (
757
816
"""
758
- @freestanding (member, names: named(subscript(a:b:) ))
817
+ @attached (member, names: named(1️⃣`class` ))
759
818
macro m()
819
+ """ ,
820
+ substructure: DeclReferenceExprSyntax ( baseName: . identifier( " `class` " ) ) ,
821
+ substructureAfterMarker: " 1️⃣ "
822
+ )
823
+
824
+ assertParse (
760
825
"""
826
+ @attached4️⃣(member, names: named(1️⃣class2️⃣))
827
+ macro m()3️⃣
828
+ """ ,
829
+ diagnostics: [
830
+ DiagnosticSpec (
831
+ locationMarker: " 1️⃣ " ,
832
+ message: " expected value and ')' to end function call " ,
833
+ fixIts: [ " insert value and ')' " ]
834
+ ) ,
835
+ DiagnosticSpec (
836
+ locationMarker: " 1️⃣ " ,
837
+ message: " expected ')' to end attribute " ,
838
+ notes: [
839
+ NoteSpec (
840
+ locationMarker: " 4️⃣ " ,
841
+ message: " to match this opening '(' "
842
+ )
843
+ ] ,
844
+ fixIts: [ " insert ')' " ]
845
+ ) ,
846
+ DiagnosticSpec (
847
+ locationMarker: " 2️⃣ " ,
848
+ message: " expected identifier in class " ,
849
+ fixIts: [ " insert identifier " ]
850
+ ) ,
851
+ DiagnosticSpec (
852
+ locationMarker: " 2️⃣ " ,
853
+ message: " expected '{' in class " ,
854
+ fixIts: [ " insert '{' " ]
855
+ ) ,
856
+ DiagnosticSpec (
857
+ locationMarker: " 2️⃣ " ,
858
+ message: " unexpected code '))' before macro "
859
+ ) ,
860
+ DiagnosticSpec (
861
+ locationMarker: " 3️⃣ " ,
862
+ message: " expected '}' to end class " ,
863
+ fixIts: [ " insert '}' " ]
864
+ ) ,
865
+ ] ,
866
+ fixedSource: """
867
+ @attached(member, names: named(<#expression#>)) class <#identifier#> {))
868
+ macro m()
869
+ }
870
+ """
761
871
)
762
872
}
763
873
0 commit comments