Skip to content

Commit a0464df

Browse files
committed
Fix colon followed by right paren spacing
1 parent 35ff56c commit a0464df

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

CodeGeneration/Sources/generate-swiftsyntax/templates/basicformat/BasicFormatFile.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,16 @@ let basicFormatFile = SourceFileSyntax {
246246
StmtSyntax(
247247
"""
248248
switch (token.tokenKind, token.nextToken(viewMode: .sourceAccurate)?.tokenKind) {
249-
case (.keyword(.as), .exclamationMark), // Ensures there is not space in `as!`
250-
(.keyword(.as), .postfixQuestionMark), // Ensures there is not space in `as?`
249+
case (.colon, .rightParen), // Ensures there is not space in `.map(Foo.init(raw:))`
251250
(.exclamationMark, .leftParen), // Ensures there is not space in `myOptionalClosure!()`
252251
(.exclamationMark, .period), // Ensures there is not space in `myOptionalBar!.foo()`
252+
(.keyword(.as), .exclamationMark), // Ensures there is not space in `as!`
253+
(.keyword(.as), .postfixQuestionMark), // Ensures there is not space in `as?`
254+
(.keyword(.try), .exclamationMark), // Ensures there is not space in `try!`
255+
(.keyword(.try), .postfixQuestionMark), // Ensures there is not space in `try?`:
253256
(.postfixQuestionMark, .leftParen), // Ensures there is not space in `init?()` or `myOptionalClosure?()`s
254257
(.postfixQuestionMark, .rightAngle), // Ensures there is not space in `ContiguousArray<RawSyntax?>`
255-
(.postfixQuestionMark, .rightParen), // Ensures there is not space in `myOptionalClosure?()`
256-
(.keyword(.try), .exclamationMark), // Ensures there is not space in `try!`
257-
(.keyword(.try), .postfixQuestionMark): // Ensures there is not space in `try?`:
258+
(.postfixQuestionMark, .rightParen): // Ensures there is not space in `myOptionalClosure?()`
258259
return false
259260
default:
260261
break

Sources/SwiftBasicFormat/generated/BasicFormat.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,16 @@ open class BasicFormat: SyntaxRewriter {
194194
return requiresTrailingSpace
195195
}
196196
switch (token.tokenKind, token.nextToken(viewMode: .sourceAccurate)?.tokenKind) {
197-
case (.keyword(.as), .exclamationMark), // Ensures there is not space in `as!`
198-
(.keyword(.as), .postfixQuestionMark), // Ensures there is not space in `as?`
197+
case (.colon, .rightParen), // Ensures there is not space in `.map(Foo.init(raw:))`
199198
(.exclamationMark, .leftParen), // Ensures there is not space in `myOptionalClosure!()`
200199
(.exclamationMark, .period), // Ensures there is not space in `myOptionalBar!.foo()`
200+
(.keyword(.as), .exclamationMark), // Ensures there is not space in `as!`
201+
(.keyword(.as), .postfixQuestionMark), // Ensures there is not space in `as?`
202+
(.keyword(.try), .exclamationMark), // Ensures there is not space in `try!`
203+
(.keyword(.try), .postfixQuestionMark), // Ensures there is not space in `try?`:
201204
(.postfixQuestionMark, .leftParen), // Ensures there is not space in `init?()` or `myOptionalClosure?()`s
202205
(.postfixQuestionMark, .rightAngle), // Ensures there is not space in `ContiguousArray<RawSyntax?>`
203-
(.postfixQuestionMark, .rightParen), // Ensures there is not space in `myOptionalClosure?()`
204-
(.keyword(.try), .exclamationMark), // Ensures there is not space in `try!`
205-
(.keyword(.try), .postfixQuestionMark): // Ensures there is not space in `try?`:
206+
(.postfixQuestionMark, .rightParen): // Ensures there is not space in `myOptionalClosure?()`
206207
return false
207208
default:
208209
break

Tests/SwiftSyntaxBuilderTest/VariableTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ final class VariableTests: XCTestCase {
8989
let bar = try! !functionThatThrows()
9090
"""
9191
),
92+
#line: (
93+
DeclSyntax("var bar: Foo { bar.map(Foo.init(raw:)) }"),
94+
"""
95+
var bar: Foo {
96+
bar.map(Foo.init(raw:))
97+
}
98+
"""
99+
),
92100
]
93101

94102
for (line, testCase) in testCases {

0 commit comments

Comments
 (0)