♻️ 使用module重构所有代码
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
module;
|
||||
|
||||
|
||||
export module lsp.provider.shutdown.shutdown;
|
||||
import spdlog;
|
||||
|
||||
import std;
|
||||
|
||||
import lsp.protocol;
|
||||
import lsp.codec.facade;
|
||||
import lsp.provider.base.interface;
|
||||
|
||||
namespace transform = lsp::codec;
|
||||
|
||||
export namespace lsp::provider
|
||||
{
|
||||
class Shutdown : public IRequestProvider
|
||||
{
|
||||
public:
|
||||
Shutdown() = default;
|
||||
|
||||
std::string GetMethod() const override;
|
||||
std::string GetProviderName() const override;
|
||||
std::string ProvideResponse(const protocol::RequestMessage& request, ExecutionContext& context) override;
|
||||
};
|
||||
}
|
||||
|
||||
namespace lsp::provider
|
||||
{
|
||||
std::string Shutdown::GetMethod() const
|
||||
{
|
||||
return "shutdown";
|
||||
}
|
||||
|
||||
std::string Shutdown::GetProviderName() const
|
||||
{
|
||||
return "Shutdown";
|
||||
}
|
||||
|
||||
std::string Shutdown::ProvideResponse(const protocol::RequestMessage& request, ExecutionContext& context)
|
||||
{
|
||||
spdlog::debug("ShutdownProvider: Providing response for method {}", request.method);
|
||||
|
||||
// 触发关闭事件
|
||||
context.TriggerLifecycleEvent(ServerLifecycleEvent::kShuttingDown);
|
||||
|
||||
context.GetManagerHub().Shutdown();
|
||||
|
||||
// 构建响应 - shutdown 返回 null
|
||||
protocol::ResponseMessage response;
|
||||
response.id = request.id;
|
||||
auto json = transform::Serialize(response);
|
||||
if (!json.has_value())
|
||||
return BuildErrorResponseMessage(request, protocol::ErrorCodes::InternalError, "Failed to serialize response");
|
||||
spdlog::info("Shutdown request processed successfully");
|
||||
return json.value();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user