1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 12:06:26 +00:00

Skip LSP cancellation handling for Notification requests

Change-Id: I0edf6206db66ed07390dafcd5ea72bb2397468fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104300
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
This commit is contained in:
Danny Tuppeny 2019-05-31 14:45:24 +00:00 committed by commit-bot@chromium.org
parent edae8c474c
commit 190599de78

View File

@ -121,16 +121,14 @@ abstract class ServerStateMessageHandler {
return handleUnknownMessage(message);
}
if (message is! RequestMessage) {
return handler.handleMessage(message, _notCancelableToken);
}
// Create a cancellation token that will allow us to cancel this request if
// requested to save processing (the handler will need to specifically
// check the token after `await` points).
//
// Notifications cannot be cancelled so they get a fake token that will never
// cancel so that they can share the same APIs with cancellable requests.
final token = message is RequestMessage
? _cancelHandler.createToken(message)
: _notCancelableToken;
final token = _cancelHandler.createToken(message);
try {
final result = await handler.handleMessage(message, token);
// Do a final check before returning the result, because if the request was
@ -141,9 +139,7 @@ abstract class ServerStateMessageHandler {
await Future.delayed(Duration.zero);
return token.isCancellationRequested ? cancelled() : result;
} finally {
if (message is RequestMessage) {
_cancelHandler.clearToken(message);
}
_cancelHandler.clearToken(message);
}
}