From f0e6b574445b04c348fc404d3aef2c6c72cf38b1 Mon Sep 17 00:00:00 2001 From: Padmashree S S Date: Thu, 7 May 2026 02:12:38 +0530 Subject: [PATCH 1/2] Fixed whitespace error --- .../SwiftRefactor/ConvertStoredPropertyToComputed.swift | 7 ++++++- .../ConvertStoredPropertyToComputedTest.swift | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Sources/SwiftRefactor/ConvertStoredPropertyToComputed.swift b/Sources/SwiftRefactor/ConvertStoredPropertyToComputed.swift index 179b6c5b600..1ca11d33f39 100644 --- a/Sources/SwiftRefactor/ConvertStoredPropertyToComputed.swift +++ b/Sources/SwiftRefactor/ConvertStoredPropertyToComputed.swift @@ -69,15 +69,20 @@ public struct ConvertStoredPropertyToComputed: SyntaxRefactoringProvider { if let existingType = binding.typeAnnotation { typeAnnotation = existingType } else if let providedType = context.type { - typeAnnotation = TypeAnnotationSyntax(type: providedType) + typeAnnotation = TypeAnnotationSyntax( + colon: .colonToken(leadingTrivia: [], trailingTrivia: .space), + type: providedType + ) } else { typeAnnotation = TypeAnnotationSyntax( + colon: .colonToken(leadingTrivia: [], trailingTrivia: .space), type: TypeSyntax(stringLiteral: "<#Type#>") ) } let newBinding = binding + .with(\.pattern, binding.pattern.with(\.trailingTrivia, [])) .with(\.initializer, nil) .with(\.typeAnnotation, typeAnnotation) .with( diff --git a/Tests/SwiftRefactorTest/ConvertStoredPropertyToComputedTest.swift b/Tests/SwiftRefactorTest/ConvertStoredPropertyToComputedTest.swift index 09f084a3a0e..adf8c799392 100644 --- a/Tests/SwiftRefactorTest/ConvertStoredPropertyToComputedTest.swift +++ b/Tests/SwiftRefactorTest/ConvertStoredPropertyToComputedTest.swift @@ -297,14 +297,14 @@ final class ConvertStoredPropertyToComputedTest: XCTestCase { func testRefactoringStoredPropertyMissingTypeAnnotation() throws { let baseline: DeclSyntax = "var foo = \"abc\"" - let expected: DeclSyntax = "var foo :<#Type#>{ \"abc\" }" + let expected: DeclSyntax = "var foo: <#Type#>{ \"abc\" }" try assertRefactorConvert(baseline, expected: expected) } func testRefactoringStoredPropertyWithTypeAnnotation() throws { let baseline: DeclSyntax = "var foo = \"abc\"" - let expected: DeclSyntax = "var foo :String{ \"abc\" }" + let expected: DeclSyntax = "var foo: String{ \"abc\" }" let context = ConvertStoredPropertyToComputed.Context(type: TypeSyntax(stringLiteral: "String")) try assertRefactorConvert(baseline, expected: expected, context: context) From 7c0a90b43ac7134c67e8ce417a7634ad5330e806 Mon Sep 17 00:00:00 2001 From: Padmashree S S Date: Fri, 8 May 2026 01:50:19 +0530 Subject: [PATCH 2/2] Remove leading trivia --- Sources/SwiftRefactor/ConvertStoredPropertyToComputed.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftRefactor/ConvertStoredPropertyToComputed.swift b/Sources/SwiftRefactor/ConvertStoredPropertyToComputed.swift index 1ca11d33f39..6ff6d8d4c1a 100644 --- a/Sources/SwiftRefactor/ConvertStoredPropertyToComputed.swift +++ b/Sources/SwiftRefactor/ConvertStoredPropertyToComputed.swift @@ -70,12 +70,12 @@ public struct ConvertStoredPropertyToComputed: SyntaxRefactoringProvider { typeAnnotation = existingType } else if let providedType = context.type { typeAnnotation = TypeAnnotationSyntax( - colon: .colonToken(leadingTrivia: [], trailingTrivia: .space), + colon: .colonToken(trailingTrivia: .space), type: providedType ) } else { typeAnnotation = TypeAnnotationSyntax( - colon: .colonToken(leadingTrivia: [], trailingTrivia: .space), + colon: .colonToken(trailingTrivia: .space), type: TypeSyntax(stringLiteral: "<#Type#>") ) }