public Task <ResponseType?> ExecuteRequestAsync <RequestType, ResponseType>( RequestExecutionQueue queue, string methodName, RequestType request, LSP.ClientCapabilities clientCapabilities, string?clientName, CancellationToken cancellationToken) where RequestType : class { Contract.ThrowIfNull(request); Contract.ThrowIfTrue(string.IsNullOrEmpty(methodName), "Invalid method name"); if (request is ExecuteCommandParams executeCommandRequest) { // If we have a workspace/executeCommand request, get the request name // from the command name. methodName = AbstractExecuteWorkspaceCommandHandler.GetRequestNameForCommandName(executeCommandRequest.Command); } var handlerEntry = _requestHandlers[methodName]; Contract.ThrowIfNull(handlerEntry, string.Format("Request handler entry not found for method {0}", methodName)); var mutatesSolutionState = handlerEntry.Value.MutatesSolutionState; var requiresLSPSolution = handlerEntry.Value.RequiresLSPSolution; var handler = (IRequestHandler <RequestType, ResponseType>?)handlerEntry.Value; Contract.ThrowIfNull(handler, string.Format("Request handler not found for method {0}", methodName)); return(ExecuteRequestAsync(queue, request, clientCapabilities, clientName, methodName, mutatesSolutionState, requiresLSPSolution, handler, cancellationToken)); }
public async Task <object?> ExecuteWorkspaceCommandAsync(LSP.ExecuteCommandParams request, CancellationToken cancellationToken) { Contract.ThrowIfNull(_clientCapabilities, $"{nameof(InitializeAsync)} has not been called."); var requestMethod = AbstractExecuteWorkspaceCommandHandler.GetRequestNameForCommandName(request.Command); var result = await _requestDispatcher.ExecuteRequestAsync <LSP.ExecuteCommandParams, object>( requestMethod, request, _clientCapabilities, _queue, cancellationToken).ConfigureAwait(false); return(result); }