8000 Merge pull request #64 from allevato/inout-function-type · adevress/swift-syntax@a2f7e14 · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit a2f7e14

Browse files
authored
Merge pull request swiftlang#64 from allevato/inout-function-type
Break after `inout` in a function type.
2 parents 3062db6 + 23e2b6f commit a2f7e14

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ private final class TokenStreamCreator: SyntaxVisitor {
991991
func visit(_ node: TupleTypeElementSyntax) -> SyntaxVisitorContinueKind {
992992
before(node.firstToken, tokens: .open)
993993
after(node.colon, tokens: .break)
994+
after(node.inOut, tokens: .break)
994995
before(node.secondName, tokens: .break)
995996

996997
if let trailingComma = node.trailingComma {

Tests/SwiftFormatPrettyPrintTests/FunctionTypeTests.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,34 @@ public class FunctionTypeTests: PrettyPrintTestCase {
120120

121121
assertPrettyPrintEqual(input: input, expected: expected, linelength: 67)
122122
}
123+
124+
func testFunctionTypeInOut() {
125+
let input =
126+
"""
127+
func f(g: (firstArg: inout FirstArg, secondArg: inout SecondArg) -> Result) {
128+
let a = 123
129+
let b = "abc"
130+
}
131+
"""
132+
133+
let expected =
134+
"""
135+
func f(
136+
g: (
137+
firstArg:
138+
inout
139+
FirstArg,
140+
secondArg:
141+
inout
142+
SecondArg
143+
) -> Result
144+
) {
145+
let a = 123
146+
let b = "abc"
147+
}
148+
149+
"""
150+
151+
assertPrettyPrintEqual(input: input, expected: expected, linelength: 17)
152+
}
123153
}

Tests/SwiftFormatPrettyPrintTests/XCTestManifests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ extension FunctionTypeTests {
253253
// to regenerate.
254254
static let __allTests__FunctionTypeTests = [
255255
("testFunctionType", testFunctionType),
256+
("testFunctionTypeInOut", testFunctionTypeInOut),
256257
("testFunctionTypeThrows", testFunctionTypeThrows),
257258
]
258259
}

0 commit comments

Comments
 (0)
0