@@ -428,22 +428,23 @@ final class CodeActionTests: XCTestCase {
428428 let diags = try await testClient. nextDiagnosticsNotification ( )
429429 XCTAssertEqual ( diags. uri, uri)
430430 XCTAssertEqual ( diags. diagnostics. count, 1 )
431+ let diagPosition = try XCTUnwrap ( diags. diagnostics. only? . range. lowerBound)
431432
432- let textDocument = TextDocumentIdentifier ( uri)
433- let actionsRequest = CodeActionRequest (
434- range: positions [ " 1️⃣ " ] ..< positions [ " 1️⃣ " ] ,
435- context: . init( diagnostics: diags. diagnostics) ,
436- textDocument: textDocument
433+ let quickFixActionResult = try await testClient. send (
434+ CodeActionRequest (
435+ range: Range ( diagPosition) ,
436+ context: . init( diagnostics: diags. diagnostics) ,
437+ textDocument: TextDocumentIdentifier ( uri)
438+ )
437439 )
438- let actionResult = try await testClient. send ( actionsRequest)
439440
440- guard case . codeActions( let codeActions ) = actionResult else {
441+ guard case . codeActions( let quickFixCodeActions ) = quickFixActionResult else {
441442 return XCTFail ( " Expected code actions, not commands as a response " )
442443 }
443444
444445 // Check that the Fix-It action contains snippets
445446
446- guard let quickFixAction = codeActions . filter ( { $0. kind == . quickFix } ) . spm_only else {
447+ guard let quickFixAction = quickFixCodeActions . filter ( { $0. kind == . quickFix } ) . spm_only else {
447448 return XCTFail ( " Expected exactly one quick fix action " )
448449 }
449450 guard let change = quickFixAction. edit? . changes ? [ uri] ? . spm_only else {
@@ -461,7 +462,19 @@ final class CodeActionTests: XCTestCase {
461462 )
462463
463464 // Check that the refactor action contains snippets
464- guard let refactorAction = codeActions. filter ( { $0. kind == . refactor } ) . spm_only else {
465+ let refactorActionResult = try await testClient. send (
466+ CodeActionRequest (
467+ range: Range ( positions [ " 1️⃣ " ] ) ,
468+ context: . init( diagnostics: diags. diagnostics) ,
469+ textDocument: TextDocumentIdentifier ( uri)
470+ )
471+ )
472+
473+ guard case . codeActions( let refactorActions) = refactorActionResult else {
474+ return XCTFail ( " Expected code actions, not commands as a response " )
475+ }
476+
477+ guard let refactorAction = refactorActions. filter ( { $0. kind == . refactor } ) . spm_only else {
465478 return XCTFail ( " Expected exactly one refactor action " )
466479 }
467480 guard let command = refactorAction. command else {
0 commit comments