Skip to content

Commit fdb4f43

Browse files
authored
Merge pull request #719 from apple/dd/documentation-vilibility-printing
Fix incorrect spacing when pretty-printing @_documentation
2 parents 26d83e5 + 36ba8dc commit fdb4f43

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift

+5
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,11 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
18021802
override func visit(_ node: OriginallyDefinedInAttributeArgumentsSyntax) -> SyntaxVisitorContinueKind {
18031803
after(node.colon.lastToken(viewMode: .sourceAccurate), tokens: .break(.same, size: 1))
18041804
after(node.comma.lastToken(viewMode: .sourceAccurate), tokens: .break(.same, size: 1))
1805+
return .visitChildren
1806+
}
1807+
1808+
override func visit(_ node: DocumentationAttributeArgumentSyntax) -> SyntaxVisitorContinueKind {
1809+
after(node.colon, tokens: .break(.same, size: 1))
18051810
return .visitChildren
18061811
}
18071812

Tests/SwiftFormatTests/PrettyPrint/AttributeTests.swift

+17
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,23 @@ final class AttributeTests: PrettyPrintTestCase {
4343
assertPrettyPrintEqual(input: input, expected: expected, linelength: 60)
4444
}
4545

46+
func testAttributeParamSpacingInDocVisibility() {
47+
let input =
48+
"""
49+
@_documentation( visibility :private )
50+
func f() {}
51+
"""
52+
53+
let expected =
54+
"""
55+
@_documentation(visibility: private)
56+
func f() {}
57+
58+
"""
59+
60+
assertPrettyPrintEqual(input: input, expected: expected, linelength: 60)
61+
}
62+
4663
func testAttributeBinPackedWrapping() {
4764
let input =
4865
"""

0 commit comments

Comments
 (0)