Skip to content

Commit 2541a14

Browse files
Fix @_expose attribute argument spacing
Pretty-print the `@_expose` with the correct spacing. It was formatted as `@_expose(wasm,"foo")` instead of `@_expose(wasm, "foo")`.
1 parent 4f19acc commit 2541a14

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,11 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
18021802
return .visitChildren
18031803
}
18041804

1805+
override func visit(_ node: ExposeAttributeArgumentsSyntax) -> SyntaxVisitorContinueKind {
1806+
after(node.comma, tokens: .break(.same, size: 1))
1807+
return .visitChildren
1808+
}
1809+
18051810
override func visit(_ node: AvailabilityLabeledArgumentSyntax) -> SyntaxVisitorContinueKind {
18061811
before(node.label, tokens: .open)
18071812

Tests/SwiftFormatTests/PrettyPrint/AttributeTests.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,28 @@ final class AttributeTests: PrettyPrintTestCase {
444444

445445
assertPrettyPrintEqual(input: input, expected: expected, linelength: 100)
446446
}
447+
448+
func testAttributeParamSpacingInExpose() {
449+
let input =
450+
"""
451+
@_expose( wasm , "foo" )
452+
func f() {}
453+
454+
@_expose( Cxx , "bar")
455+
func b() {}
456+
457+
"""
458+
459+
let expected =
460+
"""
461+
@_expose(wasm, "foo")
462+
func f() {}
463+
464+
@_expose(Cxx, "bar")
465+
func b() {}
466+
467+
"""
468+
469+
assertPrettyPrintEqual(input: input, expected: expected, linelength: 100)
470+
}
447471
}

0 commit comments

Comments
 (0)