@@ -102,8 +102,8 @@ final class ConsecutiveStatementsTests: XCTestCase {
102
102
}
103
103
""" ,
104
104
diagnostics: [
105
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
106
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
105
+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';'" ] ) ,
106
+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';'" ] ) ,
107
107
DiagnosticSpec ( locationMarker: " 3️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
108
108
DiagnosticSpec ( locationMarker: " 4️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
109
109
DiagnosticSpec ( locationMarker: " 5️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
@@ -129,7 +129,7 @@ final class ConsecutiveStatementsTests: XCTestCase {
129
129
)
130
130
}
131
131
132
- func testConsecutiveStatements4 ( ) {
132
+ func testConsecutiveStatements4a ( ) {
133
133
assertParse (
134
134
"""
135
135
class C {
@@ -142,12 +142,14 @@ final class ConsecutiveStatementsTests: XCTestCase {
142
142
}
143
143
""" ,
144
144
diagnostics: [
145
- DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] )
145
+ DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';'" ] )
146
146
] ,
147
+ applyFixIts: [ " insert newline " ] ,
147
148
fixedSource: """
148
149
class C {
149
150
// In a sequence of declarations.
150
- var a, b : Int; func d() -> Int {}
151
+ var a, b : Int
152
+ func d() -> Int {}
151
153
init() {
152
154
a = 0
153
155
b = 0
@@ -157,25 +159,75 @@ final class ConsecutiveStatementsTests: XCTestCase {
157
159
)
158
160
}
159
161
160
- func testConsecutiveStatements5( ) {
162
+ func testConsecutiveStatements4b( ) {
163
+ assertParse (
164
+ """
165
+ class C {
166
+ // In a sequence of declarations.
167
+ var a, b : Int1️⃣ func d() -> Int {}
168
+ init() {
169
+ a = 0
170
+ b = 0
171
+ }
172
+ }
173
+ """ ,
174
+ diagnostics: [
175
+ DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';' " ] )
176
+ ] ,
177
+ applyFixIts: [ " insert ';' " ] ,
178
+ fixedSource: """
179
+ class C {
180
+ // In a sequence of declarations.
181
+ var a, b : Int; func d() -> Int {}
182
+ init() {
183
+ a = 0
184
+ b = 0
185
+ }
186
+ }
187
+ """
188
+ )
189
+ }
190
+
191
+ func testConsecutiveStatements5a( ) {
161
192
assertParse (
162
193
"""
163
194
protocol P {
164
195
func a()1️⃣ func b()
165
196
}
166
197
""" ,
167
198
diagnostics: [
168
- DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] )
199
+ DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';'" ] )
169
200
] ,
201
+ applyFixIts: [ " insert newline " ] ,
170
202
fixedSource: """
171
203
protocol P {
172
- func a(); func b()
204
+ func a()
205
+ func b()
173
206
}
174
207
"""
175
208
)
176
209
}
177
210
178
- func testConsecutiveStatements6( ) {
211
+ func testConsecutiveStatements5b( ) {
212
+ assertParse (
213
+ """
214
+ protocol P {
215
+ func a()1️⃣ func b()
216
+ }
217
+ """ ,
218
+ diagnostics: [
219
+ DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';' " ] )
220
+ ] ,
221
+ applyFixIts: [ " insert ';' " ] ,
222
+ fixedSource: """
223
+ protocol P {
224
+ func a(); func b()
225
+ }
226
+ """
227
+ )
228
+ }
229
+
230
+ func testConsecutiveStatements6a( ) {
179
231
assertParse (
180
232
"""
181
233
enum Color {
@@ -184,18 +236,43 @@ final class ConsecutiveStatementsTests: XCTestCase {
184
236
}
185
237
""" ,
186
238
diagnostics: [
187
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
188
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
239
+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';'" ] ) ,
240
+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';'" ] ) ,
189
241
] ,
242
+ applyFixIts: [ " insert newline " ] ,
190
243
fixedSource: """
191
244
enum Color {
192
- case Red; case Blue
193
- func a() {}; func b() {}
245
+ case Red
246
+ case Blue
247
+ func a() {}
248
+ func b() {}
194
249
}
195
250
"""
196
251
)
197
252
}
198
253
254
+ func testConsecutiveStatements6b( ) {
255
+ assertParse (
256
+ """
257
+ enum Color {
258
+ case Red1️⃣ case Blue
259
+ func a() {}2️⃣ func b() {}
260
+ }
261
+ """ ,
262
+ diagnostics: [
263
+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';' " ] ) ,
264
+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';' " ] ) ,
265
+ ] ,
266
+ applyFixIts: [ " insert ';' " ] ,
267
+ fixedSource: """
268
+ enum Color {
269
+ case Red; case Blue
270
+ func a() {}; func b() {}
271
+ }
272
+ """
273
+ )
274
+ }
275
+
199
276
func testConsecutiveStatements7( ) {
200
277
assertParse (
201
278
"""
@@ -212,4 +289,24 @@ final class ConsecutiveStatementsTests: XCTestCase {
212
289
"""
213
290
)
214
291
}
292
+
293
+ func testConsecutiveStatements8( ) {
294
+ assertParse (
295
+ """
296
+ class Foo {
297
+ func a() {}1️⃣/* some comment */ func b() {}
298
+ }
299
+ """ ,
300
+ diagnostics: [
301
+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';' " ] ) ,
302
+ ] ,
303
+ applyFixIts: [ " insert newline " ] ,
304
+ fixedSource: """
305
+ class Foo {
306
+ func a() {}/* some comment */
307
+ func b() {}
308
+ }
309
+ """
310
+ )
311
+ }
215
312
}
0 commit comments