When cancelling an in-progress request, allow specifying the error returned to clients #33
+66
−24
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, when implicitly cancelling requests because a document has been changed, we return an error response that indicates that the client cancelled the request because we translated all
CancellationErrorto this response. The more accurate response is to indicate that the content has been modified, returning aContentModifiederror.To do so, we need to make two changes:
QueueBasedMessageHandlerneeds to keep track of the reasons why it cancelled request handling tasksQueueBasedMessageHandler.handle(request:id:reply)needs to allow returningCancellationErrorinstead of eagerly transforming it to aResponseErrorinRequestAndReply. This is an API-breaking change. I haven’t found a great way to add a compatibility layer, so I propose that we need to have linked PRs in SourceKit-LSP and SwiftPM that need to be merged when we are updating the swift-tools-protocols version in the toolchain.This is a prerequisite to fixing swiftlang/sourcekit-lsp#2136 (comment).
PRs that need to be merged when this gets picked up in toolchain builds:
QueueBasedMessageHandler.handleto returnany Errorinstead ofResponseErrorsourcekit-lsp#2416QueueBasedMessageHandler.handleto returnany Errorinstead ofResponseErrorswift-package-manager#9557QueueBasedMessageHandler.handleto returnany Errorinstead ofResponseErrorswift-build#1003