blob: 82008a9fa52abbeb09045db0debc01555767fcfd [file] [log] [blame]
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/lsp_protocol/protocol_generated.dart';
import 'package:analysis_server/lsp_protocol/protocol_special.dart';
import 'package:analysis_server/src/lsp/handlers/handlers.dart';
import 'package:analysis_server/src/lsp/lsp_analysis_server.dart';
class CancelRequestHandler extends MessageHandler<CancelParams, void> {
final Map<String, CancelableToken> _tokens = {};
CancelRequestHandler(LspAnalysisServer server) : super(server);
Method get handlesMessage => Method.cancelRequest;
LspJsonHandler<CancelParams> get jsonHandler => CancelParams.jsonHandler;
void clearToken(RequestMessage message) {
CancelableToken createToken(RequestMessage message) {
final token = CancelableToken();
_tokens[] = token;
return token;
ErrorOr<void> handle(CancelParams params, CancellationToken token) {
// Don't assume this is in the map as it's possible the client sent a
// cancellation that we processed after already starting to send the response
// and cleared the token.
return success();