Skip to content

Commit 6ff0671

Browse files
authored
Merge pull request #1730 from TTOzzi/change-children-naming-inconsistencies-between-similar-syntax-nodes
Change children naming inconsistencies between similar/dual syntax nodes
2 parents ee682e5 + ad2ae20 commit 6ff0671

File tree

12 files changed

+393
-163
lines changed

12 files changed

+393
-163
lines changed

CodeGeneration/Sources/SyntaxSupport/AttributeNodes.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ public let ATTRIBUTE_NODES: [Node] = [
168168
documentation: "The colon separating the label and the value"
169169
),
170170
Child(
171-
name: "AvailabilityList",
172-
kind: .collection(kind: .availabilitySpecList, collectionElementName: "Availability")
171+
name: "AvailabilityArguments",
172+
kind: .collection(kind: .availabilitySpecList, collectionElementName: "AvailabilityArgument")
173173
),
174174
Child(
175175
name: "Semicolon",
@@ -227,8 +227,8 @@ public let ATTRIBUTE_NODES: [Node] = [
227227
documentation: "The colon separating \"before\" and the parameter list."
228228
),
229229
Child(
230-
name: "VersionList",
231-
kind: .collection(kind: .availabilityVersionRestrictionList, collectionElementName: "Availability"),
230+
name: "Platforms",
231+
kind: .collection(kind: .availabilityVersionRestrictionList, collectionElementName: "Platform"),
232232
documentation: "The list of OS versions in which the declaration became ABI stable."
233233
),
234234
]

