🐛 fix: support LSP request id variants
This commit is contained in:
@@ -47,7 +47,7 @@ export namespace lsp::codec
|
||||
namespace debug
|
||||
{
|
||||
std::string GetTypeName(const protocol::LSPAny& any);
|
||||
std::string GetIdString(const std::variant<int, std::string>& id);
|
||||
std::string GetIdString(const protocol::RequestId& id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,10 +134,10 @@ namespace lsp::codec
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
inline std::string GetIdString(const std::variant<int, std::string>& id)
|
||||
inline std::string GetIdString(const protocol::RequestId& id)
|
||||
{
|
||||
return std::visit([](const auto& value) -> std::string {
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(value)>, int>)
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(value)>, protocol::integer>)
|
||||
return std::to_string(value);
|
||||
else
|
||||
return value;
|
||||
|
||||
@@ -189,6 +189,10 @@ namespace lsp::codec
|
||||
{
|
||||
if (any.Is<protocol::decimal>())
|
||||
return static_cast<T>(any.Get<protocol::decimal>());
|
||||
if (any.Is<protocol::integer>())
|
||||
return static_cast<T>(any.Get<protocol::integer>());
|
||||
if (any.Is<protocol::uinteger>())
|
||||
return static_cast<T>(any.Get<protocol::uinteger>());
|
||||
}
|
||||
|
||||
throw ConversionError("LSPAny does not contain a compatible numeric type");
|
||||
|
||||
Reference in New Issue
Block a user