Skip to content

Commit 9e0f4a4

Browse files
authored
Merge pull request #2006 from Matejkob/remove-string-based-reference-of-tokens
Replace string-based token references with `Token` enum in CodeGeneration
2 parents e9c5d1a + 8ebbac7 commit 9e0f4a4

22 files changed

+585
-480
lines changed

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public let ATTRIBUTE_NODES: [Node] = [
3939
Child(
4040
name: "AtSign",
4141
deprecatedName: "AtSignToken",
42-
kind: .token(choices: [.token(tokenKind: "AtSignToken")]),
42+
kind: .token(choices: [.token(.atSign)]),
4343
documentation: "The `@` sign."
4444
),
4545
Child(
@@ -50,7 +50,7 @@ public let ATTRIBUTE_NODES: [Node] = [
5050
),
5151
Child(
5252
name: "LeftParen",
53-
kind: .token(choices: [.token(tokenKind: "LeftParenToken")]),
53+
kind: .token(choices: [.token(.leftParen)]),
5454
documentation: "If the attribute takes arguments, the opening parenthesis.",
5555
isOptional: true
5656
),
@@ -144,7 +144,7 @@ public let ATTRIBUTE_NODES: [Node] = [
144144
),
145145
Child(
146146
name: "RightParen",
147-
kind: .token(choices: [.token(tokenKind: "RightParenToken")]),
147+
kind: .token(choices: [.token(.rightParen)]),
148148
documentation: "If the attribute takes arguments, the closing parenthesis.",
149149
isOptional: true
150150
),
@@ -166,7 +166,7 @@ public let ATTRIBUTE_NODES: [Node] = [
166166
),
167167
Child(
168168
name: "Colon",
169-
kind: .token(choices: [.token(tokenKind: "ColonToken")]),
169+
kind: .token(choices: [.token(.colon)]),
170170
documentation: "The colon separating the label and the value"
171171
),
172172
Child(
@@ -176,7 +176,7 @@ public let ATTRIBUTE_NODES: [Node] = [
176176
),
177177
Child(
178178
name: "Semicolon",
179-
kind: .token(choices: [.token(tokenKind: "SemicolonToken")])
179+
kind: .token(choices: [.token(.semicolon)])
180180
),
181181
]
182182
),
@@ -196,7 +196,7 @@ public let ATTRIBUTE_NODES: [Node] = [
196196
),
197197
Child(
198198
name: "TrailingComma",
199-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
199+
kind: .token(choices: [.token(.comma)]),
200200
documentation: "A trailing comma if the argument is followed by another argument",
201201
isOptional: true
202202
),
@@ -227,7 +227,7 @@ public let ATTRIBUTE_NODES: [Node] = [
227227
),
228228
Child(
229229
name: "Colon",
230-
kind: .token(choices: [.token(tokenKind: "ColonToken")]),
230+
kind: .token(choices: [.token(.colon)]),
231231
documentation: "The colon separating \"before\" and the parameter list."
232232
),
233233
Child(
@@ -248,12 +248,12 @@ public let ATTRIBUTE_NODES: [Node] = [
248248
children: [
249249
Child(
250250
name: "ConventionLabel",
251-
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]),
251+
kind: .token(choices: [.token(.identifier)]),
252252
documentation: "The convention label."
253253
),
254254
Child(
255255
name: "Comma",
256-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
256+
kind: .token(choices: [.token(.comma)]),
257257
isOptional: true
258258
),
259259
Child(
@@ -263,7 +263,7 @@ public let ATTRIBUTE_NODES: [Node] = [
263263
),
264264
Child(
265265
name: "Colon",
266-
kind: .token(choices: [.token(tokenKind: "ColonToken")]),
266+
kind: .token(choices: [.token(.colon)]),
267267
isOptional: true
268268
),
269269
Child(
@@ -287,11 +287,11 @@ public let ATTRIBUTE_NODES: [Node] = [
287287
),
288288
Child(
289289
name: "Colon",
290-
kind: .token(choices: [.token(tokenKind: "ColonToken")])
290+
kind: .token(choices: [.token(.colon)])
291291
),
292292
Child(
293293
name: "ProtocolName",
294-
kind: .token(choices: [.token(tokenKind: "IdentifierToken")])
294+
kind: .token(choices: [.token(.identifier)])
295295
),
296296
]
297297
),
@@ -316,7 +316,7 @@ public let ATTRIBUTE_NODES: [Node] = [
316316
),
317317
Child(
318318
name: "Colon",
319-
kind: .token(choices: [.token(tokenKind: "ColonToken")]),
319+
kind: .token(choices: [.token(.colon)]),
320320
documentation: "The colon separating the \"of\" label and the original declaration name."
321321
),
322322
Child(
@@ -326,7 +326,7 @@ public let ATTRIBUTE_NODES: [Node] = [
326326
),
327327
Child(
328328
name: "Period",
329-
kind: .token(choices: [.token(tokenKind: "PeriodToken")]),
329+
kind: .token(choices: [.token(.period)]),
330330
documentation: "The period separating the original declaration name and the accessor name.",
331331
isOptional: true
332332
),
@@ -339,7 +339,7 @@ public let ATTRIBUTE_NODES: [Node] = [
339339
),
340340
Child(
341341
name: "Comma",
342-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
342+
kind: .token(choices: [.token(.comma)]),
343343
isOptional: true
344344
),
345345
Child(
@@ -373,11 +373,11 @@ public let ATTRIBUTE_NODES: [Node] = [
373373
Child(
374374
name: "Argument",
375375
deprecatedName: "Parameter",
376-
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .token(tokenKind: "IntegerLiteralToken"), .keyword(text: "self")])
376+
kind: .token(choices: [.token(.identifier), .token(.integerLiteral), .keyword(text: "self")])
377377
),
378378
Child(
379379
name: "TrailingComma",
380-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
380+
kind: .token(choices: [.token(.comma)]),
381381
isOptional: true
382382
),
383383
]
@@ -398,7 +398,7 @@ public let ATTRIBUTE_NODES: [Node] = [
398398
),
399399
Child(
400400
name: "Colon",
401-
kind: .token(choices: [.token(tokenKind: "ColonToken")]),
401+
kind: .token(choices: [.token(.colon)]),
402402
documentation: "The colon separating \"wrt\" and the parameter list."
403403
),
404404
Child(
@@ -430,7 +430,7 @@ public let ATTRIBUTE_NODES: [Node] = [
430430
children: [
431431
Child(
432432
name: "LeftParen",
433-
kind: .token(choices: [.token(tokenKind: "LeftParenToken")])
433+
kind: .token(choices: [.token(.leftParen)])
434434
),
435435
Child(
436436
name: "Arguments",
@@ -440,7 +440,7 @@ public let ATTRIBUTE_NODES: [Node] = [
440440
),
441441
Child(
442442
name: "RightParen",
443-
kind: .token(choices: [.token(tokenKind: "RightParenToken")])
443+
kind: .token(choices: [.token(.rightParen)])
444444
),
445445
]
446446
),
@@ -465,7 +465,7 @@ public let ATTRIBUTE_NODES: [Node] = [
465465
Child(
466466
name: "KindSpecifierComma",
467467
deprecatedName: "DiffKindComma",
468-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
468+
kind: .token(choices: [.token(.comma)]),
469469
documentation: "The comma following the differentiability kind, if it exists.",
470470
isOptional: true
471471
),
@@ -478,7 +478,7 @@ public let ATTRIBUTE_NODES: [Node] = [
478478
Child(
479479
name: "ArgumentsComma",
480480
deprecatedName: "DiffParamsComma",
481-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
481+
kind: .token(choices: [.token(.comma)]),
482482
documentation: "The comma following the differentiability arguments clause, if it exists.",
483483
isOptional: true
484484
),
@@ -507,15 +507,15 @@ public let ATTRIBUTE_NODES: [Node] = [
507507
),
508508
Child(
509509
name: "Colon",
510-
kind: .token(choices: [.token(tokenKind: "ColonToken")])
510+
kind: .token(choices: [.token(.colon)])
511511
),
512512
Child(
513513
name: "Value",
514514
kind: .nodeChoices(choices: [
515515
Child(
516516
name: "Token",
517517
kind: .token(choices: [
518-
.token(tokenKind: "IdentifierToken"),
518+
.token(.identifier),
519519
.keyword(text: "private"),
520520
.keyword(text: "fileprivate"),
521521
.keyword(text: "internal"),
@@ -531,7 +531,7 @@ public let ATTRIBUTE_NODES: [Node] = [
531531
),
532532
Child(
533533
name: "TrailingComma",
534-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
534+
kind: .token(choices: [.token(.comma)]),
535535
documentation: "A trailing comma if this argument is followed by another one",
536536
isOptional: true
537537
),
@@ -558,7 +558,7 @@ public let ATTRIBUTE_NODES: [Node] = [
558558
),
559559
Child(
560560
name: "Colon",
561-
kind: .token(choices: [.token(tokenKind: "ColonToken")])
561+
kind: .token(choices: [.token(.colon)])
562562
),
563563
Child(
564564
name: "DeclName",
@@ -588,7 +588,7 @@ public let ATTRIBUTE_NODES: [Node] = [
588588
),
589589
Child(
590590
name: "Comma",
591-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
591+
kind: .token(choices: [.token(.comma)]),
592592
isOptional: true
593593
),
594594
Child(
@@ -616,7 +616,7 @@ public let ATTRIBUTE_NODES: [Node] = [
616616
),
617617
Child(
618618
name: "Comma",
619-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
619+
kind: .token(choices: [.token(.comma)]),
620620
documentation: "The comma separating the type and method name"
621621
),
622622
Child(
@@ -656,7 +656,7 @@ public let ATTRIBUTE_NODES: [Node] = [
656656
),
657657
Child(
658658
name: "Colon",
659-
kind: .token(choices: [.token(tokenKind: "ColonToken")]),
659+
kind: .token(choices: [.token(.colon)]),
660660
documentation: "The colon separating the label and the value"
661661
),
662662
Child(
@@ -667,7 +667,7 @@ public let ATTRIBUTE_NODES: [Node] = [
667667
),
668668
Child(
669669
name: "TrailingComma",
670-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
670+
kind: .token(choices: [.token(.comma)]),
671671
documentation: "A trailing comma if this argument is followed by another one",
672672
isOptional: true
673673
),
@@ -690,7 +690,7 @@ public let ATTRIBUTE_NODES: [Node] = [
690690
),
691691
Child(
692692
name: "Colon",
693-
kind: .token(choices: [.token(tokenKind: "ColonToken")]),
693+
kind: .token(choices: [.token(.colon)]),
694694
isOptional: true
695695
),
696696
]
@@ -718,11 +718,11 @@ public let ATTRIBUTE_NODES: [Node] = [
718718
),
719719
Child(
720720
name: "Comma",
721-
kind: .token(choices: [.token(tokenKind: "CommaToken")])
721+
kind: .token(choices: [.token(.comma)])
722722
),
723723
Child(
724724
name: "Ordinal",
725-
kind: .token(choices: [.token(tokenKind: "IntegerLiteralToken")]),
725+
kind: .token(choices: [.token(.integerLiteral)]),
726726
documentation: "The ordinal corresponding to the 'some' keyword that introduced this opaque type."
727727
),
728728
]
@@ -740,15 +740,15 @@ public let ATTRIBUTE_NODES: [Node] = [
740740
),
741741
Child(
742742
name: "Colon",
743-
kind: .token(choices: [.token(tokenKind: "ColonToken")])
743+
kind: .token(choices: [.token(.colon)])
744744
),
745745
Child(
746746
name: "ModuleName",
747747
kind: .node(kind: .stringLiteralExpr)
748748
),
749749
Child(
750750
name: "Comma",
751-
kind: .token(choices: [.token(tokenKind: "CommaToken")])
751+
kind: .token(choices: [.token(.comma)])
752752
),
753753
Child(
754754
name: "Platforms",
@@ -782,7 +782,7 @@ public let ATTRIBUTE_NODES: [Node] = [
782782
Child(
783783
name: "Period",
784784
deprecatedName: "Dot",
785-
kind: .token(choices: [.token(tokenKind: "PeriodToken")]),
785+
kind: .token(choices: [.token(.period)]),
786786
isOptional: true
787787
),
788788
Child(
@@ -827,7 +827,7 @@ public let ATTRIBUTE_NODES: [Node] = [
827827
),
828828
Child(
829829
name: "Colon",
830-
kind: .token(choices: [.token(tokenKind: "ColonToken")]),
830+
kind: .token(choices: [.token(.colon)]),
831831
documentation: "The colon separating the label and the value"
832832
),
833833
Child(
@@ -839,7 +839,7 @@ public let ATTRIBUTE_NODES: [Node] = [
839839
),
840840
Child(
841841
name: "TrailingComma",
842-
kind: .token(choices: [.token(tokenKind: "CommaToken")]),
842+
kind: .token(choices: [.token(.comma)]),
843843
documentation: "A trailing comma if this argument is followed by another one",
844844
isOptional: true
845845
),
@@ -858,7 +858,7 @@ public let ATTRIBUTE_NODES: [Node] = [
858858
),
859859
Child(
860860
name: "Colon",
861-
kind: .token(choices: [.token(tokenKind: "ColonToken")])
861+
kind: .token(choices: [.token(.colon)])
862862
),
863863
Child(
864864
name: "Message",
@@ -879,7 +879,7 @@ public let ATTRIBUTE_NODES: [Node] = [
879879
),
880880
Child(
881881
name: "Colon",
882-
kind: .token(choices: [.token(tokenKind: "ColonToken")])
882+
kind: .token(choices: [.token(.colon)])
883883
),
884884
Child(
885885
name: "Filename",

0 commit comments

Comments
 (0)