Skip to content

Commit ade5af4

Browse files
committed
Use builders for some more HasTrailingComma-conforming types
1 parent e04f28e commit ade5af4

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

Sources/SwiftSyntaxBuilder/gyb_generated/BuildableNodes.swift

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,6 +2328,20 @@ public struct ClosureCaptureSignature: SyntaxBuildable, ExpressibleAsClosureCapt
23282328
assert(rightSquare.text == "]")
23292329
}
23302330

2331+
/// A convenience initializer that allows:
2332+
/// - Initializing syntax collections using result builders
2333+
/// - Initializing tokens without default text using strings
2334+
public init(
2335+
leftSquare: TokenSyntax = TokenSyntax.`leftSquareBracket`,
2336+
rightSquare: TokenSyntax = TokenSyntax.`rightSquareBracket`,
2337+
@ClosureCaptureItemListBuilder itemsBuilder: () -> ExpressibleAsClosureCaptureItemList? = { nil }
2338+
) {
2339+
self.init(
2340+
leftSquare: leftSquare,
2341+
items: itemsBuilder(),
2342+
rightSquare: rightSquare
2343+
)
2344+
}
23312345

23322346
func buildClosureCaptureSignature(format: Format, leadingTrivia: Trivia? = nil) -> ClosureCaptureSignatureSyntax {
23332347
let result = SyntaxFactory.makeClosureCaptureSignature(
@@ -10736,6 +10750,20 @@ public struct SwitchCaseLabel: SyntaxBuildable, ExpressibleAsSwitchCaseLabel {
1073610750
assert(colon.text == ":")
1073710751
}
1073810752

10753+
/// A convenience initializer that allows:
10754+
/// - Initializing syntax collections using result builders
10755+
/// - Initializing tokens without default text using strings
10756+
public init(
10757+
caseKeyword: TokenSyntax = TokenSyntax.`case`,
10758+
colon: TokenSyntax = TokenSyntax.`colon`,
10759+
@CaseItemListBuilder caseItemsBuilder: () -> ExpressibleAsCaseItemList = { CaseItemList([]) }
10760+
) {
10761+
self.init(
10762+
caseKeyword: caseKeyword,
10763+
caseItems: caseItemsBuilder(),
10764+
colon: colon
10765+
)
10766+
}
1073910767

1074010768
func buildSwitchCaseLabel(format: Format, leadingTrivia: Trivia? = nil) -> SwitchCaseLabelSyntax {
1074110769
let result = SyntaxFactory.makeSwitchCaseLabel(
@@ -12512,6 +12540,20 @@ public struct GenericArgumentClause: SyntaxBuildable, ExpressibleAsGenericArgume
1251212540
assert(rightAngleBracket.text == ">")
1251312541
}
1251412542

12543+
/// A convenience initializer that allows:
12544+
/// - Initializing syntax collections using result builders
12545+
/// - Initializing tokens without default text using strings
12546+
public init(
12547+
leftAngleBracket: TokenSyntax = TokenSyntax.`leftAngle`,
12548+
rightAngleBracket: TokenSyntax = TokenSyntax.`rightAngle`,
12549+
@GenericArgumentListBuilder argumentsBuilder: () -> ExpressibleAsGenericArgumentList = { GenericArgumentList([]) }
12550+
) {
12551+
self.init(
12552+
leftAngleBracket: leftAngleBracket,
12553+
arguments: argumentsBuilder(),
12554+
rightAngleBracket: rightAngleBracket
12555+
)
12556+
}
1251512557

1251612558
func buildGenericArgumentClause(format: Format, leadingTrivia: Trivia? = nil) -> GenericArgumentClauseSyntax {
1251712559
let result = SyntaxFactory.makeGenericArgumentClause(
@@ -12916,6 +12958,20 @@ public struct TuplePattern: PatternBuildable, ExpressibleAsTuplePattern {
1291612958
assert(rightParen.text == ")")
1291712959
}
1291812960

12961+
/// A convenience initializer that allows:
12962+
/// - Initializing syntax collections using result builders
12963+
/// - Initializing tokens without default text using strings
12964+
public init(
12965+
leftParen: TokenSyntax = TokenSyntax.`leftParen`,
12966+
rightParen: TokenSyntax = TokenSyntax.`rightParen`,
12967+
@TuplePatternElementListBuilder elementsBuilder: () -> ExpressibleAsTuplePatternElementList = { TuplePatternElementList([]) }
12968+
) {
12969+
self.init(
12970+
leftParen: leftParen,
12971+
elements: elementsBuilder(),
12972+
rightParen: rightParen
12973+
)
12974+
}
1291912975

1292012976
func buildTuplePattern(format: Format, leadingTrivia: Trivia? = nil) -> TuplePatternSyntax {
1292112977
let result = SyntaxFactory.makeTuplePattern(

Sources/SwiftSyntaxBuilder/gyb_helpers/BuilderInitializableTypes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
'GenericParameterList': None,
1313
'GenericRequirementList': None,
1414
'InheritedTypeList': None,
15+
'ClosureCaptureItemList': None,
16+
'CaseItemList': None,
17+
'GenericArgumentList': None,
18+
'TuplePatternElementList': None,
1519
}

0 commit comments

Comments
 (0)