@@ -348,57 +348,37 @@ public func addQueuedDiagnostic(
348
348
}
349
349
}
350
350
351
- let category : DiagnosticCategory ? = categoryName. data. flatMap { categoryNamePtr in
352
- let categoryNameBuffer = UnsafeBufferPointer (
353
- start: categoryNamePtr,
354
- count: categoryName. count
355
- )
356
- let categoryName = String ( decoding: categoryNameBuffer, as: UTF8 . self)
357
-
358
- // If the data comes from serialized diagnostics, it's possible that
359
- // the category name is empty because StringRef() is serialized into
360
- // an empty string.
361
- guard !categoryName. isEmpty else {
362
- return nil
351
+ let documentationPath = String ( bridged: documentationPath)
352
+ let documentationURL : String ? = if !documentationPath. isEmpty {
353
+ // If this looks doesn't look like a URL, prepend file://.
354
+ documentationPath. looksLikeURL ? documentationPath : " file:// \( documentationPath) "
355
+ } else {
356
+ nil
363
357
}
364
358
365
- let documentationURL = documentationPath. data. map { documentationPathPtr in
366
- let documentationPathBuffer = UnsafeBufferPointer (
367
- start: documentationPathPtr,
368
- count: documentationPath. count
359
+ let categoryName = String ( bridged: categoryName)
360
+ // If the data comes from serialized diagnostics, it's possible that
361
+ // the category name is empty because StringRef() is serialized into
362
+ // an empty string.
363
+ let category : DiagnosticCategory ? = if !categoryName. isEmpty {
364
+ DiagnosticCategory (
365
+ name: categoryName,
366
+ documentationURL: documentationURL
369
367
)
370
-
371
- let documentationPath = String ( decoding: documentationPathBuffer, as: UTF8 . self)
372
-
373
- // If this looks doesn't look like a URL, prepend file://.
374
- if !documentationPath. looksLikeURL {
375
- return " file:// \( documentationPath) "
376
- }
377
-
378
- return documentationPath
368
+ } else {
369
+ nil
379
370
}
380
371
381
- return DiagnosticCategory (
382
- name: categoryName,
383
- documentationURL: documentationURL
384
- )
385
- }
386
-
387
372
// Note that we referenced this category.
388
373
if let category {
389
374
diagnosticState. pointee. referencedCategories. insert ( category)
390
375
}
391
376
392
- guard let textPtr = text. data, !text. isEmpty else {
393
- return
394
- }
395
-
396
- let textBuffer = UnsafeBufferPointer ( start: textPtr, count: text. count)
397
377
let diagnostic = Diagnostic (
398
378
node: node,
399
379
position: position,
400
380
message: SimpleDiagnostic (
401
- message: String ( decoding : textBuffer , as : UTF8 . self ) ,
381
+ message: String ( bridged : text ) ,
402
382
severity: severity. asSeverity,
403
383
category: category
404
384
) ,
0 commit comments