@@ -532,26 +532,25 @@ private nonisolated(unsafe) var notificationIDForLogging = AtomicUInt32(initialV
532532
533533extension SourceKitLSPServer : MessageHandler {
534534 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-
542535 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+ }
543543
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)
550550
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.
555554 await self . handleImpl ( params)
556555 signposter. endInterval ( " Notification " , state, " Done " )
557556 }
@@ -2430,7 +2429,7 @@ fileprivate extension RequestID {
24302429 var numericValue : Int {
24312430 switch self {
24322431 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)
24342433 }
24352434 }
24362435}
0 commit comments