@@ -329,9 +329,54 @@ final class DeclarationTests: XCTestCase {
329
329
internal(set) var defaultProp = 0
330
330
""" ,
331
331
diagnostics: [
332
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
333
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
332
+ DiagnosticSpec (
333
+ locationMarker: " 1️⃣ " ,
334
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
335
+ fixIts: [ " insert newline " , " insert ';' " ]
336
+ ) ,
337
+ DiagnosticSpec (
338
+ locationMarker: " 2️⃣ " ,
339
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
340
+ fixIts: [ " insert newline " , " insert ';' " ]
341
+ ) ,
342
+ ] ,
343
+ applyFixIts: [ " insert newline " ] ,
344
+ fixedSource: """
345
+ open
346
+ open(set)
347
+ var openProp = 0
348
+ public public(set) var publicProp = 0
349
+ package package(set) var packageProp = 0
350
+ internal internal(set) var internalProp = 0
351
+ fileprivate fileprivate(set) var fileprivateProp = 0
352
+ private private(set) var privateProp = 0
353
+ internal(set) var defaultProp = 0
354
+ """
355
+ )
356
+
357
+ assertParse (
358
+ """
359
+ open1️⃣ open(set)2️⃣ var openProp = 0
360
+ public public(set) var publicProp = 0
361
+ package package(set) var packageProp = 0
362
+ internal internal(set) var internalProp = 0
363
+ fileprivate fileprivate(set) var fileprivateProp = 0
364
+ private private(set) var privateProp = 0
365
+ internal(set) var defaultProp = 0
366
+ """ ,
367
+ diagnostics: [
368
+ DiagnosticSpec (
369
+ locationMarker: " 1️⃣ " ,
370
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
371
+ fixIts: [ " insert newline " , " insert ';' " ]
372
+ ) ,
373
+ DiagnosticSpec (
374
+ locationMarker: " 2️⃣ " ,
375
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
376
+ fixIts: [ " insert newline " , " insert ';' " ]
377
+ ) ,
334
378
] ,
379
+ applyFixIts: [ " insert ';' " ] ,
335
380
fixedSource: """
336
381
open; open(set); var openProp = 0
337
382
public public(set) var publicProp = 0
@@ -1025,18 +1070,74 @@ final class DeclarationTests: XCTestCase {
1025
1070
)
1026
1071
}
1027
1072
1028
- func testTextRecovery( ) {
1073
+ func testTextRecovery1( ) {
1074
+ assertParse (
1075
+ """
1076
+ Lorem1️⃣ ipsum2️⃣ dolor3️⃣ sit4️⃣ amet5️⃣, consectetur adipiscing elit
1077
+ """ ,
1078
+ diagnostics: [
1079
+ DiagnosticSpec (
1080
+ locationMarker: " 1️⃣ " ,
1081
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
1082
+ fixIts: [ " insert newline " , " insert ';' " ]
1083
+ ) ,
1084
+ DiagnosticSpec (
1085
+ locationMarker: " 2️⃣ " ,
1086
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
1087
+ fixIts: [ " insert newline " , " insert ';' " ]
1088
+ ) ,
1089
+ DiagnosticSpec (
1090
+ locationMarker: " 3️⃣ " ,
1091
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
1092
+ fixIts: [ " insert newline " , " insert ';' " ]
1093
+ ) ,
1094
+ DiagnosticSpec (
1095
+ locationMarker: " 4️⃣ " ,
1096
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
1097
+ fixIts: [ " insert newline " , " insert ';' " ]
1098
+ ) ,
1099
+ DiagnosticSpec ( locationMarker: " 5️⃣ " , message: " extraneous code ', consectetur adipiscing elit' at top level " ) ,
1100
+ ] ,
1101
+ applyFixIts: [ " insert newline " ] ,
1102
+ fixedSource: """
1103
+ Lorem
1104
+ ipsum
1105
+ dolor
1106
+ sit
1107
+ amet, consectetur adipiscing elit
1108
+ """
1109
+ )
1110
+ }
1111
+
1112
+ func testTextRecovery2( ) {
1029
1113
assertParse (
1030
1114
"""
1031
1115
Lorem1️⃣ ipsum2️⃣ dolor3️⃣ sit4️⃣ amet5️⃣, consectetur adipiscing elit
1032
1116
""" ,
1033
1117
diagnostics: [
1034
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
1035
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
1036
- DiagnosticSpec ( locationMarker: " 3️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
1037
- DiagnosticSpec ( locationMarker: " 4️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
1118
+ DiagnosticSpec (
1119
+ locationMarker: " 1️⃣ " ,
1120
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
1121
+ fixIts: [ " insert newline " , " insert ';' " ]
1122
+ ) ,
1123
+ DiagnosticSpec (
1124
+ locationMarker: " 2️⃣ " ,
1125
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
1126
+ fixIts: [ " insert newline " , " insert ';' " ]
1127
+ ) ,
1128
+ DiagnosticSpec (
1129
+ locationMarker: " 3️⃣ " ,
1130
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
1131
+ fixIts: [ " insert newline " , " insert ';' " ]
1132
+ ) ,
1133
+ DiagnosticSpec (
1134
+ locationMarker: " 4️⃣ " ,
1135
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
1136
+ fixIts: [ " insert newline " , " insert ';' " ]
1137
+ ) ,
1038
1138
DiagnosticSpec ( locationMarker: " 5️⃣ " , message: " extraneous code ', consectetur adipiscing elit' at top level " ) ,
1039
1139
] ,
1140
+ applyFixIts: [ " insert ';' " ] ,
1040
1141
fixedSource: """
1041
1142
Lorem; ipsum; dolor; sit; amet, consectetur adipiscing elit
1042
1143
"""
@@ -2409,4 +2510,24 @@ final class DeclarationTests: XCTestCase {
2409
2510
fixedSource: " protocol X<<#identifier#>> {} "
2410
2511
)
2411
2512
}
2513
+
2514
+ func testCorrectIndentationWithNewline( ) {
2515
+ assertParse (
2516
+ """
2517
+ func
2518
+ test() {}1️⃣ var other: Int
2519
+ """ ,
2520
+ diagnostics: [
2521
+ DiagnosticSpec (
2522
+ message: " consecutive statements on a line must be separated by newline or ';' " ,
2523
+ fixIts: [ " insert newline " , " insert ';' " ]
2524
+ )
2525
+ ] ,
2526
+ fixedSource: """
2527
+ func
2528
+ test() {}
2529
+ var other: Int
2530
+ """
2531
+ )
2532
+ }
2412
2533
}
0 commit comments