From 0978f6b3a54a878e3a7182fd500db65639775423 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Wed, 20 Sep 2023 17:00:43 -0700 Subject: [PATCH] Do not add whitespace between right angle and period `Foo.bar` should not have whitespace added between `>` and `.`. --- Sources/SwiftBasicFormat/BasicFormat.swift | 1 + Tests/SwiftBasicFormatTest/BasicFormatTests.swift | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Sources/SwiftBasicFormat/BasicFormat.swift b/Sources/SwiftBasicFormat/BasicFormat.swift index 3b277e42d5b..30c4e55c9d9 100644 --- a/Sources/SwiftBasicFormat/BasicFormat.swift +++ b/Sources/SwiftBasicFormat/BasicFormat.swift @@ -334,6 +334,7 @@ open class BasicFormat: SyntaxRewriter { (.regexLiteralPattern, _), (.regexSlash, .regexPoundDelimiter), // closing extended regex delimiter should never be separate by a space (.rightAngle, .leftParen), // func foo(x: T) + (.rightAngle, .period), // Foo.bar (.rightBrace, .leftParen), // { return 1 }() (.rightParen, .leftParen), // returnsClosure()() (.rightParen, .period), // foo().bar diff --git a/Tests/SwiftBasicFormatTest/BasicFormatTests.swift b/Tests/SwiftBasicFormatTest/BasicFormatTests.swift index 5a11a387663..7dd65b7cc2b 100644 --- a/Tests/SwiftBasicFormatTest/BasicFormatTests.swift +++ b/Tests/SwiftBasicFormatTest/BasicFormatTests.swift @@ -531,4 +531,11 @@ final class BasicFormatTest: XCTestCase { ) } } + + func testRightAnglePeriodNotFormatted() { + assertFormatted( + tree: ExprSyntax("Foo.bar"), + expected: "Foo.bar" + ) + } }