@@ -510,15 +510,22 @@ extension TSCDiagnostic {
510
510
location = UnknownLocation . location
511
511
}
512
512
513
+ let data : DiagnosticData
514
+ if let legacyData = diagnostic. metadata? . legacyDiagnosticData {
515
+ data = legacyData. underlying
516
+ } else {
517
+ data = StringDiagnostic ( diagnostic. message)
518
+ }
519
+
513
520
switch diagnostic. severity {
514
521
case . error:
515
- self = . init( message: . error( diagnostic . message ) , location: location)
522
+ self = . init( message: . error( data ) , location: location)
516
523
case . warning:
517
- self = . init( message: . warning( diagnostic . message ) , location: location)
524
+ self = . init( message: . warning( data ) , location: location)
518
525
case . info:
519
- self = . init( message: . note( diagnostic . message ) , location: location)
526
+ self = . init( message: . note( data ) , location: location)
520
527
case . debug:
521
- self = . init( message: . note( diagnostic . message ) , location: location)
528
+ self = . init( message: . note( data ) , location: location)
522
529
}
523
530
}
524
531
}
@@ -534,11 +541,11 @@ extension ObservabilityMetadata {
534
541
}
535
542
}
536
543
537
- enum LegacyLocationKey : Key {
544
+ fileprivate enum LegacyLocationKey : Key {
538
545
typealias Value = DiagnosticLocationWrapper
539
546
}
540
547
541
- public struct DiagnosticLocationWrapper : DiagnosticLocation {
548
+ public struct DiagnosticLocationWrapper : CustomStringConvertible {
542
549
let underlying : DiagnosticLocation
543
550
544
551
public init ( _ underlying: DiagnosticLocation ) {
@@ -550,3 +557,31 @@ extension ObservabilityMetadata {
550
557
}
551
558
}
552
559
}
560
+
561
+ //@available(*, deprecated, message: "temporary for transition DiagnosticsEngine -> DiagnosticsEmitter")
562
+ extension ObservabilityMetadata {
563
+ fileprivate var legacyDiagnosticData : DiagnosticDataWrapper ? {
564
+ get {
565
+ self [ LegacyDataKey . self]
566
+ }
567
+ set {
568
+ self [ LegacyDataKey . self] = newValue
569
+ }
570
+ }
571
+
572
+ fileprivate enum LegacyDataKey : Key {
573
+ typealias Value = DiagnosticDataWrapper
574
+ }
575
+
576
+ fileprivate struct DiagnosticDataWrapper : CustomStringConvertible {
577
+ let underlying : DiagnosticData
578
+
579
+ public init ( _ underlying: DiagnosticData ) {
580
+ self . underlying = underlying
581
+ }
582
+
583
+ public var description : String {
584
+ self . underlying. description
585
+ }
586
+ }
587
+ }
0 commit comments