diff --git a/Sources/LSPTestSupport/TestJSONRPCConnection.swift b/Sources/LSPTestSupport/TestJSONRPCConnection.swift index 51e54eb4..5fe8e73e 100644 --- a/Sources/LSPTestSupport/TestJSONRPCConnection.swift +++ b/Sources/LSPTestSupport/TestJSONRPCConnection.swift @@ -129,9 +129,7 @@ public final class TestMessageHandler: MessageHandler { from clientID: ObjectIdentifier, reply: @escaping (LSPResult) -> Void ) { - let cancellationToken = CancellationToken() - - let request = Request(params, id: id, clientID: clientID, cancellation: cancellationToken, reply: reply) + let request = Request(params, id: id, clientID: clientID, reply: reply) guard !oneShotRequestHandlers.isEmpty else { fatalError("unexpected request \(request)") @@ -179,14 +177,11 @@ public final class TestServer: MessageHandler { from clientID: ObjectIdentifier, reply: @escaping (LSPResult) -> Void ) { - let cancellationToken = CancellationToken() - if let params = params as? EchoRequest { let req = Request( params, id: id, clientID: clientID, - cancellation: cancellationToken, reply: { result in reply(result.map({ $0 as! R.Response })) } @@ -197,7 +192,6 @@ public final class TestServer: MessageHandler { params, id: id, clientID: clientID, - cancellation: cancellationToken, reply: { result in reply(result.map({ $0 as! R.Response })) } diff --git a/Sources/LanguageServerProtocol/CMakeLists.txt b/Sources/LanguageServerProtocol/CMakeLists.txt index 4cbc14ec..5374ddbd 100644 --- a/Sources/LanguageServerProtocol/CMakeLists.txt +++ b/Sources/LanguageServerProtocol/CMakeLists.txt @@ -1,6 +1,5 @@ add_library(LanguageServerProtocol STATIC AsyncQueue.swift - Cancellation.swift Connection.swift CustomCodable.swift Error.swift diff --git a/Sources/LanguageServerProtocol/Cancellation.swift b/Sources/LanguageServerProtocol/Cancellation.swift deleted file mode 100644 index d423f729..00000000 --- a/Sources/LanguageServerProtocol/Cancellation.swift +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -// TODO: implement -public final class CancellationToken { - - public var isCancelled: Bool { return false } - - public init() {} - - public func addCancellationHandler(_ handler: @escaping () -> Void) { - - } - - public func cancel() { - - } -} diff --git a/Sources/LanguageServerProtocol/Connection.swift b/Sources/LanguageServerProtocol/Connection.swift index c0c24966..a5514130 100644 --- a/Sources/LanguageServerProtocol/Connection.swift +++ b/Sources/LanguageServerProtocol/Connection.swift @@ -157,9 +157,9 @@ extension Connection { /// use the version with a completion handler. public func send(_ request: R) async throws -> R.Response { let requestIDWrapper = ThreadSafeBox(initialValue: nil) - try Task.checkCancellation() return try await withTaskCancellationHandler { - try await withCheckedThrowingContinuation { continuation in + try Task.checkCancellation() + return try await withCheckedThrowingContinuation { continuation in let requestID = self.send(request) { result in continuation.resume(with: result) } diff --git a/Sources/LanguageServerProtocol/Request.swift b/Sources/LanguageServerProtocol/Request.swift index ae148541..1b648536 100644 --- a/Sources/LanguageServerProtocol/Request.swift +++ b/Sources/LanguageServerProtocol/Request.swift @@ -38,20 +38,15 @@ public final class Request { } } - /// The request's cancellation state. - public let cancellationToken: CancellationToken - public init( _ request: Params, id: RequestID, clientID: ObjectIdentifier, - cancellation: CancellationToken, reply: @escaping (LSPResult) -> Void ) { self.id = id self.clientID = clientID self.params = request - self.cancellationToken = cancellation self.replyBlock = reply } @@ -71,9 +66,6 @@ public final class Request { public func reply(_ result: Response) { reply(.success(result)) } - - /// Whether the result has been cancelled. - public var isCancelled: Bool { return cancellationToken.isCancelled } } /// A request object, wrapping the parameters of a `NotificationType`. diff --git a/Sources/SourceKitLSP/Clang/ClangLanguageServer.swift b/Sources/SourceKitLSP/Clang/ClangLanguageServer.swift index a43cd683..ee0f30b4 100644 --- a/Sources/SourceKitLSP/Clang/ClangLanguageServer.swift +++ b/Sources/SourceKitLSP/Clang/ClangLanguageServer.swift @@ -298,7 +298,6 @@ actor ClangLanguageServerShim: ToolchainLanguageServer, MessageHandler { params, id: id, clientID: clientID, - cancellation: CancellationToken(), reply: { result in reply(result) } diff --git a/Sources/SourceKitLSP/SourceKitServer.swift b/Sources/SourceKitLSP/SourceKitServer.swift index a3ca1929..f48aa603 100644 --- a/Sources/SourceKitLSP/SourceKitServer.swift +++ b/Sources/SourceKitLSP/SourceKitServer.swift @@ -703,13 +703,10 @@ extension SourceKitServer: MessageHandler { ) async { let startDate = Date() - let cancellationToken = CancellationToken() - let request = Request( params, id: id, clientID: clientID, - cancellation: cancellationToken, reply: { [weak self] result in reply(result) let endDate = Date()