Skip to content

Commit b05d14a

Browse files
committed
Remove VariableDeclSyntax Initializer
1 parent 7b56382 commit b05d14a

File tree

2 files changed

+8
-44
lines changed

2 files changed

+8
-44
lines changed

Sources/SwiftSyntaxBuilder/ConvenienceInitializers.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -402,29 +402,6 @@ extension VariableDeclSyntax {
402402
)
403403
}
404404
}
405-
406-
/// Creates a computed property with the given accessor.
407-
public init(
408-
leadingTrivia: Trivia = [],
409-
attributes: AttributeListSyntax? = nil,
410-
modifiers: ModifierListSyntax? = nil,
411-
name: PatternSyntax,
412-
type: TypeAnnotationSyntax,
413-
@CodeBlockItemListBuilder accessor: () -> CodeBlockItemListSyntax
414-
) {
415-
self.init(
416-
leadingTrivia: leadingTrivia,
417-
attributes: attributes?.with(\.trailingTrivia, .space),
418-
modifiers: modifiers,
419-
letOrVarKeyword: .keyword(.var)
420-
) {
421-
PatternBindingSyntax(
422-
pattern: name,
423-
typeAnnotation: type,
424-
accessor: .getter(CodeBlockSyntax(statements: accessor()))
425-
)
426-
}
427-
}
428405
}
429406

430407
//==========================================================================//

Tests/SwiftSyntaxBuilderTest/VariableTests.swift

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ final class VariableTests: XCTestCase {
175175
}
176176

177177
func testComputedProperty() throws {
178-
let testCases: [UInt: (VariableDeclSyntax, String)] = [
178+
let testCases: [UInt: (VariableDeclSyntax, String)] = try [
179179
#line: (
180-
VariableDeclSyntax(name: "test", type: TypeAnnotationSyntax(type: TypeSyntax("Int"))) {
180+
VariableDeclSyntax("var test: Int") {
181181
SequenceExprSyntax {
182182
IntegerLiteralExprSyntax(4)
183183
BinaryOperatorExprSyntax(text: "+")
@@ -208,8 +208,8 @@ final class VariableTests: XCTestCase {
208208
}
209209
}
210210

211-
func testAccessorList() {
212-
let buildable = VariableDeclSyntax(name: "test", type: TypeAnnotationSyntax(type: TypeSyntax("Int"))) {
211+
func testAccessorList() throws {
212+
let buildable = try VariableDeclSyntax("var test: Int") {
213213
AccessorDeclSyntax(accessorKind: .keyword(.get)) {
214214
SequenceExprSyntax {
215215
IntegerLiteralExprSyntax(4)
@@ -235,8 +235,8 @@ final class VariableTests: XCTestCase {
235235
)
236236
}
237237

238-
func testAttributedVariables() {
239-
let testCases: [UInt: (VariableDeclSyntax, String)] = [
238+
func testAttributedVariables() throws {
239+
let testCases: [UInt: (VariableDeclSyntax, String)] = try [
240240
#line: (
241241
VariableDeclSyntax(
242242
attributes: AttributeListSyntax { AttributeSyntax(attributeName: TypeSyntax("Test")) },
@@ -249,11 +249,7 @@ final class VariableTests: XCTestCase {
249249
"""
250250
),
251251
#line: (
252-
VariableDeclSyntax(
253-
attributes: AttributeListSyntax { AttributeSyntax(attributeName: TypeSyntax("Test")) },
254-
name: "y",
255-
type: TypeAnnotationSyntax(type: TypeSyntax("String"))
256-
) {
252+
VariableDeclSyntax("@Test var y: String") {
257253
StringLiteralExprSyntax(content: "Hello world!")
258254
},
259255
"""
@@ -263,16 +259,7 @@ final class VariableTests: XCTestCase {
263259
"""
264260
),
265261
#line: (
266-
VariableDeclSyntax(
267-
attributes: AttributeListSyntax {
268-
AttributeSyntax("WithArgs") {
269-
TupleExprElementSyntax(expression: ExprSyntax("value1"))
270-
TupleExprElementSyntax(label: "label", expression: ExprSyntax("value2"))
271-
}
272-
},
273-
name: "z",
274-
type: TypeAnnotationSyntax(type: TypeSyntax("Float"))
275-
) {
262+
VariableDeclSyntax("@WithArgs(value1, label: value2) var z: Float") {
276263
FloatLiteralExprSyntax(0.0)
277264
},
278265
"""

0 commit comments

Comments
 (0)