@@ -428,22 +428,23 @@ final class CodeActionTests: XCTestCase {
428
428
let diags = try await testClient. nextDiagnosticsNotification ( )
429
429
XCTAssertEqual ( diags. uri, uri)
430
430
XCTAssertEqual ( diags. diagnostics. count, 1 )
431
+ let diagPosition = try XCTUnwrap ( diags. diagnostics. only? . range. lowerBound)
431
432
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
+ )
437
439
)
438
- let actionResult = try await testClient. send ( actionsRequest)
439
440
440
- guard case . codeActions( let codeActions ) = actionResult else {
441
+ guard case . codeActions( let quickFixCodeActions ) = quickFixActionResult else {
441
442
return XCTFail ( " Expected code actions, not commands as a response " )
442
443
}
443
444
444
445
// Check that the Fix-It action contains snippets
445
446
446
- guard let quickFixAction = codeActions . filter ( { $0. kind == . quickFix } ) . spm_only else {
447
+ guard let quickFixAction = quickFixCodeActions . filter ( { $0. kind == . quickFix } ) . spm_only else {
447
448
return XCTFail ( " Expected exactly one quick fix action " )
448
449
}
449
450
guard let change = quickFixAction. edit? . changes ? [ uri] ? . spm_only else {
@@ -461,7 +462,19 @@ final class CodeActionTests: XCTestCase {
461
462
)
462
463
463
464
// 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 {
465
478
return XCTFail ( " Expected exactly one refactor action " )
466
479
}
467
480
guard let command = refactorAction. command else {
0 commit comments