@@ -31,13 +31,9 @@ final class PullDiagnosticsTests: XCTestCase {
31
31
)
32
32
33
33
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
- }
38
34
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)
41
37
XCTAssertEqual ( diagnostic. range, Position ( line: 1 , utf16index: 2 ) ..< Position ( line: 1 , utf16index: 9 ) )
42
38
}
43
39
@@ -64,11 +60,7 @@ final class PullDiagnosticsTests: XCTestCase {
64
60
uri: uri
65
61
)
66
62
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)
72
64
73
65
XCTAssertEqual ( diagnostics. count, 1 )
74
66
let diagnostic = try XCTUnwrap ( diagnostics. first)
@@ -128,17 +120,11 @@ final class PullDiagnosticsTests: XCTestCase {
128
120
let report = try await project. testClient. send (
129
121
DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) )
130
122
)
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)
137
124
XCTAssertEqual ( diagnostic. message, " expected '}' to end function " )
138
125
XCTAssertEqual ( diagnostic. range, Range ( positions [ " 2️⃣ " ] ) )
139
126
140
- XCTAssertEqual ( diagnostic. relatedInformation? . count, 1 )
141
- let note = try XCTUnwrap ( diagnostic. relatedInformation? . first)
127
+ let note = try XCTUnwrap ( diagnostic. relatedInformation? . only)
142
128
XCTAssertEqual ( note. message, " to match this opening '{' " )
143
129
XCTAssertEqual ( note. location. range, positions [ " 1️⃣ " ] ..< positions [ " 2️⃣ " ] )
144
130
}
@@ -161,11 +147,9 @@ final class PullDiagnosticsTests: XCTestCase {
161
147
let beforeChangingFileA = try await project. testClient. send (
162
148
DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( bUri) )
163
149
)
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
+ )
169
153
170
154
let diagnosticsRefreshRequestReceived = self . expectation ( description: " DiagnosticsRefreshRequest received " )
171
155
project. testClient. handleSingleRequest { ( request: DiagnosticsRefreshRequest ) in
@@ -185,7 +169,7 @@ final class PullDiagnosticsTests: XCTestCase {
185
169
let afterChangingFileA = try await project. testClient. send (
186
170
DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( bUri) )
187
171
)
188
- XCTAssertEqual ( afterChangingFileA, . full ( RelatedFullDocumentDiagnosticReport ( items: [ ] ) ) )
172
+ XCTAssertEqual ( afterChangingFileA. fullReport ? . items, [ ] )
189
173
}
190
174
191
175
func testDiagnosticUpdatedAfterDependentModuleIsBuilt( ) async throws {
@@ -219,17 +203,14 @@ final class PullDiagnosticsTests: XCTestCase {
219
203
let beforeBuilding = try await project. testClient. send (
220
204
DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( bUri) )
221
205
)
222
- guard case . full( let fullReportBeforeBuilding) = beforeBuilding else {
223
- XCTFail ( " Expected full diagnostics report " )
224
- return
225
- }
226
206
XCTAssert (
227
- fullReportBeforeBuilding . items. contains ( where: {
207
+ ( beforeBuilding . fullReport ? . items ?? [ ] ) . contains ( where: {
228
208
#if compiler(>=6.1)
229
209
#warning("When we drop support for Swift 5.10 we no longer need to check for the Objective-C error message")
230
210
#endif
231
211
return $0. message == " No such module 'LibA' " || $0. message == " Could not build Objective-C module 'LibA' "
232
- } )
212
+ }
213
+ )
233
214
)
234
215
235
216
let diagnosticsRefreshRequestReceived = self . expectation ( description: " DiagnosticsRefreshRequest received " )
@@ -254,7 +235,7 @@ final class PullDiagnosticsTests: XCTestCase {
254
235
let afterChangingFileA = try await project. testClient. send (
255
236
DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( bUri) )
256
237
)
257
- XCTAssertEqual ( afterChangingFileA, . full ( RelatedFullDocumentDiagnosticReport ( items: [ ] ) ) )
238
+ XCTAssertEqual ( afterChangingFileA. fullReport ? . items, [ ] )
258
239
}
259
240
260
241
func testDiagnosticsWaitForDocumentToBePrepared( ) async throws {
@@ -307,7 +288,7 @@ final class PullDiagnosticsTests: XCTestCase {
307
288
// but before receiving a reply. The async variant doesn't allow this distinction.
308
289
let receivedDiagnostics = self . expectation ( description: " Received diagnostics " )
309
290
project. testClient. send ( DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) ) ) { diagnostics in
310
- XCTAssertEqual ( diagnostics. success, . full ( RelatedFullDocumentDiagnosticReport ( items: [ ] ) ) )
291
+ XCTAssertEqual ( diagnostics. success? . fullReport ? . items, [ ] )
311
292
receivedDiagnostics. fulfill ( )
312
293
}
313
294
diagnosticRequestSent. value = true
@@ -366,11 +347,7 @@ final class PullDiagnosticsTests: XCTestCase {
366
347
let diagnostics = try await project. testClient. send (
367
348
DocumentDiagnosticsRequest ( textDocument: TextDocumentIdentifier ( uri) )
368
349
)
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)
374
351
let note = try XCTUnwrap ( diagnostic. relatedInformation? . only)
375
352
XCTAssertEqual ( note. location, try project. location ( from: " 1️⃣ " , to: " 1️⃣ " , in: " FileA.swift " ) )
376
353
}
0 commit comments