Skip to content

Commit 8e53ebe

Browse files
committed
Improve naming of some more syntax children
1 parent e85288d commit 8e53ebe

File tree

14 files changed

+861
-452
lines changed

14 files changed

+861
-452
lines changed

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public let ATTRIBUTE_NODES: [Node] = [
5555
isOptional: true
5656
),
5757
Child(
58-
name: "Argument",
58+
name: "Arguments",
59+
deprecatedName: "Argument",
5960
kind: .nodeChoices(choices: [
6061
Child(
6162
name: "ArgumentList",
@@ -456,7 +457,7 @@ public let ATTRIBUTE_NODES: [Node] = [
456457
kind: .token(choices: [.token(tokenKind: "LeftParenToken")])
457458
),
458459
Child(
459-
name: "DiffParams",
460+
name: "DifferentiabilityParameters",
460461
kind: .collection(kind: .differentiabilityParamList, collectionElementName: "DifferentiabilityParam"),
461462
documentation: "The parameters for differentiation."
462463
),
@@ -583,7 +584,8 @@ public let ATTRIBUTE_NODES: [Node] = [
583584
kind: .token(choices: [.token(tokenKind: "ColonToken")])
584585
),
585586
Child(
586-
name: "Declname",
587+
name: "DeclName",
588+
deprecatedName: "Declname",
587589
kind: .node(kind: .declName)
588590
),
589591
]
@@ -863,7 +865,8 @@ public let ATTRIBUTE_NODES: [Node] = [
863865
documentation: "The colon separating the label and the value"
864866
),
865867
Child(
866-
name: "Declname",
868+
name: "DeclName",
869+
deprecatedName: "Declname",
867870
kind: .node(kind: .declName),
868871
nameForDiagnostics: "declaration name",
869872
documentation: "The value for this argument"

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,8 @@ public let DECL_NODES: [Node] = [
12681268
],
12691269
children: [
12701270
Child(
1271-
name: "TypeName",
1271+
name: "Type",
1272+
deprecatedName: "TypeName",
12721273
kind: .node(kind: .type)
12731274
),
12741275
Child(
@@ -1464,7 +1465,8 @@ public let DECL_NODES: [Node] = [
14641465
documentation: "The `#` sign."
14651466
),
14661467
Child(
1467-
name: "Macro",
1468+
name: "MacroName",
1469+
deprecatedName: "Macro",
14681470
kind: .token(choices: [.token(tokenKind: "IdentifierToken")])
14691471
),
14701472
Child(
@@ -1698,7 +1700,8 @@ public let DECL_NODES: [Node] = [
16981700
isOptional: true
16991701
),
17001702
Child(
1701-
name: "Accessor",
1703+
name: "Accessors",
1704+
deprecatedName: "Accessor",
17021705
kind: .nodeChoices(choices: [
17031706
Child(
17041707
name: "Accessors",
@@ -2257,7 +2260,8 @@ public let DECL_NODES: [Node] = [
22572260
isOptional: true
22582261
),
22592262
Child(
2260-
name: "Accessor",
2263+
name: "Accessors",
2264+
deprecatedName: "Accessor",
22612265
kind: .nodeChoices(choices: [
22622266
Child(
22632267
name: "Accessors",

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public let EXPR_NODES: [Node] = [
107107
isOptional: true
108108
),
109109
Child(
110-
name: "TypeName",
110+
name: "Type",
111+
deprecatedName: "TypeName",
111112
kind: .node(kind: .type)
112113
),
113114
]
@@ -996,7 +997,8 @@ public let EXPR_NODES: [Node] = [
996997
documentation: "The `is` keyword for this expression."
997998
),
998999
Child(
999-
name: "TypeName",
1000+
name: "Type",
1001+
deprecatedName: "TypeName",
10001002
kind: .node(kind: .type),
10011003
documentation: "The type against which the expression will be checked to see if the expression can be cast to it."
10021004
),
@@ -1151,7 +1153,8 @@ public let EXPR_NODES: [Node] = [
11511153
documentation: "The `#` sign."
11521154
),
11531155
Child(
1154-
name: "Macro",
1156+
name: "MacroName",
1157+
deprecatedName: "Macro",
11551158
kind: .token(choices: [.token(tokenKind: "IdentifierToken")])
11561159
),
11571160
Child(

CodeGeneration/Sources/SyntaxSupport/GenericNodes.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ public let GENERIC_NODES: [Node] = [
142142
],
143143
children: [
144144
Child(
145-
name: "Body",
145+
name: "Requirement",
146+
deprecatedName: "Body",
146147
kind: .nodeChoices(choices: [
147148
Child(
148149
name: "SameTypeRequirement",

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,11 @@ class ValidateSyntaxNodes: XCTestCase {
625625
func testNoAbbreviationsInChildNames() {
626626
var failures: [ValidationFailure] = []
627627

628+
let abbreviations = ["Args", "Params"]
629+
628630
for node in SYNTAX_NODES.compactMap(\.layoutNode) {
629631
for child in node.nonUnexpectedChildren {
630-
if child.name.contains("Args") {
632+
if abbreviations.contains(where: { child.name.contains($0) }) {
631633
failures.append(
632634
ValidationFailure(
633635
node: node.kind,

Sources/SwiftParserDiagnostics/generated/ChildNameForDiagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ private func childNameForDiagnostics(_ keyPath: AnyKeyPath) -> String? {
336336
return "label"
337337
case \TargetFunctionEntrySyntax.targetLabel:
338338
return "label"
339-
case \TargetFunctionEntrySyntax.declname:
339+
case \TargetFunctionEntrySyntax.declName:
340340
return "declaration name"
341341
case \TernaryExprSyntax.condition:
342342
return "condition"

Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift

Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
207207
return "unexpectedBetweenAsKeywordAndQuestionOrExclamationMark"
208208
case \AsExprSyntax.questionOrExclamationMark:
209209
return "questionOrExclamationMark"
210-
case \AsExprSyntax.unexpectedBetweenQuestionOrExclamationMarkAndTypeName:
211-
return "unexpectedBetweenQuestionOrExclamationMarkAndTypeName"
212-
case \AsExprSyntax.typeName:
213-
return "typeName"
214-
case \AsExprSyntax.unexpectedAfterTypeName:
215-
return "unexpectedAfterTypeName"
210+
case \AsExprSyntax.unexpectedBetweenQuestionOrExclamationMarkAndType:
211+
return "unexpectedBetweenQuestionOrExclamationMarkAndType"
212+
case \AsExprSyntax.type:
213+
return "type"
214+
case \AsExprSyntax.unexpectedAfterType:
215+
return "unexpectedAfterType"
216216
case \AssignmentExprSyntax.unexpectedBeforeEqual:
217217
return "unexpectedBeforeEqual"
218218
case \AssignmentExprSyntax.equal:
@@ -261,12 +261,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
261261
return "unexpectedBetweenAttributeNameAndLeftParen"
262262
case \AttributeSyntax.leftParen:
263263
return "leftParen"
264-
case \AttributeSyntax.unexpectedBetweenLeftParenAndArgument:
265-
return "unexpectedBetweenLeftParenAndArgument"
266-
case \AttributeSyntax.argument:
267-
return "argument"
268-
case \AttributeSyntax.unexpectedBetweenArgumentAndRightParen:
269-
return "unexpectedBetweenArgumentAndRightParen"
264+
case \AttributeSyntax.unexpectedBetweenLeftParenAndArguments:
265+
return "unexpectedBetweenLeftParenAndArguments"
266+
case \AttributeSyntax.arguments:
267+
return "arguments"
268+
case \AttributeSyntax.unexpectedBetweenArgumentsAndRightParen:
269+
return "unexpectedBetweenArgumentsAndRightParen"
270270
case \AttributeSyntax.rightParen:
271271
return "rightParen"
272272
case \AttributeSyntax.unexpectedAfterRightParen:
@@ -1047,12 +1047,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
10471047
return "unexpectedBeforeLeftParen"
10481048
case \DifferentiabilityParamsSyntax.leftParen:
10491049
return "leftParen"
1050-
case \DifferentiabilityParamsSyntax.unexpectedBetweenLeftParenAndDiffParams:
1051-
return "unexpectedBetweenLeftParenAndDiffParams"
1052-
case \DifferentiabilityParamsSyntax.diffParams:
1053-
return "diffParams"
1054-
case \DifferentiabilityParamsSyntax.unexpectedBetweenDiffParamsAndRightParen:
1055-
return "unexpectedBetweenDiffParamsAndRightParen"
1050+
case \DifferentiabilityParamsSyntax.unexpectedBetweenLeftParenAndDifferentiabilityParameters:
1051+
return "unexpectedBetweenLeftParenAndDifferentiabilityParameters"
1052+
case \DifferentiabilityParamsSyntax.differentiabilityParameters:
1053+
return "differentiabilityParameters"
1054+
case \DifferentiabilityParamsSyntax.unexpectedBetweenDifferentiabilityParametersAndRightParen:
1055+
return "unexpectedBetweenDifferentiabilityParametersAndRightParen"
10561056
case \DifferentiabilityParamsSyntax.rightParen:
10571057
return "rightParen"
10581058
case \DifferentiabilityParamsSyntax.unexpectedAfterRightParen:
@@ -1135,12 +1135,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
11351135
return "unexpectedBetweenForLabelAndColon"
11361136
case \DynamicReplacementArgumentsSyntax.colon:
11371137
return "colon"
1138-
case \DynamicReplacementArgumentsSyntax.unexpectedBetweenColonAndDeclname:
1139-
return "unexpectedBetweenColonAndDeclname"
1140-
case \DynamicReplacementArgumentsSyntax.declname:
1141-
return "declname"
1142-
case \DynamicReplacementArgumentsSyntax.unexpectedAfterDeclname:
1143-
return "unexpectedAfterDeclname"
1138+
case \DynamicReplacementArgumentsSyntax.unexpectedBetweenColonAndDeclName:
1139+
return "unexpectedBetweenColonAndDeclName"
1140+
case \DynamicReplacementArgumentsSyntax.declName:
1141+
return "declName"
1142+
case \DynamicReplacementArgumentsSyntax.unexpectedAfterDeclName:
1143+
return "unexpectedAfterDeclName"
11441144
case \EditorPlaceholderDeclSyntax.unexpectedBeforeAttributes:
11451145
return "unexpectedBeforeAttributes"
11461146
case \EditorPlaceholderDeclSyntax.attributes:
@@ -1629,12 +1629,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
16291629
return "trailingComma"
16301630
case \GenericParameterSyntax.unexpectedAfterTrailingComma:
16311631
return "unexpectedAfterTrailingComma"
1632-
case \GenericRequirementSyntax.unexpectedBeforeBody:
1633-
return "unexpectedBeforeBody"
1634-
case \GenericRequirementSyntax.body:
1635-
return "body"
1636-
case \GenericRequirementSyntax.unexpectedBetweenBodyAndTrailingComma:
1637-
return "unexpectedBetweenBodyAndTrailingComma"
1632+
case \GenericRequirementSyntax.unexpectedBeforeRequirement:
1633+
return "unexpectedBeforeRequirement"
1634+
case \GenericRequirementSyntax.requirement:
1635+
return "requirement"
1636+
case \GenericRequirementSyntax.unexpectedBetweenRequirementAndTrailingComma:
1637+
return "unexpectedBetweenRequirementAndTrailingComma"
16381638
case \GenericRequirementSyntax.trailingComma:
16391639
return "trailingComma"
16401640
case \GenericRequirementSyntax.unexpectedAfterTrailingComma:
@@ -1813,12 +1813,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
18131813
return "rightOperand"
18141814
case \InfixOperatorExprSyntax.unexpectedAfterRightOperand:
18151815
return "unexpectedAfterRightOperand"
1816-
case \InheritedTypeSyntax.unexpectedBeforeTypeName:
1817-
return "unexpectedBeforeTypeName"
1818-
case \InheritedTypeSyntax.typeName:
1819-
return "typeName"
1820-
case \InheritedTypeSyntax.unexpectedBetweenTypeNameAndTrailingComma:
1821-
return "unexpectedBetweenTypeNameAndTrailingComma"
1816+
case \InheritedTypeSyntax.unexpectedBeforeType:
1817+
return "unexpectedBeforeType"
1818+
case \InheritedTypeSyntax.type:
1819+
return "type"
1820+
case \InheritedTypeSyntax.unexpectedBetweenTypeAndTrailingComma:
1821+
return "unexpectedBetweenTypeAndTrailingComma"
18221822
case \InheritedTypeSyntax.trailingComma:
18231823
return "trailingComma"
18241824
case \InheritedTypeSyntax.unexpectedAfterTrailingComma:
@@ -1899,12 +1899,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
18991899
return "unexpectedBetweenExpressionAndIsKeyword"
19001900
case \IsExprSyntax.isKeyword:
19011901
return "isKeyword"
1902-
case \IsExprSyntax.unexpectedBetweenIsKeywordAndTypeName:
1903-
return "unexpectedBetweenIsKeywordAndTypeName"
1904-
case \IsExprSyntax.typeName:
1905-
return "typeName"
1906-
case \IsExprSyntax.unexpectedAfterTypeName:
1907-
return "unexpectedAfterTypeName"
1902+
case \IsExprSyntax.unexpectedBetweenIsKeywordAndType:
1903+
return "unexpectedBetweenIsKeywordAndType"
1904+
case \IsExprSyntax.type:
1905+
return "type"
1906+
case \IsExprSyntax.unexpectedAfterType:
1907+
return "unexpectedAfterType"
19081908
case \IsTypePatternSyntax.unexpectedBeforeIsKeyword:
19091909
return "unexpectedBeforeIsKeyword"
19101910
case \IsTypePatternSyntax.isKeyword:
@@ -2085,12 +2085,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
20852085
return "unexpectedBetweenModifiersAndPound"
20862086
case \MacroExpansionDeclSyntax.pound:
20872087
return "pound"
2088-
case \MacroExpansionDeclSyntax.unexpectedBetweenPoundAndMacro:
2089-
return "unexpectedBetweenPoundAndMacro"
2090-
case \MacroExpansionDeclSyntax.macro:
2091-
return "macro"
2092-
case \MacroExpansionDeclSyntax.unexpectedBetweenMacroAndGenericArgumentClause:
2093-
return "unexpectedBetweenMacroAndGenericArgumentClause"
2088+
case \MacroExpansionDeclSyntax.unexpectedBetweenPoundAndMacroName:
2089+
return "unexpectedBetweenPoundAndMacroName"
2090+
case \MacroExpansionDeclSyntax.macroName:
2091+
return "macroName"
2092+
case \MacroExpansionDeclSyntax.unexpectedBetweenMacroNameAndGenericArgumentClause:
2093+
return "unexpectedBetweenMacroNameAndGenericArgumentClause"
20942094
case \MacroExpansionDeclSyntax.genericArgumentClause:
20952095
return "genericArgumentClause"
20962096
case \MacroExpansionDeclSyntax.unexpectedBetweenGenericArgumentClauseAndLeftParen:
@@ -2119,12 +2119,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
21192119
return "unexpectedBeforePound"
21202120
case \MacroExpansionExprSyntax.pound:
21212121
return "pound"
2122-
case \MacroExpansionExprSyntax.unexpectedBetweenPoundAndMacro:
2123-
return "unexpectedBetweenPoundAndMacro"
2124-
case \MacroExpansionExprSyntax.macro:
2125-
return "macro"
2126-
case \MacroExpansionExprSyntax.unexpectedBetweenMacroAndGenericArgumentClause:
2127-
return "unexpectedBetweenMacroAndGenericArgumentClause"
2122+
case \MacroExpansionExprSyntax.unexpectedBetweenPoundAndMacroName:
2123+
return "unexpectedBetweenPoundAndMacroName"
2124+
case \MacroExpansionExprSyntax.macroName:
2125+
return "macroName"
2126+
case \MacroExpansionExprSyntax.unexpectedBetweenMacroNameAndGenericArgumentClause:
2127+
return "unexpectedBetweenMacroNameAndGenericArgumentClause"
21282128
case \MacroExpansionExprSyntax.genericArgumentClause:
21292129
return "genericArgumentClause"
21302130
case \MacroExpansionExprSyntax.unexpectedBetweenGenericArgumentClauseAndLeftParen:
@@ -2507,12 +2507,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
25072507
return "unexpectedBetweenTypeAnnotationAndInitializer"
25082508
case \PatternBindingSyntax.initializer:
25092509
return "initializer"
2510-
case \PatternBindingSyntax.unexpectedBetweenInitializerAndAccessor:
2511-
return "unexpectedBetweenInitializerAndAccessor"
2512-
case \PatternBindingSyntax.accessor:
2513-
return "accessor"
2514-
case \PatternBindingSyntax.unexpectedBetweenAccessorAndTrailingComma:
2515-
return "unexpectedBetweenAccessorAndTrailingComma"
2510+
case \PatternBindingSyntax.unexpectedBetweenInitializerAndAccessors:
2511+
return "unexpectedBetweenInitializerAndAccessors"
2512+
case \PatternBindingSyntax.accessors:
2513+
return "accessors"
2514+
case \PatternBindingSyntax.unexpectedBetweenAccessorsAndTrailingComma:
2515+
return "unexpectedBetweenAccessorsAndTrailingComma"
25162516
case \PatternBindingSyntax.trailingComma:
25172517
return "trailingComma"
25182518
case \PatternBindingSyntax.unexpectedAfterTrailingComma:
@@ -2953,12 +2953,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
29532953
return "unexpectedBetweenReturnClauseAndGenericWhereClause"
29542954
case \SubscriptDeclSyntax.genericWhereClause:
29552955
return "genericWhereClause"
2956-
case \SubscriptDeclSyntax.unexpectedBetweenGenericWhereClauseAndAccessor:
2957-
return "unexpectedBetweenGenericWhereClauseAndAccessor"
2958-
case \SubscriptDeclSyntax.accessor:
2959-
return "accessor"
2960-
case \SubscriptDeclSyntax.unexpectedAfterAccessor:
2961-
return "unexpectedAfterAccessor"
2956+
case \SubscriptDeclSyntax.unexpectedBetweenGenericWhereClauseAndAccessors:
2957+
return "unexpectedBetweenGenericWhereClauseAndAccessors"
2958+
case \SubscriptDeclSyntax.accessors:
2959+
return "accessors"
2960+
case \SubscriptDeclSyntax.unexpectedAfterAccessors:
2961+
return "unexpectedAfterAccessors"
29622962
case \SubscriptExprSyntax.unexpectedBeforeCalledExpression:
29632963
return "unexpectedBeforeCalledExpression"
29642964
case \SubscriptExprSyntax.calledExpression:
@@ -3069,12 +3069,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
30693069
return "unexpectedBetweenTargetLabelAndColon"
30703070
case \TargetFunctionEntrySyntax.colon:
30713071
return "colon"
3072-
case \TargetFunctionEntrySyntax.unexpectedBetweenColonAndDeclname:
3073-
return "unexpectedBetweenColonAndDeclname"
3074-
case \TargetFunctionEntrySyntax.declname:
3075-
return "declname"
3076-
case \TargetFunctionEntrySyntax.unexpectedBetweenDeclnameAndTrailingComma:
3077-
return "unexpectedBetweenDeclnameAndTrailingComma"
3072+
case \TargetFunctionEntrySyntax.unexpectedBetweenColonAndDeclName:
3073+
return "unexpectedBetweenColonAndDeclName"
3074+
case \TargetFunctionEntrySyntax.declName:
3075+
return "declName"
3076+
case \TargetFunctionEntrySyntax.unexpectedBetweenDeclNameAndTrailingComma:
3077+
return "unexpectedBetweenDeclNameAndTrailingComma"
30783078
case \TargetFunctionEntrySyntax.trailingComma:
30793079
return "trailingComma"
30803080
case \TargetFunctionEntrySyntax.unexpectedAfterTrailingComma:

0 commit comments

Comments
 (0)