File tree Expand file tree Collapse file tree 3 files changed +23
-19
lines changed
SwiftParserTest/translated Expand file tree Collapse file tree 3 files changed +23
-19
lines changed Original file line number Diff line number Diff line change @@ -123,13 +123,33 @@ extension Parser.Lookahead {
123
123
if currentTokenPrecedence >= recoveryPrecedence {
124
124
break
125
125
}
126
- self . consumeAnyToken ( )
127
126
if let closingDelimiter = currentTokenPrecedence. closingTokenKind {
128
127
let closingDelimiterSpec = TokenSpec ( closingDelimiter)
128
+ let canCloseAtSameLine : Int ? = self . withLookahead { lookahead in
129
+ var tokensToSkip = 0
130
+ while !lookahead. at ( . endOfFile) , !lookahead. currentToken. isAtStartOfLine {
131
+ tokensToSkip += 1
132
+ if lookahead. at ( closingDelimiterSpec) {
133
+ return tokensToSkip
134
+ } else {
135
+ lookahead. consumeAnyToken ( )
136
+ }
137
+ }
138
+ return nil
139
+ }
140
+ if let tokensToSkip = canCloseAtSameLine {
141
+ for _ in 0 ..< tokensToSkip {
142
+ self . consumeAnyToken ( )
143
+ }
144
+ continue
145
+ }
146
+ self . consumeAnyToken ( )
129
147
guard self . canRecoverTo ( closingDelimiterSpec) != nil else {
130
148
continue
131
149
}
132
150
self . eat ( closingDelimiterSpec)
151
+ } else {
152
+ self . consumeAnyToken ( )
133
153
}
134
154
}
135
155
Original file line number Diff line number Diff line change @@ -53,15 +53,6 @@ fileprivate func assertFormattingRoundTrips(
53
53
}
54
54
55
55
final class BasicFormatTest : XCTestCase {
56
- func testClosureParameter( ) {
57
- let source = """
58
- myFunc({
59
- return true
60
- })
61
- """
62
- assertFormatted ( source: source, expected: source)
63
- }
64
-
65
56
func testNotIndented( ) {
66
57
assertFormatted (
67
58
source: """
Original file line number Diff line number Diff line change @@ -1935,19 +1935,12 @@ final class RecoveryTests: ParserTestCase {
1935
1935
assertParse (
1936
1936
"""
1937
1937
struct ErrorInFunctionSignatureResultArrayType11 {
1938
- func foo() -> Int1️⃣[(a){a++}2️⃣ ] {
1938
+ func foo() -> Int1️⃣[(a){a++}] {
1939
1939
}
1940
1940
}
1941
1941
""" ,
1942
1942
diagnostics: [
1943
- DiagnosticSpec (
1944
- locationMarker: " 1️⃣ " ,
1945
- message: " unexpected code '[(a)' in function "
1946
- ) ,
1947
- DiagnosticSpec (
1948
- locationMarker: " 2️⃣ " ,
1949
- message: " unexpected code in struct "
1950
- )
1943
+ DiagnosticSpec ( message: " unexpected code '[(a){a++}]' in function " )
1951
1944
]
1952
1945
)
1953
1946
}
You can’t perform that action at this time.
0 commit comments