From 2422d85c7f7814c8d53da7df24d41bb3419a4602 Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Fri, 21 Nov 2025 14:16:11 -0800 Subject: [PATCH] [BSP] Make MessageRegistry.bspProtocol a static stored property This should be an immutable value and `MessageRegistry.init()` is not a trivial constructor. No reason to keep it a computed property. Also, Move `MessageRegistry.lspProtocol` to LanguageServerProtocol/Messages.swift to align with the BSP couterpart. --- Sources/BuildServerProtocol/Messages.swift | 5 ++--- Sources/LanguageServerProtocol/MessageRegistry.swift | 4 ---- Sources/LanguageServerProtocol/Messages.swift | 5 +++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/BuildServerProtocol/Messages.swift b/Sources/BuildServerProtocol/Messages.swift index 736fbbf33..91e30710d 100644 --- a/Sources/BuildServerProtocol/Messages.swift +++ b/Sources/BuildServerProtocol/Messages.swift @@ -41,10 +41,9 @@ private let notificationTypes: [NotificationType.Type] = [ ] extension MessageRegistry { - public static var bspProtocol: MessageRegistry { + public static let bspProtocol: MessageRegistry = MessageRegistry(requests: requestTypes, notifications: notificationTypes) - } } @available(*, deprecated, message: "use MessageRegistry.bspProtocol instead") -public let bspRegistry = MessageRegistry(requests: requestTypes, notifications: notificationTypes) +public var bspRegistry: MessageRegistry { MessageRegistry.bspProtocol } diff --git a/Sources/LanguageServerProtocol/MessageRegistry.swift b/Sources/LanguageServerProtocol/MessageRegistry.swift index 114ae9528..8639aa830 100644 --- a/Sources/LanguageServerProtocol/MessageRegistry.swift +++ b/Sources/LanguageServerProtocol/MessageRegistry.swift @@ -11,10 +11,6 @@ //===----------------------------------------------------------------------===// public final class MessageRegistry: Sendable { - - public static let lspProtocol: MessageRegistry = - MessageRegistry(requests: builtinRequests, notifications: builtinNotifications) - private let methodToRequest: [String: _RequestType.Type] private let methodToNotification: [String: NotificationType.Type] diff --git a/Sources/LanguageServerProtocol/Messages.swift b/Sources/LanguageServerProtocol/Messages.swift index 923676dfe..e8334738d 100644 --- a/Sources/LanguageServerProtocol/Messages.swift +++ b/Sources/LanguageServerProtocol/Messages.swift @@ -128,6 +128,11 @@ public let builtinNotifications: [NotificationType.Type] = [ WorkDoneProgress.self, ] +extension MessageRegistry { + public static let lspProtocol: MessageRegistry = + MessageRegistry(requests: builtinRequests, notifications: builtinNotifications) +} + // MARK: Miscellaneous Message Types public struct VoidResponse: ResponseType, Hashable {