CodeGeneration/Sources/SyntaxSupport/GenericNodes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public let GENERIC_NODES: [Node] = [
4444
kind: .token(choices: [.token(tokenKind: "LeftAngleToken")])
4545
),
4646
Child(
47-
name: "GenericParameterList",
48-
kind: .collection(kind: .genericParameterList, collectionElementName: "GenericParameter")
47+
name: "Parameters",
48+
kind: .collection(kind: .genericParameterList, collectionElementName: "Parameter")
4949
),
5050
Child(
5151
name: "GenericWhereClause",

CodeGeneration/Sources/SyntaxSupport/StmtNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public let STMT_NODES: [Node] = [
2626
kind: .token(choices: [.token(tokenKind: "LeftParenToken")])
2727
),
2828
Child(
29-
name: "AvailabilitySpec",
29+
name: "AvailabilityArguments",
3030
kind: .collection(kind: .availabilitySpecList, collectionElementName: "AvailabilityArgument")
3131
),
3232
Child(

Sources/SwiftParser/Attributes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ extension Parser {
729729
label: ident,
730730
unexpectedBeforeColon,
731731
colon: colon,
732-
availabilityList: availability,
732+
availabilityArguments: availability,
733733
unexpectedBeforeSemi,
734734
semicolon: semi,
735735
arena: self.arena
@@ -949,7 +949,7 @@ extension Parser {
949949
beforeLabel: label,
950950
unexpectedBeforeColon,
951951
colon: colon,
952-
versionList: RawAvailabilityVersionRestrictionListSyntax(elements: elements, arena: self.arena),
952+
platforms: RawAvailabilityVersionRestrictionListSyntax(elements: elements, arena: self.arena),
953953
arena: self.arena
954954
)
955955
}

Sources/SwiftParser/Declarations.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ extension Parser {
469469
return RawGenericParameterClauseSyntax(
470470
remainingTokens,
471471
leftAngleBracket: missingToken(.leftAngle),
472-
genericParameterList: RawGenericParameterListSyntax(elements: [], arena: self.arena),
472+
parameters: RawGenericParameterListSyntax(elements: [], arena: self.arena),
473473
genericWhereClause: nil,
474474
rightAngleBracket: missingToken(.rightAngle),
475475
arena: self.arena
@@ -574,7 +574,7 @@ extension Parser {
574574
}
575575
return RawGenericParameterClauseSyntax(
576576
leftAngleBracket: langle,
577-
genericParameterList: parameters,
577+
parameters: parameters,
578578
genericWhereClause: whereClause,
579579
rightAngleBracket: rangle,
580580
arena: self.arena

Sources/SwiftParser/Statements.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ extension Parser {
336336
precondition(self.at(.poundAvailableKeyword, .poundUnavailableKeyword))
337337
let keyword = self.consumeAnyToken()
338338
let (unexpectedBeforeLParen, lparen) = self.expect(.leftParen)
339-
let spec = self.parseAvailabilitySpecList()
339+
let arguments = self.parseAvailabilitySpecList()
340340
let (unexpectedBeforeRParen, rparen) = self.expect(.rightParen)
341341
let unexpectedAfterRParen: RawUnexpectedNodesSyntax?
342342
if let (equalOperator, falseKeyword) = self.consume(if: { $0.isContextualPunctuator("==") }, followedBy: { TokenSpec.keyword(.false) ~= $0 }) {
@@ -349,7 +349,7 @@ extension Parser {
349349
availabilityKeyword: keyword,
350350
unexpectedBeforeLParen,
351351
leftParen: lparen,
352-
availabilitySpec: spec,
352+
availabilityArguments: arguments,
353353
unexpectedBeforeRParen,
354354
rightParen: rparen,
355355
unexpectedAfterRParen,

Sources/SwiftRefactor/OpaqueParameterToGeneric.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public struct OpaqueParameterToGeneric: RefactoringProvider {
134134

135135
var newGenericParams: [GenericParameterSyntax] = []
136136
if let genericParams {
137-
newGenericParams.append(contentsOf: genericParams.genericParameterList)
137+
newGenericParams.append(contentsOf: genericParams.parameters)
138138
}
139139

140140
for rewritten in rewriter.rewrittenSomeParameters {
@@ -154,13 +154,13 @@ public struct OpaqueParameterToGeneric: RefactoringProvider {
154154
let newGenericParamClause: GenericParameterClauseSyntax
155155
if let genericParams {
156156
newGenericParamClause = genericParams.with(
157-
\.genericParameterList,
157+
\.parameters,
158158
newGenericParamSyntax
159159
)
160160
} else {
161161
newGenericParamClause = GenericParameterClauseSyntax(
162162
leftAngleBracket: .leftAngleToken(),
163-
genericParameterList: newGenericParamSyntax,
163+
parameters: newGenericParamSyntax,
164164
genericWhereClause: nil,
165165
rightAngleBracket: .rightAngleToken()
166166
)

Sources/SwiftSyntax/SwiftSyntaxCompatibility.swift

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,171 @@ public typealias AccessPathComponentSyntax = ImportPathComponentSyntax
2222
@available(*, deprecated, renamed: "WithAttributesSyntax")
2323
public typealias AttributedSyntax = WithAttributesSyntax
2424

25+
public extension AvailabilityConditionSyntax {
26+
@available(*, deprecated, renamed: "unexpectedBetweenLeftParenAndAvailabilityArguments")
27+
var unexpectedBetweenLeftParenAndAvailabilitySpec: UnexpectedNodesSyntax? {
28+
get { unexpectedBetweenLeftParenAndAvailabilityArguments }
29+
set { unexpectedBetweenLeftParenAndAvailabilityArguments = newValue }
30+
}
31+
32+
@available(*, deprecated, renamed: "availabilityArguments")
33+
var availabilitySpec: AvailabilitySpecListSyntax {
34+
get { availabilityArguments }
35+
set { availabilityArguments = newValue }
36+
}
37+
38+
@available(*, deprecated, renamed: "unexpectedBetweenAvailabilityArgumentsAndRightParen")
39+
var unexpectedBetweenAvailabilitySpecAndRightParen: UnexpectedNodesSyntax? {
40+
get { unexpectedBetweenAvailabilityArgumentsAndRightParen }
41+
set { unexpectedBetweenAvailabilityArgumentsAndRightParen = newValue }
42+
}
43+
44+
@available(*, deprecated, message: "Use an initializer with an availabilityArguments argument")
45+
init(
46+
leadingTrivia: Trivia? = nil,
47+
_ unexpectedBeforeAvailabilityKeyword: UnexpectedNodesSyntax? = nil,
48+
availabilityKeyword: TokenSyntax,
49+
_ unexpectedBetweenAvailabilityKeywordAndLeftParen: UnexpectedNodesSyntax? = nil,
50+
leftParen: TokenSyntax = .leftParenToken(),
51+
_ unexpectedBetweenLeftParenAndAvailabilitySpec: UnexpectedNodesSyntax? = nil,
52+
availabilitySpec: AvailabilitySpecListSyntax,
53+
_ unexpectedBetweenAvailabilitySpecAndRightParen: UnexpectedNodesSyntax? = nil,
54+
rightParen: TokenSyntax = .rightParenToken(),
55+
_ unexpectedAfterRightParen: UnexpectedNodesSyntax? = nil,
56+
trailingTrivia: Trivia? = nil
57+
) {
58+
self.init(
59+
leadingTrivia: leadingTrivia,
60+
unexpectedBeforeAvailabilityKeyword,
61+
availabilityKeyword: availabilityKeyword,
62+
unexpectedBetweenAvailabilityKeywordAndLeftParen,
63+
leftParen: leftParen,
64+
unexpectedBetweenLeftParenAndAvailabilitySpec,
65+
availabilityArguments: availabilitySpec,
66+
unexpectedBetweenAvailabilitySpecAndRightParen,
67+
rightParen: rightParen,
68+
unexpectedAfterRightParen,
69+
trailingTrivia: trailingTrivia
70+
)
71+
}
72+
}
73+
74+
public extension AvailabilityEntrySyntax {
75+
@available(*, deprecated, renamed: "unexpectedBetweenColonAndAvailabilityArguments")
76+
var unexpectedBetweenColonAndAvailabilityList: UnexpectedNodesSyntax? {
77+
get { unexpectedBetweenColonAndAvailabilityArguments }
78+
set { unexpectedBetweenColonAndAvailabilityArguments = newValue }
79+
}
80+
81+
@available(*, deprecated, renamed: "availabilityArguments")
82+
var availabilityList: AvailabilitySpecListSyntax {
83+
get { availabilityArguments }
84+
set { availabilityArguments = newValue }
85+
}
86+
87+
@available(*, deprecated, renamed: "unexpectedBetweenAvailabilityArgumentsAndSemicolon")
88+
var unexpectedBetweenAvailabilityListAndSemicolon: UnexpectedNodesSyntax? {
89+
get { unexpectedBetweenAvailabilityArgumentsAndSemicolon }
90+
set { unexpectedBetweenAvailabilityArgumentsAndSemicolon = newValue }
91+
}
92+
93+
/// Adds the provided `element` to the node's `availabilityList`
94+
/// collection.
95+
/// - param element: The new `Availability` to add to the node's
96+
/// `availabilityList` collection.
97+
/// - returns: A copy of the receiver with the provided `Availability`
98+
/// appended to its `availabilityList` collection.
99+
@available(*, deprecated, renamed: "addAvailabilityArgument")
100+
func addAvailability(_ element: AvailabilityArgumentSyntax) -> AvailabilityEntrySyntax {
101+
addAvailabilityArgument(element)
102+
}
103+
104+
@available(*, deprecated, message: "Use an initializer with an availabilityArguments argument")
105+
init(
106+
leadingTrivia: Trivia? = nil,
107+
_ unexpectedBeforeLabel: UnexpectedNodesSyntax? = nil,
108+
label: TokenSyntax = .keyword(.availability),
109+
_ unexpectedBetweenLabelAndColon: UnexpectedNodesSyntax? = nil,
110+
colon: TokenSyntax = .colonToken(),
111+
_ unexpectedBetweenColonAndAvailabilityList: UnexpectedNodesSyntax? = nil,
112+
availabilityList: AvailabilitySpecListSyntax,
113+
_ unexpectedBetweenAvailabilityListAndSemicolon: UnexpectedNodesSyntax? = nil,
114+
semicolon: TokenSyntax = .semicolonToken(),
115+
_ unexpectedAfterSemicolon: UnexpectedNodesSyntax? = nil,
116+
trailingTrivia: Trivia? = nil
117+
) {
118+
self.init(
119+
leadingTrivia: leadingTrivia,
120+
unexpectedBeforeLabel,
121+
label: label,
122+
unexpectedBetweenLabelAndColon,
123+
colon: colon,
124+
unexpectedBetweenColonAndAvailabilityList,
125+
availabilityArguments: availabilityList,
126+
unexpectedBetweenAvailabilityListAndSemicolon,
127+
semicolon: semicolon,
128+
unexpectedAfterSemicolon,
129+
trailingTrivia: trailingTrivia
130+
)
131+
}
132+
}
133+
134+
public extension BackDeployedAttributeSpecListSyntax {
135+
@available(*, deprecated, renamed: "unexpectedBetweenColonAndPlatforms")
136+
var unexpectedBetweenColonAndVersionList: UnexpectedNodesSyntax? {
137+
get { unexpectedBetweenColonAndPlatforms }
138+
set { unexpectedBetweenColonAndPlatforms = newValue }
139+
}
140+
141+
@available(*, deprecated, renamed: "platforms")
142+
var versionList: AvailabilityVersionRestrictionListSyntax {
143+
get { platforms }
144+
set { platforms = newValue }
145+
}
146+
147+
@available(*, deprecated, renamed: "unexpectedAfterPlatforms")
148+
var unexpectedAfterVersionList: UnexpectedNodesSyntax? {
149+
get { unexpectedAfterPlatforms }
150+
set { unexpectedAfterPlatforms = newValue }
151+
}
152+
153+
/// Adds the provided `element` to the node's `versionList`
154+
/// collection.
155+
/// - param element: The new `Availability` to add to the node's
156+
/// `versionList` collection.
157+
/// - returns: A copy of the receiver with the provided `Availability`
158+
/// appended to its `versionList` collection.
159+
@available(*, deprecated, renamed: "addPlatform")
160+
func addAvailability(_ element: AvailabilityVersionRestrictionListEntrySyntax) -> BackDeployedAttributeSpecListSyntax {
161+
addPlatform(element)
162+
}
163+
164+
@available(*, deprecated, message: "Use an initializer with a platforms argument")
165+
init(
166+
leadingTrivia: Trivia? = nil,
167+
_ unexpectedBeforeBeforeLabel: UnexpectedNodesSyntax? = nil,
168+
beforeLabel: TokenSyntax = .keyword(.before),
169+
_ unexpectedBetweenBeforeLabelAndColon: UnexpectedNodesSyntax? = nil,
170+
colon: TokenSyntax = .colonToken(),
171+
_ unexpectedBetweenColonAndVersionList: UnexpectedNodesSyntax? = nil,
172+
versionList: AvailabilityVersionRestrictionListSyntax,
173+
_ unexpectedAfterVersionList: UnexpectedNodesSyntax? = nil,
174+
trailingTrivia: Trivia? = nil
175+
) {
176+
self.init(
177+
leadingTrivia: leadingTrivia,
178+
unexpectedBeforeBeforeLabel,
179+
beforeLabel: beforeLabel,
180+
unexpectedBetweenBeforeLabelAndColon,
181+
colon: colon,
182+
unexpectedBetweenColonAndVersionList,
183+
platforms: versionList,
184+
unexpectedAfterVersionList,
185+
trailingTrivia: trailingTrivia
186+
)
187+
}
188+
}
189+
25190
public extension DeclGroupSyntax {
26191
@available(*, deprecated, renamed: "memberBlock")
27192
var members: MemberDeclBlockSyntax {
@@ -209,6 +374,66 @@ public extension FunctionTypeSyntax {
209374
}
210375
}
211376

377+
public extension GenericParameterClauseSyntax {
378+
@available(*, deprecated, renamed: "unexpectedBetweenLeftAngleBracketAndParameters")
379+
var unexpectedBetweenLeftAngleBracketAndGenericParameterList: UnexpectedNodesSyntax? {
380+
get { unexpectedBetweenLeftAngleBracketAndParameters }
381+
set { unexpectedBetweenLeftAngleBracketAndParameters = newValue }
382+
}
383+
384+
@available(*, deprecated, renamed: "parameters")
385+
var genericParameterList: GenericParameterListSyntax {
386+
get { parameters }
387+
set { parameters = newValue }
388+
}
389+
390+
@available(*, deprecated, renamed: "unexpectedBetweenParametersAndGenericWhereClause")
391+
var unexpectedBetweenGenericParameterListAndGenericWhereClause: UnexpectedNodesSyntax? {
392+
get { unexpectedBetweenParametersAndGenericWhereClause }
393+
set { unexpectedBetweenParametersAndGenericWhereClause = newValue }
394+
}
395+
396+
/// Adds the provided `element` to the node's `genericParameterList`
397+
/// collection.
398+
/// - param element: The new `GenericParameter` to add to the node's
399+
/// `genericParameterList` collection.
400+
/// - returns: A copy of the receiver with the provided `GenericParameter`
401+
/// appended to its `genericParameterList` collection.
402+
@available(*, deprecated, renamed: "addParameter")
403+
func addGenericParameter(_ element: GenericParameterSyntax) -> GenericParameterClauseSyntax {
404+
addParameter(element)
405+
}
406+
407+
@available(*, deprecated, message: "Use an initializer with a parameters argument")
408+
init(
409+
leadingTrivia: Trivia? = nil,
410+
_ unexpectedBeforeLeftAngleBracket: UnexpectedNodesSyntax? = nil,
411+
leftAngleBracket: TokenSyntax = .leftAngleToken(),
412+
_ unexpectedBetweenLeftAngleBracketAndGenericParameterList: UnexpectedNodesSyntax? = nil,
413+
genericParameterList: GenericParameterListSyntax,
414+
_ unexpectedBetweenGenericParameterListAndGenericWhereClause: UnexpectedNodesSyntax? = nil,
415+
genericWhereClause: GenericWhereClauseSyntax? = nil,
416+
_ unexpectedBetweenGenericWhereClauseAndRightAngleBracket: UnexpectedNodesSyntax? = nil,
417+
rightAngleBracket: TokenSyntax = .rightAngleToken(),
418+
_ unexpectedAfterRightAngleBracket: UnexpectedNodesSyntax? = nil,
419+
trailingTrivia: Trivia? = nil
420+
) {
421+
self.init(
422+
leadingTrivia: leadingTrivia,
423+
unexpectedBeforeLeftAngleBracket,
424+
leftAngleBracket: leftAngleBracket,
425+
unexpectedBetweenLeftAngleBracketAndGenericParameterList,
426+
parameters: genericParameterList,
427+
unexpectedBetweenGenericParameterListAndGenericWhereClause,
428+
genericWhereClause: genericWhereClause,
429+
unexpectedBetweenGenericWhereClauseAndRightAngleBracket,
430+
rightAngleBracket: rightAngleBracket,
431+
unexpectedAfterRightAngleBracket,
432+
trailingTrivia: trailingTrivia
433+
)
434+
}
435+
}
436+
212437
public extension ImportDeclSyntax {
213438
@available(*, deprecated, renamed: "unexpectedBetweenModifiersAndImportKeyword")
214439
var unexpectedBetweenModifiersAndImportTok: UnexpectedNodesSyntax? {
@@ -386,3 +611,8 @@ public extension TupleExprSyntax {
386611
)
387612
}
388613
}
614+
615+
//==========================================================================//
616+
// IMPORTANT: If you are tempted to add a compatiblity layer code here //
617+
// please insert it in alphabetical order above //
618+
//==========================================================================//

0 commit comments

Comments
 (0)