♻️ 使用module重构所有代码

This commit is contained in:
csh
2025-12-07 23:07:03 +08:00
parent 549f1d1b0a
commit f7d5a74615
369 changed files with 2272844 additions and 2202476 deletions
@@ -0,0 +1,250 @@
module;
import glaze;
export module lsp.protocol.common.basic_types;
import std;
export namespace lsp::protocol
{
using integer = std::int32_t;
using uinteger = std::uint32_t;
using decimal = double;
using boolean = bool;
using string = std::string;
using URI = string;
using DocumentUri = string;
using ProgressToken = std::variant<string, integer>;
struct LSPAny;
using LSPObject = std::map<string, LSPAny>;
using LSPArray = std::vector<LSPAny>;
struct LSPAny
{
using LSPAnyVariant = std::variant<
LSPObject,
LSPArray,
string,
integer,
uinteger,
decimal,
boolean,
std::nullptr_t>;
LSPAnyVariant value;
LSPAny() : value(std::nullptr_t{}) {}
LSPAny(const LSPAny&) = default;
LSPAny(LSPAny&&) noexcept = default;
LSPAny& operator=(const LSPAny&) = default;
LSPAny& operator=(LSPAny&&) noexcept = default;
template<typename T>
LSPAny(const T& val)
{
*this = val;
}
template<typename T>
LSPAny& operator=(const T& val);
template<typename T>
bool Is() const;
template<typename T>
T& Get();
template<typename T>
const T& Get() const;
template<typename Visitor>
auto Visit(Visitor&& visitor) const;
template<typename Visitor>
auto Visit(Visitor&& visitor);
};
template<typename T>
LSPAny& LSPAny::operator=(const T& val)
{
if constexpr (std::is_same_v<T, LSPObject> ||
std::is_same_v<T, LSPArray> ||
std::is_same_v<T, string> ||
std::is_same_v<T, integer> ||
std::is_same_v<T, uinteger> ||
std::is_same_v<T, decimal> ||
std::is_same_v<T, boolean> ||
std::is_same_v<T, std::nullptr_t>)
{
value = val;
}
else if constexpr (std::is_integral_v<T> && !std::is_same_v<T, bool>)
{
if constexpr (std::is_unsigned_v<T>)
{
if (val <= static_cast<std::make_unsigned_t<uinteger>>(std::numeric_limits<uinteger>::max()))
value = static_cast<uinteger>(val);
else
value = static_cast<decimal>(val);
}
else
{
if (val >= std::numeric_limits<integer>::min() && val <= std::numeric_limits<integer>::max())
value = static_cast<integer>(val);
else
value = static_cast<decimal>(val);
}
}
else if constexpr (std::is_floating_point_v<T>)
{
value = static_cast<decimal>(val);
}
else if constexpr (std::is_same_v<T, const char*> ||
(std::is_array_v<T> && std::is_same_v<std::remove_extent_t<T>, char>))
{
value = string(val);
}
else
{
static_assert(std::is_same_v<T, void>, "Unsupported type for LSPAny");
}
return *this;
}
template<typename T>
bool LSPAny::Is() const
{
return std::holds_alternative<T>(value);
}
template<typename T>
T& LSPAny::Get()
{
return std::get<T>(value);
}
template<typename T>
const T& LSPAny::Get() const
{
return std::get<T>(value);
}
template<typename Visitor>
auto LSPAny::Visit(Visitor&& visitor) const
{
return std::visit(std::forward<Visitor>(visitor), value);
}
template<typename Visitor>
auto LSPAny::Visit(Visitor&& visitor)
{
return std::visit(std::forward<Visitor>(visitor), value);
}
// 额外基础类型
struct Position
{
uinteger line;
uinteger character;
};
struct Range
{
Position start;
Position end;
};
using PositionEncodingKind = std::string_view;
namespace PositionEncodingKindLiterals
{
inline constexpr PositionEncodingKind UTF8 = "utf-8";
inline constexpr PositionEncodingKind UTF16 = "utf-16";
inline constexpr PositionEncodingKind UTF32 = "utf-32";
}
struct Location
{
string uri;
Range range;
};
struct Command
{
string title;
string command;
std::optional<std::vector<LSPAny>> arguments;
};
struct TextEdit
{
Range range;
string newText;
};
struct AnnotatedTextEdit
{
Range range;
string newText;
string annotationId;
};
struct SnippetTextEdit
{
Range range;
string snippet;
};
struct ChangeAnnotation
{
string label;
std::optional<string> description;
std::optional<boolean> needsResolve;
};
struct StringValue
{
string kind;
string value;
};
using MarkupKind = std::string_view;
namespace MarkupKindLiterals
{
inline constexpr MarkupKind PlainText = "plaintext";
inline constexpr MarkupKind Markdown = "markdown";
};
struct MarkupContent
{
MarkupKind kind;
string value;
};
struct RegularExpressionsClientCapabilities
{
string engine;
std::optional<string> version;
};
struct MarkdownClientCapabilities
{
string parser;
std::optional<string> version;
std::optional<std::vector<string>> allowedTags;
};
}
namespace glz
{
// 为 LSPAny 提供 glaze 支持
template<>
struct meta<lsp::protocol::LSPAny>
{
static constexpr std::string_view name = "LSPAny";
using T = lsp::protocol::LSPAny;
static constexpr auto value = &T::value;
};
}
@@ -1,8 +1,14 @@
#pragma once
#include "./basic_types.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.common.message;
import std;
import lsp.protocol.common.basic_types;
export namespace lsp::protocol
{
// LSP Error Codes
enum class ErrorCodes : int
{
ParseError = -32700,
@@ -23,42 +29,41 @@ namespace lsp::protocol
LspReservedErrorRangeEnd = -32800
};
struct Message
struct RequestMessage
{
string jsonrpc = "2.0";
};
struct RequestMessage: Message
{
std::variant<integer, string> id;
string method;
std::optional<std::variant<LSPArray, LSPObject>> params;
};
struct ResponseError: Message
{
ErrorCodes code;
string message;
std::optional<LSPAny> data;
};
struct ResponseMessage: Message
{
std::variant<integer, string> id;
std::optional<LSPAny> result;
std::optional<ResponseError> error;
};
struct NotificationMessage: Message
{
string id;
string method;
std::optional<LSPAny> params;
};
struct CancelParams
struct ResponseError
{
std::variant<integer, string> id;
string jsonrpc = "2.0";
integer code;
string message;
std::optional<LSPAny> data;
};
}
struct ResponseMessage
{
string jsonrpc = "2.0";
std::optional<string> id;
std::optional<LSPAny> result;
std::optional<ResponseError> error;
};
struct NotificationMessage
{
string jsonrpc = "2.0";
string method;
std::optional<LSPAny> params;
};
// $/cancelRequest notification params
struct CancelParams
{
// The request id to cancel.
std::variant<int, std::string> id; // integer | string
};
}
@@ -1,8 +1,18 @@
#pragma once
#include "./basic_types.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.common.registration;
import std;
import lsp.protocol.common.basic_types;
export namespace lsp::protocol
{
struct StaticRegistrationOptions
{
std::optional<string> id;
};
struct Registration
{
string id;
@@ -15,16 +25,6 @@ namespace lsp::protocol
std::vector<Registration> registrations;
};
struct StaticRegistrationOptions
{
std::optional<string> id;
};
struct TextDocumentRegistrationOptions
{
std::optional<DocumentSelector> documentSelector;
};
struct Unregistration
{
string id;
@@ -33,7 +33,6 @@ namespace lsp::protocol
struct UnregistrationParams
{
std::vector<Unregistration> unregistration;
std::vector<Unregistration> unregistrations;
};
} // namespace lsp::protocol
}
@@ -1,315 +0,0 @@
#pragma once
#include <cstdint>
#include <limits>
#include <optional>
#include <string>
#include <map>
#include <type_traits>
#include <variant>
#include <vector>
namespace lsp::protocol
{
using integer = std::int32_t;
using uinteger = std::uint32_t;
using decimal = double;
using boolean = bool;
using string = std::string;
// LSPAny 这样设计是为了glaz序列化
// export type LSPAny = LSPObject | LSPArray | string | integer | uinteger | decimal | boolean | null;
struct LSPAny;
using LSPObject = std::map<string, LSPAny>;
using LSPArray = std::vector<LSPAny>;
struct LSPAny
{
using LSPAnyVariant = std::variant<
LSPObject,
LSPArray,
string,
integer,
uinteger,
decimal,
boolean,
std::nullptr_t>;
LSPAnyVariant value;
// 默认构造函数
LSPAny();
// 拷贝和移动构造函数
LSPAny(const LSPAny& other);
LSPAny(LSPAny&& other) noexcept;
// 容器类型的构造函数
LSPAny(const LSPObject& val);
LSPAny(LSPObject&& val);
LSPAny(const LSPArray& val);
LSPAny(LSPArray&& val);
// 字符串类型的构造函数
LSPAny(const string& val);
LSPAny(string&& val);
LSPAny(const char* val);
// 浮点类型的构造函数 -- decimal
LSPAny(float val);
LSPAny(double val);
LSPAny(long double val);
// 布尔和空值
LSPAny(boolean val);
LSPAny(std::nullptr_t);
// 单个模板处理所有整数类型
template<typename T, typename = std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, bool> && !std::is_same_v<std::decay_t<T>, char>>>
LSPAny(T val);
// 赋值操作符
LSPAny& operator=(const LSPAny& other);
LSPAny& operator=(LSPAny&& other) noexcept;
LSPAny& operator=(const LSPObject& val);
LSPAny& operator=(LSPObject&& val);
LSPAny& operator=(const LSPArray& val);
LSPAny& operator=(LSPArray&& val);
LSPAny& operator=(const string& val);
LSPAny& operator=(string&& val);
LSPAny& operator=(const char* val);
LSPAny& operator=(float val);
LSPAny& operator=(double val);
LSPAny& operator=(long double val);
LSPAny& operator=(boolean val);
LSPAny& operator=(std::nullptr_t);
// 整数类型赋值 - 使用模板避免类型冲突
template<typename T, typename = std::enable_if_t<std::is_integral_v<T> && !std::is_same_v<T, bool> && !std::is_same_v<std::decay_t<T>, char>>>
LSPAny& operator=(T val);
// 类型检查辅助函数
template<typename T>
bool Is() const;
template<typename T>
T& Get();
template<typename T>
const T& Get() const;
// 访问操作符
template<typename Visitor>
auto Visit(Visitor&& visitor) const;
template<typename Visitor>
auto Visit(Visitor&& visitor);
};
using ProgressToken = std::variant<integer, string>;
template<typename T>
struct ProgressParams
{
ProgressToken token;
T value;
};
using DocumentUri = string;
using URI = string;
struct Position
{
uinteger line;
uinteger character;
};
using PositionEncodingKind = std::string_view;
namespace PositionEncodingKindLiterals
{
inline constexpr PositionEncodingKind UTF8 = "utf-8";
inline constexpr PositionEncodingKind UTF16 = "utf-16";
inline constexpr PositionEncodingKind UTF32 = "utf-32";
}
struct Range
{
Position start;
Position end;
};
struct DocumentFilter
{
string language;
string scheme;
std::optional<string> pattern;
};
using DocumentSelector = std::vector<DocumentFilter>;
struct TextEdit
{
Range range;
string newText;
};
struct ChangeAnnotation
{
string label;
boolean needsConfirmation;
string description;
};
using ChangeAnnotationIdentifier = string;
struct AnnotatedTextEdit : TextEdit
{
ChangeAnnotationIdentifier annotationId;
};
struct Location
{
DocumentUri uri;
Range range;
};
struct LocationLink
{
Range originSelectionRange;
DocumentUri targetUri;
Range targetRange;
Range targetSelectionRange;
};
struct Command
{
string title;
string command;
std::optional<LSPAny> arguments;
};
struct StringValue
{
string kind;
string value;
};
struct SnippetTextEdit
{
Range range;
StringValue snippet;
std::optional<ChangeAnnotationIdentifier> annotationId;
};
enum class ApplyKind
{
Replace = 1,
Merge = 2
};
using MarkupKind = std::string_view;
namespace MarkupKindLiterals
{
inline constexpr MarkupKind PlainText = "plaintext";
inline constexpr MarkupKind Markdown = "markdown";
};
struct MarkupContent
{
MarkupKind kind;
string value;
};
struct RegularExpressionsClientCapabilities
{
string engine;
std::optional<string> version;
};
struct MarkdownClientCapabilities
{
string parser;
std::optional<string> version;
std::optional<std::vector<string>> allowedTags;
};
// LSP模板方法
template<typename T, typename>
LSPAny::LSPAny(T val)
{
if constexpr (std::is_signed_v<T>)
{
// 有符号整数
if (val >= std::numeric_limits<integer>::min() && val <= std::numeric_limits<integer>::max())
value = static_cast<integer>(val);
else
value = static_cast<decimal>(val); // 超出 int32 范围,转为 decimal(可能丢失精度)
}
else
{
// 无符号整数
if (val <= std::numeric_limits<uinteger>::max())
value = static_cast<uinteger>(val);
else
value = static_cast<decimal>(val); // 超出 uint32 范围,转为 decimal(可能丢失精度)
}
}
template<typename T, typename>
LSPAny& LSPAny::operator=(T val)
{
if constexpr (std::is_signed_v<T>)
{
// 有符号整数
if (val >= std::numeric_limits<integer>::min() && val <= std::numeric_limits<integer>::max())
value = static_cast<integer>(val);
else
value = static_cast<decimal>(val);
}
else
{
if (val <= std::numeric_limits<uinteger>::max())
value = static_cast<uinteger>(val);
else
value = static_cast<decimal>(val);
}
return *this;
}
template<typename T>
bool LSPAny::Is() const
{
return std::holds_alternative<T>(value);
}
template<typename T>
T& LSPAny::Get()
{
return std::get<T>(value);
}
template<typename T>
const T& LSPAny::Get() const
{
return std::get<T>(value);
}
// 访问操作符
template<typename Visitor>
auto LSPAny::Visit(Visitor&& visitor) const
{
return std::visit(std::forward<Visitor>(visitor), value);
}
template<typename Visitor>
auto LSPAny::Visit(Visitor&& visitor)
{
return std::visit(std::forward<Visitor>(visitor), value);
}
}
#include "./lsp_any.inl"
-137
View File
@@ -1,137 +0,0 @@
#pragma once
// #include "./basic_types.hpp"
namespace lsp::protocol
{
inline LSPAny::LSPAny() :
value(nullptr) {}
inline LSPAny::LSPAny(const LSPAny& other) :
value(other.value) {}
inline LSPAny::LSPAny(LSPAny&& other) noexcept :
value(std::move(other.value)) {}
inline LSPAny::LSPAny(const LSPObject& val) :
value(val) {}
inline LSPAny::LSPAny(LSPObject&& val) :
value(std::move(val)) {}
inline LSPAny::LSPAny(const LSPArray& val) :
value(val) {}
inline LSPAny::LSPAny(LSPArray&& val) :
value(std::move(val)) {}
inline LSPAny::LSPAny(const string& val) :
value(val) {}
inline LSPAny::LSPAny(string&& val) :
value(std::move(val)) {}
inline LSPAny::LSPAny(const char* val) :
value(string(val)) {}
inline LSPAny::LSPAny(float val) :
value(static_cast<decimal>(val)) {}
inline LSPAny::LSPAny(double val) :
value(val) {}
inline LSPAny::LSPAny(long double val) :
value(static_cast<decimal>(val)) {}
inline LSPAny::LSPAny(boolean val) :
value(val) {}
inline LSPAny::LSPAny(std::nullptr_t) :
value(nullptr) {}
// 赋值操作符
inline LSPAny& LSPAny::operator=(const LSPAny& other)
{
value = other.value;
return *this;
}
inline LSPAny& LSPAny::operator=(LSPAny&& other) noexcept
{
value = std::move(other.value);
return *this;
}
inline LSPAny& LSPAny::operator=(const LSPObject& val)
{
value = val;
return *this;
}
inline LSPAny& LSPAny::operator=(LSPObject&& val)
{
value = std::move(val);
return *this;
}
inline LSPAny& LSPAny::operator=(const LSPArray& val)
{
value = val;
return *this;
}
inline LSPAny& LSPAny::operator=(LSPArray&& val)
{
value = std::move(val);
return *this;
}
inline LSPAny& LSPAny::operator=(const string& val)
{
value = val;
return *this;
}
inline LSPAny& LSPAny::operator=(string&& val)
{
value = std::move(val);
return *this;
}
inline LSPAny& LSPAny::operator=(const char* val)
{
value = string(val);
return *this;
}
inline LSPAny& LSPAny::operator=(float val)
{
value = static_cast<decimal>(val);
return *this;
}
inline LSPAny& LSPAny::operator=(double val)
{
value = val;
return *this;
}
inline LSPAny& LSPAny::operator=(long double val)
{
value = static_cast<decimal>(val);
return *this;
}
inline LSPAny& LSPAny::operator=(boolean val)
{
value = val;
return *this;
}
inline LSPAny& LSPAny::operator=(std::nullptr_t)
{
value = nullptr;
return *this;
}
}
@@ -1,24 +1,29 @@
#pragma once
#include "./basic_types.hpp"
#include "./progress.hpp"
#include "./diagnostics.hpp"
#include "./workspace.hpp"
#include "./document_sync.hpp"
#include "./completion.hpp"
#include "./document_features.hpp"
#include "./symbols.hpp"
#include "./navigation.hpp"
#include "./code_actions.hpp"
#include "./formatting.hpp"
#include "./rename.hpp"
#include "./semantic_tokens.hpp"
#include "./inline_features.hpp"
#include "./signature_help.hpp"
#include "./notebook.hpp"
#include "./file_operations.hpp"
#include "./configuration.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.initialize.capabilities;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.window.progress;
import lsp.protocol.text_document.diagnostics;
import lsp.protocol.workspace.workspace;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.text_document.completion;
import lsp.protocol.text_document.document_features;
import lsp.protocol.text_document.symbols;
import lsp.protocol.text_document.navigation;
import lsp.protocol.text_document.code_actions;
import lsp.protocol.text_document.formatting;
import lsp.protocol.text_document.rename;
import lsp.protocol.text_document.semantic_tokens;
import lsp.protocol.text_document.inline_features;
import lsp.protocol.text_document.signature_help;
import lsp.protocol.workspace.notebook;
import lsp.protocol.workspace.file_operations;
import lsp.protocol.initialize.configuration;
export namespace lsp::protocol
{
struct TextDocumentClientCapabilities
{
@@ -1,10 +1,14 @@
#pragma once
#include "./basic_types.hpp"
#include "./progress.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.initialize.configuration;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.window.progress;
export namespace lsp::protocol
{
// Configuration
struct ConfigurationItem
{
std::optional<URI> scopeUri;
@@ -13,7 +17,7 @@ namespace lsp::protocol
struct ConfigurationParams
{
std::vector<ConfigurationParams> items;
std::vector<ConfigurationItem> items;
};
struct DidChangeConfigurationClientCapabilities
@@ -26,7 +30,6 @@ namespace lsp::protocol
LSPAny settings;
};
// Command Execution
struct ExecuteCommandClientCapabilities
{
std::optional<boolean> dynamicRegistration;
@@ -47,7 +50,6 @@ namespace lsp::protocol
std::optional<std::vector<LSPAny>> arguments;
};
// Message
enum class MessageType
{
Error = 1,
@@ -107,5 +109,4 @@ namespace lsp::protocol
MessageType type;
string message;
};
}
+629
View File
@@ -0,0 +1,629 @@
module;
import glaze;
export module lsp.protocol;
import std;
// Aggregated LSP protocol module (facade with serialization metadata)
// This module re-exports lsp.protocol.types and all protocol submodules
// Note: transform.* modules are NOT re-exported to avoid circular dependencies
export import lsp.protocol.types;
// Import all protocol submodules for glaze metadata
import lsp.protocol.window.progress;
import lsp.protocol.initialize.configuration;
import lsp.protocol.initialize.capabilities;
import lsp.protocol.workspace.workspace;
import lsp.protocol.workspace.file_operations;
import lsp.protocol.workspace.notebook;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.text_document.completion;
import lsp.protocol.text_document.code_actions;
import lsp.protocol.text_document.diagnostics;
import lsp.protocol.text_document.document_features;
import lsp.protocol.text_document.formatting;
import lsp.protocol.text_document.inline_features;
import lsp.protocol.text_document.navigation;
import lsp.protocol.text_document.rename;
import lsp.protocol.text_document.semantic_tokens;
import lsp.protocol.text_document.signature_help;
import lsp.protocol.text_document.symbols;
// Glaze meta specializations (from legacy protocol.hpp)
namespace glz
{
template<>
struct meta<lsp::protocol::RequestMessage>
{
using T = lsp::protocol::RequestMessage;
static constexpr auto value = glz::object(
&T::jsonrpc,
&T::id,
&T::method,
&T::params);
};
template<>
struct meta<lsp::protocol::ResponseError>
{
using T = lsp::protocol::ResponseError;
static constexpr auto value = glz::object(&T::jsonrpc, &T::code, &T::message, &T::data);
};
template<>
struct meta<lsp::protocol::ResponseMessage>
{
using T = lsp::protocol::ResponseMessage;
static constexpr auto value = glz::object(&T::jsonrpc, &T::id, &T::result, &T::error);
};
template<>
struct meta<lsp::protocol::NotificationMessage>
{
using T = lsp::protocol::NotificationMessage;
static constexpr auto value = glz::object(&T::jsonrpc, &T::method, &T::params);
};
template<>
struct meta<lsp::protocol::CancelParams>
{
using T = lsp::protocol::CancelParams;
static constexpr auto value = glz::object(&T::id);
};
template<>
struct meta<lsp::protocol::AnnotatedTextEdit>
{
using T = lsp::protocol::AnnotatedTextEdit;
static constexpr auto value = glz::object(&T::range, &T::newText, &T::annotationId);
};
template<>
struct meta<lsp::protocol::InitializeParams>
{
using T = lsp::protocol::InitializeParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::processId, &T::clientInfo, &T::locale, &T::rootPath, &T::rootUri, &T::initializationOptions, &T::capabilities, &T::trace, &T::workspaceFolders);
};
template<>
struct meta<lsp::protocol::CodeActionOptions>
{
using T = lsp::protocol::CodeActionOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::codeActionKinds, &T::resolveProvider);
};
template<>
struct meta<lsp::protocol::CodeActionRegistrationOptions>
{
using T = lsp::protocol::CodeActionRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::codeActionKinds, &T::resolveProvider);
};
template<>
struct meta<lsp::protocol::CodeActionParams>
{
using T = lsp::protocol::CodeActionParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken, &T::partialResultToken, &T::textDocument, &T::range, &T::context);
};
template<>
struct meta<lsp::protocol::DocumentColorOptions>
{
using T = lsp::protocol::DocumentColorOptions;
static constexpr auto value = glz::object(&T::workDoneProgress);
};
template<>
struct meta<lsp::protocol::DocumentColorRegistrationOptions>
{
using T = lsp::protocol::DocumentColorRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::id);
};
template<>
struct meta<lsp::protocol::DocumentColorParams>
{
using T = lsp::protocol::DocumentColorParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::textDocument);
};
template<>
struct meta<lsp::protocol::ColorPresentationParams>
{
using T = lsp::protocol::ColorPresentationParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::textDocument, &T::color, &T::range);
};
template<>
struct meta<lsp::protocol::CompletionOptions>
{
using T = lsp::protocol::CompletionOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::triggerCharacters, &T::allCommitCharacters, &T::resolveProvider, &T::completionItem);
};
template<>
struct meta<lsp::protocol::CompletionRegistrationOptions>
{
using T = lsp::protocol::CompletionRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::triggerCharacters, &T::allCommitCharacters, &T::resolveProvider, &T::completionItem);
};
template<>
struct meta<lsp::protocol::CompletionParams>
{
using T = lsp::protocol::CompletionParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::textDocument, &T::position, &T::context);
};
template<>
struct meta<lsp::protocol::ExecuteCommandOptions>
{
using T = lsp::protocol::ExecuteCommandOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::commands);
};
template<>
struct meta<lsp::protocol::ExecuteCommandRegistrationOptions>
{
using T = lsp::protocol::ExecuteCommandRegistrationOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::commands);
};
template<>
struct meta<lsp::protocol::ExecuteCommandParams>
{
using T = lsp::protocol::ExecuteCommandParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::arguments);
};
template<>
struct meta<lsp::protocol::DiagnosticOptions>
{
using T = lsp::protocol::DiagnosticOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::interFileDependencies, &T::workspaceDiagnostics);
};
template<>
struct meta<lsp::protocol::DiagnosticRegistrationOptions>
{
using T = lsp::protocol::DiagnosticRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::id, &T::workDoneProgress, &T::interFileDependencies, &T::workspaceDiagnostics);
};
template<>
struct meta<lsp::protocol::DiagnosticParams>
{
using T = lsp::protocol::DiagnosticParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::textDocument, &T::identifier, &T::previousResultId);
};
template<>
struct meta<lsp::protocol::PublishDiagnosticsClientCapabilities>
{
using T = lsp::protocol::PublishDiagnosticsClientCapabilities;
static constexpr auto value = glz::object(&T::dynamicRegistration, &T::relatedDocumentSupport, &T::relatedInformation, &T::tagSupport, &T::codeDescriptionSupport, &T::markupMessageSupport, &T::dataSupport, &T::versionSupport);
};
template<>
struct meta<lsp::protocol::RelatedFullDocumentDiagnosticReport>
{
using T = lsp::protocol::RelatedFullDocumentDiagnosticReport;
static constexpr auto value = glz::object(&T::kind, &T::resultId, &T::items, &T::relatedDocuments);
};
template<>
struct meta<lsp::protocol::RelatedUnchangedDocumentDiagnosticReport>
{
using T = lsp::protocol::RelatedUnchangedDocumentDiagnosticReport;
static constexpr auto value = glz::object(&T::kind, &T::resultId, &T::relatedDocuments);
};
template<>
struct meta<lsp::protocol::WorkspaceDiagnosticParams>
{
using T = lsp::protocol::WorkspaceDiagnosticParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::identifier, &T::previousResultIds);
};
template<>
struct meta<lsp::protocol::WorkspaceFullDocumentDiagnosticReport>
{
using T = lsp::protocol::WorkspaceFullDocumentDiagnosticReport;
static constexpr auto value = glz::object(&T::kind, &T::resultId, &T::items, &T::uri, &T::version);
};
template<>
struct meta<lsp::protocol::WorkspaceUnchangedDocumentDiagnosticReport>
{
using T = lsp::protocol::WorkspaceUnchangedDocumentDiagnosticReport;
static constexpr auto value = glz::object(&T::kind, &T::resultId, &T::uri, &T::version);
};
template<>
struct meta<lsp::protocol::DocumentHighlightOptions>
{
using T = lsp::protocol::DocumentHighlightOptions;
static constexpr auto value = glz::object(&T::workDoneProgress);
};
template<>
struct meta<lsp::protocol::DocumentHighlightRegistrationOptions>
{
using T = lsp::protocol::DocumentHighlightRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress);
};
template<>
struct meta<lsp::protocol::DocumentHighlightParams>
{
using T = lsp::protocol::DocumentHighlightParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::textDocument, &T::position);
};
template<>
struct meta<lsp::protocol::DocumentLinkOptions>
{
using T = lsp::protocol::DocumentLinkOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::resolveProvider);
};
template<>
struct meta<lsp::protocol::DocumentLinkRegistrationOptions>
{
using T = lsp::protocol::DocumentLinkRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::resolveProvider);
};
template<>
struct meta<lsp::protocol::DocumentLinkParams>
{
using T = lsp::protocol::DocumentLinkParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::textDocument);
};
template<>
struct meta<lsp::protocol::HoverOptions>
{
using T = lsp::protocol::HoverOptions;
static constexpr auto value = glz::object(&T::workDoneProgress);
};
template<>
struct meta<lsp::protocol::HoverRegistrationOptions>
{
using T = lsp::protocol::HoverRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress);
};
template<>
struct meta<lsp::protocol::HoverParams>
{
using T = lsp::protocol::HoverParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::textDocument, &T::position);
};
template<>
struct meta<lsp::protocol::CodeLensOptions>
{
using T = lsp::protocol::CodeLensOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::resolveProvider);
};
template<>
struct meta<lsp::protocol::CodeLensRegistrationOptions>
{
using T = lsp::protocol::CodeLensRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::resolveProvider);
};
template<>
struct meta<lsp::protocol::CodeLensParams>
{
using T = lsp::protocol::CodeLensParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::textDocument);
};
template<>
struct meta<lsp::protocol::FoldingRangeOptions>
{
using T = lsp::protocol::FoldingRangeOptions;
static constexpr auto value = glz::object(&T::workDoneProgress);
};
template<>
struct meta<lsp::protocol::FoldingRangeRegistrationOptions>
{
using T = lsp::protocol::FoldingRangeRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::id);
};
template<>
struct meta<lsp::protocol::FoldingRangeParams>
{
using T = lsp::protocol::FoldingRangeParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::textDocument);
};
template<>
struct meta<lsp::protocol::SelectionRangeOptions>
{
using T = lsp::protocol::SelectionRangeOptions;
static constexpr auto value = glz::object(&T::workDoneProgress);
};
template<>
struct meta<lsp::protocol::SelectionRangeRegistrationOptions>
{
using T = lsp::protocol::SelectionRangeRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::id);
};
template<>
struct meta<lsp::protocol::SelectionRangeParams>
{
using T = lsp::protocol::SelectionRangeParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::textDocument, &T::positions);
};
template<>
struct meta<lsp::protocol::WorkspaceSymbolOptions>
{
using T = lsp::protocol::WorkspaceSymbolOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::resolveProvider);
};
template<>
struct meta<lsp::protocol::InlayHintOptions>
{
using T = lsp::protocol::InlayHintOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::resolveProvider);
};
template<>
struct meta<lsp::protocol::InlayHintRegistrationOptions>
{
using T = lsp::protocol::InlayHintRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::resolveProvider, &T::id);
};
template<>
struct meta<lsp::protocol::InlineValueRegistrationOptions>
{
using T = lsp::protocol::InlineValueRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::id);
};
template<>
struct meta<lsp::protocol::TypeHierarchyRegistrationOptions>
{
using T = lsp::protocol::TypeHierarchyRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::id);
};
template<>
struct meta<lsp::protocol::MonikerRegistrationOptions>
{
using T = lsp::protocol::MonikerRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress);
};
template<>
struct meta<lsp::protocol::LinkedEditingRangeRegistrationOptions>
{
using T = lsp::protocol::LinkedEditingRangeRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::id);
};
template<>
struct meta<lsp::protocol::SemanticTokensOptions>
{
using T = lsp::protocol::SemanticTokensOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::legend, &T::range, &T::full);
};
template<>
struct meta<lsp::protocol::SemanticTokensRegistrationOptions>
{
using T = lsp::protocol::SemanticTokensRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::legend, &T::range, &T::full, &T::id);
};
template<>
struct meta<lsp::protocol::CallHierarchyRegistrationOptions>
{
using T = lsp::protocol::CallHierarchyRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::id);
};
template<>
struct meta<lsp::protocol::RenameOptions>
{
using T = lsp::protocol::RenameOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::prepareProvider);
};
template<>
struct meta<lsp::protocol::RenameRegistrationOptions>
{
using T = lsp::protocol::RenameRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::prepareProvider);
};
template<>
struct meta<lsp::protocol::RenameParams>
{
using T = lsp::protocol::RenameParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken, &T::newName);
};
template<>
struct meta<lsp::protocol::PrepareRenameParams>
{
using T = lsp::protocol::PrepareRenameParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken);
};
template<>
struct meta<lsp::protocol::LinkedEditingRangeParams>
{
using T = lsp::protocol::LinkedEditingRangeParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken, &T::partialResultToken);
};
template<>
struct meta<lsp::protocol::DocumentOnTypeFormattingOptions>
{
using T = lsp::protocol::DocumentOnTypeFormattingOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::firstTriggerCharacter, &T::moreTriggerCharacter);
};
template<>
struct meta<lsp::protocol::DocumentRangeFormattingOptions>
{
using T = lsp::protocol::DocumentRangeFormattingOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::rangesSupport);
};
template<>
struct meta<lsp::protocol::DocumentSymbolOptions>
{
using T = lsp::protocol::DocumentSymbolOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::label);
};
template<>
struct meta<lsp::protocol::ImplementationRegistrationOptions>
{
using T = lsp::protocol::ImplementationRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::id);
};
template<>
struct meta<lsp::protocol::SignatureHelpOptions>
{
using T = lsp::protocol::SignatureHelpOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::triggerCharacters, &T::retriggerCharacters);
};
template<>
struct meta<lsp::protocol::DeclarationRegistrationOptions>
{
using T = lsp::protocol::DeclarationRegistrationOptions;
static constexpr auto value = glz::object(&T::workDoneProgress, &T::documentSelector, &T::id);
};
template<>
struct meta<lsp::protocol::TypeDefinitionRegistrationOptions>
{
using T = lsp::protocol::TypeDefinitionRegistrationOptions;
static constexpr auto value = glz::object(&T::documentSelector, &T::workDoneProgress, &T::id);
};
template<>
struct meta<lsp::protocol::DeclarationParams>
{
using T = lsp::protocol::DeclarationParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken, &T::partialResultToken);
};
template<>
struct meta<lsp::protocol::DefinitionParams>
{
using T = lsp::protocol::DefinitionParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken, &T::partialResultToken);
};
template<>
struct meta<lsp::protocol::TypeDefinitionParams>
{
using T = lsp::protocol::TypeDefinitionParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken);
};
template<>
struct meta<lsp::protocol::ImplementationParams>
{
using T = lsp::protocol::ImplementationParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken);
};
template<>
struct meta<lsp::protocol::ReferenceContext>
{
using T = lsp::protocol::ReferenceContext;
static constexpr auto value = glz::object(&T::includeDeclaration);
};
template<>
struct meta<lsp::protocol::ReferenceParams>
{
using T = lsp::protocol::ReferenceParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken, &T::partialResultToken, &T::context);
};
template<>
struct meta<lsp::protocol::CallHierarchyParams>
{
using T = lsp::protocol::CallHierarchyParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken);
};
template<>
struct meta<lsp::protocol::CallHierarchyIncomingCallsParams>
{
using T = lsp::protocol::CallHierarchyIncomingCallsParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::item);
};
template<>
struct meta<lsp::protocol::CallHierarchyOutgoingCallsParams>
{
using T = lsp::protocol::CallHierarchyOutgoingCallsParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::item);
};
template<>
struct meta<lsp::protocol::TypeHierarchyParams>
{
using T = lsp::protocol::TypeHierarchyParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken);
};
template<>
struct meta<lsp::protocol::TypeHierarchyPrepareParams>
{
using T = lsp::protocol::TypeHierarchyPrepareParams;
static constexpr auto value = glz::object(&T::textDocument, &T::position, &T::workDoneToken);
};
template<>
struct meta<lsp::protocol::TypeHierarchySupertypesParams>
{
using T = lsp::protocol::TypeHierarchySupertypesParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::item);
};
template<>
struct meta<lsp::protocol::TypeHierarchySubtypesParams>
{
using T = lsp::protocol::TypeHierarchySubtypesParams;
static constexpr auto value = glz::object(&T::workDoneToken, &T::partialResultToken, &T::item);
};
template<>
struct meta<lsp::protocol::NotebookDocumentSyncRegistrationOptions>
{
using T = lsp::protocol::NotebookDocumentSyncRegistrationOptions;
static constexpr auto value = glz::object(&T::notebookSelector, &T::save, &T::id);
};
template<>
struct meta<lsp::protocol::VersionedTextDocumentIdentifier>
{
using T = lsp::protocol::VersionedTextDocumentIdentifier;
static constexpr auto value = glz::object(&T::uri, &T::version);
};
}
File diff suppressed because it is too large Load Diff
@@ -1,10 +1,17 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
#include "./workspace.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.code_actions;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
import lsp.protocol.workspace.workspace;
import lsp.protocol.text_document.diagnostics;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
using CodeActionKind = std::string_view;
namespace CodeActionKindLiterals
@@ -1,9 +1,15 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.completion;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
enum class CompletionItemTag
{
@@ -1,9 +1,15 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.diagnostics;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
enum class DiagnosticSeverity
{
@@ -1,9 +1,15 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.document_features;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
// Document Highlight
struct DocumentHighlightClientCapabilities
@@ -183,7 +189,6 @@ namespace lsp::protocol
std::optional<boolean> refreshSupport;
};
// Sekection Range
struct SelectionRangeClientCapabilities
{
@@ -1,9 +1,61 @@
#pragma once
#include "./basic_types.hpp"
#include "./registration.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.document_sync;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
using DocumentUri = string;
struct DocumentFilter
{
std::optional<string> language;
std::optional<string> scheme;
std::optional<string> pattern;
};
struct DocumentSelector : std::vector<DocumentFilter>
{
};
struct TextDocumentIdentifier
{
DocumentUri uri;
};
struct VersionedTextDocumentIdentifier : TextDocumentIdentifier
{
integer version;
};
struct OptionalVersionedTextDocumentIdentifier : TextDocumentIdentifier
{
std::optional<integer> version;
};
struct TextDocumentItem
{
DocumentUri uri;
string languageId;
integer version;
string text;
};
struct TextDocumentPositionParams
{
TextDocumentIdentifier textDocument;
Position position;
};
struct TextDocumentRegistrationOptions
{
std::optional<DocumentSelector> documentSelector;
};
struct TextDocumentSyncClientCapabilities
{
boolean dynamicRegistration;
@@ -25,35 +77,6 @@ namespace lsp::protocol
std::optional<TextDocumentSyncKind> change;
};
struct TextDocumentItem
{
DocumentUri uri;
string languageId;
integer version;
string text;
};
struct TextDocumentIdentifier
{
DocumentUri uri;
};
struct VersionedTextDocumentIdentifier : TextDocumentIdentifier
{
integer version;
};
struct OptionalVersionedTextDocumentIdentifier : TextDocumentIdentifier
{
std::optional<integer> version;
};
struct TextDocumentPositionParams
{
TextDocumentIdentifier textDocument;
Position position;
};
struct DidOpenTextDocumentParams
{
TextDocumentItem textDocument;
@@ -113,8 +136,6 @@ namespace lsp::protocol
struct TextDocumentEdit
{
// OptionalVersionedTextDocumentIdentifier textDocument;
std::variant<std::vector<TextEdit>, std::vector<AnnotatedTextEdit>, std::vector<SnippetTextEdit>> edits;
};
}
@@ -1,9 +1,14 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.formatting;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
export namespace lsp::protocol
{
// Document Formatting
struct DocumentFormattingClientCapabilities
@@ -1,9 +1,15 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.inline_features;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
// Inlay Hints
struct InlayHintClientCapabilities
@@ -51,7 +57,6 @@ namespace lsp::protocol
std::variant<string, std::vector<InlayHintLabelPart>> label;
std::optional<InlayHintKind> kind;
std::optional<std::vector<TextEdit>> textEdits;
;
std::optional<std::variant<string, MarkupContent>> tooltip;
std::optional<boolean> paddingLeft;
std::optional<boolean> paddingRight;
@@ -1,10 +1,16 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
#include "./symbols.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.navigation;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
import lsp.protocol.text_document.symbols;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
// Declaration
struct DeclarationClientCapabilities
@@ -1,9 +1,15 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.rename;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
enum class PrepareSupportDefaultBehavior
{
@@ -1,9 +1,15 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.semantic_tokens;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
using SemanticTokenType = std::string_view;
namespace SemanticTokenTypesLiterals
@@ -1,9 +1,14 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.signature_help;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
export namespace lsp::protocol
{
struct SignatureHelpClientCapabilities
{
@@ -1,10 +1,15 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./progress.hpp"
#include "./completion.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.text_document.symbols;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.window.progress;
import lsp.protocol.text_document.completion;
export namespace lsp::protocol
{
enum class SymbolKind
{
@@ -1,105 +0,0 @@
#pragma once
#include <type_traits>
#include <stdexcept>
#include <vector>
#include <map>
#include <optional>
#include <variant>
#include "../detail/basic_types.hpp"
namespace lsp::transform
{
/// 转换错误异常类
class ConversionError : public std::runtime_error
{
public:
explicit ConversionError(const std::string& message) : std::runtime_error("LSP Conversion Error: " + message) {}
};
/// 类型特征:LSP 基本类型判断
template<typename T>
inline constexpr bool is_lsp_basic_type_v =
std::is_same_v<T, protocol::integer> ||
std::is_same_v<T, protocol::uinteger> ||
std::is_same_v<T, protocol::decimal> ||
std::is_same_v<T, protocol::boolean> ||
std::is_same_v<T, protocol::string> ||
std::is_same_v<T, std::nullptr_t>;
/// 类型特征:LSP 容器类型判断
template<typename T>
inline constexpr bool is_lsp_container_type_v =
std::is_same_v<T, protocol::LSPObject> ||
std::is_same_v<T, protocol::LSPArray> ||
std::is_same_v<T, protocol::LSPAny>;
/// 类型特征:检测 vector
template<typename T>
struct is_vector : std::false_type
{
};
template<typename T>
struct is_vector<std::vector<T>> : std::true_type
{
};
template<typename T>
inline constexpr bool is_vector_v = is_vector<T>::value;
/// 类型特征:检测 map
template<typename T>
struct is_map : std::false_type
{
};
template<typename K, typename V>
struct is_map<std::map<K, V>> : std::true_type
{
};
template<typename T>
inline constexpr bool is_map_v = is_map<T>::value;
/// 类型特征:检测 optional
template<typename T>
struct is_optional : std::false_type
{
};
template<typename T>
struct is_optional<std::optional<T>> : std::true_type
{
};
template<typename T>
inline constexpr bool is_optional_v = is_optional<T>::value;
/// 类型特征:检测 variant
template<typename T>
struct is_variant : std::false_type
{
};
template<typename... Ts>
struct is_variant<std::variant<Ts...>> : std::true_type
{
};
template<typename T>
inline constexpr bool is_variant_v = is_variant<T>::value;
/// 类型特征:用户自定义 struct 判断
template<typename T>
inline constexpr bool is_user_struct_v =
std::is_class_v<T> &&
!std::is_pointer_v<T> &&
!std::is_same_v<T, protocol::string> &&
!std::is_same_v<T, std::string> &&
!is_lsp_basic_type_v<T> &&
!is_lsp_container_type_v<T> &&
!is_vector_v<T> &&
!is_map_v<T> &&
!is_optional_v<T> &&
!is_variant_v<T>;
}
@@ -1,82 +0,0 @@
#pragma once
#include "./transformer.hpp"
namespace lsp::transform
{
// ==================== JSON 序列化/反序列化 ====================
template<typename T>
std::optional<T> Deserialize(const std::string& json);
template<typename T>
std::optional<std::string> Serialize(const T& obj);
// ==================== 转换为 LSPAny ====================
/// 任意类型转换为 LSPAny
///
/// 支持的类型:
/// - 基本类型:bool, int, double, string, nullptr
/// - 容器类型:vector, map, optional
/// - LSP 类型:LSPObject, LSPArray, LSPAny
/// - 用户结构体(需要 glaze 支持)
inline constexpr auto ToLSPAny = [](const auto& value) {
return LSPAnyConverter::ToLSPAny(value);
};
/// LSPAny 转换为指定类型
///
/// 支持的类型:
/// - 基本类型:bool, int, double, string
/// - 容器类型:vector<T>, optional<T>
/// - LSP 类型:LSPObject, LSPArray
/// - 用户结构体(需要 glaze 支持)
inline constexpr auto FromLSPAny = []<typename T>(const auto& input) -> T {
using InputType = std::decay_t<decltype(input)>;
protocol::LSPAny any;
// 如果是 variant,先提取
if constexpr (std::is_same_v<InputType, std::variant<protocol::LSPArray, protocol::LSPObject>>)
any = std::visit([](const auto& v) -> protocol::LSPAny { return v; }, input);
// 否则直接用(LSPAny、LSPObject、LSPArray 都能隐式转换)
else
any = input;
return LSPAnyConverter::FromLSPAny<T>(any);
};
namespace check
{
/// 检查是否为 LSPObject
bool IsObject(const protocol::LSPAny& any);
/// 检查是否为 LSPArray
bool IsArray(const protocol::LSPAny& any);
/// 检查是否为字符串
bool IsString(const protocol::LSPAny& any);
/// 检查是否为数字(integer/uinteger/decimal
bool IsNumber(const protocol::LSPAny& any);
/// 检查是否为布尔值
bool IsBool(const protocol::LSPAny& any);
/// 检查是否为 null
bool IsNull(const protocol::LSPAny& any);
}
// ==================== 调试工具 ====================
namespace debug
{
/// 获取 LSPAny 的类型名称字符串
std::string GetTypeName(const protocol::LSPAny& any);
/// 将 variant<int, string> 转换为字符串(用于 ID)
std::string GetIdString(const std::variant<int, std::string>& id);
}
}
#include "./facade.inl"
@@ -1,103 +0,0 @@
#pragma once
// #include "./facade.hpp"
namespace lsp::transform
{
// ==================== JSON 序列化/反序列化 ====================
template<typename T>
inline std::optional<T> Deserialize(const std::string& json)
{
T obj;
auto ce = glz::read_json(obj, json);
if (ce)
return std::nullopt;
else
return obj;
}
template<typename T>
inline std::optional<std::string> Serialize(const T& obj)
{
std::string json;
auto ce = glz::write_json(obj, json);
if (ce)
return std::nullopt;
else
return json;
}
// ==================== 类型检查 ====================
namespace check
{
inline bool IsObject(const protocol::LSPAny& any)
{
return any.Is<protocol::LSPObject>();
}
inline bool IsArray(const protocol::LSPAny& any)
{
return any.Is<protocol::LSPArray>();
}
inline bool IsString(const protocol::LSPAny& any)
{
return any.Is<protocol::string>();
}
inline bool IsNumber(const protocol::LSPAny& any)
{
return any.Is<protocol::integer>() ||
any.Is<protocol::uinteger>() ||
any.Is<protocol::decimal>();
}
inline bool IsBool(const protocol::LSPAny& any)
{
return any.Is<protocol::boolean>();
}
inline bool IsNull(const protocol::LSPAny& any)
{
return any.Is<std::nullptr_t>();
}
}
// ==================== 调试工具 ====================
namespace debug
{
inline std::string GetTypeName(const protocol::LSPAny& any)
{
if (any.Is<protocol::LSPObject>())
return "LSPObject";
if (any.Is<protocol::LSPArray>())
return "LSPArray";
if (any.Is<protocol::string>())
return "string";
if (any.Is<protocol::integer>())
return "integer";
if (any.Is<protocol::uinteger>())
return "uinteger";
if (any.Is<protocol::decimal>())
return "decimal";
if (any.Is<protocol::boolean>())
return "boolean";
if (any.Is<std::nullptr_t>())
return "null";
return "unknown";
}
inline std::string GetIdString(const std::variant<int, std::string>& id)
{
return std::visit([](const auto& value) -> std::string {
if constexpr (std::is_same_v<std::decay_t<decltype(value)>, int>)
return std::to_string(value);
else
return value;
},
id);
}
}
}
@@ -1,43 +0,0 @@
#pragma once
#include "../protocol.hpp"
#include "./common.hpp"
namespace lsp::transform
{
/// LSPAny 转换核心类
/// 提供所有类型的双向转换
class LSPAnyConverter
{
public:
// ==================== 任意类型 → LSPAny ====================
/// 通用转换入口:任意类型 → LSPAny
/// 根据类型特征自动分派到具体实现
template<typename T>
static protocol::LSPAny ToLSPAny(const T& value);
// ==================== LSPAny → 任意类型 ====================
/// 通用转换入口:LSPAny → 任意类型
/// 根据类型特征自动分派到具体实现
template<typename T>
static T FromLSPAny(const protocol::LSPAny& any);
private:
// ==================== 辅助工具 ====================
/// 提取数字(支持三种数字类型)
template<typename T>
static T ExtractNumber(const protocol::LSPAny& any);
/// 通过 JSON 转换用户结构体
template<typename T>
static T ConvertViaJson(const protocol::LSPAny& any);
/// 将用户结构体序列化为 LSPAny
template<typename T>
static protocol::LSPAny SerializeViaJson(const T& obj);
};
}
#include "./transformer.inl"
@@ -1,244 +0,0 @@
#pragma once
namespace lsp::transform
{
// ==================== ToLSPAny 实现 ====================
template<typename T>
inline protocol::LSPAny LSPAnyConverter::ToLSPAny(const T& value)
{
using Type = std::decay_t<T>;
// LSPAny 直接返回
if constexpr (std::is_same_v<Type, protocol::LSPAny>)
{
return value;
}
// LSPObject 直接返回
else if constexpr (std::is_same_v<Type, protocol::LSPObject>)
{
return protocol::LSPAny(value);
}
// LSPArray 直接返回
else if constexpr (std::is_same_v<Type, protocol::LSPArray>)
{
return protocol::LSPAny(value);
}
else if constexpr (std::is_same_v<Type, const char*> ||
std::is_same_v<Type, char*>)
{
return protocol::LSPAny(protocol::string(value));
}
// LSP 基本类型(boolean, string, decimal, nullptr
else if constexpr (is_lsp_basic_type_v<Type>)
{
return protocol::LSPAny(value);
}
// 整数类型(依赖 LSPAny 模板构造函数)
else if constexpr (std::is_integral_v<Type> &&
!std::is_same_v<Type, bool>)
{
return protocol::LSPAny(value);
}
// 浮点类型
else if constexpr (std::is_floating_point_v<Type>)
{
return protocol::LSPAny(value);
}
// vector → LSPArray
else if constexpr (is_vector_v<Type>)
{
protocol::LSPArray arr;
arr.reserve(value.size());
for (const auto& item : value)
arr.push_back(ToLSPAny(item));
return protocol::LSPAny(std::move(arr));
}
// map → LSPObject
else if constexpr (is_map_v<Type>)
{
protocol::LSPObject obj;
for (const auto& [key, val] : value)
obj[key] = ToLSPAny(val);
return protocol::LSPAny(std::move(obj));
}
// optional → LSPAny or null
else if constexpr (is_optional_v<Type>)
{
if (value.has_value())
return ToLSPAny(*value);
return protocol::LSPAny(nullptr);
}
// 用户结构体 → LSPAny (通过 JSON)
else if constexpr (is_user_struct_v<Type>)
{
return SerializeViaJson(value);
}
else
{
static_assert(!sizeof(Type), "Unsupported type for ToLSPAny");
}
}
// ==================== FromLSPAny 实现 ====================
template<typename T>
inline T LSPAnyConverter::FromLSPAny(const protocol::LSPAny& any)
{
using Type = std::decay_t<T>;
// LSPAny 直接返回
if constexpr (std::is_same_v<Type, protocol::LSPAny>)
{
return any;
}
// LSPObject 提取
else if constexpr (std::is_same_v<Type, protocol::LSPObject>)
{
if (!any.Is<protocol::LSPObject>())
throw ConversionError("LSPAny does not contain LSPObject");
return any.Get<protocol::LSPObject>();
}
// LSPArray 提取
else if constexpr (std::is_same_v<Type, protocol::LSPArray>)
{
if (!any.Is<protocol::LSPArray>())
throw ConversionError("LSPAny does not contain LSPArray");
return any.Get<protocol::LSPArray>();
}
// boolean 提取
else if constexpr (std::is_same_v<Type, bool>)
{
if (!any.Is<protocol::boolean>())
throw ConversionError("LSPAny does not contain a boolean");
return any.Get<protocol::boolean>();
}
// string 提取
else if constexpr (std::is_same_v<Type, protocol::string> ||
std::is_same_v<Type, std::string>)
{
if (!any.Is<protocol::string>())
throw ConversionError("LSPAny does not contain a string");
return any.Get<protocol::string>();
}
// 数字类型提取
else if constexpr (std::is_arithmetic_v<Type> &&
!std::is_same_v<Type, bool>)
{
return ExtractNumber<Type>(any);
}
// vector 提取
else if constexpr (is_vector_v<Type>)
{
if (!any.Is<protocol::LSPArray>())
throw ConversionError("LSPAny does not contain an array");
const auto& arr = any.Get<protocol::LSPArray>();
Type result;
result.reserve(arr.size());
for (const auto& item : arr)
result.push_back(FromLSPAny<typename Type::value_type>(item));
return result;
}
// map 提取
else if constexpr (is_map_v<Type>)
{
if (!any.Is<protocol::LSPObject>())
throw ConversionError("LSPAny does not contain an object");
const auto& obj = any.Get<protocol::LSPObject>();
Type result;
for (const auto& [key, val] : obj)
result[key] = FromLSPAny<typename Type::mapped_type>(val);
return result;
}
// optional 提取
else if constexpr (is_optional_v<Type>)
{
if (any.Is<std::nullptr_t>())
return std::nullopt;
return FromLSPAny<typename Type::value_type>(any);
}
// 用户结构体提取(通过 JSON)
else if constexpr (is_user_struct_v<Type>)
{
return ConvertViaJson<Type>(any);
}
else
{
static_assert(!sizeof(Type), "Unsupported type for FromLSPAny");
}
}
// ==================== 辅助工具实现 ====================
template<typename T>
inline T LSPAnyConverter::ExtractNumber(const protocol::LSPAny& any)
{
if (any.Is<protocol::integer>())
{
return static_cast<T>(any.Get<protocol::integer>());
}
else if (any.Is<protocol::uinteger>())
{
return static_cast<T>(any.Get<protocol::uinteger>());
}
else if (any.Is<protocol::decimal>())
{
return static_cast<T>(any.Get<protocol::decimal>());
}
else
{
throw ConversionError("LSPAny does not contain a number (integer/uinteger/decimal)");
}
}
template<typename T>
inline T LSPAnyConverter::ConvertViaJson(const protocol::LSPAny& any)
{
try
{
// 序列化 LSPAny 为 JSON
std::string json;
auto ec = glz::write_json(any.value, json);
if (ec)
throw ConversionError("Failed to serialize LSPAny to JSON: " + std::string(glz::format_error(ec, json)));
// 解析 JSON 到目标类型
T result;
ec = glz::read_json(result, json);
if (ec)
throw ConversionError("Failed to parse JSON to target type: " + std::string(glz::format_error(ec, json)));
return result;
}
catch (const std::exception& e)
{
throw ConversionError("LSPAny to struct conversion failed: " + std::string(e.what()));
}
}
template<typename T>
inline protocol::LSPAny LSPAnyConverter::SerializeViaJson(const T& obj)
{
try
{
// 使用 glaze 序列化为 JSON 字符串
std::string json;
auto ec = glz::write_json(obj, json);
if (ec)
throw ConversionError("Failed to serialize struct to JSON: " + std::string(glz::format_error(ec, json)));
// 直接解析为 LSPAny
protocol::LSPAny result;
ec = glz::read_json(result, json);
if (ec)
throw ConversionError("Failed to parse JSON to LSPAny: " + std::string(glz::format_error(ec, json)));
return result;
}
catch (const std::exception& e)
{
throw ConversionError("struct to LSPAny conversion failed: " + std::string(e.what()));
}
}
}
+34
View File
@@ -0,0 +1,34 @@
module;
export module lsp.protocol.types;
// Core protocol types
export import lsp.protocol.common.basic_types;
export import lsp.protocol.common.message;
export import lsp.protocol.common.registration;
// Window protocol
export import lsp.protocol.window.progress;
// Initialize protocol
export import lsp.protocol.initialize.configuration;
export import lsp.protocol.initialize.capabilities;
// Workspace protocol
export import lsp.protocol.workspace.workspace;
export import lsp.protocol.workspace.file_operations;
export import lsp.protocol.workspace.notebook;
// Text document protocol
export import lsp.protocol.text_document.document_sync;
export import lsp.protocol.text_document.completion;
export import lsp.protocol.text_document.code_actions;
export import lsp.protocol.text_document.diagnostics;
export import lsp.protocol.text_document.document_features;
export import lsp.protocol.text_document.formatting;
export import lsp.protocol.text_document.inline_features;
export import lsp.protocol.text_document.navigation;
export import lsp.protocol.text_document.rename;
export import lsp.protocol.text_document.semantic_tokens;
export import lsp.protocol.text_document.signature_help;
export import lsp.protocol.text_document.symbols;
@@ -1,7 +1,12 @@
#pragma once
#include "./basic_types.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.window.progress;
import std;
import lsp.protocol.common.basic_types;
export namespace lsp::protocol
{
struct WorkDoneProgressBegin
{
@@ -69,5 +74,4 @@ namespace lsp::protocol
string message;
std::optional<string> verbose;
};
}
@@ -1,9 +1,13 @@
module;
#pragma once
#include "./basic_types.hpp"
#include "./workspace.hpp"
export module lsp.protocol.workspace.file_operations;
namespace lsp::protocol
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.workspace.workspace;
export namespace lsp::protocol
{
using FileOperationPatternKind = std::string_view;
namespace FileOperationPatternKindLiterals
@@ -1,8 +1,14 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.workspace.notebook;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
enum class NotebookCellKind
{
@@ -1,10 +1,15 @@
#pragma once
#include "./basic_types.hpp"
#include "./document_sync.hpp"
#include "./diagnostics.hpp"
#include "registration.hpp"
module;
namespace lsp::protocol
export module lsp.protocol.workspace.workspace;
import std;
import lsp.protocol.common.basic_types;
import lsp.protocol.text_document.document_sync;
import lsp.protocol.text_document.diagnostics;
import lsp.protocol.common.registration;
export namespace lsp::protocol
{
struct CreateFileOptions
{