refactor
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#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, ProviderContext& 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);
|
||||
|
||||
if (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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include <spdlog/spdlog.h>
|
||||
#include "../base/provider_interface.hpp"
|
||||
#include "../../scheduler/request_scheduler.hpp"
|
||||
#include "../../protocol/transform/facade.hpp"
|
||||
|
||||
namespace lsp::providers::cancel_request
|
||||
{
|
||||
class CancelRequestProvider : public INotificationProvider
|
||||
{
|
||||
public:
|
||||
std::string GetMethod() const override;
|
||||
std::string GetProviderName() const override;
|
||||
void HandleNotification(const protocol::NotificationMessage& notification, ProviderContext& context) override;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user