From 43577558abcf9fab34fa0724ae4e7756f2c466e5 Mon Sep 17 00:00:00 2001 From: Kim de Vos Date: Thu, 30 Mar 2023 14:36:44 +0200 Subject: [PATCH] Added missing fix its --- Tests/SwiftParserTest/Assertions.swift | 30 +- Tests/SwiftParserTest/AttributeTests.swift | 22 +- Tests/SwiftParserTest/AvailabilityTests.swift | 8 +- Tests/SwiftParserTest/DeclarationTests.swift | 162 +++++----- Tests/SwiftParserTest/DirectiveTests.swift | 2 +- Tests/SwiftParserTest/ExpressionTests.swift | 162 +++++----- Tests/SwiftParserTest/Parser+EntryTests.swift | 2 +- Tests/SwiftParserTest/RegexLiteralTests.swift | 58 ++-- Tests/SwiftParserTest/StatementTests.swift | 14 +- Tests/SwiftParserTest/TypeMemberTests.swift | 4 +- Tests/SwiftParserTest/TypeTests.swift | 10 +- .../VariadicGenericsTests.swift | 45 ++- .../translated/ActorTests.swift | 5 +- .../translated/AsyncTests.swift | 17 +- .../translated/AvailabilityQueryTests.swift | 30 +- ...AvailabilityQueryUnavailabilityTests.swift | 91 ++++-- .../translated/BraceRecoveryEofTests.swift | 4 +- .../ConsecutiveStatementsTests.swift | 20 +- .../translated/DeprecatedWhereTests.swift | 16 +- .../DiagnoseDynamicReplacementTests.swift | 17 +- ...agnoseInitializerAsTypedPatternTests.swift | 2 +- .../DiagnosticMissingFuncKeywordTests.swift | 24 +- .../translated/DollarIdentifierTests.swift | 12 +- .../translated/EffectfulPropertiesTests.swift | 65 +++- .../translated/EnumTests.swift | 30 +- .../translated/ErrorsTests.swift | 34 +-- .../translated/ForeachAsyncTests.swift | 6 +- .../translated/ForeachTests.swift | 6 +- ...orwardSlashRegexSkippingAllowedTests.swift | 2 +- ...orwardSlashRegexSkippingInvalidTests.swift | 16 +- .../translated/ForwardSlashRegexTests.swift | 63 ++-- .../translated/GuardTests.swift | 4 +- .../translated/IdentifiersTests.swift | 8 +- .../translated/IfconfigExprTests.swift | 4 +- .../ImplicitGetterIncompleteTests.swift | 4 +- .../translated/InitDeinitTests.swift | 14 +- .../translated/InvalidIfExprTests.swift | 2 +- .../translated/InvalidTests.swift | 60 ++-- .../translated/MultilineErrorsTests.swift | 78 ++--- ...ePoundDiagnosticArgRdar41154797Tests.swift | 4 +- .../translated/ObjectLiteralsTests.swift | 18 +- .../translated/OperatorDeclTests.swift | 34 +-- .../translated/OperatorsTests.swift | 4 +- .../OriginalDefinedInAttrTests.swift | 10 +- .../translated/PoundAssertTests.swift | 11 +- .../translated/RawStringErrorsTests.swift | 16 +- .../translated/RecoveryTests.swift | 287 ++++++++++-------- .../RegexParseEndOfBufferTests.swift | 2 +- .../translated/RegexParseErrorTests.swift | 18 +- .../translated/SelfRebindingTests.swift | 2 +- .../translated/StringLiteralEofTests.swift | 44 ++- .../translated/SubscriptingTests.swift | 34 +-- .../translated/SuperTests.swift | 2 +- .../translated/SwitchIncompleteTests.swift | 8 +- .../translated/SwitchTests.swift | 29 +- .../translated/ToplevelLibraryTests.swift | 2 +- .../translated/TrailingClosuresTests.swift | 2 +- .../translated/TrailingSemiTests.swift | 8 +- .../SwiftParserTest/translated/TryTests.swift | 2 +- .../translated/TypeExprTests.swift | 8 +- .../translated/TypealiasTests.swift | 16 +- .../UnclosedStringInterpolationTests.swift | 37 +-- 62 files changed, 967 insertions(+), 784 deletions(-) diff --git a/Tests/SwiftParserTest/Assertions.swift b/Tests/SwiftParserTest/Assertions.swift index 153091a742d..2a4343d69ee 100644 --- a/Tests/SwiftParserTest/Assertions.swift +++ b/Tests/SwiftParserTest/Assertions.swift @@ -242,7 +242,7 @@ struct DiagnosticSpec { let notes: [NoteSpec]? /// If not `nil`, assert that the diagnostic contains fix-its with these messages. /// Use the `fixedSource` parameter on `AssertParse` to check that applying the Fix-It yields the expected result. - let fixIts: [String]? + let fixIts: [String] /// The file and line at which this `DiagnosticSpec` was created, so that assertion failures can be reported at its location. let file: StaticString @@ -255,7 +255,7 @@ struct DiagnosticSpec { severity: DiagnosticSeverity = .error, highlight: String? = nil, notes: [NoteSpec]? = nil, - fixIts: [String]? = nil, + fixIts: [String] = [], file: StaticString = #file, line: UInt = #line ) { @@ -434,15 +434,23 @@ func assertDiagnostic( } } } - if let fixIts = spec.fixIts { - if fixIts != diag.fixIts.map(\.message.message) { - failStringsEqualWithDiff( - diag.fixIts.map(\.message.message).joined(separator: "\n"), - fixIts.joined(separator: "\n"), - file: file, - line: line - ) - } + + if diag.fixIts.count != spec.fixIts.count { + XCTFail( + """ + Expected \(spec.fixIts.count) fix its but received \(diag.fixIts.count): + \(diag.fixIts.map { $0.message.message }.joined(separator: "\n")) + """, + file: file, + line: line + ) + } else if spec.fixIts != diag.fixIts.map(\.message.message) { + failStringsEqualWithDiff( + diag.fixIts.map(\.message.message).joined(separator: "\n"), + spec.fixIts.joined(separator: "\n"), + file: file, + line: line + ) } } diff --git a/Tests/SwiftParserTest/AttributeTests.swift b/Tests/SwiftParserTest/AttributeTests.swift index 81bc05183c5..19c859b1f21 100644 --- a/Tests/SwiftParserTest/AttributeTests.swift +++ b/Tests/SwiftParserTest/AttributeTests.swift @@ -60,9 +60,9 @@ final class AttributeTests: XCTestCase { @_specialize(e1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected ':' in attribute argument"), - DiagnosticSpec(message: "expected ')' to end attribute"), - DiagnosticSpec(message: "expected declaration after attribute"), + DiagnosticSpec(message: "expected ':' in attribute argument", fixIts: ["insert ':'"]), + DiagnosticSpec(message: "expected ')' to end attribute", fixIts: ["insert ')'"]), + DiagnosticSpec(message: "expected declaration after attribute", fixIts: ["insert declaration"]), ] ) } @@ -73,9 +73,9 @@ final class AttributeTests: XCTestCase { @_specialize(e1️⃣, exported2️⃣)3️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ':' in attribute argument"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ': false' in attribute argument"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected declaration after attribute"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ':' in attribute argument", fixIts: ["insert ':'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ': false' in attribute argument", fixIts: ["insert ': false'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected declaration after attribute", fixIts: ["insert declaration"]), ] ) } @@ -309,7 +309,7 @@ final class AttributeTests: XCTestCase { func testMissingDeclarationAfterAttributes() { assertParse( "@resultBuilder1️⃣", - diagnostics: [DiagnosticSpec(message: "expected declaration after attribute")], + diagnostics: [DiagnosticSpec(message: "expected declaration after attribute", fixIts: ["insert declaration"])], fixedSource: """ @resultBuilder <#declaration#> @@ -426,7 +426,7 @@ final class AttributeTests: XCTestCase { @_expose(Cxx, 1️⃣baz) func foo() {} """, diagnostics: [ - DiagnosticSpec(message: "expected string literal to end @_expose arguments"), + DiagnosticSpec(message: "expected string literal to end @_expose arguments", fixIts: ["insert string literal"]), DiagnosticSpec(message: "unexpected code 'baz' in attribute"), ] ) @@ -476,7 +476,7 @@ final class AttributeTests: XCTestCase { func foo() {} """, diagnostics: [ - DiagnosticSpec(message: "expected 'message' in @_unavailableFromAsync argument"), + DiagnosticSpec(message: "expected 'message' in @_unavailableFromAsync argument", fixIts: ["insert 'message'"]), DiagnosticSpec(message: "unexpected code 'nope' before @_unavailableFromAsync argument"), ] ) @@ -487,7 +487,7 @@ final class AttributeTests: XCTestCase { func foo() {} """, diagnostics: [ - DiagnosticSpec(message: "expected ':' and string literal in @_unavailableFromAsync argument"), + DiagnosticSpec(message: "expected ':' and string literal in @_unavailableFromAsync argument", fixIts: ["insert ':' and string literal"]), DiagnosticSpec(message: #"unexpected code '= "abc"' in attribute"#), ] ) @@ -498,7 +498,7 @@ final class AttributeTests: XCTestCase { func foo() {} """, diagnostics: [ - DiagnosticSpec(message: "expected string literal to end @_unavailableFromAsync argument"), + DiagnosticSpec(message: "expected string literal to end @_unavailableFromAsync argument", fixIts: ["insert string literal"]), DiagnosticSpec(message: "unexpected code 'abc' in attribute"), ] ) diff --git a/Tests/SwiftParserTest/AvailabilityTests.swift b/Tests/SwiftParserTest/AvailabilityTests.swift index c325a00fefe..13cb6eb65ae 100644 --- a/Tests/SwiftParserTest/AvailabilityTests.swift +++ b/Tests/SwiftParserTest/AvailabilityTests.swift @@ -149,7 +149,7 @@ final class AvailabilityTests: XCTestCase { func test() {} """, diagnostics: [ - DiagnosticSpec(message: "expected version tuple in version restriction"), + DiagnosticSpec(message: "expected version tuple in version restriction", fixIts: ["insert version tuple"]), DiagnosticSpec(message: "unexpected code '10e10' in attribute"), ] ) @@ -160,7 +160,7 @@ final class AvailabilityTests: XCTestCase { func test() {} """, diagnostics: [ - DiagnosticSpec(message: "expected integer literal in version tuple"), + DiagnosticSpec(message: "expected integer literal in version tuple", fixIts: ["insert integer literal"]), DiagnosticSpec(message: "unexpected code '0e10' in attribute"), ] ) @@ -171,7 +171,7 @@ final class AvailabilityTests: XCTestCase { func test() {} """, diagnostics: [ - DiagnosticSpec(message: "expected version tuple in version restriction"), + DiagnosticSpec(message: "expected version tuple in version restriction", fixIts: ["insert version tuple"]), DiagnosticSpec(message: "unexpected code '0xff' in attribute"), ] ) @@ -182,7 +182,7 @@ final class AvailabilityTests: XCTestCase { func test() {} """, diagnostics: [ - DiagnosticSpec(message: "expected integer literal in version tuple"), + DiagnosticSpec(message: "expected integer literal in version tuple", fixIts: ["insert integer literal"]), DiagnosticSpec(message: "unexpected code '0xff' in attribute"), ] ) diff --git a/Tests/SwiftParserTest/DeclarationTests.swift b/Tests/SwiftParserTest/DeclarationTests.swift index b97e722c2f5..9b76ba4f541 100644 --- a/Tests/SwiftParserTest/DeclarationTests.swift +++ b/Tests/SwiftParserTest/DeclarationTests.swift @@ -55,7 +55,7 @@ final class DeclarationTests: XCTestCase { diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'where' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]), DiagnosticSpec(locationMarker: "2️⃣", message: "expected '(' to start parameter clause", fixIts: ["insert '('"]), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected ':' and type in parameter"), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected ':' and type in parameter", fixIts: ["insert ':' and type"]), DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), ], fixedSource: """ @@ -124,15 +124,15 @@ final class DeclarationTests: XCTestCase { "class T where t1️⃣", diagnostics: [ DiagnosticSpec(message: "expected ':' or '==' to indicate a conformance or same-type requirement"), - DiagnosticSpec(message: "expected member block in class"), + DiagnosticSpec(message: "expected member block in class", fixIts: ["insert member block"]), ] ) assertParse( "class B' to end generic parameter clause"), - DiagnosticSpec(message: "expected member block in class"), + DiagnosticSpec(message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), + DiagnosticSpec(message: "expected member block in class", fixIts: ["insert member block"]), ] ) } @@ -188,8 +188,8 @@ final class DeclarationTests: XCTestCase { "protocol P{1️⃣{}case2️⃣", diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code '{}' before enum case"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in enum case"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end protocol"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in enum case", fixIts: ["insert identifier"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end protocol", fixIts: ["insert '}'"]), ] ) } @@ -220,7 +220,7 @@ final class DeclarationTests: XCTestCase { assertParse( "_ = foo/* */?.description1️⃣", diagnostics: [ - DiagnosticSpec(message: "expected ':' and expression after '? ...' in ternary expression") + DiagnosticSpec(message: "expected ':' and expression after '? ...' in ternary expression", fixIts: ["insert ':' and expression"]) ] ) @@ -288,8 +288,8 @@ final class DeclarationTests: XCTestCase { internal(set) var defaultProp = 0 """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), ] ) @@ -298,7 +298,7 @@ final class DeclarationTests: XCTestCase { private(1️⃣get) var a = 0 """, diagnostics: [ - DiagnosticSpec(message: "expected 'set' in modifier"), + DiagnosticSpec(message: "expected 'set' in modifier", fixIts: ["insert 'set'"]), DiagnosticSpec(message: "unexpected code 'get' in modifier"), ] ) @@ -310,7 +310,7 @@ final class DeclarationTests: XCTestCase { ) var a = 0 """, diagnostics: [ - DiagnosticSpec(message: "expected 'set)' to end modifier"), + DiagnosticSpec(message: "expected 'set)' to end modifier", fixIts: ["insert 'set)'"]), // FIXME: It should print `+` as detail of text. DiagnosticSpec(message: "unexpected code in variable"), ] @@ -348,7 +348,7 @@ final class DeclarationTests: XCTestCase { private(1️⃣var a = 0 """, diagnostics: [ - DiagnosticSpec(message: "expected 'set)' to end modifier") + DiagnosticSpec(message: "expected 'set)' to end modifier", fixIts: ["insert 'set)'"]) ] ) @@ -367,7 +367,7 @@ final class DeclarationTests: XCTestCase { private(1️⃣get, didSet var a = 0 """, diagnostics: [ - DiagnosticSpec(message: "expected 'set)' to end modifier"), + DiagnosticSpec(message: "expected 'set)' to end modifier", fixIts: ["insert 'set)'"]), DiagnosticSpec(message: "unexpected code 'get, didSet' in variable"), ] ) @@ -601,7 +601,7 @@ final class DeclarationTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected declaration after 'public' modifier") + DiagnosticSpec(message: "expected declaration after 'public' modifier", fixIts: ["insert declaration"]) ] ) } @@ -610,7 +610,7 @@ final class DeclarationTests: XCTestCase { assertParse( "func test(first second 1️⃣Int)", diagnostics: [ - DiagnosticSpec(message: "expected ':' in parameter") + DiagnosticSpec(message: "expected ':' in parameter", fixIts: ["insert ':'"]) ] ) } @@ -628,7 +628,7 @@ final class DeclarationTests: XCTestCase { assertParse( "func test(first second: Int1️⃣", diagnostics: [ - DiagnosticSpec(message: "expected ')' to end parameter clause") + DiagnosticSpec(message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]) ] ) } @@ -637,7 +637,7 @@ final class DeclarationTests: XCTestCase { assertParse( "func test 1️⃣first second: Int)", diagnostics: [ - DiagnosticSpec(message: "expected '(' to start parameter clause") + DiagnosticSpec(message: "expected '(' to start parameter clause", fixIts: ["insert '('"]) ] ) } @@ -665,7 +665,7 @@ final class DeclarationTests: XCTestCase { ) ), diagnostics: [ - DiagnosticSpec(message: "expected parameter clause in function signature") + DiagnosticSpec(message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]) ] ) } @@ -702,7 +702,7 @@ final class DeclarationTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '->' and return type in subscript") + DiagnosticSpec(message: "expected '->' and return type in subscript", fixIts: ["insert '->' and return type"]) ] ) } @@ -737,7 +737,7 @@ final class DeclarationTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected async specifier; did you mean 'async'?") + DiagnosticSpec(message: "expected async specifier; did you mean 'async'?", fixIts: ["replace 'reasync' with 'async'"]) ] ) } @@ -750,9 +750,9 @@ final class DeclarationTests: XCTestCase { 4️⃣} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end struct"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end struct", fixIts: ["insert '}'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "bare slash regex literal may not start with space"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected '/' to end regex literal"), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected '/' to end regex literal", fixIts: ["insert '/\'"]), DiagnosticSpec(locationMarker: "4️⃣", message: "extraneous brace at top level"), ] ) @@ -790,10 +790,10 @@ final class DeclarationTests: XCTestCase { Lorem1️⃣ ipsum2️⃣ dolor3️⃣ sit4️⃣ amet5️⃣, consectetur adipiscing elit """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "4️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "4️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), DiagnosticSpec(locationMarker: "5️⃣", message: "extraneous code ', consectetur adipiscing elit' at top level"), ] ) @@ -847,9 +847,9 @@ final class DeclarationTests: XCTestCase { ) ), diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ':' in parameter"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end parameter clause"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected identifier in struct"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ':' in parameter", fixIts: ["insert ':'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected identifier in struct", fixIts: ["insert identifier"]), DiagnosticSpec(locationMarker: "4️⃣", message: "unexpected code ')' in struct"), ] ) @@ -894,8 +894,8 @@ final class DeclarationTests: XCTestCase { ) ), diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ':' in parameter"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ']' to end array type"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ':' in parameter", fixIts: ["insert ':'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ']' to end array type", fixIts: ["insert ']'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code 'fourth: Int' in parameter clause"), ] ) @@ -916,8 +916,8 @@ final class DeclarationTests: XCTestCase { ) ), diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ':' in parameter"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end parameter clause"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ':' in parameter", fixIts: ["insert ':'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), DiagnosticSpec(locationMarker: "3️⃣", message: "extraneous code ': Int) {}' at top level"), ] ) @@ -931,12 +931,12 @@ final class DeclarationTests: XCTestCase { @3️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in struct"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected condition in conditional compilation clause"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected name in attribute"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected declaration after attribute"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected '#endif' in conditional compilation block"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected '}' to end struct"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in struct", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected condition in conditional compilation clause", fixIts: ["insert condition"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected name in attribute", fixIts: ["insert name"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected declaration after attribute", fixIts: ["insert declaration"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected '#endif' in conditional compilation block", fixIts: ["insert '#endif'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected '}' to end struct", fixIts: ["insert '}'"]), ] ) } @@ -1002,7 +1002,7 @@ final class DeclarationTests: XCTestCase { "1️⃣}class C2️⃣", diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected brace before class"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected member block in class"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected member block in class", fixIts: ["insert member block"]), ], fixedSource: """ }class C {} @@ -1012,50 +1012,50 @@ final class DeclarationTests: XCTestCase { "1️⃣}enum C2️⃣", diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected brace before enum"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected member block in enum"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected member block in enum", fixIts: ["insert member block"]), ] ) assertParse( "1️⃣}protocol C2️⃣", diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected brace before protocol"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected member block in protocol"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected member block in protocol", fixIts: ["insert member block"]), ] ) assertParse( "1️⃣}actor C2️⃣", diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected brace before actor"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected member block in actor"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected member block in actor", fixIts: ["insert member block"]), ] ) assertParse( "1️⃣}struct C2️⃣", diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected brace before struct"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected member block in struct"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected member block in struct", fixIts: ["insert member block"]), ] ) assertParse( "1️⃣}func C2️⃣", diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected brace before function"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]), ] ) assertParse( "1️⃣}init2️⃣", diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected brace before initializer"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]), ] ) assertParse( "1️⃣}subscript2️⃣", diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected brace before subscript"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in subscript"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '->' and return type in subscript"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in subscript", fixIts: ["insert parameter clause"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '->' and return type in subscript", fixIts: ["insert '->' and return type"]), ] ) } @@ -1143,10 +1143,10 @@ final class DeclarationTests: XCTestCase { struct U<@1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected name in attribute"), - DiagnosticSpec(message: "expected name in generic parameter"), - DiagnosticSpec(message: "expected '>' to end generic parameter clause"), - DiagnosticSpec(message: "expected member block in struct"), + DiagnosticSpec(message: "expected name in attribute", fixIts: ["insert name"]), + DiagnosticSpec(message: "expected name in generic parameter", fixIts: ["insert name"]), + DiagnosticSpec(message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), + DiagnosticSpec(message: "expected member block in struct", fixIts: ["insert member block"]), ] ) } @@ -1159,7 +1159,7 @@ final class DeclarationTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected member block in struct") + DiagnosticSpec(message: "expected member block in struct", fixIts: ["insert member block"]) ] ) } @@ -1168,7 +1168,7 @@ final class DeclarationTests: XCTestCase { assertParse( "func 1️⃣{}", diagnostics: [ - DiagnosticSpec(message: "expected identifier and function signature in function") + DiagnosticSpec(message: "expected identifier and function signature in function", fixIts: ["insert identifier and function signature"]) ] ) } @@ -1210,7 +1210,7 @@ final class DeclarationTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '{' in variable") + DiagnosticSpec(message: "expected '{' in variable", fixIts: ["insert '{'"]) ] ) } @@ -1230,7 +1230,7 @@ final class DeclarationTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '{' in variable") + DiagnosticSpec(message: "expected '{' in variable", fixIts: ["insert '{'"]) ] ) } @@ -1247,10 +1247,30 @@ final class DeclarationTests: XCTestCase { } func testNominalDeclarationRecovery() { - assertParse("protocol 1️⃣{}", diagnostics: [DiagnosticSpec(message: "expected identifier in protocol")]) - assertParse("class 1️⃣{}", diagnostics: [DiagnosticSpec(message: "expected identifier in class")]) - assertParse("struct 1️⃣{}", diagnostics: [DiagnosticSpec(message: "expected identifier in struct")]) - assertParse("enum 1️⃣{}", diagnostics: [DiagnosticSpec(message: "expected identifier in enum")]) + assertParse( + "protocol 1️⃣{}", + diagnostics: [ + DiagnosticSpec(message: "expected identifier in protocol", fixIts: ["insert identifier"]) + ] + ) + assertParse( + "class 1️⃣{}", + diagnostics: [ + DiagnosticSpec(message: "expected identifier in class", fixIts: ["insert identifier"]) + ] + ) + assertParse( + "struct 1️⃣{}", + diagnostics: [ + DiagnosticSpec(message: "expected identifier in struct", fixIts: ["insert identifier"]) + ] + ) + assertParse( + "enum 1️⃣{}", + diagnostics: [ + DiagnosticSpec(message: "expected identifier in enum", fixIts: ["insert identifier"]) + ] + ) // `actor` cannot recover from a missing identifier since it's contextual // based on the presence of the identifier. } @@ -1313,8 +1333,8 @@ final class DeclarationTests: XCTestCase { ]) ), diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'func' in function"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'func' in function", fixIts: ["insert 'func'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]), ] ) } @@ -1342,9 +1362,9 @@ final class DeclarationTests: XCTestCase { macro m5(_: T) """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected parameter clause in function signature"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]), DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code ': Int = A.M1' before macro"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code ': T = A.M4 where T.Assoc: P' before macro"), ] ) @@ -1354,7 +1374,7 @@ final class DeclarationTests: XCTestCase { macro m1 1️⃣= A """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected parameter clause in function signature") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]) ] ) } @@ -1363,11 +1383,11 @@ final class DeclarationTests: XCTestCase { assertParse( "protocol1️⃣<2️⃣:3️⃣", diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in protocol"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected name in primary associated type clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '>' to end primary associated type clause"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected type in inherited type"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected member block in protocol"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in protocol", fixIts: ["insert identifier"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected name in primary associated type clause", fixIts: ["insert name"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '>' to end primary associated type clause", fixIts: ["insert '>'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected type in inherited type", fixIts: ["insert type"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected member block in protocol", fixIts: ["insert member block"]), ] ) } @@ -1415,7 +1435,7 @@ final class DeclarationTests: XCTestCase { let a =1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected expression in variable") + DiagnosticSpec(message: "expected expression in variable", fixIts: ["insert expression"]) ], fixedSource: """ let a = <#expression#> diff --git a/Tests/SwiftParserTest/DirectiveTests.swift b/Tests/SwiftParserTest/DirectiveTests.swift index 68a557e5ffb..95feff6e685 100644 --- a/Tests/SwiftParserTest/DirectiveTests.swift +++ b/Tests/SwiftParserTest/DirectiveTests.swift @@ -117,7 +117,7 @@ final class DirectiveTests: XCTestCase { assertParse( "#if test1️⃣", diagnostics: [ - DiagnosticSpec(message: "expected '#endif' in conditional compilation block") + DiagnosticSpec(message: "expected '#endif' in conditional compilation block", fixIts: ["insert '#endif'"]) ] ) } diff --git a/Tests/SwiftParserTest/ExpressionTests.swift b/Tests/SwiftParserTest/ExpressionTests.swift index d7ef84e2a79..17c6fbf026e 100644 --- a/Tests/SwiftParserTest/ExpressionTests.swift +++ b/Tests/SwiftParserTest/ExpressionTests.swift @@ -19,7 +19,7 @@ final class ExpressionTests: XCTestCase { assertParse( "let a =1️⃣", diagnostics: [ - DiagnosticSpec(message: "expected expression in variable") + DiagnosticSpec(message: "expected expression in variable", fixIts: ["insert expression"]) ] ) @@ -27,7 +27,7 @@ final class ExpressionTests: XCTestCase { assertParse( "a ? b :1️⃣", diagnostics: [ - DiagnosticSpec(message: "expected expression after ternary operator") + DiagnosticSpec(message: "expected expression after ternary operator", fixIts: ["insert expression"]) ] ) } @@ -150,7 +150,7 @@ final class ExpressionTests: XCTestCase { cℹ️[1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected value and ']' to end subscript") + DiagnosticSpec(message: "expected value and ']' to end subscript", fixIts: ["insert value and ']'"]) ] ) @@ -332,8 +332,8 @@ final class ExpressionTests: XCTestCase { ,2️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected value in array element"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ']' to end array"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected value in array element", fixIts: ["insert value"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ']' to end array", fixIts: ["insert ']'"]), ] ) @@ -342,8 +342,8 @@ final class ExpressionTests: XCTestCase { ([1:1️⃣) """, diagnostics: [ - DiagnosticSpec(message: "expected value in dictionary element"), - DiagnosticSpec(message: "expected ']' to end dictionary"), + DiagnosticSpec(message: "expected value in dictionary element", fixIts: ["insert value"]), + DiagnosticSpec(message: "expected ']' to end dictionary", fixIts: ["insert ']'"]), ] ) @@ -420,8 +420,8 @@ final class ExpressionTests: XCTestCase { "\(()1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: #"expected ')' in string literal"#), - DiagnosticSpec(message: #"expected '"' to end string literal"#), + DiagnosticSpec(message: "expected ')' in string literal", fixIts: ["insert ')'"]), + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -476,7 +476,8 @@ final class ExpressionTests: XCTestCase { message: #"expected '"' to end string literal"#, notes: [ NoteSpec(message: #"to match this opening '"'"#) - ] + ], + fixIts: [#"insert '"'"#] ) ] ) @@ -548,7 +549,8 @@ final class ExpressionTests: XCTestCase { message: #"expected '"""' to end string literal"#, notes: [ NoteSpec(message: #"to match this opening '"""'"#) - ] + ], + fixIts: [#"insert '"""'"#] ) ] ) @@ -558,7 +560,7 @@ final class ExpressionTests: XCTestCase { """""1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: #"expected '"""' to end string literal"#) + DiagnosticSpec(message: #"expected '"""' to end string literal"#, fixIts: [#"insert '"""'"#]) ] ) @@ -567,7 +569,7 @@ final class ExpressionTests: XCTestCase { """1️⃣""" """##, diagnostics: [ - DiagnosticSpec(message: "multi-line string literal closing delimiter must begin on a new line") + DiagnosticSpec(message: "multi-line string literal closing delimiter must begin on a new line", fixIts: ["insert newline"]) ], fixedSource: ##""" """ @@ -580,7 +582,7 @@ final class ExpressionTests: XCTestCase { #"1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: ##"expected '"#' to end string literal"##, notes: []) + DiagnosticSpec(message: ##"expected '"#' to end string literal"##, fixIts: [##"insert '"#'"##]) ] ) @@ -589,7 +591,7 @@ final class ExpressionTests: XCTestCase { #"""1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: ##"expected '"""#' to end string literal"##) + DiagnosticSpec(message: ##"expected '"""#' to end string literal"##, fixIts: [##"insert '"""#'"##]) ] ) @@ -598,7 +600,7 @@ final class ExpressionTests: XCTestCase { #"""a1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: ##"expected '"""#' to end string literal"##) + DiagnosticSpec(message: ##"expected '"""#' to end string literal"##, fixIts: [##"insert '"""#'"##]) ] ) @@ -606,7 +608,7 @@ final class ExpressionTests: XCTestCase { ###""1️⃣\2️⃣"###, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "invalid escape sequence in literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -659,8 +661,8 @@ final class ExpressionTests: XCTestCase { \1️⃣\(2️⃣ """##, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected root in key path"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end tuple type"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected root in key path", fixIts: ["insert root"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end tuple type", fixIts: ["insert ')'"]), ] ) @@ -675,7 +677,7 @@ final class ExpressionTests: XCTestCase { "1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: #"expected '"' to end string literal"#) + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]) ] ) @@ -684,7 +686,7 @@ final class ExpressionTests: XCTestCase { "'1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: #"expected '"' to end string literal"#) + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]) ] ) } @@ -719,7 +721,7 @@ final class ExpressionTests: XCTestCase { assertParse( "foo ? 11️⃣", diagnostics: [ - DiagnosticSpec(message: "expected ':' and expression after '? ...' in ternary expression") + DiagnosticSpec(message: "expected ':' and expression after '? ...' in ternary expression", fixIts: ["insert ':' and expression"]) ] ) } @@ -734,18 +736,18 @@ final class ExpressionTests: XCTestCase { print1️⃣ "\(i)\"\n2️⃣ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end 'if' statement"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end function"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end 'if' statement", fixIts: ["insert '}'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end function", fixIts: ["insert '}'"]), ] ) assertParse( "#keyPath((b:1️⃣)2️⃣", diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected value in tuple"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end macro expansion"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected value in tuple", fixIts: ["insert value"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end macro expansion", fixIts: ["insert ')'"]), ] ) } @@ -770,7 +772,7 @@ final class ExpressionTests: XCTestCase { assertParse( "let _ = [Int throws 1️⃣Int]()", diagnostics: [ - DiagnosticSpec(message: "expected '->' in array element") + DiagnosticSpec(message: "expected '->' in array element", fixIts: ["insert '->'"]) ] ) } @@ -784,7 +786,7 @@ final class ExpressionTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after ternary operator") + DiagnosticSpec(message: "expected expression after ternary operator", fixIts: ["insert expression"]) ] ) } @@ -795,10 +797,10 @@ final class ExpressionTests: XCTestCase { let 1️⃣:(2️⃣..)->3️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected pattern in variable"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected type in function type"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected pattern in variable", fixIts: ["insert pattern"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected type in function type", fixIts: ["insert type"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code '..' in function type"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected return type in function type"), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected return type in function type", fixIts: ["insert return type"]), ] ) } @@ -810,7 +812,7 @@ final class ExpressionTests: XCTestCase { substructure: Syntax(TokenSyntax.keyword(.async)), substructureAfterMarker: "1️⃣", diagnostics: [ - DiagnosticSpec(locationMarker: "2️⃣", message: "expected expression") + DiagnosticSpec(locationMarker: "2️⃣", message: "expected expression", fixIts: ["insert expression"]) ] ) } @@ -935,9 +937,9 @@ final class ExpressionTests: XCTestCase { foo2️⃣)" """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected value in string literal"), - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ')' in string literal"), - DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected value in string literal", fixIts: ["insert value"]), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ')' in string literal", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), DiagnosticSpec(locationMarker: "2️⃣", message: #"extraneous code ')"' at top level"#), ] ) @@ -959,7 +961,7 @@ final class ExpressionTests: XCTestCase { ) ), diagnostics: [ - DiagnosticSpec(message: #"expected '"' to end string literal"#) + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]) ] ) } @@ -1028,7 +1030,7 @@ final class ExpressionTests: XCTestCase { ) ), diagnostics: [ - DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed") + DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed", fixIts: ["remove ''"]) ], options: [.substructureCheckTrivia] ) @@ -1103,7 +1105,7 @@ final class ExpressionTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal") + DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" """ @@ -1121,7 +1123,7 @@ final class ExpressionTests: XCTestCase { a ? b :1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected expression after ternary operator") + DiagnosticSpec(message: "expected expression after ternary operator", fixIts: ["insert expression"]) ], fixedSource: """ a ? b : <#expression#> @@ -1133,7 +1135,7 @@ final class ExpressionTests: XCTestCase { a +1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ], fixedSource: """ a + <#expression#> @@ -1145,7 +1147,7 @@ final class ExpressionTests: XCTestCase { a as1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected type after 'as'") + DiagnosticSpec(message: "expected type after 'as'", fixIts: ["insert type"]) ], fixedSource: """ a as <#type#> @@ -1157,7 +1159,7 @@ final class ExpressionTests: XCTestCase { a is1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected type after 'is'") + DiagnosticSpec(message: "expected type after 'is'", fixIts: ["insert type"]) ], fixedSource: """ a is <#type#> @@ -1217,7 +1219,7 @@ final class MemberExprTests: XCTestCase { for (line, trailing) in cases { assertParse( "someVar.1️⃣\(trailing)", - diagnostics: [DiagnosticSpec(message: "expected name in member access")], + diagnostics: [DiagnosticSpec(message: "expected name in member access", fixIts: ["insert name"])], fixedSource: "someVar.<#identifier#>\(trailing)", line: line ) @@ -1671,8 +1673,8 @@ final class StatementExpressionTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "multi-line string literal content must begin on a new line"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected value and ')' to end tuple"), + DiagnosticSpec(locationMarker: "1️⃣", message: "multi-line string literal content must begin on a new line", fixIts: ["insert newline"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected value and ')' to end tuple", fixIts: ["insert value and ')'"]), ] ) } @@ -1684,8 +1686,8 @@ final class StatementExpressionTests: XCTestCase { "2️⃣ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -1697,8 +1699,8 @@ final class StatementExpressionTests: XCTestCase { "2️⃣ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -1710,9 +1712,9 @@ final class StatementExpressionTests: XCTestCase { \(def)2️⃣"3️⃣ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "3️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -1724,8 +1726,8 @@ final class StatementExpressionTests: XCTestCase { 3️⃣)" """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ')' in string literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ')' in string literal", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), DiagnosticSpec(locationMarker: "3️⃣", message: #"extraneous code ')"' at top level"#), ] ) @@ -1738,8 +1740,8 @@ final class StatementExpressionTests: XCTestCase { def3️⃣)" """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected value and ')' in string literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected value and ')' in string literal", fixIts: ["insert value and ')'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), DiagnosticSpec(locationMarker: "3️⃣", message: #"extraneous code ')"' at top level"#), ] ) @@ -1753,9 +1755,9 @@ final class StatementExpressionTests: XCTestCase { """#, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "invalid escape sequence in literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), - DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "4️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), + DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "4️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -1767,9 +1769,9 @@ final class StatementExpressionTests: XCTestCase { "abc"2️⃣#3️⃣ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected identifier in macro expansion"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]), ] ) } @@ -1781,9 +1783,9 @@ final class StatementExpressionTests: XCTestCase { abc2️⃣"#3️⃣ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: ##"expected '"#' to end string literal"##), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "3️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: ##"expected '"#' to end string literal"##, fixIts: [##"insert '"#'"##]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -1795,8 +1797,8 @@ final class StatementExpressionTests: XCTestCase { "#2️⃣ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: ##"expected '"#' to end string literal"##), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: ##"expected '"#' to end string literal"##, fixIts: [##"insert '"#'"##]), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -1808,8 +1810,8 @@ final class StatementExpressionTests: XCTestCase { #2️⃣ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: ##"expected '"#' to end string literal"##), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion"), + DiagnosticSpec(locationMarker: "1️⃣", message: ##"expected '"#' to end string literal"##, fixIts: [##"insert '"#'"##]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]), ] ) } @@ -1826,8 +1828,8 @@ final class StatementExpressionTests: XCTestCase { assertParse( "{a1️⃣ b2️⃣ c}", diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), ] ) } @@ -1836,8 +1838,8 @@ final class StatementExpressionTests: XCTestCase { assertParse( "switch x {case y: a1️⃣ b2️⃣ c}", diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), ] ) } @@ -1848,8 +1850,8 @@ final class StatementExpressionTests: XCTestCase { var i: Int { a1️⃣ b2️⃣ c } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), ] ) } @@ -1860,8 +1862,8 @@ final class StatementExpressionTests: XCTestCase { var i: Int { get {a1️⃣ b} set {c2️⃣ d} } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), ] ) } @@ -1909,7 +1911,7 @@ final class StatementExpressionTests: XCTestCase { \String.?1️⃣"" """#, diagnostics: [ - DiagnosticSpec(message: "consecutive statements on a line must be separated by ';'") + DiagnosticSpec(message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]) ] ) } diff --git a/Tests/SwiftParserTest/Parser+EntryTests.swift b/Tests/SwiftParserTest/Parser+EntryTests.swift index 0fbceed5a61..a0b04ecf4ce 100644 --- a/Tests/SwiftParserTest/Parser+EntryTests.swift +++ b/Tests/SwiftParserTest/Parser+EntryTests.swift @@ -61,7 +61,7 @@ public class EntryTests: XCTestCase { substructureAfterMarker: "2️⃣", diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "'test' is considered an identifier and must not appear within an operator name"), - DiagnosticSpec(locationMarker: "2️⃣", message: "operator should not be declared with body"), + DiagnosticSpec(locationMarker: "2️⃣", message: "operator should not be declared with body", fixIts: ["remove operator body"]), ] ) } diff --git a/Tests/SwiftParserTest/RegexLiteralTests.swift b/Tests/SwiftParserTest/RegexLiteralTests.swift index acc3b690812..9762af1a15d 100644 --- a/Tests/SwiftParserTest/RegexLiteralTests.swift +++ b/Tests/SwiftParserTest/RegexLiteralTests.swift @@ -41,7 +41,7 @@ final class RegexLiteralTests: XCTestCase { #//#1️⃣# """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "too many '#' characters in closing delimiter") + DiagnosticSpec(locationMarker: "1️⃣", message: "too many '#' characters in closing delimiter", fixIts: ["remove extraneous delimiters"]) ], fixedSource: "#//#" ) @@ -52,7 +52,7 @@ final class RegexLiteralTests: XCTestCase { #/abc/#1️⃣# """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "too many '#' characters in closing delimiter") + DiagnosticSpec(locationMarker: "1️⃣", message: "too many '#' characters in closing delimiter", fixIts: ["remove extraneous delimiters"]) ], fixedSource: "#/abc/#" ) @@ -64,7 +64,7 @@ final class RegexLiteralTests: XCTestCase { #1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected identifier in macro expansion") + DiagnosticSpec(message: "expected identifier in macro expansion", fixIts: ["insert identifier"]) ] ) } @@ -75,7 +75,7 @@ final class RegexLiteralTests: XCTestCase { /1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '/' to end regex literal") + DiagnosticSpec(message: "expected '/' to end regex literal", fixIts: ["insert '/'"]) ] ) } @@ -86,7 +86,7 @@ final class RegexLiteralTests: XCTestCase { /#1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected identifier in macro expansion") + DiagnosticSpec(message: "expected identifier in macro expansion", fixIts: ["insert identifier"]) ] ) } @@ -97,7 +97,7 @@ final class RegexLiteralTests: XCTestCase { #/1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '/#' to end regex literal") + DiagnosticSpec(message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]) ] ) } @@ -108,7 +108,7 @@ final class RegexLiteralTests: XCTestCase { #//1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '#' to end regex literal") + DiagnosticSpec(message: "expected '#' to end regex literal", fixIts: ["insert '#'"]) ] ) } @@ -119,7 +119,7 @@ final class RegexLiteralTests: XCTestCase { #///1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '#' to end regex literal") + DiagnosticSpec(message: "expected '#' to end regex literal", fixIts: ["insert '#'"]) ] ) } @@ -130,7 +130,7 @@ final class RegexLiteralTests: XCTestCase { #/#1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '/#' to end regex literal") + DiagnosticSpec(message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]) ] ) } @@ -141,7 +141,7 @@ final class RegexLiteralTests: XCTestCase { #/##1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '/#' to end regex literal") + DiagnosticSpec(message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]) ] ) } @@ -152,7 +152,7 @@ final class RegexLiteralTests: XCTestCase { #/##/1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '#' to end regex literal") + DiagnosticSpec(message: "expected '#' to end regex literal", fixIts: ["insert '#'"]) ] ) } @@ -163,7 +163,7 @@ final class RegexLiteralTests: XCTestCase { ##/##/#1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected additional '#' characters in closing delimiter") + DiagnosticSpec(message: "expected additional '#' characters in closing delimiter", fixIts: ["insert additional closing '#' delimiters"]) ], fixedSource: "##/##/##" ) @@ -175,7 +175,7 @@ final class RegexLiteralTests: XCTestCase { ##/###1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '/##' to end regex literal") + DiagnosticSpec(message: "expected '/##' to end regex literal", fixIts: ["insert '/##'"]) ], fixedSource: "##/###/##" ) @@ -187,7 +187,7 @@ final class RegexLiteralTests: XCTestCase { #/\/#1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '/#' to end regex literal") + DiagnosticSpec(message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]) ], fixedSource: #"#/\/#/#"# ) @@ -199,7 +199,7 @@ final class RegexLiteralTests: XCTestCase { ##/abc/#def1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '/##' to end regex literal") + DiagnosticSpec(message: "expected '/##' to end regex literal", fixIts: ["insert '/##'"]) ], fixedSource: "##/abc/#def/##" ) @@ -211,7 +211,7 @@ final class RegexLiteralTests: XCTestCase { ##/abc/def#1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '/##' to end regex literal") + DiagnosticSpec(message: "expected '/##' to end regex literal", fixIts: ["insert '/##'"]) ], fixedSource: "##/abc/def#/##" ) @@ -314,8 +314,8 @@ final class RegexLiteralTests: XCTestCase { /#2️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '/#' to end regex literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]), ] ) } @@ -327,8 +327,8 @@ final class RegexLiteralTests: XCTestCase { \t \t /#2️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '/#' to end regex literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]), ] ) } @@ -391,7 +391,7 @@ final class RegexLiteralTests: XCTestCase { /a /1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -402,7 +402,7 @@ final class RegexLiteralTests: XCTestCase { let x = /a /1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -685,7 +685,7 @@ final class RegexLiteralTests: XCTestCase { x.1️⃣ /^ x/ """, diagnostics: [ - DiagnosticSpec(message: "expected name in member access") + DiagnosticSpec(message: "expected name in member access", fixIts: ["insert name"]) ] ) } @@ -697,7 +697,7 @@ final class RegexLiteralTests: XCTestCase { # 1️⃣/^ x/ """, diagnostics: [ - DiagnosticSpec(message: "expected identifier in macro expansion") + DiagnosticSpec(message: "expected identifier in macro expansion", fixIts: ["insert identifier"]) ] ) } @@ -717,7 +717,7 @@ final class RegexLiteralTests: XCTestCase { \ 1️⃣/^ x/ """#, diagnostics: [ - DiagnosticSpec(message: "expected root in key path") + DiagnosticSpec(message: "expected root in key path", fixIts: ["insert root"]) ] ) } @@ -825,7 +825,7 @@ final class RegexLiteralTests: XCTestCase { await 1️⃣/^ x/ """, diagnostics: [ - DiagnosticSpec(message: "expected expression in 'await' expression") + DiagnosticSpec(message: "expected expression in 'await' expression", fixIts: ["insert expression"]) ] ) } @@ -1132,7 +1132,7 @@ final class RegexLiteralTests: XCTestCase { let x =1️⃣/abc/ """, diagnostics: [ - DiagnosticSpec(message: "'=' must have consistent whitespace on both sides") + DiagnosticSpec(message: "'=' must have consistent whitespace on both sides", fixIts: ["insert whitespace"]) ] ) } @@ -1143,8 +1143,8 @@ final class RegexLiteralTests: XCTestCase { let x1️⃣ .2️⃣/abc/ """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected name in member access"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected name in member access", fixIts: ["insert name"]), ] ) } diff --git a/Tests/SwiftParserTest/StatementTests.swift b/Tests/SwiftParserTest/StatementTests.swift index 697ee554550..0ea575be207 100644 --- a/Tests/SwiftParserTest/StatementTests.swift +++ b/Tests/SwiftParserTest/StatementTests.swift @@ -78,7 +78,7 @@ final class StatementTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression, '=', and expression in pattern matching"), + DiagnosticSpec(message: "expected expression, '=', and expression in pattern matching", fixIts: ["insert expression, '=', and expression"]), DiagnosticSpec(message: "unexpected code '* ! = x' in 'if' statement"), ] ) @@ -285,7 +285,7 @@ final class StatementTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code 'foo()' before conditional compilation clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "all statements inside a switch must be covered by a 'case' or 'default' label"), + DiagnosticSpec(locationMarker: "2️⃣", message: "all statements inside a switch must be covered by a 'case' or 'default' label", fixIts: ["insert label"]), ] ) @@ -613,7 +613,7 @@ final class StatementTests: XCTestCase { _forget 1️⃣case """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression in 'forget' statement"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression in 'forget' statement", fixIts: ["insert expression"]), DiagnosticSpec(locationMarker: "1️⃣", message: "'case' can only appear inside a 'switch' statement or 'enum' declaration"), ] ) @@ -681,7 +681,7 @@ final class StatementTests: XCTestCase { if p{""1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected '}' to end 'if' statement") + DiagnosticSpec(message: "expected '}' to end 'if' statement", fixIts: ["insert '}'"]) ] ) } @@ -692,9 +692,9 @@ final class StatementTests: XCTestCase { subscript(1️⃣{2️⃣@self _modify """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ')' to end parameter clause"), - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '->' and return type in subscript"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end subscript"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '->' and return type in subscript", fixIts: ["insert '->' and return type"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end subscript", fixIts: ["insert '}'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "extraneous code '@self _modify' at top level"), ] ) diff --git a/Tests/SwiftParserTest/TypeMemberTests.swift b/Tests/SwiftParserTest/TypeMemberTests.swift index e6c464a99e7..fa3eac6a698 100644 --- a/Tests/SwiftParserTest/TypeMemberTests.swift +++ b/Tests/SwiftParserTest/TypeMemberTests.swift @@ -42,7 +42,7 @@ final class TypeMemberTests: XCTestCase { name: .identifier("", presence: .missing) ) ), - diagnostics: [DiagnosticSpec(message: "expected name in member type")] + diagnostics: [DiagnosticSpec(message: "expected name in member type", fixIts: ["insert name"])] ) } @@ -86,7 +86,7 @@ final class TypeMemberTests: XCTestCase { assertParse( source, TypeSyntax.parse, - diagnostics: [DiagnosticSpec(message: "extraneous whitespace after '.' is not permitted")], + diagnostics: [DiagnosticSpec(message: "extraneous whitespace after '.' is not permitted", fixIts: ["remove whitespace"])], fixedSource: expected, line: line ) diff --git a/Tests/SwiftParserTest/TypeTests.swift b/Tests/SwiftParserTest/TypeTests.swift index 273d0f5382b..90eaf0f0683 100644 --- a/Tests/SwiftParserTest/TypeTests.swift +++ b/Tests/SwiftParserTest/TypeTests.swift @@ -59,9 +59,9 @@ final class TypeTests: XCTestCase { assertParse( "t as(1️⃣..)->2️⃣", diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected type in function type"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected type in function type", fixIts: ["insert type"]), DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code '..' in function type"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected return type in function type"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected return type in function type", fixIts: ["insert return type"]), ] ) } @@ -94,9 +94,9 @@ final class TypeTests: XCTestCase { "{[1️⃣class]in2️⃣", { ExprSyntax.parse(from: &$0) }, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in closure capture item"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in closure capture item", fixIts: ["insert identifier"]), DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected 'class' keyword in closure capture signature"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end closure"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end closure", fixIts: ["insert '}'"]), ] ) @@ -112,7 +112,7 @@ final class TypeTests: XCTestCase { "{[weak1️⃣^]in}", { ExprSyntax.parse(from: &$0) }, diagnostics: [ - DiagnosticSpec(message: "expected identifier in closure capture item"), + DiagnosticSpec(message: "expected identifier in closure capture item", fixIts: ["insert identifier"]), DiagnosticSpec(message: "unexpected code '^' in closure capture signature"), ] ) diff --git a/Tests/SwiftParserTest/VariadicGenericsTests.swift b/Tests/SwiftParserTest/VariadicGenericsTests.swift index a540b2a09ba..0ad82e72509 100644 --- a/Tests/SwiftParserTest/VariadicGenericsTests.swift +++ b/Tests/SwiftParserTest/VariadicGenericsTests.swift @@ -60,7 +60,7 @@ final class VariadicGenericsTests: XCTestCase { func invalid() -> (each any 1️⃣T) {} """, diagnostics: [ - DiagnosticSpec(message: "expected ',' in tuple type") + DiagnosticSpec(message: "expected ',' in tuple type", fixIts: ["insert ','"]) ] ) @@ -561,8 +561,11 @@ final class TypeParameterPackTests: XCTestCase { var foo: (bar: Int 1️⃣bar2: Int) """, diagnostics: [ - DiagnosticSpec(message: "expected ',' in tuple type") - ] + DiagnosticSpec(message: "expected ',' in tuple type", fixIts: ["insert ','"]) + ], + fixedSource: """ + var foo: (bar: Int, bar2: Int) + """ ) assertParse( @@ -570,7 +573,7 @@ final class TypeParameterPackTests: XCTestCase { var foo: (bar: Int 1️⃣Int) """, diagnostics: [ - DiagnosticSpec(message: "expected ',' in tuple type") + DiagnosticSpec(message: "expected ',' in tuple type", fixIts: ["insert ','"]) ] ) @@ -579,8 +582,11 @@ final class TypeParameterPackTests: XCTestCase { var foo: (a 1️⃣Int) """, diagnostics: [ - DiagnosticSpec(message: "expected ':' in tuple type") - ] + DiagnosticSpec(message: "expected ':' in tuple type", fixIts: ["insert ':'"]) + ], + fixedSource: """ + var foo: (a: Int) + """ ) assertParse( @@ -588,7 +594,7 @@ final class TypeParameterPackTests: XCTestCase { var foo: (A 1️⃣Int) """, diagnostics: [ - DiagnosticSpec(message: "expected ',' in tuple type") + DiagnosticSpec(message: "expected ',' in tuple type", fixIts: ["insert ','"]) ] ) @@ -597,8 +603,8 @@ final class TypeParameterPackTests: XCTestCase { var foo: (_ 1️⃣a 2️⃣Int) """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ':' in tuple type"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ',' in tuple type"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ':' in tuple type", fixIts: ["insert ':'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ',' in tuple type", fixIts: ["insert ','"]), ] ) @@ -607,8 +613,11 @@ final class TypeParameterPackTests: XCTestCase { var foo: (Array 1️⃣Array) """, diagnostics: [ - DiagnosticSpec(message: "expected ',' in tuple type") - ] + DiagnosticSpec(message: "expected ',' in tuple type", fixIts: ["insert ','"]) + ], + fixedSource: """ + var foo: (Array , Array) + """ ) assertParse( @@ -616,8 +625,11 @@ final class TypeParameterPackTests: XCTestCase { var foo: (a 1️⃣Array) """, diagnostics: [ - DiagnosticSpec(message: "expected ':' in tuple type") - ] + DiagnosticSpec(message: "expected ':' in tuple type", fixIts: ["insert ':'"]) + ], + fixedSource: """ + var foo: (a: Array) + """ ) assertParse( @@ -625,8 +637,11 @@ final class TypeParameterPackTests: XCTestCase { var foo: (Array 1️⃣a) """, diagnostics: [ - DiagnosticSpec(message: "expected ',' in tuple type") - ] + DiagnosticSpec(message: "expected ',' in tuple type", fixIts: ["insert ','"]) + ], + fixedSource: """ + var foo: (Array , a) + """ ) } } diff --git a/Tests/SwiftParserTest/translated/ActorTests.swift b/Tests/SwiftParserTest/translated/ActorTests.swift index b68937a6aa0..d087221ed7f 100644 --- a/Tests/SwiftParserTest/translated/ActorTests.swift +++ b/Tests/SwiftParserTest/translated/ActorTests.swift @@ -21,7 +21,7 @@ final class ActorTests: XCTestCase { actor MyActor11️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected member block in actor") + DiagnosticSpec(message: "expected member block in actor", fixIts: ["insert member block"]) ] ) } @@ -39,7 +39,8 @@ final class ActorTests: XCTestCase { message: "expected '}' to end actor", notes: [ NoteSpec(message: "to match this opening '{'") - ] + ], + fixIts: ["insert '}'"] ) ] ) diff --git a/Tests/SwiftParserTest/translated/AsyncTests.swift b/Tests/SwiftParserTest/translated/AsyncTests.swift index b71b9cf6ac7..21b2e14e383 100644 --- a/Tests/SwiftParserTest/translated/AsyncTests.swift +++ b/Tests/SwiftParserTest/translated/AsyncTests.swift @@ -59,7 +59,7 @@ final class AsyncTests: XCTestCase { assertParse( "func asyncGlobal5() -> Int 1️⃣async throws { }", diagnostics: [ - DiagnosticSpec(message: "'async throws' must preceed '->'") + DiagnosticSpec(message: "'async throws' must preceed '->'", fixIts: ["move 'async throws' in front of '->'"]) ], fixedSource: "func asyncGlobal5() async throws -> Int { }" ) @@ -79,7 +79,7 @@ final class AsyncTests: XCTestCase { assertParse( "func asyncGlobal7() throws -> Int 1️⃣async { }", diagnostics: [ - DiagnosticSpec(message: "'async' must preceed '->'") + DiagnosticSpec(message: "'async' must preceed '->'", fixIts: ["move 'async' in front of '->'"]) ], fixedSource: "func asyncGlobal7() async throws -> Int { }" ) @@ -118,7 +118,7 @@ final class AsyncTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "deinitializers cannot have a name"), + DiagnosticSpec(locationMarker: "1️⃣", message: "deinitializers cannot have a name", fixIts: ["remove 'async'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code 'async' in subscript"), ] ) @@ -144,7 +144,7 @@ final class AsyncTests: XCTestCase { assertParse( "typealias AsyncFunc3 = () throws 1️⃣async -> ()", diagnostics: [ - DiagnosticSpec(message: "'async' must precede 'throws'") + DiagnosticSpec(message: "'async' must precede 'throws'", fixIts: ["move 'async' in front of 'throws'"]) ], fixedSource: "typealias AsyncFunc3 = () async throws -> ()" ) @@ -170,7 +170,7 @@ final class AsyncTests: XCTestCase { assertParse( "let _ = [() throws 1️⃣async -> ()]()", diagnostics: [ - DiagnosticSpec(message: "'async' must precede 'throws'") + DiagnosticSpec(message: "'async' must precede 'throws'", fixIts: ["move 'async' in front of 'throws'"]) ], fixedSource: "let _ = [() async throws -> ()]()" ) @@ -182,8 +182,11 @@ final class AsyncTests: XCTestCase { let _ = [() -> 1️⃣async ()]() """, diagnostics: [ - DiagnosticSpec(message: "'async' must preceed '->'") - ] + DiagnosticSpec(message: "'async' must preceed '->'", fixIts: ["move 'async' in front of '->'"]) + ], + fixedSource: """ + let _ = [() async -> ()]() + """ ) } diff --git a/Tests/SwiftParserTest/translated/AvailabilityQueryTests.swift b/Tests/SwiftParserTest/translated/AvailabilityQueryTests.swift index f5e84512990..207886d40aa 100644 --- a/Tests/SwiftParserTest/translated/AvailabilityQueryTests.swift +++ b/Tests/SwiftParserTest/translated/AvailabilityQueryTests.swift @@ -109,7 +109,11 @@ final class AvailabilityQueryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(', '@availability' arguments, and ')' in availability condition") + DiagnosticSpec( + locationMarker: "1️⃣", + message: "expected '(', '@availability' arguments, and ')' in availability condition", + fixIts: ["insert '(', '@availability' arguments, and ')'"] + ) ] ) } @@ -121,8 +125,8 @@ final class AvailabilityQueryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected version restriction in availability argument"), - DiagnosticSpec(message: "expected ')' to end availability condition"), + DiagnosticSpec(message: "expected version restriction in availability argument", fixIts: ["insert version restriction"]), + DiagnosticSpec(message: "expected ')' to end availability condition", fixIts: ["insert ')'"]), ] ) } @@ -134,7 +138,7 @@ final class AvailabilityQueryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected version restriction in availability argument") + DiagnosticSpec(message: "expected version restriction in availability argument", fixIts: ["insert version restriction"]) ] ) } @@ -150,7 +154,8 @@ final class AvailabilityQueryTests: XCTestCase { message: "expected ')' to end availability condition", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) ] ) @@ -176,7 +181,8 @@ final class AvailabilityQueryTests: XCTestCase { message: "expected ')' to end availability condition", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) ] ) @@ -300,7 +306,8 @@ final class AvailabilityQueryTests: XCTestCase { message: "expected ')' to end availability condition", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) ] ) @@ -323,8 +330,8 @@ final class AvailabilityQueryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected version restriction in availability argument"), - DiagnosticSpec(message: "expected ')' to end availability condition"), + DiagnosticSpec(message: "expected version restriction in availability argument", fixIts: ["insert version restriction"]), + DiagnosticSpec(message: "expected ')' to end availability condition", fixIts: ["insert ')'"]), ] ) } @@ -336,7 +343,7 @@ final class AvailabilityQueryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected version restriction in availability argument") + DiagnosticSpec(message: "expected version restriction in availability argument", fixIts: ["insert version restriction"]) ] ) } @@ -352,7 +359,8 @@ final class AvailabilityQueryTests: XCTestCase { message: "expected ')' to end availability condition", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) ] ) diff --git a/Tests/SwiftParserTest/translated/AvailabilityQueryUnavailabilityTests.swift b/Tests/SwiftParserTest/translated/AvailabilityQueryUnavailabilityTests.swift index 62c27d4d9a5..66ce7dd2d03 100644 --- a/Tests/SwiftParserTest/translated/AvailabilityQueryUnavailabilityTests.swift +++ b/Tests/SwiftParserTest/translated/AvailabilityQueryUnavailabilityTests.swift @@ -90,8 +90,12 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '(', '@availability' arguments, and ')' in availability condition") - ] + DiagnosticSpec(message: "expected '(', '@availability' arguments, and ')' in availability condition", fixIts: ["insert '(', '@availability' arguments, and ')'"]) + ], + fixedSource: """ + if #unavailable( <#identifier#>){ + } + """ ) } @@ -102,9 +106,13 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected version restriction in availability argument"), - DiagnosticSpec(message: "expected ')' to end availability condition"), - ] + DiagnosticSpec(message: "expected version restriction in availability argument", fixIts: ["insert version restriction"]), + DiagnosticSpec(message: "expected ')' to end availability condition", fixIts: ["insert ')'"]), + ], + fixedSource: """ + if #unavailable(<#identifier#> ){ + } + """ ) } @@ -115,8 +123,12 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected version restriction in availability argument") - ] + DiagnosticSpec(message: "expected version restriction in availability argument", fixIts: ["insert version restriction"]) + ], + fixedSource: """ + if #unavailable(<#identifier#>) { + } + """ ) } @@ -131,7 +143,8 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { message: "expected ')' to end availability condition", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) ] ) @@ -157,9 +170,14 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { message: "expected ')' to end availability condition", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) - ] + ], + fixedSource: """ + if #unavailable(OSX 10.51) { + } + """ ) } @@ -253,8 +271,13 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected version restriction in availability argument") - ] + DiagnosticSpec(message: "expected version restriction in availability argument", fixIts: ["insert version restriction"]) + ], + fixedSource: """ + // Should this be a valid spelling since `#unvailable(*)` cannot be written? + if #unavailable(<#identifier#>) { + } + """ ) } @@ -269,9 +292,14 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { message: "expected ')' to end availability condition", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) - ] + ], + fixedSource: """ + if #unavailable(OSX 10) { + } + """ ) } @@ -292,9 +320,13 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected version restriction in availability argument"), - DiagnosticSpec(message: "expected ')' to end availability condition"), - ] + DiagnosticSpec(message: "expected version restriction in availability argument", fixIts: ["insert version restriction"]), + DiagnosticSpec(message: "expected ')' to end availability condition", fixIts: ["insert ')'"]), + ], + fixedSource: """ + if #unavailable(OSX 10.51,<#identifier#> ){ + } + """ ) } @@ -305,8 +337,12 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected version restriction in availability argument") - ] + DiagnosticSpec(message: "expected version restriction in availability argument", fixIts: ["insert version restriction"]) + ], + fixedSource: """ + if #unavailable(OSX 10.51,<#identifier#>) { + } + """ ) } @@ -321,9 +357,14 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { message: "expected ')' to end availability condition", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) - ] + ], + fixedSource: """ + if #unavailable(OSX 10.51, iOS) { + } + """ ) } @@ -352,8 +393,12 @@ final class AvailabilityQueryUnavailabilityTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected ',' joining platforms in availability condition") - ] + DiagnosticSpec(message: "expected ',' joining platforms in availability condition", fixIts: ["replace '||' with ','"]) + ], + fixedSource: """ + if #unavailable(OSX 10.51 , iOS 8.0) { + } + """ ) } diff --git a/Tests/SwiftParserTest/translated/BraceRecoveryEofTests.swift b/Tests/SwiftParserTest/translated/BraceRecoveryEofTests.swift index 2726156e900..6dd408cf043 100644 --- a/Tests/SwiftParserTest/translated/BraceRecoveryEofTests.swift +++ b/Tests/SwiftParserTest/translated/BraceRecoveryEofTests.swift @@ -27,10 +27,10 @@ final class BraceRecoveryEofTests: XCTestCase { message: "expected '}' to end 'for' statement", notes: [ NoteSpec(message: "to match this opening '{'") - ] + ], + fixIts: ["insert '}'"] ) ] ) } - } diff --git a/Tests/SwiftParserTest/translated/ConsecutiveStatementsTests.swift b/Tests/SwiftParserTest/translated/ConsecutiveStatementsTests.swift index ca91b226255..47e3cee123c 100644 --- a/Tests/SwiftParserTest/translated/ConsecutiveStatementsTests.swift +++ b/Tests/SwiftParserTest/translated/ConsecutiveStatementsTests.swift @@ -61,9 +61,9 @@ final class ConsecutiveStatementsTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), ] ) } @@ -89,11 +89,11 @@ final class ConsecutiveStatementsTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive declarations on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive declarations on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "4️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "5️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive declarations on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive declarations on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "4️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "5️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), ] ) } @@ -172,8 +172,8 @@ final class ConsecutiveStatementsTests: XCTestCase { var i, j : Int1️⃣ i = j2️⃣ j = i """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), ] ) } diff --git a/Tests/SwiftParserTest/translated/DeprecatedWhereTests.swift b/Tests/SwiftParserTest/translated/DeprecatedWhereTests.swift index 2ddf8b03c22..aadceeb012f 100644 --- a/Tests/SwiftParserTest/translated/DeprecatedWhereTests.swift +++ b/Tests/SwiftParserTest/translated/DeprecatedWhereTests.swift @@ -161,10 +161,10 @@ final class DeprecatedWhereTests: XCTestCase { func testCombinedConstraintsOld where T: ProtoC4️⃣>(x: T) {} """, diagnostics: [ - DiagnosticSpec(locationMarker: "2️⃣", message: "expected inherited type in generic parameter"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '>' to end generic parameter clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected identifier in protocol"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected inherited type in generic parameter", fixIts: ["insert inherited type"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected identifier in protocol", fixIts: ["insert identifier"]), DiagnosticSpec(locationMarker: "4️⃣", message: "unexpected code '>(x: T)' in protocol"), ] ) @@ -176,10 +176,10 @@ final class DeprecatedWhereTests: XCTestCase { func testCombinedConstraintsOld where T: ProtoC4️⃣>(x: T) where T: ProtoD {} """, diagnostics: [ - DiagnosticSpec(locationMarker: "2️⃣", message: "expected inherited type in generic parameter"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '>' to end generic parameter clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected identifier in protocol"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected inherited type in generic parameter", fixIts: ["insert inherited type"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected identifier in protocol", fixIts: ["insert identifier"]), DiagnosticSpec(locationMarker: "4️⃣", message: "unexpected code '>(x: T) where T: ProtoD' in protocol"), ] ) diff --git a/Tests/SwiftParserTest/translated/DiagnoseDynamicReplacementTests.swift b/Tests/SwiftParserTest/translated/DiagnoseDynamicReplacementTests.swift index acba50d0941..141c72855b2 100644 --- a/Tests/SwiftParserTest/translated/DiagnoseDynamicReplacementTests.swift +++ b/Tests/SwiftParserTest/translated/DiagnoseDynamicReplacementTests.swift @@ -32,7 +32,7 @@ final class DiagnoseDynamicReplacementTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '(', @_dynamicReplacement argument, and ')' in attribute") + DiagnosticSpec(message: "expected '(', @_dynamicReplacement argument, and ')' in attribute", fixIts: ["insert '(', @_dynamicReplacement argument, and ')'"]) ] ) } @@ -45,8 +45,8 @@ final class DiagnoseDynamicReplacementTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected argument for '@_dynamicReplacement' attribute"), - DiagnosticSpec(message: "expected ')' to end attribute"), + DiagnosticSpec(message: "expected argument for '@_dynamicReplacement' attribute", fixIts: ["insert attribute argument"]), + DiagnosticSpec(message: "expected ')' to end attribute", fixIts: ["insert ')'"]), ] ) } @@ -63,10 +63,15 @@ final class DiagnoseDynamicReplacementTests: XCTestCase { message: "expected ')' to end attribute", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) - ] + ], + fixedSource: """ + @_dynamicReplacement(for: dynamically_replaceable() ) + func test_dynamic_replacement_for3() { + } + """ ) } - } diff --git a/Tests/SwiftParserTest/translated/DiagnoseInitializerAsTypedPatternTests.swift b/Tests/SwiftParserTest/translated/DiagnoseInitializerAsTypedPatternTests.swift index 2f0afb23aec..712ef3a5e27 100644 --- a/Tests/SwiftParserTest/translated/DiagnoseInitializerAsTypedPatternTests.swift +++ b/Tests/SwiftParserTest/translated/DiagnoseInitializerAsTypedPatternTests.swift @@ -70,7 +70,7 @@ final class DiagnoseInitializerAsTypedPatternTests: XCTestCase { let e1️⃣: X(), ee: Int """, diagnostics: [ - DiagnosticSpec(message: "unexpected initializer in pattern; did you mean to use '='?") + DiagnosticSpec(message: "unexpected initializer in pattern; did you mean to use '='?", fixIts: ["replace ':' with '='"]) ], fixedSource: "let e= X(), ee: Int" ) diff --git a/Tests/SwiftParserTest/translated/DiagnosticMissingFuncKeywordTests.swift b/Tests/SwiftParserTest/translated/DiagnosticMissingFuncKeywordTests.swift index 0289b5614da..e8a55685bfc 100644 --- a/Tests/SwiftParserTest/translated/DiagnosticMissingFuncKeywordTests.swift +++ b/Tests/SwiftParserTest/translated/DiagnosticMissingFuncKeywordTests.swift @@ -43,7 +43,7 @@ final class DiagnosticMissingFuncKeywordTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected 'var' in variable") + DiagnosticSpec(message: "expected 'var' in variable", fixIts: ["insert 'var'"]) ], fixedSource: """ protocol Brew { @@ -100,8 +100,8 @@ final class DiagnosticMissingFuncKeywordTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'var' in variable"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected 'var' in variable"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'var' in variable", fixIts: ["insert 'var'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected 'var' in variable", fixIts: ["insert 'var'"]), ], fixedSource: """ protocol Brew { @@ -120,8 +120,8 @@ final class DiagnosticMissingFuncKeywordTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'var' in variable"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected 'var' in variable"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'var' in variable", fixIts: ["insert 'var'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected 'var' in variable", fixIts: ["insert 'var'"]), ], fixedSource: """ protocol Brew { @@ -147,7 +147,7 @@ final class DiagnosticMissingFuncKeywordTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected 'var' in variable") + DiagnosticSpec(message: "expected 'var' in variable", fixIts: ["insert 'var'"]) ] ) } @@ -175,7 +175,7 @@ final class DiagnosticMissingFuncKeywordTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected 'var' in variable") + DiagnosticSpec(message: "expected 'var' in variable", fixIts: ["insert 'var'"]) ] ) } @@ -188,7 +188,7 @@ final class DiagnosticMissingFuncKeywordTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected 'var' in variable") + DiagnosticSpec(message: "expected 'var' in variable", fixIts: ["insert 'var'"]) ] ) } @@ -219,7 +219,7 @@ final class DiagnosticMissingFuncKeywordTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected 'func' in function") + DiagnosticSpec(message: "expected 'func' in function", fixIts: ["insert 'func'"]) ] ) } @@ -232,7 +232,7 @@ final class DiagnosticMissingFuncKeywordTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected 'func' in function") + DiagnosticSpec(message: "expected 'func' in function", fixIts: ["insert 'func'"]) ] ) } @@ -245,7 +245,7 @@ final class DiagnosticMissingFuncKeywordTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected 'var' in variable") + DiagnosticSpec(message: "expected 'var' in variable", fixIts: ["insert 'var'"]) ] ) } @@ -258,7 +258,7 @@ final class DiagnosticMissingFuncKeywordTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected 'var' in variable") + DiagnosticSpec(message: "expected 'var' in variable", fixIts: ["insert 'var'"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/DollarIdentifierTests.swift b/Tests/SwiftParserTest/translated/DollarIdentifierTests.swift index 5ad240df9d3..8f5371b7c52 100644 --- a/Tests/SwiftParserTest/translated/DollarIdentifierTests.swift +++ b/Tests/SwiftParserTest/translated/DollarIdentifierTests.swift @@ -35,7 +35,7 @@ final class DollarIdentifierTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "'$' is not a valid identifier") + DiagnosticSpec(message: "'$' is not a valid identifier", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -80,7 +80,7 @@ final class DollarIdentifierTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "'$' is not a valid identifier") + DiagnosticSpec(message: "'$' is not a valid identifier", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -93,7 +93,7 @@ final class DollarIdentifierTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "'$' is not a valid identifier") + DiagnosticSpec(message: "'$' is not a valid identifier", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -104,8 +104,8 @@ final class DollarIdentifierTests: XCTestCase { func 1️⃣$(2️⃣$ dollarParam: Int) {} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "'$' is not a valid identifier"), - DiagnosticSpec(locationMarker: "2️⃣", message: "'$' is not a valid identifier"), + DiagnosticSpec(locationMarker: "1️⃣", message: "'$' is not a valid identifier", fixIts: ["if this name is unavoidable, use backticks to escape it"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "'$' is not a valid identifier", fixIts: ["if this name is unavoidable, use backticks to escape it"]), ], fixedSource: "func `$`(`$` dollarParam: Int) {}" ) @@ -117,7 +117,7 @@ final class DollarIdentifierTests: XCTestCase { $(1️⃣$: 24) """, diagnostics: [ - DiagnosticSpec(message: "'$' is not a valid identifier") + DiagnosticSpec(message: "'$' is not a valid identifier", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/EffectfulPropertiesTests.swift b/Tests/SwiftParserTest/translated/EffectfulPropertiesTests.swift index f7ead214162..7041c8b5d5b 100644 --- a/Tests/SwiftParserTest/translated/EffectfulPropertiesTests.swift +++ b/Tests/SwiftParserTest/translated/EffectfulPropertiesTests.swift @@ -179,8 +179,15 @@ final class EffectfulPropertiesTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected throwing specifier; did you mean 'throws'?"), + DiagnosticSpec( + message: "expected throwing specifier; did you mean 'throws'?", + fixIts: ["replace 'rethrows' with 'throws'"] + ), + DiagnosticSpec( + locationMarker: "2️⃣", + message: "expected throwing specifier; did you mean 'throws'?", + fixIts: ["replace 'rethrows' with 'throws'"] + ), ] ) } @@ -194,8 +201,16 @@ final class EffectfulPropertiesTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected async specifier; did you mean 'async'?"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected async specifier; did you mean 'async'?"), + DiagnosticSpec( + locationMarker: "1️⃣", + message: "expected async specifier; did you mean 'async'?", + fixIts: ["replace 'reasync' with 'async'"] + ), + DiagnosticSpec( + locationMarker: "2️⃣", + message: "expected async specifier; did you mean 'async'?", + fixIts: ["replace 'reasync' with 'async'"] + ), ] ) } @@ -219,8 +234,17 @@ final class EffectfulPropertiesTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected async specifier; did you mean 'async'?", fixIts: ["replace 'reasync' with 'async'"]), - DiagnosticSpec(locationMarker: "2️⃣", message: "'rethrows' conflicts with 'throws'", notes: [NoteSpec(locationMarker: "3️⃣", message: "'throws' declared here")], fixIts: ["remove redundant 'rethrows'"]), + DiagnosticSpec( + locationMarker: "1️⃣", + message: "expected async specifier; did you mean 'async'?", + fixIts: ["replace 'reasync' with 'async'"] + ), + DiagnosticSpec( + locationMarker: "2️⃣", + message: "'rethrows' conflicts with 'throws'", + notes: [NoteSpec(locationMarker: "3️⃣", message: "'throws' declared here")], + fixIts: ["remove redundant 'rethrows'"] + ), ] ) } @@ -259,7 +283,11 @@ final class EffectfulPropertiesTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected throwing specifier; did you mean 'throws'?"), + DiagnosticSpec( + locationMarker: "1️⃣", + message: "expected throwing specifier; did you mean 'throws'?", + fixIts: ["replace 'rethrows' with 'throws'"] + ), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code '-> Int' in accessor"), ] ) @@ -273,7 +301,7 @@ final class EffectfulPropertiesTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "'async' must precede 'throws'") + DiagnosticSpec(message: "'async' must precede 'throws'", fixIts: ["move 'async' in front of 'throws'"]) ] ) } @@ -287,7 +315,7 @@ final class EffectfulPropertiesTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "'async' must precede 'throws'") + DiagnosticSpec(message: "'async' must precede 'throws'", fixIts: ["move 'async' in front of 'throws'"]) ] ) } @@ -304,13 +332,24 @@ final class EffectfulPropertiesTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code 'bogus rethrows set' in variable"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected throwing specifier; did you mean 'throws'?"), + DiagnosticSpec( + locationMarker: "2️⃣", + message: "expected throwing specifier; did you mean 'throws'?", + fixIts: ["replace 'rethrows' with 'throws'"] + ), DiagnosticSpec(locationMarker: "3️⃣", message: "unexpected code 'bogus set' in variable"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected async specifier; did you mean 'async'?"), + DiagnosticSpec( + locationMarker: "4️⃣", + message: "expected async specifier; did you mean 'async'?", + fixIts: ["replace 'reasync' with 'async'"] + ), DiagnosticSpec(locationMarker: "5️⃣", message: "unexpected code 'bogus set' in variable"), - DiagnosticSpec(locationMarker: "6️⃣", message: "'async' must precede 'throws'"), + DiagnosticSpec( + locationMarker: "6️⃣", + message: "'async' must precede 'throws'", + fixIts: ["move 'async' in front of 'throws'"] + ), ] ) } - } diff --git a/Tests/SwiftParserTest/translated/EnumTests.swift b/Tests/SwiftParserTest/translated/EnumTests.swift index 365bcff77df..2bdf1d1b9e4 100644 --- a/Tests/SwiftParserTest/translated/EnumTests.swift +++ b/Tests/SwiftParserTest/translated/EnumTests.swift @@ -287,8 +287,8 @@ final class EnumTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in enum case"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ':' and type in parameter"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in enum case", fixIts: ["insert identifier"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ':' and type in parameter", fixIts: ["insert ':' and type"]), DiagnosticSpec(locationMarker: "3️⃣", message: "unexpected code '0' in parameter clause"), DiagnosticSpec(locationMarker: "4️⃣", message: "unexpected code ':' in enum"), ], @@ -343,7 +343,7 @@ final class EnumTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected identifier in enum case") + DiagnosticSpec(message: "expected identifier in enum case", fixIts: ["insert identifier"]) ] ) } @@ -356,7 +356,7 @@ final class EnumTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected identifier in enum case"), + DiagnosticSpec(message: "expected identifier in enum case", fixIts: ["insert identifier"]), DiagnosticSpec(message: "unexpected code ':' in enum"), ] ) @@ -396,7 +396,7 @@ final class EnumTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'Self' cannot be used as an identifier here"), + DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'Self' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected 'Self' keyword in enum"), ] ) @@ -430,7 +430,7 @@ final class EnumTests: XCTestCase { diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "'_' cannot be used as an identifier here"), DiagnosticSpec(locationMarker: "2️⃣", message: "'_' cannot be used as an identifier here"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected identifier in enum case"), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected identifier in enum case", fixIts: ["insert identifier"]), ] ) } @@ -1207,7 +1207,7 @@ final class EnumTests: XCTestCase { enum 1️⃣switch {} """, diagnostics: [ - DiagnosticSpec(message: "keyword 'switch' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'switch' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -1240,7 +1240,7 @@ final class EnumTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "keyword 'operator' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'operator' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -1255,7 +1255,7 @@ final class EnumTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "keyword 'var' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'var' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -1283,7 +1283,7 @@ final class EnumTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "keyword 'func' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'func' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -1299,7 +1299,7 @@ final class EnumTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected identifier in enum case") + DiagnosticSpec(message: "expected identifier in enum case", fixIts: ["insert identifier"]) ] ) } @@ -1313,7 +1313,7 @@ final class EnumTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected identifier in enum case") + DiagnosticSpec(message: "expected identifier in enum case", fixIts: ["insert identifier"]) ] ) } @@ -1326,7 +1326,7 @@ final class EnumTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'let' cannot be used as an identifier here"), + DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'let' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code '.foo(x, y):' in enum"), ] ) @@ -1341,8 +1341,8 @@ final class EnumTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in enum case"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in enum case"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in enum case", fixIts: ["insert identifier"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in enum case", fixIts: ["insert identifier"]), ] ) } diff --git a/Tests/SwiftParserTest/translated/ErrorsTests.swift b/Tests/SwiftParserTest/translated/ErrorsTests.swift index 40a8c35ca14..1b3bde275c1 100644 --- a/Tests/SwiftParserTest/translated/ErrorsTests.swift +++ b/Tests/SwiftParserTest/translated/ErrorsTests.swift @@ -86,7 +86,7 @@ final class ErrorsTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression after ternary operator") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression after ternary operator", fixIts: ["insert expression"]) ] ) } @@ -154,7 +154,7 @@ final class ErrorsTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "'throws' must preceed '->'") + DiagnosticSpec(message: "'throws' must preceed '->'", fixIts: ["move 'throws' in front of '->'"]) ], fixedSource: """ func postThrows() throws -> Int { @@ -172,7 +172,7 @@ final class ErrorsTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "'throws' must preceed '->'") + DiagnosticSpec(message: "'throws' must preceed '->'", fixIts: ["move 'throws' in front of '->'"]) ] ) } @@ -185,7 +185,7 @@ final class ErrorsTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "'rethrows' must preceed '->'") + DiagnosticSpec(message: "'rethrows' must preceed '->'", fixIts: ["move 'rethrows' in front of '->'"]) ], fixedSource: """ func postRethrows(_ f: () throws -> Int) rethrows -> Int { @@ -203,7 +203,7 @@ final class ErrorsTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "'rethrows' must preceed '->'") + DiagnosticSpec(message: "'rethrows' must preceed '->'", fixIts: ["move 'rethrows' in front of '->'"]) ] ) } @@ -216,7 +216,7 @@ final class ErrorsTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "'throws' must preceed '->'") + DiagnosticSpec(message: "'throws' must preceed '->'", fixIts: ["move 'throws' in front of '->'"]) ] ) } @@ -227,7 +227,7 @@ final class ErrorsTests: XCTestCase { func dupThrows1() throws 1️⃣rethrows -> 2️⃣throws Int 3️⃣throw {} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "'rethrows' conflicts with 'throws'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "'rethrows' conflicts with 'throws'", fixIts: ["remove redundant 'rethrows'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "'throws' must preceed '->'", fixIts: ["remove redundant 'throws'"]), DiagnosticSpec(locationMarker: "3️⃣", message: "'throw' must preceed '->'", fixIts: ["remove redundant 'throw'"]), ], @@ -335,7 +335,7 @@ final class ErrorsTests: XCTestCase { func fixitThrow1() 1️⃣throw -> Int {} """, diagnostics: [ - DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?") + DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?", fixIts: ["replace 'throw' with 'throws'"]) ], fixedSource: """ func fixitThrow1() throws -> Int {} @@ -353,7 +353,7 @@ final class ErrorsTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?") + DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?", fixIts: ["replace 'throw' with 'throws'"]) ], fixedSource: """ func fixitThrow2() throws { @@ -371,7 +371,7 @@ final class ErrorsTests: XCTestCase { let fn: () -> 1️⃣throws Void """, diagnostics: [ - DiagnosticSpec(message: "'throws' must preceed '->'") + DiagnosticSpec(message: "'throws' must preceed '->'", fixIts: ["move 'throws' in front of '->'"]) ], fixedSource: """ let fn: () throws -> Void @@ -393,7 +393,7 @@ final class ErrorsTests: XCTestCase { func fixitTry0(a: T) 1️⃣try where T:ExpressibleByStringLiteral {} """, diagnostics: [ - DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?") + DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?", fixIts: ["replace 'try' with 'throws'"]) ] ) } @@ -404,7 +404,7 @@ final class ErrorsTests: XCTestCase { func fixitTry1(a: T) 1️⃣try {} """, diagnostics: [ - DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?") + DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?", fixIts: ["replace 'try' with 'throws'"]) ], fixedSource: """ func fixitTry1(a: T) throws {} @@ -418,7 +418,7 @@ final class ErrorsTests: XCTestCase { func fixitTry2() 1️⃣try {} """, diagnostics: [ - DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?") + DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?", fixIts: ["replace 'try' with 'throws'"]) ] ) } @@ -429,7 +429,7 @@ final class ErrorsTests: XCTestCase { let fixitTry3 : () 1️⃣try -> Int """, diagnostics: [ - DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?") + DiagnosticSpec(message: "expected throwing specifier; did you mean 'throws'?", fixIts: ["replace 'try' with 'throws'"]) ] ) } @@ -454,7 +454,7 @@ final class ErrorsTests: XCTestCase { func fixitAwait1() 1️⃣await -> Int { } """, diagnostics: [ - DiagnosticSpec(message: "expected async specifier; did you mean 'async'?") + DiagnosticSpec(message: "expected async specifier; did you mean 'async'?", fixIts: ["replace 'await' with 'async'"]) ], fixedSource: """ func fixitAwait1() async -> Int { } @@ -482,7 +482,7 @@ final class ErrorsTests: XCTestCase { func fixitAwait2() async 1️⃣await throws -> Int { } """, diagnostics: [ - DiagnosticSpec(message: "'await' conflicts with 'async'") + DiagnosticSpec(message: "'await' conflicts with 'async'", fixIts: ["remove redundant 'await'"]) ], fixedSource: """ func fixitAwait2() async throws -> Int { } @@ -496,7 +496,7 @@ final class ErrorsTests: XCTestCase { func fixitAwait2() async 1️⃣await -> Int { } """, diagnostics: [ - DiagnosticSpec(message: "'await' conflicts with 'async'") + DiagnosticSpec(message: "'await' conflicts with 'async'", fixIts: ["remove redundant 'await'"]) ], fixedSource: """ func fixitAwait2() async -> Int { } diff --git a/Tests/SwiftParserTest/translated/ForeachAsyncTests.swift b/Tests/SwiftParserTest/translated/ForeachAsyncTests.swift index cc618cf5476..518de0e6a18 100644 --- a/Tests/SwiftParserTest/translated/ForeachAsyncTests.swift +++ b/Tests/SwiftParserTest/translated/ForeachAsyncTests.swift @@ -79,9 +79,9 @@ final class ForeachAsyncTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'in' in 'for' statement"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '{' in 'for' statement"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected '}' to end 'for' statement"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'in' in 'for' statement", fixIts: ["insert 'in'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '{' in 'for' statement", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected '}' to end 'for' statement", fixIts: ["insert '}'"]), ] ) } diff --git a/Tests/SwiftParserTest/translated/ForeachTests.swift b/Tests/SwiftParserTest/translated/ForeachTests.swift index a49e627f74a..60171bbce90 100644 --- a/Tests/SwiftParserTest/translated/ForeachTests.swift +++ b/Tests/SwiftParserTest/translated/ForeachTests.swift @@ -56,9 +56,9 @@ final class ForeachTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'in' in 'for' statement"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '{' in 'for' statement"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected '}' to end 'for' statement"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'in' in 'for' statement", fixIts: ["insert 'in'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '{' in 'for' statement", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected '}' to end 'for' statement", fixIts: ["insert '}'"]), ] ) } diff --git a/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingAllowedTests.swift b/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingAllowedTests.swift index 550e60e3a3f..5666ee81cc2 100644 --- a/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingAllowedTests.swift +++ b/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingAllowedTests.swift @@ -22,7 +22,7 @@ final class ForwardSlashRegexSkippingAllowedTests: XCTestCase { var 1️⃣: Int """, diagnostics: [ - DiagnosticSpec(message: "expected pattern in variable") + DiagnosticSpec(message: "expected pattern in variable", fixIts: ["insert pattern"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingInvalidTests.swift b/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingInvalidTests.swift index 58c28998a3b..b381ee90204 100644 --- a/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingInvalidTests.swift +++ b/Tests/SwiftParserTest/translated/ForwardSlashRegexSkippingInvalidTests.swift @@ -64,7 +64,7 @@ final class ForwardSlashRegexSkippingInvalidTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "bare slash regex literal may not start with space"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '/' to end regex literal"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '/' to end regex literal", fixIts: ["insert '/'"]), ] ) } @@ -78,7 +78,7 @@ final class ForwardSlashRegexSkippingInvalidTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "bare slash regex literal may not start with space"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '/' to end regex literal"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '/' to end regex literal", fixIts: ["insert '/'"]), ] ) } @@ -115,8 +115,8 @@ final class ForwardSlashRegexSkippingInvalidTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -129,7 +129,7 @@ final class ForwardSlashRegexSkippingInvalidTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '/' to end regex literal") + DiagnosticSpec(message: "expected '/' to end regex literal", fixIts: ["insert '/'"]) ] ) } @@ -142,7 +142,7 @@ final class ForwardSlashRegexSkippingInvalidTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(message: "expected '/' to end regex literal") + DiagnosticSpec(message: "expected '/' to end regex literal", fixIts: ["insert '/'"]) ] ) } @@ -155,7 +155,7 @@ final class ForwardSlashRegexSkippingInvalidTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '/' to end regex literal") + DiagnosticSpec(message: "expected '/' to end regex literal", fixIts: ["insert '/'"]) ] ) } @@ -170,7 +170,7 @@ final class ForwardSlashRegexSkippingInvalidTests: XCTestCase { """#, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "bare slash regex literal may not start with space"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '/' to end regex literal"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '/' to end regex literal", fixIts: ["insert '/'"]), DiagnosticSpec(locationMarker: "3️⃣", message: "extraneous brace at top level"), ] diff --git a/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift b/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift index 1d381c7b2a2..71b1740499a 100644 --- a/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift +++ b/Tests/SwiftParserTest/translated/ForwardSlashRegexTests.swift @@ -205,7 +205,7 @@ final class ForwardSlashRegexTests: XCTestCase { _ = /^)1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected '/' to end regex literal") + DiagnosticSpec(message: "expected '/' to end regex literal", fixIts: ["insert '/'"]) ] ) } @@ -288,7 +288,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -302,7 +302,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator"), + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]), DiagnosticSpec(message: "unexpected code '? 0 : 1' in 'do' statement"), ] ) @@ -325,7 +325,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator"), + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]), DiagnosticSpec(message: "unexpected code '?? /x /' in 'do' statement"), ] ) @@ -390,8 +390,8 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected expression in operator"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected expression in operator", fixIts: ["insert expression"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code '...' in 'do' statement"), ] ) @@ -405,7 +405,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -440,7 +440,7 @@ final class ForwardSlashRegexTests: XCTestCase { foo(/abc/, y: /abc /1️⃣) """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -470,7 +470,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -486,7 +486,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -509,7 +509,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -522,8 +522,8 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression after operator"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected expression after operator"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression after operator", fixIts: ["insert expression"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected expression after operator", fixIts: ["insert expression"]), ] ) } @@ -596,7 +596,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -749,7 +749,7 @@ final class ForwardSlashRegexTests: XCTestCase { _ = 0.1️⃣ / 1 / 2 """, diagnostics: [ - DiagnosticSpec(message: "expected name in member access") + DiagnosticSpec(message: "expected name in member access", fixIts: ["insert name"]) ] ) } @@ -760,7 +760,7 @@ final class ForwardSlashRegexTests: XCTestCase { _ = 0 . 1️⃣/ 1 / 2 """, diagnostics: [ - DiagnosticSpec(message: "expected name in member access") + DiagnosticSpec(message: "expected name in member access", fixIts: ["insert name"]) ] ) } @@ -863,7 +863,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected pattern in variable") + DiagnosticSpec(message: "expected pattern in variable", fixIts: ["insert pattern"]) ] ) } @@ -876,7 +876,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -889,7 +889,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -902,7 +902,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression after operator") + DiagnosticSpec(message: "expected expression after operator", fixIts: ["insert expression"]) ] ) } @@ -1066,7 +1066,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(message: "expected ')' to end function call") + DiagnosticSpec(message: "expected ')' to end function call", fixIts: ["insert ')'"]) ] ) } @@ -1223,7 +1223,7 @@ final class ForwardSlashRegexTests: XCTestCase { _ = /1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected '/' to end regex literal") + DiagnosticSpec(message: "expected '/' to end regex literal", fixIts: ["insert '/'"]) ] ) } @@ -1234,7 +1234,7 @@ final class ForwardSlashRegexTests: XCTestCase { _ = /)1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected '/' to end regex literal") + DiagnosticSpec(message: "expected '/' to end regex literal", fixIts: ["insert '/'"]) ] ) } @@ -1270,7 +1270,8 @@ final class ForwardSlashRegexTests: XCTestCase { message: "expected ')' to end tuple", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) ] ) @@ -1310,7 +1311,7 @@ final class ForwardSlashRegexTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected root in key path"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected root in key path", fixIts: ["insert root"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code '])/' in 'do' statement"), ] ) @@ -1346,8 +1347,8 @@ final class ForwardSlashRegexTests: XCTestCase { _ = ^/"/1️⃣"2️⃣ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -1358,8 +1359,8 @@ final class ForwardSlashRegexTests: XCTestCase { _ = ^/"[/1️⃣"2️⃣ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -1451,7 +1452,7 @@ final class ForwardSlashRegexTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "bare slash regex literal may not start with space"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '/' to end regex literal"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '/' to end regex literal", fixIts: ["insert '/'"]), ] ) } @@ -1463,7 +1464,7 @@ final class ForwardSlashRegexTests: XCTestCase { _ = /^ 1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected '/' to end regex literal") + DiagnosticSpec(message: "expected '/' to end regex literal", fixIts: ["insert '/'"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/GuardTests.swift b/Tests/SwiftParserTest/translated/GuardTests.swift index 937b6977e37..598c779bcfc 100644 --- a/Tests/SwiftParserTest/translated/GuardTests.swift +++ b/Tests/SwiftParserTest/translated/GuardTests.swift @@ -23,7 +23,7 @@ final class GuardTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected 'else' and body in 'guard' statement") + DiagnosticSpec(message: "expected 'else' and body in 'guard' statement", fixIts: ["insert 'else' and body"]) ] ) } @@ -36,7 +36,7 @@ final class GuardTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected condition in 'guard' statement") + DiagnosticSpec(message: "expected condition in 'guard' statement", fixIts: ["insert condition"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/IdentifiersTests.swift b/Tests/SwiftParserTest/translated/IdentifiersTests.swift index 0e5a9667a5e..b491dbc01db 100644 --- a/Tests/SwiftParserTest/translated/IdentifiersTests.swift +++ b/Tests/SwiftParserTest/translated/IdentifiersTests.swift @@ -113,7 +113,7 @@ final class IdentifiersTests: XCTestCase { struct 1️⃣Self {} """, diagnostics: [ - DiagnosticSpec(message: "keyword 'Self' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'Self' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -132,7 +132,7 @@ final class IdentifiersTests: XCTestCase { struct 1️⃣Any {} """, diagnostics: [ - DiagnosticSpec(message: "keyword 'Any' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'Any' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -143,7 +143,7 @@ final class IdentifiersTests: XCTestCase { protocol 1️⃣enum {} """, diagnostics: [ - DiagnosticSpec(message: "keyword 'enum' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'enum' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -157,7 +157,7 @@ final class IdentifiersTests: XCTestCase { func 2️⃣_(_ x: Int) {} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'public' cannot be used as an identifier here"), + DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'public' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]), DiagnosticSpec(locationMarker: "2️⃣", message: "'_' cannot be used as an identifier here"), ] ) diff --git a/Tests/SwiftParserTest/translated/IfconfigExprTests.swift b/Tests/SwiftParserTest/translated/IfconfigExprTests.swift index b6ca20488e7..ae33c113f4b 100644 --- a/Tests/SwiftParserTest/translated/IfconfigExprTests.swift +++ b/Tests/SwiftParserTest/translated/IfconfigExprTests.swift @@ -330,7 +330,7 @@ final class IfconfigExprTests: XCTestCase { #endif """, diagnostics: [ - DiagnosticSpec(message: "expected value in function call") + DiagnosticSpec(message: "expected value in function call", fixIts: ["insert value"]) ] ) } @@ -369,7 +369,7 @@ final class IfconfigExprTests: XCTestCase { #endif """, diagnostics: [ - DiagnosticSpec(message: "expected value in function call") + DiagnosticSpec(message: "expected value in function call", fixIts: ["insert value"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/ImplicitGetterIncompleteTests.swift b/Tests/SwiftParserTest/translated/ImplicitGetterIncompleteTests.swift index 0becd842e73..3d09f025b6d 100644 --- a/Tests/SwiftParserTest/translated/ImplicitGetterIncompleteTests.swift +++ b/Tests/SwiftParserTest/translated/ImplicitGetterIncompleteTests.swift @@ -41,8 +41,8 @@ final class ImplicitGetterIncompleteTests: XCTestCase { }1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '}' to end variable"), - DiagnosticSpec(message: "expected '}' to end function"), + DiagnosticSpec(message: "expected '}' to end variable", fixIts: ["insert '}'"]), + DiagnosticSpec(message: "expected '}' to end function", fixIts: ["insert '}'"]), ] ) } diff --git a/Tests/SwiftParserTest/translated/InitDeinitTests.swift b/Tests/SwiftParserTest/translated/InitDeinitTests.swift index 8e99acfc563..ac213675820 100644 --- a/Tests/SwiftParserTest/translated/InitDeinitTests.swift +++ b/Tests/SwiftParserTest/translated/InitDeinitTests.swift @@ -25,7 +25,7 @@ final class InitDeinitTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected parameter clause in function signature") + DiagnosticSpec(message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]) ] ) } @@ -48,7 +48,7 @@ final class InitDeinitTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected parameter clause in function signature") + DiagnosticSpec(message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]) ] ) } @@ -61,7 +61,7 @@ final class InitDeinitTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected parameter clause in function signature") + DiagnosticSpec(message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]) ] ) } @@ -74,7 +74,7 @@ final class InitDeinitTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected parameter clause in function signature") + DiagnosticSpec(message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]) ] ) } @@ -195,8 +195,8 @@ final class InitDeinitTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "deinitializers cannot have a name"), - DiagnosticSpec(locationMarker: "2️⃣", message: "deinitializers cannot have parameters"), + DiagnosticSpec(locationMarker: "1️⃣", message: "deinitializers cannot have a name", fixIts: ["remove 'x'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "deinitializers cannot have parameters", fixIts: ["remove function signature"]), ], fixedSource: """ class FooClassDeinitializerC { @@ -214,7 +214,7 @@ final class InitDeinitTests: XCTestCase { init() {} """, diagnostics: [ - DiagnosticSpec(message: "expected parameter clause in function signature") + DiagnosticSpec(message: "expected parameter clause in function signature", fixIts: ["insert parameter clause"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/InvalidIfExprTests.swift b/Tests/SwiftParserTest/translated/InvalidIfExprTests.swift index 3ba07ade092..527b5332de5 100644 --- a/Tests/SwiftParserTest/translated/InvalidIfExprTests.swift +++ b/Tests/SwiftParserTest/translated/InvalidIfExprTests.swift @@ -46,7 +46,7 @@ final class InvalidIfExprTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(message: "expected ':' and expression after '? ...' in ternary expression", fixIts: ["insert ':' and expression"]), - DiagnosticSpec(message: "expected ')' to end tuple"), + DiagnosticSpec(message: "expected ')' to end tuple", fixIts: ["insert ')'"]), ], fixedSource: "(a ? b ? c : d: <#expression#>)" ) diff --git a/Tests/SwiftParserTest/translated/InvalidTests.swift b/Tests/SwiftParserTest/translated/InvalidTests.swift index 8019ee30749..5d59ed45922 100644 --- a/Tests/SwiftParserTest/translated/InvalidTests.swift +++ b/Tests/SwiftParserTest/translated/InvalidTests.swift @@ -34,7 +34,7 @@ final class InvalidTests: XCTestCase { func test2(1️⃣inout let x : Int) {} """, diagnostics: [ - DiagnosticSpec(message: "'inout' before a parameter name is not allowed") + DiagnosticSpec(message: "'inout' before a parameter name is not allowed", fixIts: ["move 'inout' in front of type"]) ] ) } @@ -57,7 +57,7 @@ final class InvalidTests: XCTestCase { func test1s(1️⃣__shared var x : Int) {} """, diagnostics: [ - DiagnosticSpec(message: "'__shared' before a parameter name is not allowed") + DiagnosticSpec(message: "'__shared' before a parameter name is not allowed", fixIts: ["move '__shared' in front of type"]) ] ) } @@ -68,7 +68,7 @@ final class InvalidTests: XCTestCase { func test2s(1️⃣__shared let x : Int) {} """, diagnostics: [ - DiagnosticSpec(message: "'__shared' before a parameter name is not allowed") + DiagnosticSpec(message: "'__shared' before a parameter name is not allowed", fixIts: ["move '__shared' in front of type"]) ] ) } @@ -79,7 +79,7 @@ final class InvalidTests: XCTestCase { func test1o(1️⃣__owned var x : Int) {} """, diagnostics: [ - DiagnosticSpec(message: "'__owned' before a parameter name is not allowed") + DiagnosticSpec(message: "'__owned' before a parameter name is not allowed", fixIts: ["move '__owned' in front of type"]) ] ) } @@ -90,7 +90,7 @@ final class InvalidTests: XCTestCase { func test2o(1️⃣__owned let x : Int) {} """, diagnostics: [ - DiagnosticSpec(message: "'__owned' before a parameter name is not allowed") + DiagnosticSpec(message: "'__owned' before a parameter name is not allowed", fixIts: ["move '__owned' in front of type"]) ] ) } @@ -103,7 +103,7 @@ final class InvalidTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected value and ')' to end function call") + DiagnosticSpec(message: "expected value and ')' to end function call", fixIts: ["insert value and ')'"]) ] ) } @@ -126,7 +126,7 @@ final class InvalidTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected ')' to end function call") + DiagnosticSpec(message: "expected ')' to end function call", fixIts: ["insert ')'"]) ] ) } @@ -149,7 +149,7 @@ final class InvalidTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "all statements inside a switch must be covered by a 'case' or 'default' label") + DiagnosticSpec(message: "all statements inside a switch must be covered by a 'case' or 'default' label", fixIts: ["insert label"]) ] ) } @@ -174,8 +174,8 @@ final class InvalidTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "all statements inside a switch must be covered by a 'case' or 'default' label"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "all statements inside a switch must be covered by a 'case' or 'default' label", fixIts: ["insert label"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), ] ) } @@ -190,7 +190,7 @@ final class InvalidTests: XCTestCase { """##, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected brace in string literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end function"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end function", fixIts: ["insert '}'"]), ] ) } @@ -202,10 +202,10 @@ final class InvalidTests: XCTestCase { func d(_ b: 1️⃣String 2️⃣-> 3️⃣() -> T4️⃣) {} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start function type"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' in function type"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected return type in function type"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' to end parameter clause"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start function type", fixIts: ["insert '('"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' in function type", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected return type in function type", fixIts: ["insert return type"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), DiagnosticSpec(locationMarker: "3️⃣", message: "unexpected code '() -> T)' in function"), ] ) @@ -236,7 +236,7 @@ final class InvalidTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected ':' and type in parameter") + DiagnosticSpec(message: "expected ':' and type in parameter", fixIts: ["insert ':' and type"]) ] ) } @@ -251,7 +251,7 @@ final class InvalidTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected value in function call") + DiagnosticSpec(message: "expected value in function call", fixIts: ["insert value"]) ] ) } @@ -305,7 +305,7 @@ final class InvalidTests: XCTestCase { func f4_43591(1️⃣inout x: inout String) {} """, diagnostics: [ - DiagnosticSpec(message: "'inout' before a parameter name is not allowed") + DiagnosticSpec(message: "'inout' before a parameter name is not allowed", fixIts: ["remove redundant 'inout'"]) ] ) } @@ -316,7 +316,7 @@ final class InvalidTests: XCTestCase { func f5_43591(1️⃣inout i: inout Int) {} """, diagnostics: [ - DiagnosticSpec(message: "'inout' before a parameter name is not allowed") + DiagnosticSpec(message: "'inout' before a parameter name is not allowed", fixIts: ["remove redundant 'inout'"]) ] ) } @@ -327,7 +327,7 @@ final class InvalidTests: XCTestCase { func 1️⃣repeat() {} """, diagnostics: [ - DiagnosticSpec(message: "keyword 'repeat' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'repeat' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -338,7 +338,7 @@ final class InvalidTests: XCTestCase { let 1️⃣for = 2 """, diagnostics: [ - DiagnosticSpec(message: "keyword 'for' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'for' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -349,7 +349,7 @@ final class InvalidTests: XCTestCase { func f4_43591(1️⃣inout x: inout String) {} """, diagnostics: [ - DiagnosticSpec(message: "'inout' before a parameter name is not allowed") + DiagnosticSpec(message: "'inout' before a parameter name is not allowed", fixIts: ["remove redundant 'inout'"]) ] ) } @@ -372,7 +372,7 @@ final class InvalidTests: XCTestCase { func 1️⃣repeat() {} """, diagnostics: [ - DiagnosticSpec(message: "keyword 'repeat' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'repeat' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -383,7 +383,7 @@ final class InvalidTests: XCTestCase { let 1️⃣for = 2 """, diagnostics: [ - DiagnosticSpec(message: "keyword 'for' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'for' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } @@ -476,9 +476,9 @@ final class InvalidTests: XCTestCase { wolf2️⃣() 3️⃣{} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start parameter clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ':' in parameter"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' to end parameter clause"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start parameter clause", fixIts: ["insert '('"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ':' in parameter", fixIts: ["insert ':'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), ], fixedSource: """ func were( @@ -494,9 +494,9 @@ final class InvalidTests: XCTestCase { leavings2️⃣(x: T) {} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start parameter clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ':' and type in parameter"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end parameter clause"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start parameter clause", fixIts: ["insert '('"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ':' and type in parameter", fixIts: ["insert ':' and type"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code '(x: T)' in function"), ] ) diff --git a/Tests/SwiftParserTest/translated/MultilineErrorsTests.swift b/Tests/SwiftParserTest/translated/MultilineErrorsTests.swift index adb96da9949..951dd3d0f24 100644 --- a/Tests/SwiftParserTest/translated/MultilineErrorsTests.swift +++ b/Tests/SwiftParserTest/translated/MultilineErrorsTests.swift @@ -93,7 +93,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal") + DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" _ = """ @@ -114,7 +114,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal") + DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" _ = """ @@ -134,7 +134,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal") + DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" _ = """ @@ -154,7 +154,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal") + DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" _ = """ @@ -175,7 +175,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal") + DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" _ = """ @@ -197,7 +197,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "unexpected tab in indentation of line in multi-line string literal") + DiagnosticSpec(message: "unexpected tab in indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" _ = """ @@ -218,7 +218,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "unexpected tab in indentation of line in multi-line string literal") + DiagnosticSpec(message: "unexpected tab in indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" _ = """ @@ -239,7 +239,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "unexpected space in indentation of line in multi-line string literal") + DiagnosticSpec(message: "unexpected space in indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" _ = """ @@ -260,7 +260,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "unexpected space in indentation of line in multi-line string literal") + DiagnosticSpec(message: "unexpected space in indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ] ) } @@ -292,7 +292,7 @@ final class MultilineErrorsTests: XCTestCase { Pi1️⃣""" """#, diagnostics: [ - DiagnosticSpec(message: "multi-line string literal closing delimiter must begin on a new line") + DiagnosticSpec(message: "multi-line string literal closing delimiter must begin on a new line", fixIts: ["insert newline"]) ], fixedSource: #""" _ = """ @@ -343,7 +343,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "unexpected space in indentation of the next 2 lines in multi-line string literal") + DiagnosticSpec(message: "unexpected space in indentation of the next 2 lines in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" _ = """ @@ -373,9 +373,9 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "insufficient indentation of the next 4 lines in multi-line string literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected space in indentation of the next 2 lines in multi-line string literal"), - DiagnosticSpec(locationMarker: "3️⃣", message: "insufficient indentation of the next 2 lines in multi-line string literal"), + DiagnosticSpec(locationMarker: "1️⃣", message: "insufficient indentation of the next 4 lines in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected space in indentation of the next 2 lines in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "insufficient indentation of the next 2 lines in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]), ], fixedSource: #""" _ = """ @@ -406,7 +406,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "insufficient indentation of the next 2 lines in multi-line string literal") + DiagnosticSpec(message: "insufficient indentation of the next 2 lines in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" _ = """ @@ -428,8 +428,8 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "insufficient indentation of line in multi-line string literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: "insufficient indentation of line in multi-line string literal"), + DiagnosticSpec(locationMarker: "1️⃣", message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]), ], fixedSource: #""" _ = """ @@ -450,8 +450,8 @@ final class MultilineErrorsTests: XCTestCase { 2️⃣)!" """##, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ')' in string literal"), - DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ')' in string literal", fixIts: [#"insert ')'"#]), + DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), DiagnosticSpec(locationMarker: "2️⃣", message: #"extraneous code ')!"' at top level"#), ] ) @@ -466,8 +466,8 @@ final class MultilineErrorsTests: XCTestCase { """2️⃣)!" """##, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected value and ')' in string literal"), - DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected value and ')' in string literal", fixIts: ["insert value and ')'"]), + DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), DiagnosticSpec(locationMarker: "2️⃣", message: #"extraneous code ')!"' at top level"#), ] ) @@ -515,7 +515,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed") + DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed", fixIts: ["remove ''"]) ], fixedSource: #""" _ = """ @@ -533,7 +533,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed") + DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed", fixIts: ["remove ''"]) ], fixedSource: #""" _ = """ @@ -551,7 +551,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed") + DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed", fixIts: ["remove ''"]) ], fixedSource: #""" _ = """ @@ -569,7 +569,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed") + DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed", fixIts: ["remove ''"]) ], fixedSource: #""" _ = """ @@ -587,7 +587,7 @@ final class MultilineErrorsTests: XCTestCase { """##, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "invalid escape sequence in literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"""' to end string literal"#), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"""' to end string literal"#, fixIts: [#"insert '"""'"#]), ] ) } @@ -600,7 +600,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed") + DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed", fixIts: ["remove ''"]) ], fixedSource: #""" _ = """ @@ -617,8 +617,8 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "multi-line string literal content must begin on a new line"), - DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed"), + DiagnosticSpec(message: "multi-line string literal content must begin on a new line", fixIts: ["insert newline"]), + DiagnosticSpec(message: "escaped newline at the last line of a multi-line string literal is not allowed", fixIts: ["remove ''"]), ], fixedSource: #""" _ = """ @@ -638,9 +638,9 @@ final class MultilineErrorsTests: XCTestCase { """ """##, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), DiagnosticSpec(locationMarker: "2️⃣", message: #"unexpected code 'baz' in string literal"#), - DiagnosticSpec(locationMarker: "3️⃣", message: #"expected ')' in string literal"#, notes: [NoteSpec(message: "to match this opening '('")]), + DiagnosticSpec(locationMarker: "3️⃣", message: #"expected ')' in string literal"#, notes: [NoteSpec(message: "to match this opening '('")], fixIts: ["insert ')'"]), ], fixedSource: ##""" let _ = """ @@ -664,9 +664,9 @@ final class MultilineErrorsTests: XCTestCase { """##, substructure: Syntax(IdentifierExprSyntax(identifier: .identifier("abc"))), diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), DiagnosticSpec(locationMarker: "2️⃣", message: #"unexpected code 'baz' in string literal"#), - DiagnosticSpec(locationMarker: "3️⃣", message: #"expected ')' in string literal"#, notes: [NoteSpec(message: "to match this opening '('")]), + DiagnosticSpec(locationMarker: "3️⃣", message: #"expected ')' in string literal"#, notes: [NoteSpec(message: "to match this opening '('")], fixIts: ["insert ')'"]), ] ) } @@ -678,7 +678,7 @@ final class MultilineErrorsTests: XCTestCase { \(1)1️⃣""" """#, diagnostics: [ - DiagnosticSpec(message: "multi-line string literal closing delimiter must begin on a new line") + DiagnosticSpec(message: "multi-line string literal closing delimiter must begin on a new line", fixIts: ["insert newline"]) ], fixedSource: #""" _ = """ @@ -698,7 +698,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal") + DiagnosticSpec(message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" """ @@ -720,8 +720,8 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "insufficient indentation of line in multi-line string literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: "insufficient indentation of line in multi-line string literal"), + DiagnosticSpec(locationMarker: "1️⃣", message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "insufficient indentation of line in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]), ], fixedSource: #""" """ @@ -745,7 +745,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "insufficient indentation of the next 3 lines in multi-line string literal") + DiagnosticSpec(message: "insufficient indentation of the next 3 lines in multi-line string literal", fixIts: ["change indentation of this line to match closing delimiter"]) ], fixedSource: #""" """ @@ -766,7 +766,7 @@ final class MultilineErrorsTests: XCTestCase { """ """#, diagnostics: [ - DiagnosticSpec(message: "multi-line string literal content must begin on a new line") + DiagnosticSpec(message: "multi-line string literal content must begin on a new line", fixIts: ["insert newline"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/MultilinePoundDiagnosticArgRdar41154797Tests.swift b/Tests/SwiftParserTest/translated/MultilinePoundDiagnosticArgRdar41154797Tests.swift index ee0a506abe2..26e33c8df88 100644 --- a/Tests/SwiftParserTest/translated/MultilinePoundDiagnosticArgRdar41154797Tests.swift +++ b/Tests/SwiftParserTest/translated/MultilinePoundDiagnosticArgRdar41154797Tests.swift @@ -21,8 +21,8 @@ final class MultilinePoundDiagnosticArgRdar41154797Tests: XCTestCase { #error("""1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: #"expected '"""' to end string literal"#), - DiagnosticSpec(message: "expected ')' to end macro expansion"), + DiagnosticSpec(message: #"expected '"""' to end string literal"#, fixIts: [#"insert '"""'"#]), + DiagnosticSpec(message: "expected ')' to end macro expansion", fixIts: ["insert ')'"]), ] ) } diff --git a/Tests/SwiftParserTest/translated/ObjectLiteralsTests.swift b/Tests/SwiftParserTest/translated/ObjectLiteralsTests.swift index 02f695b5c0a..2f7e132db54 100644 --- a/Tests/SwiftParserTest/translated/ObjectLiteralsTests.swift +++ b/Tests/SwiftParserTest/translated/ObjectLiteralsTests.swift @@ -21,7 +21,7 @@ final class ObjectLiteralsTests: XCTestCase { let _ = [#Color(colorLiteralRed: red, green: green, blue: blue, alpha: alpha)#1️⃣] """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]) ] ) } @@ -32,7 +32,7 @@ final class ObjectLiteralsTests: XCTestCase { let _ = [#Image(imageLiteral: localResourceNameAsString)#1️⃣] """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]) ] ) } @@ -43,7 +43,7 @@ final class ObjectLiteralsTests: XCTestCase { let _ = [#FileReference(fileReferenceLiteral: localResourceNameAsString)#1️⃣] """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]) ] ) } @@ -102,8 +102,8 @@ final class ObjectLiteralsTests: XCTestCase { let _ = [#1️⃣#2️⃣] """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]), ] ) } @@ -114,7 +114,7 @@ final class ObjectLiteralsTests: XCTestCase { let _ = [#Color(_: 1, green: 1, 2)2️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ']' to end array") + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ']' to end array", fixIts: ["insert ']'"]) ] ) } @@ -125,8 +125,8 @@ final class ObjectLiteralsTests: XCTestCase { let _ = [1️⃣#Color(red: 1, green: 1, blue: 1)#2️⃣3️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected ']' to end array"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected ']' to end array", fixIts: ["insert ']'"]), ] ) } @@ -137,7 +137,7 @@ final class ObjectLiteralsTests: XCTestCase { let _ = [#Color(withRed: 1, green: 1, whatever: 2)#1️⃣] """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/OperatorDeclTests.swift b/Tests/SwiftParserTest/translated/OperatorDeclTests.swift index ad0f92010b2..35527ff1e2c 100644 --- a/Tests/SwiftParserTest/translated/OperatorDeclTests.swift +++ b/Tests/SwiftParserTest/translated/OperatorDeclTests.swift @@ -33,7 +33,7 @@ final class OperatorDeclTests: XCTestCase { postfix operator +++ 1️⃣{} """, diagnostics: [ - DiagnosticSpec(message: "operator should not be declared with body") + DiagnosticSpec(message: "operator should not be declared with body", fixIts: ["remove operator body"]) ] ) } @@ -44,7 +44,7 @@ final class OperatorDeclTests: XCTestCase { infix operator +++ 1️⃣{} """, diagnostics: [ - DiagnosticSpec(message: "operator should not be declared with body") + DiagnosticSpec(message: "operator should not be declared with body", fixIts: ["remove operator body"]) ] ) } @@ -71,7 +71,7 @@ final class OperatorDeclTests: XCTestCase { infix operator +++*+ : A 1️⃣{ } """, diagnostics: [ - DiagnosticSpec(message: "operator should not be declared with body") + DiagnosticSpec(message: "operator should not be declared with body", fixIts: ["remove operator body"]) ] ) } @@ -82,7 +82,7 @@ final class OperatorDeclTests: XCTestCase { prefix operator +++** : A 1️⃣{ } """, diagnostics: [ - DiagnosticSpec(message: "operator should not be declared with body") + DiagnosticSpec(message: "operator should not be declared with body", fixIts: ["remove operator body"]) ] ) } @@ -101,7 +101,7 @@ final class OperatorDeclTests: XCTestCase { postfix operator ++*+* : A 1️⃣{ } """, diagnostics: [ - DiagnosticSpec(message: "operator should not be declared with body") + DiagnosticSpec(message: "operator should not be declared with body", fixIts: ["remove operator body"]) ] ) } @@ -132,7 +132,7 @@ final class OperatorDeclTests: XCTestCase { """, diagnostics: [ // TODO: Old parser expected error on line 1: operator must be declared as 'prefix', 'postfix', or 'infix' - DiagnosticSpec(message: "operator should not be declared with body") + DiagnosticSpec(message: "operator should not be declared with body", fixIts: ["remove operator body"]) ] ) } @@ -144,7 +144,7 @@ final class OperatorDeclTests: XCTestCase { """, diagnostics: [ // TODO: Old parser expected error on line 1: operator must be declared as 'prefix', 'postfix', or 'infix' - DiagnosticSpec(message: "operator should not be declared with body") + DiagnosticSpec(message: "operator should not be declared with body", fixIts: ["remove operator body"]) ] ) } @@ -155,7 +155,7 @@ final class OperatorDeclTests: XCTestCase { prefix operator1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected binary operator in operator declaration") + DiagnosticSpec(message: "expected binary operator in operator declaration", fixIts: ["insert binary operator"]) ] ) } @@ -258,7 +258,7 @@ final class OperatorDeclTests: XCTestCase { infix operator !!1️⃣@aa2️⃣ """, diagnostics: [ - DiagnosticSpec(message: "'@aa' is not allowed in operator names") + DiagnosticSpec(message: "'@aa' is not allowed in operator names", fixIts: ["remove '@aa'"]) ] ) } @@ -281,7 +281,7 @@ final class OperatorDeclTests: XCTestCase { infix operator ++=1️⃣# """, diagnostics: [ - DiagnosticSpec(message: "'#' is not allowed in operator names") + DiagnosticSpec(message: "'#' is not allowed in operator names", fixIts: ["remove '#'"]) ] ) } @@ -292,7 +292,7 @@ final class OperatorDeclTests: XCTestCase { infix operator ->1️⃣# """, diagnostics: [ - DiagnosticSpec(message: "'#' is not allowed in operator names") + DiagnosticSpec(message: "'#' is not allowed in operator names", fixIts: ["remove '#'"]) ] ) } @@ -305,7 +305,7 @@ final class OperatorDeclTests: XCTestCase { infix operator =1️⃣#= """, diagnostics: [ - DiagnosticSpec(message: "'#=' is not allowed in operator names") + DiagnosticSpec(message: "'#=' is not allowed in operator names", fixIts: ["remove '#='"]) ] ) } @@ -318,7 +318,7 @@ final class OperatorDeclTests: XCTestCase { infix operator --- : 1️⃣; """, diagnostics: [ - DiagnosticSpec(message: "expected precedence group in operator declaration") + DiagnosticSpec(message: "expected precedence group in operator declaration", fixIts: ["insert precedence group"]) ] ) } @@ -331,7 +331,7 @@ final class OperatorDeclTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected identifier in precedencegroup") + DiagnosticSpec(message: "expected identifier in precedencegroup", fixIts: ["insert identifier"]) ] ) } @@ -344,7 +344,7 @@ final class OperatorDeclTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected ':' in 'associativity' property of precedencegroup") + DiagnosticSpec(message: "expected ':' in 'associativity' property of precedencegroup", fixIts: ["insert ':'"]) ] ) } @@ -396,7 +396,7 @@ final class OperatorDeclTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected name in 'relation' property of precedencegroup") + DiagnosticSpec(message: "expected name in 'relation' property of precedencegroup", fixIts: ["insert name"]) ] ) } @@ -475,7 +475,7 @@ final class OperatorDeclTests: XCTestCase { postfix operator ++:1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected precedence group in operator declaration") + DiagnosticSpec(message: "expected precedence group in operator declaration", fixIts: ["insert precedence group"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/OperatorsTests.swift b/Tests/SwiftParserTest/translated/OperatorsTests.swift index 0a1c364f3c7..6684266e9a5 100644 --- a/Tests/SwiftParserTest/translated/OperatorsTests.swift +++ b/Tests/SwiftParserTest/translated/OperatorsTests.swift @@ -337,7 +337,7 @@ final class OperatorsTests: XCTestCase { foo!!1️⃣foo """, diagnostics: [ - DiagnosticSpec(message: "consecutive statements on a line must be separated by ';'") + DiagnosticSpec(message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]) ] ) } @@ -348,7 +348,7 @@ final class OperatorsTests: XCTestCase { foo??1️⃣bar """, diagnostics: [ - DiagnosticSpec(message: "consecutive statements on a line must be separated by ';'") + DiagnosticSpec(message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/OriginalDefinedInAttrTests.swift b/Tests/SwiftParserTest/translated/OriginalDefinedInAttrTests.swift index ef7bfffdd76..7fe2115dcc1 100644 --- a/Tests/SwiftParserTest/translated/OriginalDefinedInAttrTests.swift +++ b/Tests/SwiftParserTest/translated/OriginalDefinedInAttrTests.swift @@ -31,7 +31,7 @@ final class OriginalDefinedInAttrTests: XCTestCase { public func foo1() {} """#, diagnostics: [ - DiagnosticSpec(message: "expected 'module' in @_originallyDefinedIn arguments"), + DiagnosticSpec(message: "expected 'module' in @_originallyDefinedIn arguments", fixIts: ["insert 'module'"]), DiagnosticSpec(message: "unexpected code 'modulename' before @_originallyDefinedIn arguments"), ] ) @@ -53,7 +53,7 @@ final class OriginalDefinedInAttrTests: XCTestCase { public class ToplevelClass1 {} """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ',' and version list in @_originallyDefinedIn arguments") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ',' and version list in @_originallyDefinedIn arguments", fixIts: ["insert ',' and version list"]) ] ) } @@ -65,7 +65,7 @@ final class OriginalDefinedInAttrTests: XCTestCase { public class ToplevelClass2 {} """, diagnostics: [ - DiagnosticSpec(message: "expected 'module:', string literal, and ',' in @_originallyDefinedIn arguments") + DiagnosticSpec(message: "expected 'module:', string literal, and ',' in @_originallyDefinedIn arguments", fixIts: ["insert 'module:', string literal, and ','"]) ] ) } @@ -77,8 +77,8 @@ final class OriginalDefinedInAttrTests: XCTestCase { public class ToplevelClass3 {} """#, diagnostics: [ - DiagnosticSpec(message: "expected version restriction in version"), - DiagnosticSpec(message: "expected ')' to end attribute"), + DiagnosticSpec(message: "expected version restriction in version", fixIts: ["insert version restriction"]), + DiagnosticSpec(message: "expected ')' to end attribute", fixIts: ["insert ')'"]), ] ) } diff --git a/Tests/SwiftParserTest/translated/PoundAssertTests.swift b/Tests/SwiftParserTest/translated/PoundAssertTests.swift index b18270c7094..5eaa82ea99f 100644 --- a/Tests/SwiftParserTest/translated/PoundAssertTests.swift +++ b/Tests/SwiftParserTest/translated/PoundAssertTests.swift @@ -37,7 +37,7 @@ final class PoundAssertTests: XCTestCase { #assert1️⃣ true2️⃣, "error message") """#, diagnostics: [ - DiagnosticSpec(message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), DiagnosticSpec(locationMarker: "2️⃣", message: #"extraneous code ', "error message")' at top level"#), ] ) @@ -49,7 +49,7 @@ final class PoundAssertTests: XCTestCase { #assert(1️⃣, "error message") """#, diagnostics: [ - DiagnosticSpec(message: "expected value in macro expansion") + DiagnosticSpec(message: "expected value in macro expansion", fixIts: ["insert value"]) ] ) } @@ -66,7 +66,8 @@ final class PoundAssertTests: XCTestCase { message: "expected ')' to end macro expansion", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) ] ) @@ -84,10 +85,10 @@ final class PoundAssertTests: XCTestCase { message: "expected ')' to end macro expansion", notes: [ NoteSpec(message: "to match this opening '('") - ] + ], + fixIts: ["insert ')'"] ) ] ) } - } diff --git a/Tests/SwiftParserTest/translated/RawStringErrorsTests.swift b/Tests/SwiftParserTest/translated/RawStringErrorsTests.swift index b960effa541..ce06deb436e 100644 --- a/Tests/SwiftParserTest/translated/RawStringErrorsTests.swift +++ b/Tests/SwiftParserTest/translated/RawStringErrorsTests.swift @@ -21,7 +21,7 @@ final class RawStringErrorsTests: XCTestCase { let _ = "foo\(#"bar"#1️⃣#)baz" """###, diagnostics: [ - DiagnosticSpec(message: "too many '#' characters in closing delimiter") + DiagnosticSpec(message: "too many '#' characters in closing delimiter", fixIts: ["remove extraneous delimiters"]) ] ) } @@ -32,7 +32,7 @@ final class RawStringErrorsTests: XCTestCase { let _ = #"\#1️⃣#("invalid")"# """###, diagnostics: [ - DiagnosticSpec(message: "too many '#' characters to start string interpolation") + DiagnosticSpec(message: "too many '#' characters to start string interpolation", fixIts: ["remove extraneous delimiters"]) ], fixedSource: ###""" let _ = #"\#("invalid")"# @@ -60,7 +60,7 @@ final class RawStringErrorsTests: XCTestCase { let _ = ####"invalid"###1️⃣ """#####, diagnostics: [ - DiagnosticSpec(message: #####"expected '"####' to end string literal"#####) + DiagnosticSpec(message: #####"expected '"####' to end string literal"#####, fixIts: [#####"insert '"####'"#####]) ] ) } @@ -71,7 +71,7 @@ final class RawStringErrorsTests: XCTestCase { let _ = ###"invalid"###1️⃣### """#####, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "too many '#' characters in closing delimiter") + DiagnosticSpec(locationMarker: "1️⃣", message: "too many '#' characters in closing delimiter", fixIts: ["remove extraneous delimiters"]) ] ) } @@ -84,8 +84,8 @@ final class RawStringErrorsTests: XCTestCase { aa2️⃣"""## """###, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "multi-line string literal content must begin on a new line"), - DiagnosticSpec(locationMarker: "2️⃣", message: "multi-line string literal closing delimiter must begin on a new line"), + DiagnosticSpec(locationMarker: "1️⃣", message: "multi-line string literal content must begin on a new line", fixIts: ["insert newline"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "multi-line string literal closing delimiter must begin on a new line", fixIts: ["insert newline"]), ], fixedSource: ###""" let _ = ##""" @@ -104,7 +104,7 @@ final class RawStringErrorsTests: XCTestCase { """# """##, diagnostics: [ - DiagnosticSpec(message: "multi-line string literal content must begin on a new line") + DiagnosticSpec(message: "multi-line string literal content must begin on a new line", fixIts: ["insert newline"]) ], fixedSource: ##""" let _ = #""" @@ -121,7 +121,7 @@ final class RawStringErrorsTests: XCTestCase { """### """####, diagnostics: [ - DiagnosticSpec(message: "multi-line string literal content must begin on a new line") + DiagnosticSpec(message: "multi-line string literal content must begin on a new line", fixIts: ["insert newline"]) ], fixedSource: ####""" let _ = ###""" diff --git a/Tests/SwiftParserTest/translated/RecoveryTests.swift b/Tests/SwiftParserTest/translated/RecoveryTests.swift index 124423d43aa..ca8872a0277 100644 --- a/Tests/SwiftParserTest/translated/RecoveryTests.swift +++ b/Tests/SwiftParserTest/translated/RecoveryTests.swift @@ -77,10 +77,10 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '>' to end generic argument clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '>' to end generic argument clause", fixIts: ["insert '>'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), DiagnosticSpec(locationMarker: "3️⃣", message: "unexpected code 'this greater: >' in subscript"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected expression after operator"), + DiagnosticSpec(locationMarker: "4️⃣", message: "expected expression after operator", fixIts: ["insert expression"]), DiagnosticSpec(locationMarker: "4️⃣", message: "unexpected code in function"), ] ) @@ -118,7 +118,7 @@ final class RecoveryTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected brace before function"), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), ] ) } @@ -167,7 +167,7 @@ final class RecoveryTests: XCTestCase { if1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected expression and body in 'if' statement") + DiagnosticSpec(message: "expected expression and body in 'if' statement", fixIts: ["insert expression and body"]) ] ) } @@ -260,7 +260,7 @@ final class RecoveryTests: XCTestCase { while1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected expression and code block in 'while' statement") + DiagnosticSpec(message: "expected expression and code block in 'while' statement", fixIts: ["insert expression and code block"]) ] ) } @@ -341,7 +341,7 @@ final class RecoveryTests: XCTestCase { } while1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected condition in 'repeat' statement") + DiagnosticSpec(message: "expected condition in 'repeat' statement", fixIts: ["insert condition"]) ] ) } @@ -378,7 +378,7 @@ final class RecoveryTests: XCTestCase { }1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected 'while' and condition in 'repeat' statement") + DiagnosticSpec(message: "expected 'while' and condition in 'repeat' statement", fixIts: ["insert 'while' and condition"]) ] ) } @@ -390,8 +390,8 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected pattern, 'in', and expression in 'for' statement"), - DiagnosticSpec(message: "unexpected ';' separator"), + DiagnosticSpec(message: "expected pattern, 'in', and expression in 'for' statement", fixIts: ["insert pattern, 'in', and expression"]), + DiagnosticSpec(message: "unexpected ';' separator", fixIts: ["remove ';'"]), ] ) } @@ -404,8 +404,8 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected pattern, 'in', and expression in 'for' statement"), - DiagnosticSpec(message: "unexpected ';' separator"), + DiagnosticSpec(message: "expected pattern, 'in', and expression in 'for' statement", fixIts: ["insert pattern, 'in', and expression"]), + DiagnosticSpec(message: "unexpected ';' separator", fixIts: ["remove ';'"]), ] ) } @@ -417,7 +417,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected pattern, 'in', and expression in 'for' statement"), + DiagnosticSpec(message: "expected pattern, 'in', and expression in 'for' statement", fixIts: ["insert pattern, 'in', and expression"]), DiagnosticSpec(message: "unexpected code '; true' in 'for' statement"), ] ) @@ -431,7 +431,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected 'in' and expression in 'for' statement"), + DiagnosticSpec(message: "expected 'in' and expression in 'for' statement", fixIts: ["insert 'in' and expression"]), DiagnosticSpec(message: "unexpected code '= 0; true' in 'for' statement"), ] ) @@ -443,7 +443,7 @@ final class RecoveryTests: XCTestCase { for1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected pattern, 'in', expression, and body in 'for' statement") + DiagnosticSpec(message: "expected pattern, 'in', expression, and body in 'for' statement", fixIts: ["insert pattern, 'in', expression, and body"]) ] ) } @@ -455,7 +455,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected pattern, 'in', and expression in 'for' statement") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected pattern, 'in', and expression in 'for' statement", fixIts: ["insert pattern, 'in', and expression"]) ] ) } @@ -468,7 +468,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected pattern, 'in', and expression in 'for' statement") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected pattern, 'in', and expression in 'for' statement", fixIts: ["insert pattern, 'in', and expression"]) ] ) } @@ -480,7 +480,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'in' and expression in 'for' statement") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'in' and expression in 'for' statement", fixIts: ["insert 'in' and expression"]) ] ) } @@ -492,7 +492,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'in' and expression in 'for' statement") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'in' and expression in 'for' statement", fixIts: ["insert 'in' and expression"]) ] ) } @@ -504,8 +504,8 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'in' cannot be used as an identifier here"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected 'in' and expression in 'for' statement"), + DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'in' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected 'in' and expression in 'for' statement", fixIts: ["insert 'in' and expression"]), ] ) } @@ -517,7 +517,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected pattern and 'in' in 'for' statement") + DiagnosticSpec(message: "expected pattern and 'in' in 'for' statement", fixIts: ["insert pattern and 'in'"]) ] ) } @@ -529,7 +529,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'for' cannot be used as an identifier here"), + DiagnosticSpec(locationMarker: "1️⃣", message: "keyword 'for' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]), DiagnosticSpec(locationMarker: "2️⃣", message: "expected Sequence expression for for-each loop"), ] ) @@ -580,9 +580,9 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected pattern, 'in', and expression in 'for' statement"), - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in 'for' statement"), - DiagnosticSpec(locationMarker: "2️⃣", message: "standalone ';' statements are not allowed"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected pattern, 'in', and expression in 'for' statement", fixIts: ["insert pattern, 'in', and expression"]), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in 'for' statement", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "standalone ';' statements are not allowed", fixIts: ["remove ';'"]), ] ) } @@ -593,7 +593,7 @@ final class RecoveryTests: XCTestCase { switch1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected expression and '{}' to end 'switch' statement") + DiagnosticSpec(message: "expected expression and '{}' to end 'switch' statement", fixIts: ["insert expression and '{}'"]) ] ) } @@ -605,7 +605,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression in 'switch' statement") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression in 'switch' statement", fixIts: ["insert expression"]) ] ) } @@ -618,7 +618,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression in 'switch' statement") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression in 'switch' statement", fixIts: ["insert expression"]) ] ) } @@ -660,7 +660,7 @@ final class RecoveryTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression in 'switch' statement"), - DiagnosticSpec(locationMarker: "2️⃣", message: "all statements inside a switch must be covered by a 'case' or 'default' label"), + DiagnosticSpec(locationMarker: "2️⃣", message: "all statements inside a switch must be covered by a 'case' or 'default' label", fixIts: ["insert label"]), DiagnosticSpec(locationMarker: "3️⃣", message: "'case' can only appear inside a 'switch' statement or 'enum' declaration"), ] ) @@ -675,8 +675,8 @@ final class RecoveryTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression in 'switch' statement"), - DiagnosticSpec(locationMarker: "2️⃣", message: "all statements inside a switch must be covered by a 'case' or 'default' label"), - DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "2️⃣", message: "all statements inside a switch must be covered by a 'case' or 'default' label", fixIts: ["insert label"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), DiagnosticSpec(locationMarker: "4️⃣", message: "'case' can only appear inside a 'switch' statement or 'enum' declaration"), ] ) @@ -689,7 +689,7 @@ final class RecoveryTests: XCTestCase { struct NoBracesStruct11️⃣() """, diagnostics: [ - DiagnosticSpec(message: "expected member block in struct") + DiagnosticSpec(message: "expected member block in struct", fixIts: ["insert member block"]) ] ) } @@ -703,16 +703,16 @@ final class RecoveryTests: XCTestCase { extension NoBracesStruct14️⃣() """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in enum"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in enum", fixIts: ["insert '{'"]), DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code '()' before class"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '{' in class"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '{' in class", fixIts: ["insert '{'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code '()' before protocol"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected '{' in protocol"), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected '{' in protocol", fixIts: ["insert '{'"]), DiagnosticSpec(locationMarker: "3️⃣", message: "unexpected code '()' before extension"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected member block in extension"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected '}' to end protocol"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected '}' to end class"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected '}' to end enum"), + DiagnosticSpec(locationMarker: "4️⃣", message: "expected member block in extension", fixIts: ["insert member block"]), + DiagnosticSpec(locationMarker: "4️⃣", message: "expected '}' to end protocol", fixIts: ["insert '}'"]), + DiagnosticSpec(locationMarker: "4️⃣", message: "expected '}' to end class", fixIts: ["insert '}'"]), + DiagnosticSpec(locationMarker: "4️⃣", message: "expected '}' to end enum", fixIts: ["insert '}'"]), ] ) } @@ -727,15 +727,15 @@ final class RecoveryTests: XCTestCase { extension NoBracesStruct25️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in struct"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '{' in enum"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected '{' in class"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected '{' in protocol"), - DiagnosticSpec(locationMarker: "5️⃣", message: "expected member block in extension"), - DiagnosticSpec(locationMarker: "5️⃣", message: "expected '}' to end protocol"), - DiagnosticSpec(locationMarker: "5️⃣", message: "expected '}' to end class"), - DiagnosticSpec(locationMarker: "5️⃣", message: "expected '}' to end enum"), - DiagnosticSpec(locationMarker: "5️⃣", message: "expected '}' to end struct"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in struct", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '{' in enum", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected '{' in class", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "4️⃣", message: "expected '{' in protocol", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "5️⃣", message: "expected member block in extension", fixIts: ["insert member block"]), + DiagnosticSpec(locationMarker: "5️⃣", message: "expected '}' to end protocol", fixIts: ["insert '}'"]), + DiagnosticSpec(locationMarker: "5️⃣", message: "expected '}' to end class", fixIts: ["insert '}'"]), + DiagnosticSpec(locationMarker: "5️⃣", message: "expected '}' to end enum", fixIts: ["insert '}'"]), + DiagnosticSpec(locationMarker: "5️⃣", message: "expected '}' to end struct", fixIts: ["insert '}'"]), ] ) } @@ -765,7 +765,6 @@ final class RecoveryTests: XCTestCase { line: line ) } - } func testRecovery60() { @@ -795,8 +794,16 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "found an unexpected second identifier in enum; is there an accidental break?", fixIts: ["join the identifiers together"]), - DiagnosticSpec(locationMarker: "2️⃣", message: "consecutive declarations on a line must be separated by ';'"), + DiagnosticSpec( + locationMarker: "1️⃣", + message: "found an unexpected second identifier in enum; is there an accidental break?", + fixIts: ["join the identifiers together"] + ), + DiagnosticSpec( + locationMarker: "2️⃣", + message: "consecutive declarations on a line must be separated by ';'", + fixIts: ["insert ';'"] + ), DiagnosticSpec(locationMarker: "3️⃣", message: "unexpected code 'a' before enum case"), ] ) @@ -814,10 +821,22 @@ final class RecoveryTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "found an unexpected second identifier in struct; is there an accidental break?", fixIts: ["join the identifiers together"]), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ':' in type annotation"), + DiagnosticSpec( + locationMarker: "1️⃣", + message: "found an unexpected second identifier in struct; is there an accidental break?", + fixIts: ["join the identifiers together"] + ), + DiagnosticSpec( + locationMarker: "2️⃣", + message: "expected ':' in type annotation", + fixIts: ["insert ':'"] + ), DiagnosticSpec(locationMarker: "3️⃣", message: #"unexpected code ': Int = ""' before function"#), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected ':' in type annotation"), + DiagnosticSpec( + locationMarker: "4️⃣", + message: "expected ':' in type annotation", + fixIts: ["insert ':'"] + ), ] ) } @@ -868,7 +887,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected type in type annotation") + DiagnosticSpec(message: "expected type in type annotation", fixIts: ["insert type"]) ] ) } @@ -882,7 +901,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected name in member type") + DiagnosticSpec(message: "expected name in member type", fixIts: ["insert name"]) ] ) } @@ -896,7 +915,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '>' to end generic argument clause") + DiagnosticSpec(message: "expected '>' to end generic argument clause", fixIts: ["insert '>'"]) ] ) } @@ -910,7 +929,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '>' to end generic argument clause") + DiagnosticSpec(message: "expected '>' to end generic argument clause", fixIts: ["insert '>'"]) ] ) } @@ -924,7 +943,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '>' to end generic argument clause") + DiagnosticSpec(message: "expected '>' to end generic argument clause", fixIts: ["insert '>'"]) ] ) } @@ -939,7 +958,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '>' to end generic argument clause", notes: [NoteSpec(message: "to match this opening '<'")]) + DiagnosticSpec(message: "expected '>' to end generic argument clause", notes: [NoteSpec(message: "to match this opening '<'")], fixIts: ["insert '>'"]) ] ) } @@ -953,8 +972,8 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected type in generic argument"), - DiagnosticSpec(message: "expected '>' to end generic argument clause"), + DiagnosticSpec(message: "expected type in generic argument", fixIts: ["insert type"]), + DiagnosticSpec(message: "expected '>' to end generic argument clause", fixIts: ["insert '>'"]), ] ) } @@ -968,7 +987,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected type in type composition") + DiagnosticSpec(message: "expected type in type composition", fixIts: ["insert type"]) ] ) } @@ -982,7 +1001,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected type in type composition") + DiagnosticSpec(message: "expected type in type composition", fixIts: ["insert type"]) ] ) } @@ -996,7 +1015,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected type in type composition") + DiagnosticSpec(message: "expected type in type composition", fixIts: ["insert type"]) ] ) } @@ -1007,7 +1026,7 @@ final class RecoveryTests: XCTestCase { func ErrorTypeInPattern4(_: FooProtocol & 1️⃣) { } """, diagnostics: [ - DiagnosticSpec(message: "expected type in type composition") + DiagnosticSpec(message: "expected type in type composition", fixIts: ["insert type"]) ] ) } @@ -1018,8 +1037,8 @@ final class RecoveryTests: XCTestCase { struct ErrorGenericParameterList1<1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected '>' to end generic parameter clause"), - DiagnosticSpec(message: "expected member block in struct"), + DiagnosticSpec(message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), + DiagnosticSpec(message: "expected member block in struct", fixIts: ["insert member block"]), ] ) } @@ -1030,9 +1049,9 @@ final class RecoveryTests: XCTestCase { struct ErrorGenericParameterList1' to end generic parameter clause"), - DiagnosticSpec(message: "expected member block in struct"), + DiagnosticSpec(message: "expected name in generic parameter", fixIts: ["insert name"]), + DiagnosticSpec(message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), + DiagnosticSpec(message: "expected member block in struct", fixIts: ["insert member block"]), ] ) } @@ -1043,8 +1062,8 @@ final class RecoveryTests: XCTestCase { struct ErrorGenericParameterList2' to end generic parameter clause"), - DiagnosticSpec(message: "expected member block in struct"), + DiagnosticSpec(message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), + DiagnosticSpec(message: "expected member block in struct", fixIts: ["insert member block"]), ] ) } @@ -1055,9 +1074,9 @@ final class RecoveryTests: XCTestCase { struct ErrorGenericParameterList3' to end generic parameter clause"), - DiagnosticSpec(message: "expected member block in struct"), + DiagnosticSpec(message: "expected generic parameter in generic parameter clause", fixIts: ["insert generic parameter"]), + DiagnosticSpec(message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), + DiagnosticSpec(message: "expected member block in struct", fixIts: ["insert member block"]), ] ) } @@ -1071,7 +1090,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '>' to end generic parameter clause") + DiagnosticSpec(message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]) ] ) } @@ -1085,7 +1104,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '>' to end generic parameter clause") + DiagnosticSpec(message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]) ] ) } @@ -1099,8 +1118,8 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected generic parameter in generic parameter clause"), - DiagnosticSpec(message: "expected '>' to end generic parameter clause"), + DiagnosticSpec(message: "expected generic parameter in generic parameter clause", fixIts: ["insert generic parameter"]), + DiagnosticSpec(message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), ] ) } @@ -1114,7 +1133,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected return type in function type") + DiagnosticSpec(message: "expected return type in function type", fixIts: ["insert return type"]) ] ) } @@ -1136,7 +1155,7 @@ final class RecoveryTests: XCTestCase { let a2: Set """, diagnostics: [ - DiagnosticSpec(message: "expected '>' to end generic argument clause"), + DiagnosticSpec(message: "expected '>' to end generic argument clause", fixIts: ["insert '>'"]), DiagnosticSpec(message: "extraneous code ']>' at top level"), ] ) @@ -1214,7 +1233,7 @@ final class RecoveryTests: XCTestCase { """, diagnostics: [ // TODO: Old parser expected error on line 2: unexpected ':' in type; did you mean to write a dictionary type?, Fix-It replacements: 11 - 11 = '[' - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive declarations on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive declarations on a line must be separated by ';'", fixIts: ["insert ';'"]), DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code ':' before variable"), // TODO: Old parser expected error on line 3: unexpected ':' in type; did you mean to write a dictionary type?, Fix-It replacements: 11 - 11 = '[' DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code ': Int]' before variable"), @@ -1239,8 +1258,8 @@ final class RecoveryTests: XCTestCase { 4️⃣} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end struct"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ']' to end array"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end struct", fixIts: ["insert '}'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ']' to end array", fixIts: ["insert ']'"]), // TODO: Old parser expected error on line 5: unexpected ']' in type; did you mean to write an array type?, Fix-It replacements: 17 - 17 = '[' DiagnosticSpec(locationMarker: "3️⃣", message: "unexpected code ']' in function"), DiagnosticSpec(locationMarker: "4️⃣", message: "extraneous brace at top level"), @@ -1260,8 +1279,8 @@ final class RecoveryTests: XCTestCase { diagnostics: [ // TODO: Old parser expected error on line 2: expected ']' in array type // TODO: Old parser expected note on line 2: to match this opening '[' - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end struct"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ']' to end array"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end struct", fixIts: ["insert '}'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ']' to end array", fixIts: ["insert ']'"]), DiagnosticSpec(locationMarker: "3️⃣", message: "extraneous brace at top level"), ] ) @@ -1324,7 +1343,7 @@ final class RecoveryTests: XCTestCase { 2️⃣} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end struct"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end struct", fixIts: ["insert '}'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "extraneous brace at top level"), ] ) @@ -1346,7 +1365,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression in variable") + DiagnosticSpec(message: "expected expression in variable", fixIts: ["insert expression"]) ] ) } @@ -1367,7 +1386,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected name in member access") + DiagnosticSpec(message: "expected name in member access", fixIts: ["insert name"]) ] ) } @@ -1381,7 +1400,7 @@ final class RecoveryTests: XCTestCase { """, diagnostics: [ // TODO: Old parser expected error on line 2: '.42' is not a valid floating point literal; it must be written '0.42', Fix-It replacements: 7 - 7 = '0' - DiagnosticSpec(message: "expected name in member access") + DiagnosticSpec(message: "expected name in member access", fixIts: ["insert name"]) ] ) } @@ -1424,7 +1443,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected name in member access") + DiagnosticSpec(message: "expected name in member access", fixIts: ["insert name"]) ] ) } @@ -1473,7 +1492,7 @@ final class RecoveryTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'func' in function"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'func' in function", fixIts: ["insert 'func'"]), DiagnosticSpec(locationMarker: "2️⃣", message: #"unexpected code '"No one else was in the room where it happened"' in parameter clause"#), ] ) @@ -1487,7 +1506,7 @@ final class RecoveryTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'func' in function"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'func' in function", fixIts: ["insert 'func'"]), DiagnosticSpec(locationMarker: "2️⃣", message: #"unexpected code '"The room where it happened, the room where it happened"' in parameter clause"#), ] ) @@ -1612,10 +1631,10 @@ final class RecoveryTests: XCTestCase { """, diagnostics: [ // TODO: Old parser expected error on line 1: expected ':' to begin inheritance clause, Fix-It replacements: 30 - 31 = ': ' - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in class"), - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'var' in variable"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end tuple pattern"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected '}' to end class"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in class", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'var' in variable", fixIts: ["insert 'var'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end tuple pattern", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected '}' to end class", fixIts: ["insert '}'"]), ] ) } @@ -1627,10 +1646,10 @@ final class RecoveryTests: XCTestCase { """, diagnostics: [ // TODO: Old parser expected error on line 1: expected ':' to begin inheritance clause, Fix-It replacements: 33 - 34 = ': ' - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in class"), - DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'var' in variable"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end tuple pattern"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end class"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in class", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected 'var' in variable", fixIts: ["insert 'var'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end tuple pattern", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end class", fixIts: ["insert '}'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "extraneous code 'where T:AnyObject {}' at top level"), ] ) @@ -1655,7 +1674,7 @@ final class RecoveryTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(message: "expected ':' and type in parameter"), + DiagnosticSpec(message: "expected ':' and type in parameter", fixIts: ["insert ':' and type"]), DiagnosticSpec(message: #"unexpected code '._core.count != 0, "Can't form a Character from an empty String"' in parameter clause"#), ] ) @@ -1670,7 +1689,7 @@ final class RecoveryTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(message: "expected ':' and type in parameter"), + DiagnosticSpec(message: "expected ':' and type in parameter", fixIts: ["insert ':' and type"]), DiagnosticSpec(message: #"unexpected code '._core.count ?= 0, "Can't form a Character from an empty String"' in parameter clause"#), ] ) @@ -1692,7 +1711,7 @@ final class RecoveryTests: XCTestCase { func foo1(bar1️⃣!=baz) {} """, diagnostics: [ - DiagnosticSpec(message: "expected ':' and type in parameter"), + DiagnosticSpec(message: "expected ':' and type in parameter", fixIts: ["insert ':' and type"]), DiagnosticSpec(message: "unexpected code '!=baz' in parameter clause"), ] ) @@ -1704,7 +1723,7 @@ final class RecoveryTests: XCTestCase { func foo2(bar1️⃣! = baz) {} """, diagnostics: [ - DiagnosticSpec(message: "expected ':' and type in parameter"), + DiagnosticSpec(message: "expected ':' and type in parameter", fixIts: ["insert ':' and type"]), DiagnosticSpec(message: "unexpected code '! = baz' in parameter clause"), ] ) @@ -1720,8 +1739,8 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '>' to end generic parameter clause"), - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in class"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in class", fixIts: ["insert '{'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code '> {}' in 'switch' statement"), ] ) @@ -1738,10 +1757,10 @@ final class RecoveryTests: XCTestCase { #endif """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected ')' to end parameter clause"), - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end struct"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end struct", fixIts: ["insert '}'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code ') -> Int {}' in closure"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected ']' to end array"), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected ']' to end array", fixIts: ["insert ']'"]), DiagnosticSpec(locationMarker: "3️⃣", message: "unexpected brace in conditional compilation block"), ] ) @@ -1757,8 +1776,8 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '>' to end generic parameter clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end parameter clause"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '>' to end generic parameter clause", fixIts: ["insert '>'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), DiagnosticSpec(locationMarker: "3️⃣", message: "unexpected code ')}' before struct"), DiagnosticSpec(locationMarker: "4️⃣", message: "initializers cannot have a name", fixIts: ["remove 'x'"]), ] @@ -1827,8 +1846,8 @@ final class RecoveryTests: XCTestCase { init 1️⃣c d: Int 2️⃣{} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start parameter clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end parameter clause"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start parameter clause", fixIts: ["insert '('"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), ] ) } @@ -1856,9 +1875,9 @@ final class RecoveryTests: XCTestCase { """#, diagnostics: [ // TODO: Old parser expected error on line 4: expected ',' joining parts of a multi-clause condition, Fix-It replacements: 15 - 21 = ',' - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in 'if' statement"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in 'if' statement", fixIts: ["insert '{'"]), DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code 'where y == 0,' before variable"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end 'if' statement"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end 'if' statement", fixIts: ["insert '}'"]), ] ) } @@ -1940,7 +1959,7 @@ final class RecoveryTests: XCTestCase { let curlyQuotes1 = 1️⃣“hello world!” """, diagnostics: [ - DiagnosticSpec(message: #"unicode curly quote found; use '"' instead"#) + DiagnosticSpec(message: #"unicode curly quote found; use '"' instead"#, fixIts: [#"replace curly quotes with '"'"#]) ], fixedSource: """ let curlyQuotes1 = "hello world!" @@ -1954,7 +1973,7 @@ final class RecoveryTests: XCTestCase { let curlyQuotes2 = 1️⃣“hello world!" """#, diagnostics: [ - DiagnosticSpec(message: #"unicode curly quote found; use '"' instead"#) + DiagnosticSpec(message: #"unicode curly quote found; use '"' instead"#, fixIts: [#"replace curly quotes with '"'"#]) ], fixedSource: #""" let curlyQuotes2 = "hello world!" @@ -2117,8 +2136,8 @@ final class RecoveryTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "'·' is considered an identifier and must not appear within an operator name"), - DiagnosticSpec(locationMarker: "2️⃣", message: "operator should not be declared with body"), - DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "2️⃣", message: "operator should not be declared with body", fixIts: ["remove operator body"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), DiagnosticSpec(locationMarker: "4️⃣", message: "extraneous brace at top level"), ] ) @@ -2130,7 +2149,7 @@ final class RecoveryTests: XCTestCase { infix operator -1️⃣@-class Recover1 {} """, diagnostics: [ - DiagnosticSpec(message: "'@-class' is not allowed in operator names") + DiagnosticSpec(message: "'@-class' is not allowed in operator names", fixIts: ["remove '@-class'"]) ] ) } @@ -2141,7 +2160,7 @@ final class RecoveryTests: XCTestCase { prefix operator -1️⃣фф--class Recover2 {} """, diagnostics: [ - DiagnosticSpec(message: "'фф--class' is not allowed in operator names") + DiagnosticSpec(message: "'фф--class' is not allowed in operator names", fixIts: ["remove 'фф--class'"]) ] ) } @@ -2158,7 +2177,7 @@ final class RecoveryTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(message: "expected ']' to end subscript") + DiagnosticSpec(message: "expected ']' to end subscript", fixIts: ["insert ']'"]) ] ) } @@ -2175,9 +2194,9 @@ final class RecoveryTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "extraneous whitespace after '.' is not permitted"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected name in member access"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected name in member access"), + DiagnosticSpec(locationMarker: "1️⃣", message: "extraneous whitespace after '.' is not permitted", fixIts: ["remove whitespace"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected name in member access", fixIts: ["insert name"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected name in member access", fixIts: ["insert name"]), ] ) } @@ -2191,7 +2210,7 @@ final class RecoveryTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(message: "expected name in member access") + DiagnosticSpec(message: "expected name in member access", fixIts: ["insert name"]) ] ) } @@ -2235,7 +2254,7 @@ final class RecoveryTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end function"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '}' to end function", fixIts: ["insert '}'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "extraneous code at top level"), ] ) @@ -2249,9 +2268,9 @@ final class RecoveryTests: XCTestCase { }2️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression, '=', and expression in pattern matching"), - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in 'if' statement"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end function"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression, '=', and expression in pattern matching", fixIts: ["insert expression, '=', and expression"]), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in 'if' statement", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end function", fixIts: ["insert '}'"]), ] ) } @@ -2265,7 +2284,7 @@ final class RecoveryTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' or 'if' after 'else'"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end function"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end function", fixIts: ["insert '}'"]), ] ) } diff --git a/Tests/SwiftParserTest/translated/RegexParseEndOfBufferTests.swift b/Tests/SwiftParserTest/translated/RegexParseEndOfBufferTests.swift index 5929db521f2..18cd41a31ae 100644 --- a/Tests/SwiftParserTest/translated/RegexParseEndOfBufferTests.swift +++ b/Tests/SwiftParserTest/translated/RegexParseEndOfBufferTests.swift @@ -19,7 +19,7 @@ final class RegexParseEndOfBufferTests: XCTestCase { assertParse( "var unterminated = #/(xy1️⃣", diagnostics: [ - DiagnosticSpec(message: "expected '/#' to end regex literal") + DiagnosticSpec(message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/RegexParseErrorTests.swift b/Tests/SwiftParserTest/translated/RegexParseErrorTests.swift index 92c102d8249..228d1b0ccb1 100644 --- a/Tests/SwiftParserTest/translated/RegexParseErrorTests.swift +++ b/Tests/SwiftParserTest/translated/RegexParseErrorTests.swift @@ -53,7 +53,7 @@ final class RegexParseErrorTests: XCTestCase { _ = #/\\/''/1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '#' to end regex literal") + DiagnosticSpec(message: "expected '#' to end regex literal", fixIts: ["insert '#'"]) ] ) } @@ -64,7 +64,7 @@ final class RegexParseErrorTests: XCTestCase { _ = #/\|1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: "expected '/#' to end regex literal") + DiagnosticSpec(message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]) ] ) } @@ -75,7 +75,7 @@ final class RegexParseErrorTests: XCTestCase { _ = #//1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected '#' to end regex literal") + DiagnosticSpec(message: "expected '#' to end regex literal", fixIts: ["insert '#'"]) ] ) } @@ -86,7 +86,7 @@ final class RegexParseErrorTests: XCTestCase { _ = #/xy1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected '/#' to end regex literal") + DiagnosticSpec(message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]) ] ) } @@ -131,7 +131,7 @@ final class RegexParseErrorTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '/#' to end regex literal") + DiagnosticSpec(message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]) ] ) } @@ -153,8 +153,8 @@ final class RegexParseErrorTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected root in key path"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected expression after operator"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected root in key path", fixIts: ["insert root"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected expression after operator", fixIts: ["insert expression"]), ] ) } @@ -168,8 +168,8 @@ final class RegexParseErrorTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '/#' to end regex literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '/#' to end regex literal", fixIts: ["insert '/#'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier in macro expansion", fixIts: ["insert identifier"]), ] ) } diff --git a/Tests/SwiftParserTest/translated/SelfRebindingTests.swift b/Tests/SwiftParserTest/translated/SelfRebindingTests.swift index 92d982221ec..2e9cbf9d48f 100644 --- a/Tests/SwiftParserTest/translated/SelfRebindingTests.swift +++ b/Tests/SwiftParserTest/translated/SelfRebindingTests.swift @@ -63,7 +63,7 @@ final class SelfRebindingTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "keyword 'self' cannot be used as an identifier here") + DiagnosticSpec(message: "keyword 'self' cannot be used as an identifier here", fixIts: ["if this name is unavoidable, use backticks to escape it"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/StringLiteralEofTests.swift b/Tests/SwiftParserTest/translated/StringLiteralEofTests.swift index 45b4e5bb6c2..ea10d0e065b 100644 --- a/Tests/SwiftParserTest/translated/StringLiteralEofTests.swift +++ b/Tests/SwiftParserTest/translated/StringLiteralEofTests.swift @@ -22,8 +22,8 @@ final class StringLiteralEofTests: XCTestCase { _ = "foo\(1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: "expected value and ')' in string literal"), - DiagnosticSpec(message: #"expected '"' to end string literal"#), + DiagnosticSpec(message: "expected value and ')' in string literal", fixIts: ["insert value and ')'"]), + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -35,9 +35,21 @@ final class StringLiteralEofTests: XCTestCase { _ = 9️⃣"foo\8️⃣(7️⃣"bar1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: #"expected '"' to end string literal"#, notes: [NoteSpec(locationMarker: "7️⃣", message: #"to match this opening '"'"#)]), - DiagnosticSpec(message: #"expected ')' in string literal"#, notes: [NoteSpec(locationMarker: "8️⃣", message: "to match this opening '('")]), - DiagnosticSpec(message: #"expected '"' to end string literal"#, notes: [NoteSpec(locationMarker: "9️⃣", message: #"to match this opening '"'"#)]), + DiagnosticSpec( + message: #"expected '"' to end string literal"#, + notes: [NoteSpec(locationMarker: "7️⃣", message: #"to match this opening '"'"#)], + fixIts: [#"insert '"'"#] + ), + DiagnosticSpec( + message: #"expected ')' in string literal"#, + notes: [NoteSpec(locationMarker: "8️⃣", message: "to match this opening '('")], + fixIts: ["insert ')'"] + ), + DiagnosticSpec( + message: #"expected '"' to end string literal"#, + notes: [NoteSpec(locationMarker: "9️⃣", message: #"to match this opening '"'"#)], + fixIts: [#"insert '"'"#] + ), ], fixedSource: ##""" _ = "foo\("bar")" @@ -52,7 +64,7 @@ final class StringLiteralEofTests: XCTestCase { """##, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "invalid escape sequence in literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -65,7 +77,7 @@ final class StringLiteralEofTests: XCTestCase { """##, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "invalid escape sequence in literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -78,7 +90,7 @@ final class StringLiteralEofTests: XCTestCase { foo1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: #"expected '"""' to end string literal"#) + DiagnosticSpec(message: #"expected '"""' to end string literal"#, fixIts: [#"insert '"""'"#]) ] ) } @@ -92,8 +104,8 @@ final class StringLiteralEofTests: XCTestCase { \(1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: "expected value and ')' in string literal"), - DiagnosticSpec(message: #"expected '"""' to end string literal"#), + DiagnosticSpec(message: "expected value and ')' in string literal", fixIts: ["insert value and ')'"]), + DiagnosticSpec(message: #"expected '"""' to end string literal"#, fixIts: [#"insert '"""'"#]), ], fixedSource: ##""" _ = """ @@ -113,9 +125,9 @@ final class StringLiteralEofTests: XCTestCase { \("bar1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: #"expected '"' to end string literal"#), - DiagnosticSpec(message: "expected ')' in string literal"), - DiagnosticSpec(message: #"expected '"""' to end string literal"#), + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), + DiagnosticSpec(message: "expected ')' in string literal", fixIts: ["insert ')'"]), + DiagnosticSpec(message: #"expected '"""' to end string literal"#, fixIts: [#"insert '"""'"#]), ] ) } @@ -128,10 +140,10 @@ final class StringLiteralEofTests: XCTestCase { 2️⃣baz3️⃣ """##, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "1️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), DiagnosticSpec(locationMarker: "2️⃣", message: "unexpected code 'baz' in string literal"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' in string literal"), - DiagnosticSpec(locationMarker: "3️⃣", message: #"expected '"""' to end string literal"#), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' in string literal", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "3️⃣", message: #"expected '"""' to end string literal"#, fixIts: [#"insert '"""'"#]), ] ) } diff --git a/Tests/SwiftParserTest/translated/SubscriptingTests.swift b/Tests/SwiftParserTest/translated/SubscriptingTests.swift index a0a98cdadc7..2b7b1c67d7f 100644 --- a/Tests/SwiftParserTest/translated/SubscriptingTests.swift +++ b/Tests/SwiftParserTest/translated/SubscriptingTests.swift @@ -200,11 +200,11 @@ final class SubscriptingTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start parameter clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '(' to start function type"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' in function type"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected ')' to end parameter clause"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected '->' and return type in subscript"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start parameter clause", fixIts: ["insert '('"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '(' to start function type", fixIts: ["insert '('"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' in function type", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "4️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "4️⃣", message: "expected '->' and return type in subscript", fixIts: ["insert '->' and return type"]), ], fixedSource: """ struct A0 { @@ -234,7 +234,7 @@ final class SubscriptingTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected parameter clause in subscript") + DiagnosticSpec(message: "expected parameter clause in subscript", fixIts: ["insert parameter clause"]) ] ) } @@ -255,7 +255,7 @@ final class SubscriptingTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '->' in subscript") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '->' in subscript", fixIts: ["insert '->'"]) ] ) } @@ -276,7 +276,7 @@ final class SubscriptingTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected return type in subscript") + DiagnosticSpec(message: "expected return type in subscript", fixIts: ["insert return type"]) ] ) } @@ -294,7 +294,7 @@ final class SubscriptingTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '->' and return type in subscript") + DiagnosticSpec(message: "expected '->' and return type in subscript", fixIts: ["insert '->' and return type"]) ] ) } @@ -311,7 +311,7 @@ final class SubscriptingTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected '->' and return type in subscript") + DiagnosticSpec(message: "expected '->' and return type in subscript", fixIts: ["insert '->' and return type"]) ] ) } @@ -385,8 +385,8 @@ final class SubscriptingTests: XCTestCase { }2️⃣ """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in subscript"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end struct"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{' in subscript", fixIts: ["insert '{'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '}' to end struct", fixIts: ["insert '}'"]), ] ) } @@ -452,11 +452,11 @@ final class SubscriptingTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start parameter clause"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected '(' to start function type"), - DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' in function type"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected ')' to end parameter clause"), - DiagnosticSpec(locationMarker: "4️⃣", message: "expected '->' and return type in subscript"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start parameter clause", fixIts: ["insert '('"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected '(' to start function type", fixIts: ["insert '('"]), + DiagnosticSpec(locationMarker: "3️⃣", message: "expected ')' in function type", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "4️⃣", message: "expected ')' to end parameter clause", fixIts: ["insert ')'"]), + DiagnosticSpec(locationMarker: "4️⃣", message: "expected '->' and return type in subscript", fixIts: ["insert '->' and return type"]), ], fixedSource: """ struct A11 { diff --git a/Tests/SwiftParserTest/translated/SuperTests.swift b/Tests/SwiftParserTest/translated/SuperTests.swift index e0e28909f44..2d19b54e0a5 100644 --- a/Tests/SwiftParserTest/translated/SuperTests.swift +++ b/Tests/SwiftParserTest/translated/SuperTests.swift @@ -115,7 +115,7 @@ final class SuperTests: XCTestCase { } """#, diagnostics: [ - DiagnosticSpec(message: "expected name in member access") + DiagnosticSpec(message: "expected name in member access", fixIts: ["insert name"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/SwitchIncompleteTests.swift b/Tests/SwiftParserTest/translated/SwitchIncompleteTests.swift index eff89918f51..80bbf194d6d 100644 --- a/Tests/SwiftParserTest/translated/SwitchIncompleteTests.swift +++ b/Tests/SwiftParserTest/translated/SwitchIncompleteTests.swift @@ -16,10 +16,10 @@ import XCTest final class SwitchIncompleteTests: XCTestCase { func testSwitchIncomplete1() { + // Incomplete switch was parsing to an AST that + // triggered an assertion failure. assertParse( """ - // Incomplete switch was parsing to an AST that - // triggered an assertion failure. switch 1 ℹ️{ case 1:1️⃣ """, @@ -28,10 +28,10 @@ final class SwitchIncompleteTests: XCTestCase { message: "expected '}' to end 'switch' statement", notes: [ NoteSpec(message: "to match this opening '{'") - ] + ], + fixIts: ["insert '}'"] ) ] ) } - } diff --git a/Tests/SwiftParserTest/translated/SwitchTests.swift b/Tests/SwiftParserTest/translated/SwitchTests.swift index 5e6e2e1b120..48d22e636c6 100644 --- a/Tests/SwiftParserTest/translated/SwitchTests.swift +++ b/Tests/SwiftParserTest/translated/SwitchTests.swift @@ -33,8 +33,8 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression and '{}' to end 'switch' statement"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier and function signature in function"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected expression and '{}' to end 'switch' statement", fixIts: ["insert expression and '{}'"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected identifier and function signature in function", fixIts: ["insert identifier and function signature"]), ] ) } @@ -47,7 +47,7 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{}' in 'switch' statement") + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '{}' in 'switch' statement", fixIts: ["insert '{}'"]) ] ) } @@ -62,7 +62,7 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression and ':' in switch case") + DiagnosticSpec(message: "expected expression and ':' in switch case", fixIts: ["insert expression and ':'"]) ] ) } @@ -77,8 +77,8 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected expression in 'where' clause"), - DiagnosticSpec(message: "expected ':' in switch case"), + DiagnosticSpec(message: "expected expression in 'where' clause", fixIts: ["insert expression"]), + DiagnosticSpec(message: "expected ':' in switch case", fixIts: ["insert ':'"]), ] ) } @@ -93,7 +93,7 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected ':' in switch case") + DiagnosticSpec(message: "expected ':' in switch case", fixIts: ["insert ':'"]) ] ) } @@ -108,7 +108,7 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected ':' in switch case") + DiagnosticSpec(message: "expected ':' in switch case", fixIts: ["insert ':'"]) ] ) } @@ -250,7 +250,7 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "all statements inside a switch must be covered by a 'case' or 'default' label") + DiagnosticSpec(message: "all statements inside a switch must be covered by a 'case' or 'default' label", fixIts: ["insert label"]) ] ) } @@ -299,7 +299,7 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "all statements inside a switch must be covered by a 'case' or 'default' label") + DiagnosticSpec(message: "all statements inside a switch must be covered by a 'case' or 'default' label", fixIts: ["insert label"]) ] ) } @@ -313,7 +313,7 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "all statements inside a switch must be covered by a 'case' or 'default' label") + DiagnosticSpec(message: "all statements inside a switch must be covered by a 'case' or 'default' label", fixIts: ["insert label"]) ] ) } @@ -1190,7 +1190,7 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected ':' in switch case") + DiagnosticSpec(message: "expected ':' in switch case", fixIts: ["insert ':'"]) ] ) } @@ -1207,7 +1207,7 @@ final class SwitchTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "expected label in switch case") + DiagnosticSpec(message: "expected label in switch case", fixIts: ["insert label"]) ] ) } @@ -1229,7 +1229,8 @@ final class SwitchTests: XCTestCase { message: "expected ']' to end array", notes: [ NoteSpec(message: "to match this opening '['") - ] + ], + fixIts: ["insert ']'"] ) ] ) diff --git a/Tests/SwiftParserTest/translated/ToplevelLibraryTests.swift b/Tests/SwiftParserTest/translated/ToplevelLibraryTests.swift index 426f39fb098..e24d70fa8c9 100644 --- a/Tests/SwiftParserTest/translated/ToplevelLibraryTests.swift +++ b/Tests/SwiftParserTest/translated/ToplevelLibraryTests.swift @@ -43,7 +43,7 @@ final class ToplevelLibraryTests: XCTestCase { for i1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected 'in', expression, and body in 'for' statement") + DiagnosticSpec(message: "expected 'in', expression, and body in 'for' statement", fixIts: ["insert 'in', expression, and body"]) ], fixedSource: """ for i in <#expression#> {} diff --git a/Tests/SwiftParserTest/translated/TrailingClosuresTests.swift b/Tests/SwiftParserTest/translated/TrailingClosuresTests.swift index 91b64277098..4acd9591066 100644 --- a/Tests/SwiftParserTest/translated/TrailingClosuresTests.swift +++ b/Tests/SwiftParserTest/translated/TrailingClosuresTests.swift @@ -210,7 +210,7 @@ final class TrailingClosuresTests: XCTestCase { _ = produce { 2 } `default`: { 3 } """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'"), + DiagnosticSpec(locationMarker: "1️⃣", message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]), DiagnosticSpec(locationMarker: "2️⃣", message: "'default' label can only appear inside a 'switch' statement"), ] ) diff --git a/Tests/SwiftParserTest/translated/TrailingSemiTests.swift b/Tests/SwiftParserTest/translated/TrailingSemiTests.swift index 1143cb45f69..b27aab489ac 100644 --- a/Tests/SwiftParserTest/translated/TrailingSemiTests.swift +++ b/Tests/SwiftParserTest/translated/TrailingSemiTests.swift @@ -83,7 +83,7 @@ final class TrailingSemiTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "consecutive declarations on a line must be separated by ';'") + DiagnosticSpec(message: "consecutive declarations on a line must be separated by ';'", fixIts: ["insert ';'"]) ] ) } @@ -106,7 +106,7 @@ final class TrailingSemiTests: XCTestCase { let x = 5;1️⃣; """, diagnostics: [ - DiagnosticSpec(message: "unexpected ';' separator") + DiagnosticSpec(message: "unexpected ';' separator", fixIts: ["remove ';'"]) ], fixedSource: "let x = 5;" ) @@ -152,7 +152,7 @@ final class TrailingSemiTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "consecutive declarations on a line must be separated by ';'") + DiagnosticSpec(message: "consecutive declarations on a line must be separated by ';'", fixIts: ["insert ';'"]) ], fixedSource: """ struct X { @@ -174,7 +174,7 @@ final class TrailingSemiTests: XCTestCase { } """, diagnostics: [ - DiagnosticSpec(message: "consecutive statements on a line must be separated by ';'") + DiagnosticSpec(message: "consecutive statements on a line must be separated by ';'", fixIts: ["insert ';'"]) ], fixedSource: """ func foo() { diff --git a/Tests/SwiftParserTest/translated/TryTests.swift b/Tests/SwiftParserTest/translated/TryTests.swift index 414df6fa7f9..12893c1ce8b 100644 --- a/Tests/SwiftParserTest/translated/TryTests.swift +++ b/Tests/SwiftParserTest/translated/TryTests.swift @@ -248,7 +248,7 @@ final class TryTests: XCTestCase { func method() {} """, diagnostics: [ - DiagnosticSpec(message: "expected expression after 'try'") + DiagnosticSpec(message: "expected expression after 'try'", fixIts: ["insert expression"]) ] ) } diff --git a/Tests/SwiftParserTest/translated/TypeExprTests.swift b/Tests/SwiftParserTest/translated/TypeExprTests.swift index 51a210f4fa2..c9377870ce7 100644 --- a/Tests/SwiftParserTest/translated/TypeExprTests.swift +++ b/Tests/SwiftParserTest/translated/TypeExprTests.swift @@ -558,7 +558,7 @@ final class TypeExprTests: XCTestCase { let _ = [(Int) -> 1️⃣throws Int]() """, diagnostics: [ - DiagnosticSpec(message: "'throws' must preceed '->'") + DiagnosticSpec(message: "'throws' must preceed '->'", fixIts: ["move 'throws' in front of '->'"]) ], fixedSource: """ let _ = [(Int) throws -> Int]() @@ -572,7 +572,7 @@ final class TypeExprTests: XCTestCase { let _ = [Int throws 1️⃣Int](); """, diagnostics: [ - DiagnosticSpec(message: "expected '->' in array element") + DiagnosticSpec(message: "expected '->' in array element", fixIts: ["insert '->'"]) ] ) } @@ -702,8 +702,8 @@ final class TypeExprTests: XCTestCase { func takesVoid(f: 1️⃣Void 2️⃣-> ()) {} """, diagnostics: [ - DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start function type"), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' in function type"), + DiagnosticSpec(locationMarker: "1️⃣", message: "expected '(' to start function type", fixIts: ["insert '('"]), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected ')' in function type", fixIts: ["insert ')'"]), ] ) } diff --git a/Tests/SwiftParserTest/translated/TypealiasTests.swift b/Tests/SwiftParserTest/translated/TypealiasTests.swift index 12fd7af8408..42ac61c8f7f 100644 --- a/Tests/SwiftParserTest/translated/TypealiasTests.swift +++ b/Tests/SwiftParserTest/translated/TypealiasTests.swift @@ -54,7 +54,7 @@ final class TypealiasTests: XCTestCase { typealias Foo1 1️⃣: Int """, diagnostics: [ - DiagnosticSpec(message: "expected '=' in typealias declaration") + DiagnosticSpec(message: "expected '=' in typealias declaration", fixIts: ["replace ':' with '='"]) ], fixedSource: "typealias Foo1 = Int" ) @@ -66,7 +66,7 @@ final class TypealiasTests: XCTestCase { typealias Foo21️⃣: Int """, diagnostics: [ - DiagnosticSpec(message: "expected '=' in typealias declaration") + DiagnosticSpec(message: "expected '=' in typealias declaration", fixIts: ["replace ':' with '='"]) ], fixedSource: "typealias Foo2= Int" ) @@ -78,7 +78,7 @@ final class TypealiasTests: XCTestCase { typealias Foo3 1️⃣:Int """, diagnostics: [ - DiagnosticSpec(message: "expected '=' in typealias declaration") + DiagnosticSpec(message: "expected '=' in typealias declaration", fixIts: ["replace ':' with '='"]) ], fixedSource: "typealias Foo3 =Int" ) @@ -90,7 +90,7 @@ final class TypealiasTests: XCTestCase { typealias Foo41️⃣:/*comment*/Int """, diagnostics: [ - DiagnosticSpec(message: "expected '=' in typealias declaration") + DiagnosticSpec(message: "expected '=' in typealias declaration", fixIts: ["replace ':' with '='"]) ], fixedSource: "typealias Foo4=/*comment*/Int" ) @@ -102,7 +102,7 @@ final class TypealiasTests: XCTestCase { typealias Recovery11️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected '=' and type in typealias declaration") + DiagnosticSpec(message: "expected '=' and type in typealias declaration", fixIts: ["insert '=' and type"]) ] ) } @@ -114,7 +114,7 @@ final class TypealiasTests: XCTestCase { """, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "expected '=' in typealias declaration", fixIts: ["replace ':' with '='"]), - DiagnosticSpec(locationMarker: "2️⃣", message: "expected type in typealias declaration"), + DiagnosticSpec(locationMarker: "2️⃣", message: "expected type in typealias declaration", fixIts: ["insert type"]), ] ) } @@ -125,7 +125,7 @@ final class TypealiasTests: XCTestCase { typealias Recovery3 =1️⃣ """, diagnostics: [ - DiagnosticSpec(message: "expected type in typealias declaration") + DiagnosticSpec(message: "expected type in typealias declaration", fixIts: ["insert type"]) ] ) } @@ -159,7 +159,7 @@ final class TypealiasTests: XCTestCase { typealias Recovery6 = 1️⃣= """, diagnostics: [ - DiagnosticSpec(message: "expected type in typealias declaration"), + DiagnosticSpec(message: "expected type in typealias declaration", fixIts: ["insert type"]), DiagnosticSpec(message: "extraneous code '=' at top level"), ] ) diff --git a/Tests/SwiftParserTest/translated/UnclosedStringInterpolationTests.swift b/Tests/SwiftParserTest/translated/UnclosedStringInterpolationTests.swift index 6defd396454..43b729de7d6 100644 --- a/Tests/SwiftParserTest/translated/UnclosedStringInterpolationTests.swift +++ b/Tests/SwiftParserTest/translated/UnclosedStringInterpolationTests.swift @@ -29,8 +29,11 @@ final class UnclosedStringInterpolationTests: XCTestCase { _ = "mid == \(pete1️⃣" """##, diagnostics: [ - DiagnosticSpec(message: "expected ')' in string literal") - ] + DiagnosticSpec(message: "expected ')' in string literal", fixIts: ["insert ')'"]) + ], + fixedSource: ##""" + _ = "mid == \(pete)" + """## ) } @@ -40,9 +43,9 @@ final class UnclosedStringInterpolationTests: XCTestCase { let theGoat = "kanye \("1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: #"expected '"' to end string literal"#), - DiagnosticSpec(message: "expected ')' in string literal"), - DiagnosticSpec(message: #"expected '"' to end string literal"#), + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), + DiagnosticSpec(message: "expected ')' in string literal", fixIts: ["insert ')'"]), + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -53,7 +56,7 @@ final class UnclosedStringInterpolationTests: XCTestCase { let equation1 = "2 + 2 = \(2 + 21️⃣" """##, diagnostics: [ - DiagnosticSpec(message: "expected ')' in string literal") + DiagnosticSpec(message: "expected ')' in string literal", fixIts: ["insert ')'"]) ] ) } @@ -64,7 +67,7 @@ final class UnclosedStringInterpolationTests: XCTestCase { let s = "\(x1️⃣"; print(x) """##, diagnostics: [ - DiagnosticSpec(message: "expected ')' in string literal") + DiagnosticSpec(message: "expected ')' in string literal", fixIts: ["insert ')'"]) ] ) } @@ -76,7 +79,7 @@ final class UnclosedStringInterpolationTests: XCTestCase { """##, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code '; print(x' in string literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -87,8 +90,8 @@ final class UnclosedStringInterpolationTests: XCTestCase { let goatedAlbum = "The Life Of \("Pablo"1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: "expected ')' in string literal"), - DiagnosticSpec(message: #"expected '"' to end string literal"#), + DiagnosticSpec(message: "expected ')' in string literal", fixIts: ["insert ')'"]), + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -101,9 +104,9 @@ final class UnclosedStringInterpolationTests: XCTestCase { """1️⃣ """##, diagnostics: [ - DiagnosticSpec(message: #"expected '"""' to end string literal"#), - DiagnosticSpec(message: "expected ')' in string literal"), - DiagnosticSpec(message: #"expected '"""' to end string literal"#), + DiagnosticSpec(message: #"expected '"""' to end string literal"#, fixIts: [#"insert '"""'"#]), + DiagnosticSpec(message: "expected ')' in string literal", fixIts: ["insert ')'"]), + DiagnosticSpec(message: #"expected '"""' to end string literal"#, fixIts: [#"insert '"""'"#]), ] ) } @@ -115,7 +118,7 @@ final class UnclosedStringInterpolationTests: XCTestCase { """#, diagnostics: [ DiagnosticSpec(locationMarker: "1️⃣", message: "unexpected code 'H(' in string literal"), - DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#), + DiagnosticSpec(locationMarker: "2️⃣", message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) } @@ -126,9 +129,9 @@ final class UnclosedStringInterpolationTests: XCTestCase { "\("1️⃣ """#, diagnostics: [ - DiagnosticSpec(message: #"expected '"' to end string literal"#), - DiagnosticSpec(message: #"expected ')' in string literal"#), - DiagnosticSpec(message: #"expected '"' to end string literal"#), + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), + DiagnosticSpec(message: "expected ')' in string literal", fixIts: ["insert ')'"]), + DiagnosticSpec(message: #"expected '"' to end string literal"#, fixIts: [#"insert '"'"#]), ] ) }