34 lines
1.1 KiB
C++
34 lines
1.1 KiB
C++
#include "./cancel_request_provider.hpp"
|
|
|
|
namespace lsp::providers::cancel_request
|
|
{
|
|
std::string CancelRequestProvider::GetMethod() const
|
|
{
|
|
return "$/cancelRequest";
|
|
}
|
|
|
|
std::string CancelRequestProvider::GetProviderName() const
|
|
{
|
|
return "CancelRequestProvider";
|
|
}
|
|
|
|
void CancelRequestProvider::HandleNotification(const protocol::NotificationMessage& notification, ExecutionContext& context)
|
|
{
|
|
try
|
|
{
|
|
auto params = transform::As<protocol::CancelParams>(notification.params.value());
|
|
std::string id_to_cancel = transform::debug::GetIdString(params.id);
|
|
spdlog::info("Processing cancel request for ID: {}", id_to_cancel);
|
|
|
|
auto& scheduler = context.GetScheduler();
|
|
|
|
bool cancelled = scheduler.Cancel(id_to_cancel);
|
|
spdlog::info("Cancel request {} result: {}", id_to_cancel, cancelled ? "success" : "not found");
|
|
}
|
|
catch (const std::exception& e)
|
|
{
|
|
spdlog::error("Error handling cancel request: {}", e.what());
|
|
}
|
|
}
|
|
}
|