Skip to content

Commit 5988d62

Browse files
committed
WIP
1 parent 821f5a4 commit 5988d62

File tree

63 files changed

+2387
-2320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2387
-2320
lines changed

CodeGeneration/Sources/SyntaxSupport/BuilderInitializableTypes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
/// type and synthesize all other members to form the node.
1616
public let BUILDER_INITIALIZABLE_TYPES: [SyntaxNodeKind: SyntaxNodeKind?] = [
1717
.codeBlock: .codeBlockItemList,
18-
.memberDeclBlock: .memberDeclList,
18+
.memberBlock: .memberBlockItemList,
1919
.codeBlockItemList: nil,
20-
.memberDeclList: nil,
20+
.memberBlockItemList: nil,
2121
.patternBindingList: nil,
2222
.switchCaseList: nil,
2323
.arrayElementList: nil,

CodeGeneration/Sources/SyntaxSupport/DeclNodes.swift

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public let DECL_NODES: [Node] = [
291291
),
292292
Child(
293293
name: "MemberBlock",
294-
kind: .node(kind: .memberDeclBlock)
294+
kind: .node(kind: .memberBlock)
295295
),
296296
]
297297
),
@@ -302,7 +302,7 @@ public let DECL_NODES: [Node] = [
302302
// generic-where-clause?
303303
// associatedtype-name -> identifier
304304
Node(
305-
kind: .associatedtypeDecl,
305+
kind: .associatedTypeDecl,
306306
base: .decl,
307307
nameForDiagnostics: "associatedtype declaration",
308308
documentation: """
@@ -474,7 +474,7 @@ public let DECL_NODES: [Node] = [
474474
),
475475
Child(
476476
name: "MemberBlock",
477-
kind: .node(kind: .memberDeclBlock),
477+
kind: .node(kind: .memberBlock),
478478
documentation:
479479
"The members of the class declaration. As class extension declarations may declare additional members, the contents of this member block isn't guaranteed to be a complete list of members for this type."
480480
),
@@ -668,7 +668,7 @@ public let DECL_NODES: [Node] = [
668668
),
669669

670670
Node(
671-
kind: .enumCaseAssociatedValue,
671+
kind: .enumCaseParameterClause,
672672
base: .syntax,
673673
nameForDiagnostics: "parameter clause",
674674
traits: [
@@ -816,7 +816,7 @@ public let DECL_NODES: [Node] = [
816816
),
817817
Child(
818818
name: "AssociatedValue",
819-
kind: .node(kind: .enumCaseAssociatedValue),
819+
kind: .node(kind: .enumCaseParameterClause),
820820
nameForDiagnostics: "associated values",
821821
documentation: "The set of associated values of the case.",
822822
isOptional: true
@@ -898,7 +898,7 @@ public let DECL_NODES: [Node] = [
898898
),
899899
Child(
900900
name: "MemberBlock",
901-
kind: .node(kind: .memberDeclBlock),
901+
kind: .node(kind: .memberBlock),
902902
documentation:
903903
"The cases and other members associated with this enum declaration. Because enum extension declarations may declare additional members the contents of this member block isn't guaranteed to be a complete list of members for this type."
904904
),
@@ -956,7 +956,7 @@ public let DECL_NODES: [Node] = [
956956
),
957957
Child(
958958
name: "MemberBlock",
959-
kind: .node(kind: .memberDeclBlock)
959+
kind: .node(kind: .memberBlock)
960960
),
961961
]
962962
),
@@ -1104,7 +1104,7 @@ public let DECL_NODES: [Node] = [
11041104
Child(
11051105
name: "ParameterClause",
11061106
deprecatedName: "Input",
1107-
kind: .node(kind: .parameterClause)
1107+
kind: .node(kind: .functionParameterClause)
11081108
),
11091109
Child(
11101110
name: "EffectSpecifiers",
@@ -1157,7 +1157,7 @@ public let DECL_NODES: [Node] = [
11571157
),
11581158
Child(
11591159
name: "Decls",
1160-
kind: .node(kind: .memberDeclList)
1160+
kind: .node(kind: .memberBlockItemList)
11611161
),
11621162
Child(
11631163
name: "PostfixExpression",
@@ -1504,7 +1504,7 @@ public let DECL_NODES: [Node] = [
15041504
),
15051505

15061506
Node(
1507-
kind: .memberDeclBlock,
1507+
kind: .memberBlock,
15081508
base: .syntax,
15091509
nameForDiagnostics: "member block",
15101510
parserFunction: "parseMemberDeclList",
@@ -1516,7 +1516,7 @@ public let DECL_NODES: [Node] = [
15161516
),
15171517
Child(
15181518
name: "Members",
1519-
kind: .collection(kind: .memberDeclList, collectionElementName: "Member")
1519+
kind: .collection(kind: .memberBlockItemList, collectionElementName: "Member")
15201520
),
15211521
Child(
15221522
name: "RightBrace",
@@ -1527,7 +1527,7 @@ public let DECL_NODES: [Node] = [
15271527

15281528
// member-decl = decl ';'?
15291529
Node(
1530-
kind: .memberDeclListItem,
1530+
kind: .memberBlockItem,
15311531
base: .syntax,
15321532
nameForDiagnostics: nil,
15331533
documentation: "A member declaration of a type consisting of a declaration and an optional semicolon;",
@@ -1548,10 +1548,10 @@ public let DECL_NODES: [Node] = [
15481548

15491549
// member-decl-list = member-decl member-decl-list?
15501550
Node(
1551-
kind: .memberDeclList,
1551+
kind: .memberBlockItemList,
15521552
base: .syntaxCollection,
15531553
nameForDiagnostics: nil,
1554-
elementChoices: [.memberDeclListItem]
1554+
elementChoices: [.memberBlockItem]
15551555
),
15561556

15571557
// declaration-modifier -> access-level-modifier
@@ -1644,7 +1644,7 @@ public let DECL_NODES: [Node] = [
16441644
),
16451645

16461646
Node(
1647-
kind: .parameterClause,
1647+
kind: .functionParameterClause,
16481648
base: .syntax,
16491649
nameForDiagnostics: "parameter clause",
16501650
traits: [
@@ -2033,7 +2033,7 @@ public let DECL_NODES: [Node] = [
20332033
),
20342034
Child(
20352035
name: "MemberBlock",
2036-
kind: .node(kind: .memberDeclBlock),
2036+
kind: .node(kind: .memberBlock),
20372037
documentation: "The members of the protocol declaration."
20382038
),
20392039
]
@@ -2203,7 +2203,7 @@ public let DECL_NODES: [Node] = [
22032203
),
22042204
Child(
22052205
name: "MemberBlock",
2206-
kind: .node(kind: .memberDeclBlock),
2206+
kind: .node(kind: .memberBlock),
22072207
documentation:
22082208
"The members of the struct declaration. Because struct extension declarations may declare additional members the contents of this member block isn't guaranteed to be a complete list of members for this type."
22092209
),
@@ -2246,7 +2246,7 @@ public let DECL_NODES: [Node] = [
22462246
Child(
22472247
name: "ParameterClause",
22482248
deprecatedName: "Indices",
2249-
kind: .node(kind: .parameterClause)
2249+
kind: .node(kind: .functionParameterClause)
22502250
),
22512251
Child(
22522252
name: "ReturnClause",

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,14 @@ public let EXPR_NODES: [Node] = [
489489

490490
// a, b, c
491491
Node(
492-
kind: .closureParamList,
492+
kind: .closureShorthandParameterList,
493493
base: .syntaxCollection,
494494
nameForDiagnostics: nil,
495-
elementChoices: [.closureParam]
495+
elementChoices: [.closureShorthandParameter]
496496
),
497497

498498
Node(
499-
kind: .closureParam,
499+
kind: .closureShorthandParameter,
500500
base: .syntax,
501501
nameForDiagnostics: "closure parameter",
502502
traits: [
@@ -541,7 +541,7 @@ public let EXPR_NODES: [Node] = [
541541
kind: .nodeChoices(choices: [
542542
Child(
543543
name: "SimpleInput",
544-
kind: .node(kind: .closureParamList)
544+
kind: .node(kind: .closureShorthandParameterList)
545545
),
546546
Child(
547547
name: "ParameterClause",

CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public enum SyntaxNodeKind: String, CaseIterable {
3535
case arrowExpr
3636
case asExpr
3737
case assignmentExpr
38-
case associatedtypeDecl
38+
case associatedTypeDecl
3939
case attributeList
4040
case attribute
4141
case attributedType
@@ -67,8 +67,8 @@ public enum SyntaxNodeKind: String, CaseIterable {
6767
case closureCaptureItem
6868
case closureCaptureSignature
6969
case closureExpr
70-
case closureParamList
71-
case closureParam
70+
case closureShorthandParameterList
71+
case closureShorthandParameter
7272
case closureParameterClause
7373
case closureParameterList
7474
case closureParameter
@@ -121,7 +121,7 @@ public enum SyntaxNodeKind: String, CaseIterable {
121121
case enumCaseDecl
122122
case enumCaseElementList
123123
case enumCaseElement
124-
case enumCaseAssociatedValue
124+
case enumCaseParameterClause
125125
case enumCaseParameterList
126126
case enumCaseParameter
127127
case enumDecl
@@ -188,9 +188,9 @@ public enum SyntaxNodeKind: String, CaseIterable {
188188
case macroExpansionExpr
189189
case matchingPatternCondition
190190
case memberAccessExpr
191-
case memberDeclBlock
192-
case memberDeclListItem
193-
case memberDeclList
191+
case memberBlock
192+
case memberBlockItem
193+
case memberBlockItemList
194194
case memberType
195195
case metatypeType
196196
case missingDecl
@@ -217,8 +217,8 @@ public enum SyntaxNodeKind: String, CaseIterable {
217217
case packElementExpr
218218
case packExpansionExpr
219219
case packExpansionType
220-
case packReferenceType
221-
case parameterClause
220+
case packElementType
221+
case functionParameterClause
222222
case patternBindingList
223223
case patternBinding
224224
case pattern
@@ -374,6 +374,15 @@ public enum SyntaxNodeKind: String, CaseIterable {
374374
/// deprecated.
375375
public var deprecatedRawValue: String? {
376376
switch self {
377+
case .memberBlock: return "memberDeclBlock"
378+
case .memberBlockItemList: return "memberDeclList"
379+
case .memberBlockItem: return "memberDeclListItem"
380+
case .packElementType: return "packReferenceType"
381+
case .functionParameterClause: return "parameterClause"
382+
case .associatedTypeDecl: return "associatedtypeDecl"
383+
case .enumCaseParameterClause: return "enumCaseAssociatedValue"
384+
case .closureShorthandParameterList: return "closureParamList"
385+
case .closureShorthandParameter: return "closureParam"
377386
case .accessorDeclList: return "accessorList"
378387
case .importPathComponentList: return "accessPath"
379388
case .importPathComponent: return "accessPathComponent"
@@ -393,7 +402,6 @@ public enum SyntaxNodeKind: String, CaseIterable {
393402
case .differentiabilityArguments: return "differentiabilityParams"
394403
case .differentiabilityArgument: return "differentiabilityParam"
395404
case .dynamicReplacementAttributeArguments: return "dynamicReplacementArguments"
396-
case .enumCaseAssociatedValue: return "enumCaseParameterClause"
397405
case .exprPattern: return "expressionPattern"
398406
case .exprSegment: return "expressionSegment"
399407
case .forceUnwrapExpr: return "forcedValueExpr"

CodeGeneration/Sources/SyntaxSupport/Traits.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public let TRAITS: [Trait] = [
4646
documentation: "A `where` clause that places additional constraints on generic parameters like `where Element: Hashable`.",
4747
isOptional: true
4848
),
49-
Child(name: "MemberBlock", kind: .node(kind: .memberDeclBlock)),
49+
Child(name: "MemberBlock", kind: .node(kind: .memberBlock)),
5050
]
5151
),
5252
Trait(

CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,9 @@ public let TYPE_NODES: [Node] = [
408408

409409
// pack-reference-type -> 'each' type
410410
Node(
411-
kind: .packReferenceType,
411+
kind: .packElementType,
412412
base: .type,
413-
nameForDiagnostics: "pack reference",
413+
nameForDiagnostics: "pack element",
414414
children: [
415415
Child(
416416
name: "EachKeyword",

CodeGeneration/Sources/Utils/SyntaxBuildableChild.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public extension Child {
5454
}
5555

5656
var parameterType: TypeSyntax {
57-
return self.type.optionalWrapped(type: SimpleTypeIdentifierSyntax(name: .identifier(parameterBaseType)))
57+
return self.type.optionalWrapped(type: IdentifierTypeSyntax(name: .identifier(parameterBaseType)))
5858
}
5959

6060
var defaultValue: ExprSyntax? {

CodeGeneration/Sources/Utils/SyntaxBuildableType.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public struct SyntaxBuildableType: Hashable {
8585
/// - For token: ``TokenSyntax`` (tokens don't have a dedicated type in SwiftSyntaxBuilder)
8686
/// If the type is optional, the type is wrapped in an `OptionalType`.
8787
public var buildable: TypeSyntax {
88-
optionalWrapped(type: SimpleTypeIdentifierSyntax(name: .identifier(syntaxBaseName)))
88+
optionalWrapped(type: IdentifierTypeSyntax(name: .identifier(syntaxBaseName)))
8989
}
9090

9191
/// Whether parameters of this type should be initializable by a result builder.
@@ -133,7 +133,7 @@ public struct SyntaxBuildableType: Hashable {
133133
/// which will eventually get built from `SwiftSyntaxBuilder`. If the type
134134
/// is optional, this terminates with a `?`.
135135
public var syntax: TypeSyntax {
136-
return optionalWrapped(type: SimpleTypeIdentifierSyntax(name: .identifier(syntaxBaseName)))
136+
return optionalWrapped(type: IdentifierTypeSyntax(name: .identifier(syntaxBaseName)))
137137
}
138138

139139
/// The type that is used for parameters in SwiftSyntaxBuilder that take this
@@ -147,7 +147,7 @@ public struct SyntaxBuildableType: Hashable {
147147
}
148148

149149
public var parameterType: TypeSyntax {
150-
return optionalWrapped(type: SimpleTypeIdentifierSyntax(name: .identifier(parameterBaseType)))
150+
return optionalWrapped(type: IdentifierTypeSyntax(name: .identifier(parameterBaseType)))
151151
}
152152

153153
/// Assuming that this is a collection type, the non-optional type of the result builder
@@ -197,7 +197,7 @@ public struct SyntaxBuildableType: Hashable {
197197
/// Wraps a type in a force unwrap expression depending on whether `isOptional` is true.
198198
public func forceUnwrappedIfNeeded(expr: some ExprSyntaxProtocol) -> ExprSyntax {
199199
if isOptional {
200-
return ExprSyntax(ForcedValueExprSyntax(expression: expr))
200+
return ExprSyntax(ForceUnwrapExprSyntax(expression: expr))
201201
} else {
202202
return ExprSyntax(expr)
203203
}

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RawSyntaxNodesFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ let rawSyntaxNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
113113
let cases = CaseItemListSyntax {
114114
for n in SYNTAX_NODES where n.base == node.kind {
115115
CaseItemSyntax(
116-
pattern: ExpressionPatternSyntax(
116+
pattern: ExprPatternSyntax(
117117
expression: ExprSyntax(".\(raw: n.varOrCaseName)")
118118
)
119119
)

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/RawSyntaxValidationFile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ let rawSyntaxValidationFile = try! SourceFileSyntax(leadingTrivia: copyrightHead
227227
}
228228
}
229229
} else if let node = node.collectionNode {
230-
try ForInStmtSyntax("for (index, element) in layout.enumerated()") {
230+
try ForStmtSyntax("for (index, element) in layout.enumerated()") {
231231
if let onlyElement = node.elementChoices.only {
232232
ExprSyntax("assertNoError(kind, index, verify(element, as: \(onlyElement.rawType).self))")
233233
} else {

CodeGeneration/Sources/generate-swiftsyntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
111111
SwitchCaseLabelSyntax {
112112
for childNode in SYNTAX_NODES where childNode.base == node.kind {
113113
CaseItemSyntax(
114-
pattern: ExpressionPatternSyntax(
114+
pattern: ExprPatternSyntax(
115115
expression: ExprSyntax(".\(childNode.varOrCaseName)")
116116
)
117117
)
@@ -144,7 +144,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
144144
SwitchCaseLabelSyntax {
145145
for childNode in SYNTAX_NODES where childNode.base == node.kind {
146146
CaseItemSyntax(
147-
pattern: ExpressionPatternSyntax(
147+
pattern: ExprPatternSyntax(
148148
expression: ExprSyntax(".\(childNode.varOrCaseName)")
149149
)
150150
)

CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ class ValidateSyntaxNodes: XCTestCase {
478478
"child 'RawValue' is named inconsistently with 'MatchingPatternConditionSyntax.Initializer', which has the same type ('InitializerClauseSyntax')"
479479
),
480480
ValidationFailure(
481-
node: .enumCaseParameter,
481+
node: .enumCaseParameterClause,
482482
message:
483483
"child 'DefaultArgument' is named inconsistently with 'MatchingPatternConditionSyntax.Initializer', which has the same type ('InitializerClauseSyntax')"
484484
),

0 commit comments

Comments
 (0)