Skip to content

Commit ec5e933

Browse files
committed
[NFC] Change deprecated child representation
Introduce a much more sophisticated way of describing past revisions to a node’s children. This allows: • Multiple past changes (for instance, a property that has been renamed more than once). • The ability to represent the order of multiple changes and group together simultaneous changes. • Multiple kinds of changes, including changes that introduce more than one member. Note that this commit does not use any of these new capabilities; it just ports existing behavior to the new representation.
1 parent 7031ea3 commit ec5e933

20 files changed

+923
-308
lines changed

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

+74-22
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public let ATTRIBUTE_NODES: [Node] = [
4141
children: [
4242
Child(
4343
name: "atSign",
44-
deprecatedName: "atSignToken",
4544
kind: .token(choices: [.token(.atSign)]),
4645
documentation: "The `@` sign."
4746
),
@@ -59,7 +58,6 @@ public let ATTRIBUTE_NODES: [Node] = [
5958
),
6059
Child(
6160
name: "arguments",
62-
deprecatedName: "argument",
6361
kind: .nodeChoices(choices: [
6462
Child(
6563
name: "argumentList",
@@ -156,6 +154,12 @@ public let ATTRIBUTE_NODES: [Node] = [
156154
documentation: "If the attribute takes arguments, the closing parenthesis.",
157155
isOptional: true
158156
),
157+
],
158+
childHistory: [
159+
[
160+
"atSign": .renamed(from: "atSignToken"),
161+
"arguments": .renamed(from: "argument"),
162+
]
159163
]
160164
),
161165

@@ -167,7 +171,6 @@ public let ATTRIBUTE_NODES: [Node] = [
167171
children: [
168172
Child(
169173
name: "availabilityLabel",
170-
deprecatedName: "label",
171174
kind: .token(choices: [.keyword(.availability)]),
172175
nameForDiagnostics: "label",
173176
documentation: "The label of the argument"
@@ -179,7 +182,6 @@ public let ATTRIBUTE_NODES: [Node] = [
179182
),
180183
Child(
181184
name: "availabilityArguments",
182-
deprecatedName: "availabilityList",
183185
kind: .collection(
184186
kind: .availabilityArgumentList,
185187
collectionElementName: "AvailabilityArgument",
@@ -190,6 +192,12 @@ public let ATTRIBUTE_NODES: [Node] = [
190192
name: "semicolon",
191193
kind: .token(choices: [.token(.semicolon)])
192194
),
195+
],
196+
childHistory: [
197+
[
198+
"availabilityLabel": .renamed(from: "label"),
199+
"availabilityArguments": .renamed(from: "availabilityList"),
200+
]
193201
]
194202
),
195203

@@ -202,7 +210,6 @@ public let ATTRIBUTE_NODES: [Node] = [
202210
children: [
203211
Child(
204212
name: "platformVersion",
205-
deprecatedName: "availabilityVersionRestriction",
206213
kind: .node(kind: .platformVersion),
207214
documentation: "The platform/version pair, e.g. `iOS 10.1`"
208215
),
@@ -212,6 +219,11 @@ public let ATTRIBUTE_NODES: [Node] = [
212219
documentation: "A trailing comma if the argument is followed by another argument",
213220
isOptional: true
214221
),
222+
],
223+
childHistory: [
224+
[
225+
"platformVersion": .renamed(from: "availabilityVersionRestriction"),
226+
]
215227
]
216228
),
217229

@@ -240,14 +252,18 @@ public let ATTRIBUTE_NODES: [Node] = [
240252
),
241253
Child(
242254
name: "platforms",
243-
deprecatedName: "versionList",
244255
kind: .collection(
245256
kind: .platformVersionItemList,
246257
collectionElementName: "Platform",
247258
deprecatedCollectionElementName: "Availability"
248259
),
249260
documentation: "The list of OS versions in which the declaration became ABI stable."
250261
),
262+
],
263+
childHistory: [
264+
[
265+
"platforms": .renamed(from: "versionList"),
266+
]
251267
]
252268
),
253269

@@ -340,7 +356,6 @@ public let ATTRIBUTE_NODES: [Node] = [
340356
),
341357
Child(
342358
name: "accessorSpecifier",
343-
deprecatedName: "accessorKind",
344359
kind: .token(choices: [.keyword(.get), .keyword(.set)]),
345360
documentation: "The accessor name.",
346361
isOptional: true
@@ -352,10 +367,15 @@ public let ATTRIBUTE_NODES: [Node] = [
352367
),
353368
Child(
354369
name: "arguments",
355-
deprecatedName: "diffParams",
356370
kind: .node(kind: .differentiabilityWithRespectToArgument),
357371
isOptional: true
358372
),
373+
],
374+
childHistory: [
375+
[
376+
"accessorSpecifier": .renamed(from: "accessorKind"),
377+
"arguments": .renamed(from: "diffParams"),
378+
]
359379
]
360380
),
361381

@@ -378,14 +398,18 @@ public let ATTRIBUTE_NODES: [Node] = [
378398
children: [
379399
Child(
380400
name: "argument",
381-
deprecatedName: "parameter",
382401
kind: .token(choices: [.token(.identifier), .token(.integerLiteral), .keyword(.self)])
383402
),
384403
Child(
385404
name: "trailingComma",
386405
kind: .token(choices: [.token(.comma)]),
387406
isOptional: true
388407
),
408+
],
409+
childHistory: [
410+
[
411+
"argument": .renamed(from: "parameter"),
412+
]
389413
]
390414
),
391415

@@ -407,21 +431,29 @@ public let ATTRIBUTE_NODES: [Node] = [
407431
),
408432
Child(
409433
name: "arguments",
410-
deprecatedName: "parameters",
411434
kind: .nodeChoices(choices: [
412435
Child(
413436
name: "argument",
414-
deprecatedName: "parameter",
415437
kind: .node(kind: .differentiabilityArgument)
416438
),
417439
Child(
418440
name: "argumentList",
419-
deprecatedName: "parameterList",
420441
kind: .node(kind: .differentiabilityArguments)
421442
),
443+
],
444+
childHistory: [
445+
[
446+
"argument": .renamed(from: "parameter"),
447+
"argumentList": .renamed(from: "parameterList"),
448+
]
422449
]),
423450
nameForDiagnostics: "arguments"
424451
),
452+
],
453+
childHistory: [
454+
[
455+
"arguments": .renamed(from: "parameters"),
456+
]
425457
]
426458
),
427459

@@ -437,14 +469,18 @@ public let ATTRIBUTE_NODES: [Node] = [
437469
),
438470
Child(
439471
name: "arguments",
440-
deprecatedName: "differentiabilityParameters",
441472
kind: .collection(kind: .differentiabilityArgumentList, collectionElementName: "Argument"),
442473
documentation: "The parameters for differentiation."
443474
),
444475
Child(
445476
name: "rightParen",
446477
kind: .token(choices: [.token(.rightParen)])
447478
),
479+
],
480+
childHistory: [
481+
[
482+
"arguments": .renamed(from: "differentiabilityParameters"),
483+
]
448484
]
449485
),
450486

