Skip to content

Commit ee3a4be

Browse files
authored
Merge pull request #750 from kateinoigakukun/katei/fix-expose-attribute
Fix `@_expose` attribute argument spacing
2 parents 53279ee + 2541a14 commit ee3a4be

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
@@ -1818,6 +1818,11 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
18181818
return .visitChildren
18191819
}
18201820

1821+
override func visit(_ node: ExposeAttributeArgumentsSyntax) -> SyntaxVisitorContinueKind {
1822+
after(node.comma, tokens: .break(.same, size: 1))
1823+
return .visitChildren
1824+
}
1825+
18211826
override func visit(_ node: AvailabilityLabeledArgumentSyntax) -> SyntaxVisitorContinueKind {
18221827
before(node.label, tokens: .open)
18231828

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)