mirror of
https://github.com/apple/sourcekit-lsp.git
synced 2026-03-06 18:24:36 +01:00
Remove CancellationToken
This is no longer needed because we handle cancellation on the `Task` level.
This commit is contained in:
@@ -129,9 +129,7 @@ public final class TestMessageHandler: MessageHandler {
|
||||
from clientID: ObjectIdentifier,
|
||||
reply: @escaping (LSPResult<R.Response>) -> 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<R.Response>) -> 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 }))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
add_library(LanguageServerProtocol STATIC
|
||||
AsyncQueue.swift
|
||||
Cancellation.swift
|
||||
Connection.swift
|
||||
CustomCodable.swift
|
||||
Error.swift
|
||||
|
||||
@@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -157,9 +157,9 @@ extension Connection {
|
||||
/// use the version with a completion handler.
|
||||
public func send<R: RequestType>(_ request: R) async throws -> R.Response {
|
||||
let requestIDWrapper = ThreadSafeBox<RequestID?>(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)
|
||||
}
|
||||
|
||||
@@ -38,20 +38,15 @@ public final class Request<R: RequestType> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The request's cancellation state.
|
||||
public let cancellationToken: CancellationToken
|
||||
|
||||
public init(
|
||||
_ request: Params,
|
||||
id: RequestID,
|
||||
clientID: ObjectIdentifier,
|
||||
cancellation: CancellationToken,
|
||||
reply: @escaping (LSPResult<Response>) -> Void
|
||||
) {
|
||||
self.id = id
|
||||
self.clientID = clientID
|
||||
self.params = request
|
||||
self.cancellationToken = cancellation
|
||||
self.replyBlock = reply
|
||||
}
|
||||
|
||||
@@ -71,9 +66,6 @@ public final class Request<R: RequestType> {
|
||||
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`.
|
||||
|
||||
@@ -298,7 +298,6 @@ actor ClangLanguageServerShim: ToolchainLanguageServer, MessageHandler {
|
||||
params,
|
||||
id: id,
|
||||
clientID: clientID,
|
||||
cancellation: CancellationToken(),
|
||||
reply: { result in
|
||||
reply(result)
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user