@@ -457,40 +493,44 @@ public let ATTRIBUTE_NODES: [Node] = [
457493
children: [
458494
Child(
459495
name: "kindSpecifier",
460-
deprecatedName: "diffKind",
461496
kind: .token(choices: [.keyword(._forward), .keyword(.reverse), .keyword(._linear)]),
462497
documentation: "The differentiability kind, if it exists.",
463498
isOptional: true
464499
),
465500
Child(
466501
name: "kindSpecifierComma",
467-
deprecatedName: "diffKindComma",
468502
kind: .token(choices: [.token(.comma)]),
469503
documentation: "The comma following the differentiability kind, if it exists.",
470504
isOptional: true
471505
),
472506
Child(
473507
name: "arguments",
474-
deprecatedName: "diffParams",
475508
kind: .node(kind: .differentiabilityWithRespectToArgument),
476509
documentation: "The differentiability arguments, if any exists.",
477510
isOptional: true
478511
),
479512
Child(
480513
name: "argumentsComma",
481-
deprecatedName: "diffParamsComma",
482514
kind: .token(choices: [.token(.comma)]),
483515
documentation: "The comma following the differentiability arguments clause, if it exists.",
484516
isOptional: true
485517
),
486518
Child(
487519
name: "genericWhereClause",
488-
deprecatedName: "whereClause",
489520
kind: .node(kind: .genericWhereClause),
490521
documentation:
491522
"A `where` clause that places additional constraints on generic parameters like `where T: Differentiable`.",
492523
isOptional: true
493524
),
525+
],
526+
childHistory: [
527+
[
528+
"kindSpecifier": .renamed(from: "diffKind"),
529+
"kindSpecifierComma": .renamed(from: "diffKindComma"),
530+
"arguments": .renamed(from: "diffParams"),
531+
"argumentsComma": .renamed(from: "diffParamsComma"),
532+
"genericWhereClause": .renamed(from: "whereClause"),
533+
]
494534
]
495535
),
496536

