@@ -31,13 +31,9 @@ final class PullDiagnosticsTests: XCTestCase {
3131 )
3232
3333 let report = try await testClient. send ( DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) ) )
34- guard case . full( let fullReport) = report else {
35- XCTFail ( " Expected full diagnostics report " )
36- return
37- }
3834
39- XCTAssertEqual ( fullReport. items. count, 1 )
40- let diagnostic = try XCTUnwrap ( fullReport. items. first)
35+ XCTAssertEqual ( report . fullReport? . items. count, 1 )
36+ let diagnostic = try XCTUnwrap ( report . fullReport? . items. first)
4137 XCTAssertEqual ( diagnostic. range, Position ( line: 1 , utf16index: 2 ) ..< Position ( line: 1 , utf16index: 9 ) )
4238 }
4339
@@ -64,11 +60,7 @@ final class PullDiagnosticsTests: XCTestCase {
6460 uri: uri
6561 )
6662 let report = try await testClient. send ( DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) ) )
67- guard case . full( let fullReport) = report else {
68- XCTFail ( " Expected full diagnostics report " )
69- return
70- }
71- let diagnostics = fullReport. items
63+ let diagnostics = try XCTUnwrap ( report. fullReport? . items)
7264
7365 XCTAssertEqual ( diagnostics. count, 1 )
7466 let diagnostic = try XCTUnwrap ( diagnostics. first)
@@ -128,17 +120,11 @@ final class PullDiagnosticsTests: XCTestCase {
128120 let report = try await project. testClient. send (
129121 DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) )
130122 )
131- guard case . full( let fullReport) = report else {
132- XCTFail ( " Expected full diagnostics report " )
133- return
134- }
135- XCTAssertEqual ( fullReport. items. count, 1 )
136- let diagnostic = try XCTUnwrap ( fullReport. items. first)
123+ let diagnostic = try XCTUnwrap ( report. fullReport? . items. only)
137124 XCTAssertEqual ( diagnostic. message, " expected '}' to end function " )
138125 XCTAssertEqual ( diagnostic. range, Range ( positions [ " 2️⃣ " ] ) )
139126
140- XCTAssertEqual ( diagnostic. relatedInformation? . count, 1 )
141- let note = try XCTUnwrap ( diagnostic. relatedInformation? . first)
127+ let note = try XCTUnwrap ( diagnostic. relatedInformation? . only)
142128 XCTAssertEqual ( note. message, " to match this opening '{' " )
143129 XCTAssertEqual ( note. location. range, positions [ " 1️⃣ " ] ..< positions [ " 2️⃣ " ] )
144130 }
@@ -161,11 +147,9 @@ final class PullDiagnosticsTests: XCTestCase {
161147 let beforeChangingFileA = try await project. testClient. send (
162148 DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( bUri) )
163149 )
164- guard case . full( let fullReportBeforeChangingFileA) = beforeChangingFileA else {
165- XCTFail ( " Expected full diagnostics report " )
166- return
167- }
168- XCTAssert ( fullReportBeforeChangingFileA. items. contains ( where: { $0. message == " Cannot find 'sayHello' in scope " } ) )
150+ XCTAssert (
151+ ( beforeChangingFileA. fullReport? . items ?? [ ] ) . contains ( where: { $0. message == " Cannot find 'sayHello' in scope " } )
152+ )
169153
170154 let diagnosticsRefreshRequestReceived = self . expectation ( description: " DiagnosticsRefreshRequest received " )
171155 project. testClient. handleSingleRequest { ( request: DiagnosticsRefreshRequest ) in
@@ -185,7 +169,7 @@ final class PullDiagnosticsTests: XCTestCase {
185169 let afterChangingFileA = try await project. testClient. send (
186170 DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( bUri) )
187171 )
188- XCTAssertEqual ( afterChangingFileA, . full ( RelatedFullDocumentDiagnosticReport ( items: [ ] ) ) )
172+ XCTAssertEqual ( afterChangingFileA. fullReport ? . items, [ ] )
189173 }
190174
191175 func testDiagnosticUpdatedAfterDependentModuleIsBuilt( ) async throws {
@@ -219,17 +203,14 @@ final class PullDiagnosticsTests: XCTestCase {
219203 let beforeBuilding = try await project. testClient. send (
220204 DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( bUri) )
221205 )
222- guard case . full( let fullReportBeforeBuilding) = beforeBuilding else {
223- XCTFail ( " Expected full diagnostics report " )
224- return
225- }
226206 XCTAssert (
227- fullReportBeforeBuilding . items. contains ( where: {
207+ ( beforeBuilding . fullReport ? . items ?? [ ] ) . contains ( where: {
228208 #if compiler(>=6.1)
229209 #warning("When we drop support for Swift 5.10 we no longer need to check for the Objective-C error message")
230210 #endif
231211 return $0. message == " No such module 'LibA' " || $0. message == " Could not build Objective-C module 'LibA' "
232- } )
212+ }
213+ )
233214 )
234215
235216 let diagnosticsRefreshRequestReceived = self . expectation ( description: " DiagnosticsRefreshRequest received " )
@@ -254,7 +235,7 @@ final class PullDiagnosticsTests: XCTestCase {
254235 let afterChangingFileA = try await project. testClient. send (
255236 DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( bUri) )
256237 )
257- XCTAssertEqual ( afterChangingFileA, . full ( RelatedFullDocumentDiagnosticReport ( items: [ ] ) ) )
238+ XCTAssertEqual ( afterChangingFileA. fullReport ? . items, [ ] )
258239 }
259240
260241 func testDiagnosticsWaitForDocumentToBePrepared( ) async throws {
@@ -307,7 +288,7 @@ final class PullDiagnosticsTests: XCTestCase {
307288 // but before receiving a reply. The async variant doesn't allow this distinction.
308289 let receivedDiagnostics = self . expectation ( description: " Received diagnostics " )
309290 project. testClient. send ( DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) ) ) { diagnostics in
310- XCTAssertEqual ( diagnostics. success, . full ( RelatedFullDocumentDiagnosticReport ( items: [ ] ) ) )
291+ XCTAssertEqual ( diagnostics. success? . fullReport ? . items, [ ] )
311292 receivedDiagnostics. fulfill ( )
312293 }
313294 diagnosticRequestSent. value = true
@@ -366,11 +347,7 @@ final class PullDiagnosticsTests: XCTestCase {
366347 let diagnostics = try await project. testClient. send (
367348 DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) )
368349 )
369- guard case . full( let diagnostics) = diagnostics else {
370- XCTFail ( " Expected full diagnostics report " )
371- return
372- }
373- let diagnostic = try XCTUnwrap ( diagnostics. items. only)
350+ let diagnostic = try XCTUnwrap ( diagnostics. fullReport? . items. only)
374351 let note = try XCTUnwrap ( diagnostic. relatedInformation? . only)
375352 XCTAssertEqual ( note. location, try project. location ( from: " 1️⃣ " , to: " 1️⃣ " , in: " FileA.swift " ) )
376353 }
0 commit comments