Skip to content

Commit 26d83e5

Browse files
authored
Merge pull request #717 from apple/dd/originally-defined-in-arguments
Fix @_originallyDefinedIn argument spacing
2 parents 5eb3d20 + b04a373 commit 26d83e5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,12 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
17991799
return .visitChildren
18001800
}
18011801

1802+
override func visit(_ node: OriginallyDefinedInAttributeArgumentsSyntax) -> SyntaxVisitorContinueKind {
1803+
after(node.colon.lastToken(viewMode: .sourceAccurate), tokens: .break(.same, size: 1))
1804+
after(node.comma.lastToken(viewMode: .sourceAccurate), tokens: .break(.same, size: 1))
1805+
return .visitChildren
1806+
}
1807+
18021808
override func visit(_ node: AvailabilityLabeledArgumentSyntax) -> SyntaxVisitorContinueKind {
18031809
before(node.label, tokens: .open)
18041810

Tests/SwiftFormatTests/PrettyPrint/AttributeTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@ final class AttributeTests: PrettyPrintTestCase {
2626
assertPrettyPrintEqual(input: input, expected: expected, linelength: 60)
2727
}
2828

29+
func testAttributeParamSpacingInOriginallyDefinedIn() {
30+
let input =
31+
"""
32+
@_originallyDefinedIn( module :"SwiftUI" , iOS 10.0 )
33+
func f() {}
34+
"""
35+
36+
let expected =
37+
"""
38+
@_originallyDefinedIn(module: "SwiftUI", iOS 10.0)
39+
func f() {}
40+
41+
"""
42+
43+
assertPrettyPrintEqual(input: input, expected: expected, linelength: 60)
44+
}
45+
2946
func testAttributeBinPackedWrapping() {
3047
let input =
3148
"""

0 commit comments

Comments
 (0)