@@ -564,9 +604,13 @@ public let ATTRIBUTE_NODES: [Node] = [
564604
),
565605
Child(
566606
name: "declName",
567-
deprecatedName: "declname",
568607
kind: .node(kind: .declReferenceExpr)
569608
),
609+
],
610+
childHistory: [
611+
[
612+
"declName": .renamed(from: "declname"),
613+
]
570614
]
571615
),
572616

@@ -621,11 +665,15 @@ public let ATTRIBUTE_NODES: [Node] = [
621665
),
622666
Child(
623667
name: "declName",
624-
deprecatedName: "declname",
625668
kind: .node(kind: .declReferenceExpr),
626669
nameForDiagnostics: "declaration name",
627670
documentation: "The value for this argument"
628671
),
672+
],
673+
childHistory: [
674+
[
675+
"declName": .renamed(from: "declname"),
676+
]
629677
]
630678
),
631679

@@ -776,7 +824,6 @@ public let ATTRIBUTE_NODES: [Node] = [
776824
children: [
777825
Child(
778826
name: "targetLabel",
779-
deprecatedName: "label",
780827
kind: .token(choices: [.keyword(.target)]),
781828
nameForDiagnostics: "label",
782829
documentation: "The label of the argument"
@@ -788,7 +835,6 @@ public let ATTRIBUTE_NODES: [Node] = [
788835
),
789836
Child(
790837
name: "declName",
791-
deprecatedName: "declname",
792838
kind: .node(kind: .declReferenceExpr),
793839
nameForDiagnostics: "declaration name",
794840
documentation: "The value for this argument"
@@ -799,6 +845,12 @@ public let ATTRIBUTE_NODES: [Node] = [
799845
documentation: "A trailing comma if this argument is followed by another one",
800846
isOptional: true
801847
),
848+
],
849+
childHistory: [
850+
[
851+
"targetLabel": .renamed(from: "label"),
852+
"declName": .renamed(from: "declname"),
853+
]
802854
]
803855
),
804856

CodeGeneration/Sources/SyntaxSupport/AvailabilityNodes.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public let AVAILABILITY_NODES: [Node] = [
2121
children: [
2222
Child(
2323
name: "argument",
24-
deprecatedName: "entry",
2524
kind: .nodeChoices(choices: [
2625
Child(
2726
name: "token",
@@ -48,6 +47,11 @@ public let AVAILABILITY_NODES: [Node] = [
4847
documentation: "A trailing comma if the argument is followed by another argument.",
4948
isOptional: true
5049
),
50+
],
51+
childHistory: [
52+
[
53+
"argument": .renamed(from: "entry"),
54+
]
5155
]
5256
),
5357

0 commit comments

Comments
 (0)