@@ -646,51 +646,45 @@ final class LocalSwiftTests: XCTestCase {
646
646
}
647
647
648
648
func testMultiEditFixitCodeActionPrimary( ) async throws {
649
- // FIXME: Update this test to use different syntax to test multi-fixit diagnostics
650
- try XCTSkipIf ( true , " https://github.com/swiftlang/sourcekit-lsp/issues/1961 " )
651
-
652
- let testClient = try await TestSourceKitLSPClient ( capabilities: quickFixCapabilities, usePullDiagnostics: false )
653
- let url = URL ( fileURLWithPath: " / \( UUID ( ) ) /a.swift " )
654
- let uri = DocumentURI ( url)
655
-
656
- testClient. openDocument (
649
+ let project = try await IndexedSingleSwiftFileTestProject (
657
650
"""
658
- @available(*, introduced: 10, deprecated: 11)
659
- func foo() {}
651
+ func foo(a: Int, b: Int) {}
652
+ func test() {
653
+ foo(1️⃣1, 2️⃣2)
654
+ }
660
655
""" ,
661
- uri: uri
656
+ capabilities: quickFixCapabilities,
657
+ allowBuildFailure: true
662
658
)
663
-
664
- let diags = try await testClient . nextDiagnosticsNotification ( )
665
- XCTAssertEqual ( diags . diagnostics . count , 1 )
666
- let diagnostic = diags. diagnostics . first
659
+ let diags = try await project . testClient . send (
660
+ DocumentDiagnosticsRequest ( textDocument : TextDocumentIdentifier ( project . fileURI ) )
661
+ )
662
+ let diagnostic = try XCTUnwrap ( diags. fullReport ? . items . only )
667
663
668
664
let request = CodeActionRequest (
669
- range: Position ( line : 0 , utf16index : 1 ) ..< Position ( line : 0 , utf16index : 10 ) ,
665
+ range: diagnostic . range ,
670
666
context: CodeActionContext (
671
667
diagnostics: [ try XCTUnwrap ( diagnostic, " expected diagnostic to be available " ) ] ,
672
668
only: nil
673
669
) ,
674
- textDocument: TextDocumentIdentifier ( uri )
670
+ textDocument: TextDocumentIdentifier ( project . fileURI )
675
671
)
676
- let response = try await testClient. send ( request)
672
+ let response = try await project . testClient. send ( request)
677
673
678
- XCTAssertNotNil ( response)
679
674
guard case . codeActions( let codeActions) = response else {
680
675
XCTFail ( " Expected code actions as response " )
681
676
return
682
677
}
683
678
let quickFixes = codeActions. filter { $0. kind == . quickFix }
684
- XCTAssertEqual ( quickFixes. count, 1 )
685
- guard let fixit = quickFixes. first else { return }
679
+ let fixit = try XCTUnwrap ( quickFixes. only)
686
680
687
- XCTAssertEqual ( fixit. title, " Remove ': 10 '..." )
681
+ XCTAssertEqual ( fixit. title, " Insert 'a: '..." )
688
682
XCTAssertEqual ( fixit. diagnostics? . count, 1 )
689
683
XCTAssertEqual (
690
- fixit. edit? . changes ? [ uri ] ,
684
+ fixit. edit? . changes ? [ project . fileURI ] ,
691
685
[
692
- TextEdit ( range: Position ( line : 0 , utf16index : 24 ) ..< Position ( line : 0 , utf16index : 28 ) , newText: " " ) ,
693
- TextEdit ( range: Position ( line : 0 , utf16index : 40 ) ..< Position ( line : 0 , utf16index : 44 ) , newText: " " ) ,
686
+ TextEdit ( range: Range ( project . positions [ " 1️⃣ " ] ) , newText: " a: " ) ,
687
+ TextEdit ( range: Range ( project . positions [ " 2️⃣ " ] ) , newText: " b: " ) ,
694
688
]
695
689
)
696
690
}
0 commit comments