@@ -353,15 +353,23 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
353
353
}
354
354
progressAnimation. update ( step: step, total: 100 , text: message)
355
355
case . diagnostic( let info) :
356
- if info. kind == . error {
357
- self . observabilityScope. emit ( error: " \( info. location) \( info. message) \( info. fixIts) " )
358
- } else if info. kind == . warning {
359
- self . observabilityScope. emit ( warning: " \( info. location) \( info. message) \( info. fixIts) " )
360
- } else if info. kind == . note {
361
- self . observabilityScope. emit ( info: " \( info. location) \( info. message) \( info. fixIts) " )
362
- } else if info. kind == . remark {
363
- self . observabilityScope. emit ( debug: " \( info. location) \( info. message) \( info. fixIts) " )
356
+ let fixItsDescription = if info. fixIts. hasContent {
357
+ " : " + info. fixIts. map { String ( describing: $0) } . joined ( separator: " , " )
358
+ } else {
359
+ " "
360
+ }
361
+ let message = if let locationDescription = info. location. userDescription {
362
+ " \( locationDescription) \( info. message) \( fixItsDescription) "
363
+ } else {
364
+ " \( info. message) \( fixItsDescription) "
364
365
}
366
+ let severity : Diagnostic . Severity = switch info. kind {
367
+ case . error: . error
368
+ case . warning: . warning
369
+ case . note: . info
370
+ case . remark: . debug
371
+ }
372
+ self . observabilityScope. emit ( severity: severity, message: message)
365
373
case . taskOutput( let info) :
366
374
self . observabilityScope. emit ( info: " \( info. data) " )
367
375
case . taskStarted( let info) :
@@ -509,6 +517,8 @@ public final class SwiftBuildSystem: SPMBuildCore.BuildSystem {
509
517
}
510
518
}
511
519
520
+ // MARK: - Helpers
521
+
512
522
extension String {
513
523
/// Escape the usual shell related things, such as quoting, but also handle Windows
514
524
/// back-slashes.
@@ -541,3 +551,30 @@ extension Basics.Diagnostic.Severity {
541
551
self <= . info
542
552
}
543
553
}
554
+
555
+ fileprivate extension SwiftBuild . SwiftBuildMessage . DiagnosticInfo . Location {
556
+ var userDescription : String ? {
557
+ switch self {
558
+ case . path( let path, let fileLocation) :
559
+ switch fileLocation {
560
+ case . textual( let line, let column) :
561
+ var description = " \( path) : \( line) "
562
+ if let column { description += " : \( column) " }
563
+ return description
564
+ case . object( let identifier) :
565
+ return " \( path) : \( identifier) "
566
+ case . none:
567
+ return path
568
+ }
569
+
570
+ case . buildSettings( let names) :
571
+ return names. joined ( separator: " , " )
572
+
573
+ case . buildFiles( let buildFiles, let targetGUID) :
574
+ return " \( targetGUID) : " + buildFiles. map { String ( describing: $0) } . joined ( separator: " , " )
575
+
576
+ case . unknown:
577
+ return nil
578
+ }
579
+ }
580
+ }
0 commit comments