@@ -241,14 +241,11 @@ public func addQueuedSourceFile(
241
241
public func addQueuedDiagnostic(
242
242
queuedDiagnosticsPtr: UnsafeMutableRawPointer ,
243
243
perFrontendDiagnosticStatePtr: UnsafeMutableRawPointer ,
244
- text: UnsafePointer < UInt8 > ,
245
- textLength: Int ,
244
+ text: BridgedStringRef ,
246
245
severity: BridgedDiagnosticSeverity ,
247
246
cLoc: BridgedSourceLoc ,
248
- categoryName: UnsafePointer < UInt8 > ? ,
249
- categoryLength: Int ,
250
- documentationPath: UnsafePointer < UInt8 > ? ,
251
- documentationPathLength: Int ,
247
+ categoryName: BridgedStringRef ,
248
+ documentationPath: BridgedStringRef ,
252
249
highlightRangesPtr: UnsafePointer < BridgedSourceLoc > ? ,
253
250
numHighlightRanges: Int
254
251
) {
@@ -349,10 +346,10 @@ public func addQueuedDiagnostic(
349
346
}
350
347
}
351
348
352
- let category : DiagnosticCategory ? = categoryName. flatMap { categoryNamePtr in
349
+ let category : DiagnosticCategory ? = categoryName. data . flatMap { categoryNamePtr in
353
350
let categoryNameBuffer = UnsafeBufferPointer (
354
351
start: categoryNamePtr,
355
- count: categoryLength
352
+ count: categoryName . count
356
353
)
357
354
let categoryName = String ( decoding: categoryNameBuffer, as: UTF8 . self)
358
355
@@ -363,10 +360,10 @@ public func addQueuedDiagnostic(
363
360
return nil
364
361
}
365
362
366
- let documentationURL = documentationPath. map { documentationPathPtr in
363
+ let documentationURL = documentationPath. data . map { documentationPathPtr in
367
364
let documentationPathBuffer = UnsafeBufferPointer (
368
365
start: documentationPathPtr,
369
- count: documentationPathLength
366
+ count: documentationPath . count
370
367
)
371
368
372
369
let documentationPath = String ( decoding: documentationPathBuffer, as: UTF8 . self)
@@ -390,7 +387,11 @@ public func addQueuedDiagnostic(
390
387
diagnosticState. pointee. referencedCategories. insert ( category)
391
388
}
392
389
393
- let textBuffer = UnsafeBufferPointer ( start: text, count: textLength)
390
+ guard let textPtr = text. data, !text. isEmpty else {
391
+ return
392
+ }
393
+
394
+ let textBuffer = UnsafeBufferPointer ( start: textPtr, count: text. count)
394
395
let diagnostic = Diagnostic (
395
396
node: node,
396
397
position: position,
0 commit comments