@@ -532,26 +532,25 @@ private nonisolated(unsafe) var notificationIDForLogging = AtomicUInt32(initialV
532
532
533
533
extension SourceKitLSPServer : MessageHandler {
534
534
public nonisolated func handle( _ params: some NotificationType ) {
535
- if let params = params as? CancelRequestNotification {
536
- // Request cancellation needs to be able to overtake any other message we
537
- // are currently handling. Ordering is not important here. We thus don't
538
- // need to execute it on `messageHandlingQueue`.
539
- self . cancelRequest ( params)
540
- }
541
-
542
535
let notificationID = notificationIDForLogging. fetchAndIncrement ( )
536
+ withLoggingScope ( " notification- \( notificationID % 100 ) " ) {
537
+ if let params = params as? CancelRequestNotification {
538
+ // Request cancellation needs to be able to overtake any other message we
539
+ // are currently handling. Ordering is not important here. We thus don't
540
+ // need to execute it on `messageHandlingQueue`.
541
+ self . cancelRequest ( params)
542
+ }
543
543
544
- let signposter = Logger ( subsystem: LoggingScope . subsystem, category: " message-handling " )
545
- . makeSignposter ( )
546
- let signpostID = signposter. makeSignpostID ( )
547
- let state = signposter. beginInterval ( " Notification " , id: signpostID, " \( type ( of: params) ) " )
548
- messageHandlingQueue. async ( metadata: MessageHandlingDependencyTracker ( params) ) {
549
- signposter. emitEvent ( " Start handling " , id: signpostID)
544
+ let signposter = Logger ( subsystem: LoggingScope . subsystem, category: " message-handling " )
545
+ . makeSignposter ( )
546
+ let signpostID = signposter. makeSignpostID ( )
547
+ let state = signposter. beginInterval ( " Notification " , id: signpostID, " \( type ( of: params) ) " )
548
+ messageHandlingQueue. async ( metadata: MessageHandlingDependencyTracker ( params) ) {
549
+ signposter. emitEvent ( " Start handling " , id: signpostID)
550
550
551
- // Only use the last two digits of the notification ID for the logging scope to avoid creating too many scopes.
552
- // See comment in `withLoggingScope`.
553
- // The last 2 digits should be sufficient to differentiate between multiple concurrently running notifications.
554
- await withLoggingScope ( " notification- \( notificationID % 100 ) " ) {
551
+ // Only use the last two digits of the notification ID for the logging scope to avoid creating too many scopes.
552
+ // See comment in `withLoggingScope`.
553
+ // The last 2 digits should be sufficient to differentiate between multiple concurrently running notifications.
555
554
await self . handleImpl ( params)
556
555
signposter. endInterval ( " Notification " , state, " Done " )
557
556
}
@@ -2430,7 +2429,7 @@ fileprivate extension RequestID {
2430
2429
var numericValue : Int {
2431
2430
switch self {
2432
2431
case . number( let number) : return number
2433
- case . string( let string) : return Int ( string) ?? string. hashValue
2432
+ case . string( let string) : return Int ( string) ?? abs ( string. hashValue)
2434
2433
}
2435
2434
}
2436
2435
}
0 commit comments