Skip to content

Commit 72d58c7

Browse files
authored
Merge pull request #1208 from DougGregor/macro-attribute-generalize
Generalize macro expansion for macros written as attributes
2 parents 5307fa1 + f04885f commit 72d58c7

File tree

19 files changed

+204
-89
lines changed

19 files changed

+204
-89
lines changed

CodeGeneration/Sources/SyntaxSupport/gyb_generated/CommonNodes.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public let COMMON_NODES: [Node] = [
4545
Node(name: "MissingDecl",
4646
nameForDiagnostics: "declaration",
4747
kind: "Decl",
48+
traits: [
49+
"Attributed"
50+
],
4851
children: [
4952
Child(name: "Attributes",
5053
kind: "AttributeList",

CodeGeneration/Sources/SyntaxSupport/gyb_generated/DeclNodes.swift

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public let DECL_NODES: [Node] = [
3030
nameForDiagnostics: "typealias declaration",
3131
kind: "Decl",
3232
traits: [
33-
"IdentifiedDecl"
33+
"IdentifiedDecl",
34+
"Attributed"
3435
],
3536
children: [
3637
Child(name: "Attributes",
@@ -65,7 +66,8 @@ public let DECL_NODES: [Node] = [
6566
nameForDiagnostics: "associatedtype declaration",
6667
kind: "Decl",
6768
traits: [
68-
"IdentifiedDecl"
69+
"IdentifiedDecl",
70+
"Attributed"
6971
],
7072
children: [
7173
Child(name: "Attributes",
@@ -454,7 +456,8 @@ public let DECL_NODES: [Node] = [
454456
kind: "Decl",
455457
traits: [
456458
"DeclGroup",
457-
"IdentifiedDecl"
459+
"IdentifiedDecl",
460+
"Attributed"
458461
],
459462
children: [
460463
Child(name: "Attributes",
@@ -493,7 +496,8 @@ public let DECL_NODES: [Node] = [
493496
kind: "Decl",
494497
traits: [
495498
"DeclGroup",
496-
"IdentifiedDecl"
499+
"IdentifiedDecl",
500+
"Attributed"
497501
],
498502
children: [
499503
Child(name: "Attributes",
@@ -535,7 +539,8 @@ public let DECL_NODES: [Node] = [
535539
kind: "Decl",
536540
traits: [
537541
"DeclGroup",
538-
"IdentifiedDecl"
542+
"IdentifiedDecl",
543+
"Attributed"
539544
],
540545
children: [
541546
Child(name: "Attributes",
@@ -574,7 +579,8 @@ public let DECL_NODES: [Node] = [
574579
kind: "Decl",
575580
traits: [
576581
"DeclGroup",
577-
"IdentifiedDecl"
582+
"IdentifiedDecl",
583+
"Attributed"
578584
],
579585
children: [
580586
Child(name: "Attributes",
@@ -612,7 +618,8 @@ public let DECL_NODES: [Node] = [
612618
nameForDiagnostics: "extension",
613619
kind: "Decl",
614620
traits: [
615-
"DeclGroup"
621+
"DeclGroup",
622+
"Attributed"
616623
],
617624
children: [
618625
Child(name: "Attributes",
@@ -721,7 +728,8 @@ public let DECL_NODES: [Node] = [
721728
nameForDiagnostics: "parameter",
722729
kind: "Syntax",
723730
traits: [
724-
"WithTrailingComma"
731+
"WithTrailingComma",
732+
"Attributed"
725733
],
726734
children: [
727735
Child(name: "Attributes",
@@ -783,7 +791,8 @@ public let DECL_NODES: [Node] = [
783791
nameForDiagnostics: "function",
784792
kind: "Decl",
785793
traits: [
786-
"IdentifiedDecl"
794+
"IdentifiedDecl",
795+
"Attributed"
787796
],
788797
children: [
789798
Child(name: "Attributes",
@@ -824,6 +833,9 @@ public let DECL_NODES: [Node] = [
824833
Node(name: "InitializerDecl",
825834
nameForDiagnostics: "initializer",
826835
kind: "Decl",
836+
traits: [
837+
"Attributed"
838+
],
827839
children: [
828840
Child(name: "Attributes",
829841
kind: "AttributeList",
@@ -862,6 +874,9 @@ public let DECL_NODES: [Node] = [
862874
Node(name: "DeinitializerDecl",
863875
nameForDiagnostics: "deinitializer",
864876
kind: "Decl",
877+
traits: [
878+
"Attributed"
879+
],
865880
children: [
866881
Child(name: "Attributes",
867882
kind: "AttributeList",
@@ -884,6 +899,9 @@ public let DECL_NODES: [Node] = [
884899
Node(name: "SubscriptDecl",
885900
nameForDiagnostics: "subscript",
886901
kind: "Decl",
902+
traits: [
903+
"Attributed"
904+
],
887905
children: [
888906
Child(name: "Attributes",
889907
kind: "AttributeList",
@@ -944,6 +962,9 @@ public let DECL_NODES: [Node] = [
944962
Node(name: "ImportDecl",
945963
nameForDiagnostics: "import",
946964
kind: "Decl",
965+
traits: [
966+
"Attributed"
967+
],
947968
children: [
948969
Child(name: "Attributes",
949970
kind: "AttributeList",
@@ -1003,6 +1024,9 @@ public let DECL_NODES: [Node] = [
10031024
Node(name: "AccessorDecl",
10041025
nameForDiagnostics: "accessor",
10051026
kind: "Decl",
1027+
traits: [
1028+
"Attributed"
1029+
],
10061030
children: [
10071031
Child(name: "Attributes",
10081032
kind: "AttributeList",
@@ -1118,6 +1142,9 @@ public let DECL_NODES: [Node] = [
11181142
Node(name: "VariableDecl",
11191143
nameForDiagnostics: "variable",
11201144
kind: "Decl",
1145+
traits: [
1146+
"Attributed"
1147+
],
11211148
children: [
11221149
Child(name: "Attributes",
11231150
kind: "AttributeList",
@@ -1179,6 +1206,9 @@ public let DECL_NODES: [Node] = [
11791206
nameForDiagnostics: "enum case",
11801207
description: "A `case` declaration of a Swift `enum`. It can have 1 or more`EnumCaseElement`s inside, each declaring a different case of theenum.",
11811208
kind: "Decl",
1209+
traits: [
1210+
"Attributed"
1211+
],
11821212
children: [
11831213
Child(name: "Attributes",
11841214
kind: "AttributeList",
@@ -1207,7 +1237,8 @@ public let DECL_NODES: [Node] = [
12071237
description: "A Swift `enum` declaration.",
12081238
kind: "Decl",
12091239
traits: [
1210-
"IdentifiedDecl"
1240+
"IdentifiedDecl",
1241+
"Attributed"
12111242
],
12121243
children: [
12131244
Child(name: "Attributes",
@@ -1254,7 +1285,8 @@ public let DECL_NODES: [Node] = [
12541285
description: "A Swift `operator` declaration.",
12551286
kind: "Decl",
12561287
traits: [
1257-
"IdentifiedDecl"
1288+
"IdentifiedDecl",
1289+
"Attributed"
12581290
],
12591291
children: [
12601292
Child(name: "Attributes",
@@ -1336,7 +1368,8 @@ public let DECL_NODES: [Node] = [
13361368
description: "A Swift `precedencegroup` declaration.",
13371369
kind: "Decl",
13381370
traits: [
1339-
"IdentifiedDecl"
1371+
"IdentifiedDecl",
1372+
"Attributed"
13401373
],
13411374
children: [
13421375
Child(name: "Attributes",
@@ -1495,7 +1528,8 @@ public let DECL_NODES: [Node] = [
14951528
nameForDiagnostics: "macro",
14961529
kind: "Decl",
14971530
traits: [
1498-
"IdentifiedDecl"
1531+
"IdentifiedDecl",
1532+
"Attributed"
14991533
],
15001534
children: [
15011535
Child(name: "Attributes",

CodeGeneration/Sources/SyntaxSupport/gyb_generated/ExprNodes.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ public let EXPR_NODES: [Node] = [
720720
Node(name: "ClosureSignature",
721721
nameForDiagnostics: "closure signature",
722722
kind: "Syntax",
723+
traits: [
724+
"Attributed"
725+
],
723726
children: [
724727
Child(name: "Attributes",
725728
kind: "AttributeList",

CodeGeneration/Sources/SyntaxSupport/gyb_generated/GenericNodes.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ public let GENERIC_NODES: [Node] = [
133133
nameForDiagnostics: "generic parameter",
134134
kind: "Syntax",
135135
traits: [
136-
"WithTrailingComma"
136+
"WithTrailingComma",
137+
"Attributed"
137138
],
138139
children: [
139140
Child(name: "Attributes",

CodeGeneration/Sources/SyntaxSupport/gyb_generated/Traits.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public class Trait {
2525
}
2626

2727
public let TRAITS: [Trait] = [
28+
Trait(traitName: "Attributed",
29+
children: [
30+
Child(name: "Attributes", kind: "AttributeList", isOptional: true),
31+
]
32+
),
2833
Trait(traitName: "DeclGroup",
2934
children: [
3035
Child(name: "Attributes", kind: "AttributeList", isOptional: true),

CodeGeneration/Sources/SyntaxSupport/gyb_generated/TypeNodes.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ public let TYPE_NODES: [Node] = [
355355
Node(name: "AttributedType",
356356
nameForDiagnostics: "type",
357357
kind: "Type",
358+
traits: [
359+
"Attributed"
360+
],
358361
children: [
359362
Child(name: "Specifier",
360363
kind: "Token",

Sources/SwiftSyntax/Documentation.docc/gyb_generated/SwiftSyntax.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ allows Swift tools to parse, inspect, generate, and transform Swift source code.
419419

420420
### Traits
421421

422+
- <doc:SwiftSyntax/AttributedSyntax>
422423
- <doc:SwiftSyntax/DeclGroupSyntax>
423424
- <doc:SwiftSyntax/BracedSyntax>
424425
- <doc:SwiftSyntax/IdentifiedDeclSyntax>

0 commit comments

Comments
 (0)