From 1f5f818540595535c3448da71ff0e525acd2cd74 Mon Sep 17 00:00:00 2001 From: Matt <85322+mattmassicotte@users.noreply.github.com> Date: Fri, 17 May 2024 06:53:43 -0400 Subject: [PATCH] Remove unused enum/protocol --- Sources/LanguageServerProtocol/Client.swift | 2 +- .../Client/JSONRPCServerConnection.swift | 6 +++--- .../LanguageServerProtocol/Client/MockServer.swift | 2 +- .../LanguageServerProtocol.swift | 14 -------------- 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/Sources/LanguageServerProtocol/Client.swift b/Sources/LanguageServerProtocol/Client.swift index a5871ce..86aea8f 100644 --- a/Sources/LanguageServerProtocol/Client.swift +++ b/Sources/LanguageServerProtocol/Client.swift @@ -25,7 +25,7 @@ extension Registration { func decodeServerRegistration() throws -> ServerRegistration { guard let regMethod = ServerRegistration.Method(rawValue: method) else { - throw ServerError.unhandledRegistrationMethod(method) + throw ProtocolError.unhandledRegistrationMethod(method) } switch regMethod { diff --git a/Sources/LanguageServerProtocol/Client/JSONRPCServerConnection.swift b/Sources/LanguageServerProtocol/Client/JSONRPCServerConnection.swift index e4e7fad..07d4c9b 100644 --- a/Sources/LanguageServerProtocol/Client/JSONRPCServerConnection.swift +++ b/Sources/LanguageServerProtocol/Client/JSONRPCServerConnection.swift @@ -194,7 +194,7 @@ public actor JSONRPCServerConnection: ServerConnection { let note = try JSONDecoder().decode(JSONRPCNotification.self, from: data) guard let params = note.params else { - throw ServerError.missingParams + throw ProtocolError.missingParams } return params @@ -213,7 +213,7 @@ public actor JSONRPCServerConnection: ServerConnection { do { guard let method = ServerNotification.Method(rawValue: methodName) else { - throw ServerError.unrecognizedMethod(methodName) + throw ProtocolError.unrecognizedMethod(methodName) } switch method { @@ -257,7 +257,7 @@ public actor JSONRPCServerConnection: ServerConnection { let req = try JSONDecoder().decode(JSONRPCRequest.self, from: data) guard let params = req.params else { - throw ServerError.missingParams + throw ProtocolError.missingParams } return params diff --git a/Sources/LanguageServerProtocol/Client/MockServer.swift b/Sources/LanguageServerProtocol/Client/MockServer.swift index 65a8015..2d8a33d 100644 --- a/Sources/LanguageServerProtocol/Client/MockServer.swift +++ b/Sources/LanguageServerProtocol/Client/MockServer.swift @@ -44,7 +44,7 @@ public actor MockServer: ServerConnection { sentMessageContinuation.yield(.request(request)) if mockResponses.isEmpty { - throw ServerError.missingReply + throw ProtocolError.missingReply } let data = mockResponses.removeFirst() diff --git a/Sources/LanguageServerProtocol/LanguageServerProtocol.swift b/Sources/LanguageServerProtocol/LanguageServerProtocol.swift index 41951b2..ff0731e 100644 --- a/Sources/LanguageServerProtocol/LanguageServerProtocol.swift +++ b/Sources/LanguageServerProtocol/LanguageServerProtocol.swift @@ -10,20 +10,6 @@ public enum ProtocolError: Error { case missingReply } -// NOTE: We should remove these and only use `ProtocolError`? -public typealias ServerError = ProtocolError -public typealias ClientError = ProtocolError - -public enum ClientEvent: Sendable { - public typealias RequestResult = Result - public typealias RequestHandler = @Sendable (RequestResult) async -> Void - - case request(id: JSONId, request: ClientRequest) - case notification(ClientNotification) - case error(Error) - // case error(ClientError) -} - public enum ServerEvent: Sendable { public typealias RequestResult = Result public typealias RequestHandler = @Sendable (RequestResult) async -> Void