tree-sitter and lsp-methods

This commit is contained in:
csh
2025-09-14 12:28:37 +08:00
parent e9972fd869
commit aac12137cb
214 changed files with 350938 additions and 142202 deletions
@@ -0,0 +1,34 @@
#include <spdlog/spdlog.h>
#include "./shutdown.hpp"
#include "../../protocol/transform/facade.hpp"
namespace lsp::providers
{
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);
// 构建响应 - shutdown 返回 null
protocol::ResponseMessage response;
response.id = request.id;
auto json = transform::Serialize(response);
if (!json.has_value())
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Failed to serialize response");
spdlog::info("Shutdown request processed successfully");
return json.value();
}
}
@@ -1,12 +1,12 @@
#pragma once
#include "../base/provider_interface.hpp"
namespace lsp::providers::shutdown
namespace lsp::providers
{
class ShutdownProvider : public IRequestProvider
class Shutdown : public IRequestProvider
{
public:
ShutdownProvider() = default;
Shutdown() = default;
std::string GetMethod() const override;
std::string GetProviderName() const override;
@@ -1,47 +0,0 @@
#include <spdlog/spdlog.h>
#include "./shutdown_provider.hpp"
#include "../../protocol/transform/facade.hpp"
namespace lsp::providers::shutdown
{
std::string ShutdownProvider::GetMethod() const
{
return "shutdown";
}
std::string ShutdownProvider::GetProviderName() const
{
return "ShutdownProvider";
}
std::string ShutdownProvider::ProvideResponse(const protocol::RequestMessage& request, ExecutionContext& context)
{
spdlog::debug("ShutdownProvider: Providing response for method {}", request.method);
try
{
// 触发关闭事件
context.TriggerLifecycleEvent(ServerLifecycleEvent::kShuttingDown);
// 构建响应 - shutdown 返回 null
protocol::ResponseMessage response;
response.id = request.id;
std::string json;
auto ec = glz::write_json(response, json);
if (ec)
{
return BuildErrorResponseMessage(request, protocol::ErrorCode::kInternalError, "Failed to serialize response");
}
spdlog::info("Shutdown request processed successfully");
return json;
}
catch (const std::exception& e)
{
spdlog::error("Shutdown request failed: {}", e.what());
return BuildErrorResponseMessage(request, protocol::ErrorCode::kInternalError, e.what());
}
}
}