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,33 @@
#include <spdlog/spdlog.h>
#include "./register_capability.hpp"
#include "../../protocol/transform/facade.hpp"
namespace lsp::providers::client
{
std::string RegisterCapability::GetMethod() const
{
return "client/registerCapability";
}
std::string RegisterCapability::GetProviderName() const
{
return "ClientRegisterCapability";
}
std::string RegisterCapability::ProvideResponse(const protocol::RequestMessage& request, ExecutionContext& context)
{
static_cast<void>(context);
spdlog::debug("RegisterCapabilityProvider: Providing response for method {}", request.method);
// 这个方法通常不会被调用,因为这是服务器发起的请求
// 但为了完整性还是实现它
protocol::ResponseMessage response;
response.id = request.id;
response.result = std::nullopt; // 成功返回null
std::optional<std::string> json = transform::Serialize(response);
if (!json.has_value())
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Internal error");
return json.value();
}
}
@@ -0,0 +1,17 @@
#pragma once
#include <string>
#include "../base/provider_interface.hpp"
#include "../../protocol/protocol.hpp"
namespace lsp::providers::client
{
class RegisterCapability : public IRequestProvider
{
public:
RegisterCapability() = default;
std::string GetMethod() const override;
std::string GetProviderName() const override;
std::string ProvideResponse(const protocol::RequestMessage& request, ExecutionContext& context) override;
};
}
@@ -0,0 +1,30 @@
#include <spdlog/spdlog.h>
#include "./unregister_capability.hpp"
#include "../../protocol/transform/facade.hpp"
namespace lsp::providers::client
{
std::string UnregisterCapability::GetMethod() const
{
return "client/unregisterCapability";
}
std::string UnregisterCapability::GetProviderName() const
{
return "ClientUnregisterCapability";
}
std::string UnregisterCapability::ProvideResponse(const protocol::RequestMessage& request, ExecutionContext& context)
{
static_cast<void>(context);
spdlog::debug("UnregisterCapabilityProvider: Providing response for method {}", request.method);
protocol::ResponseMessage response;
response.id = request.id;
response.result = std::nullopt;
std::optional<std::string> json = transform::Serialize(response);
if (!json.has_value())
return BuildErrorResponseMessage(request, protocol::ErrorCodes::kInternalError, "Internal error");
return json.value();
}
}
@@ -0,0 +1,17 @@
#pragma once
#include <string>
#include "../base/provider_interface.hpp"
#include "../../protocol/protocol.hpp"
namespace lsp::providers::client
{
class UnregisterCapability : public IRequestProvider
{
public:
UnregisterCapability() = default;
std::string GetMethod() const override;
std::string GetProviderName() const override;
std::string ProvideResponse(const protocol::RequestMessage& request, ExecutionContext& context) override;
};
}