Skip to content

Commit 334ecdc

Browse files
committed
Remove IfStmtSyntax Initializer
1 parent b961d7d commit 334ecdc

File tree

2 files changed

+0
-47
lines changed

2 files changed

+0
-47
lines changed

Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -186,29 +186,6 @@ extension FunctionParameterSyntax {
186186
}
187187
}
188188

189-
// MARK: - IfStmt
190-
191-
extension IfStmtSyntax {
192-
/// A convenience initializer that uses builder closures to express an
193-
/// if body, potentially with a second trailing builder closure for an else
194-
/// body.
195-
public init(
196-
leadingTrivia: Trivia = [],
197-
conditions: ConditionElementListSyntax,
198-
@CodeBlockItemListBuilder body: () -> CodeBlockItemListSyntax,
199-
@CodeBlockItemListBuilder elseBody: () -> CodeBlockItemListSyntax? = { nil }
200-
) {
201-
let generatedElseBody = elseBody()
202-
self.init(
203-
leadingTrivia: leadingTrivia,
204-
conditions: conditions,
205-
body: CodeBlockSyntax(statements: body()),
206-
elseKeyword: generatedElseBody == nil ? nil : .keyword(.else, leadingTrivia: .space),
207-
elseBody: generatedElseBody.map { .codeBlock(CodeBlockSyntax(statements: $0)) }
208-
)
209-
}
210-
}
211-
212189
// MARK: - IntegerLiteralExpr
213190

214191
extension IntegerLiteralExprSyntax: ExpressibleByIntegerLiteral {

Tests/SwiftSyntaxBuilderTest/IfStmtTests.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,30 +114,6 @@ final class IfStmtTests: XCTestCase {
114114
}
115115
}
116116

117-
func testIfElseStmt() {
118-
// Use the convenience initializer from IfStmtConvenienceInitializers
119-
// with an else branch expressed by a second trailing closure.
120-
let buildable = IfStmtSyntax(conditions: ConditionElementListSyntax { BooleanLiteralExprSyntax(true) }) {
121-
FunctionCallExprSyntax(callee: ExprSyntax("print")) {
122-
TupleExprElementSyntax(expression: StringLiteralExprSyntax(content: "Hello from the if-branch!"))
123-
}
124-
} elseBody: {
125-
FunctionCallExprSyntax(callee: ExprSyntax("print")) {
126-
TupleExprElementSyntax(expression: StringLiteralExprSyntax(content: "Hello from the else-branch!"))
127-
}
128-
}
129-
AssertBuildResult(
130-
buildable,
131-
"""
132-
if true {
133-
print("Hello from the if-branch!")
134-
} else {
135-
print("Hello from the else-branch!")
136-
}
137-
"""
138-
)
139-
}
140-
141117
func testIfLetStmt() {
142118
let buildable = IfStmtSyntax(
143119
conditions: ConditionElementListSyntax {

0 commit comments

Comments
 (0)