mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Change lsVersionedTextDocumentIdentifier::version to variant<monostate,int>
version: number | null Maybe we need to change it to double
This commit is contained in:
parent
3e076b4111
commit
060b92b214
@ -5,6 +5,13 @@
|
||||
#include <doctest/doctest.h>
|
||||
#include <loguru.hpp>
|
||||
|
||||
void Reflect(Reader& visitor, std::variant<std::monostate, int>& version) {
|
||||
if (visitor.IsNull())
|
||||
version = std::monostate();
|
||||
else
|
||||
version = visitor.GetInt();
|
||||
}
|
||||
|
||||
void Reflect(Reader& visitor, lsRequestId& id) {
|
||||
if (visitor.IsInt()) {
|
||||
int v;
|
||||
|
@ -11,8 +11,6 @@
|
||||
#include <variant.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
|
||||
@ -254,10 +252,11 @@ struct lsTextDocumentIdentifier {
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsTextDocumentIdentifier, uri);
|
||||
|
||||
void Reflect(Reader& visitor, std::variant<std::monostate, int>& version);
|
||||
struct lsVersionedTextDocumentIdentifier {
|
||||
lsDocumentUri uri;
|
||||
// The version number of this document.
|
||||
optional<int> version;
|
||||
// The version number of this document. number | null
|
||||
std::variant<std::monostate, int> version;
|
||||
|
||||
lsTextDocumentIdentifier AsTextDocumentIdentifier() const;
|
||||
};
|
||||
|
@ -160,6 +160,12 @@ void Reflect(Writer& visitor, bool& value);
|
||||
void Reflect(Reader& visitor, std::string& value);
|
||||
void Reflect(Writer& visitor, std::string& value);
|
||||
|
||||
void Reflect(Reader& visitor, std::monostate&);
|
||||
void Reflect(Writer& visitor, std::monostate&);
|
||||
|
||||
void Reflect(Reader& visitor, SerializeFormat& value);
|
||||
void Reflect(Writer& visitor, SerializeFormat& value);
|
||||
|
||||
// std::optional
|
||||
template <typename T>
|
||||
void Reflect(Reader& visitor, optional<T>& value) {
|
||||
@ -272,14 +278,6 @@ void ReflectMember(Reader& visitor, const char* name, T& value) {
|
||||
visitor.DoMember(name, [&](Reader& child) { Reflect(child, value); });
|
||||
}
|
||||
|
||||
// Specializations
|
||||
|
||||
void Reflect(Reader& visitor, std::monostate&);
|
||||
void Reflect(Writer& visitor, std::monostate&);
|
||||
|
||||
void Reflect(Reader& visitor, SerializeFormat& value);
|
||||
void Reflect(Writer& visitor, SerializeFormat& value);
|
||||
|
||||
// API
|
||||
|
||||
std::string Serialize(SerializeFormat format, IndexFile& file);
|
||||
|
@ -317,8 +317,9 @@ void WorkingFiles::OnChange(const lsTextDocumentDidChangeParams& change) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (change.textDocument.version)
|
||||
file->version = *change.textDocument.version;
|
||||
// version: number | null
|
||||
if (std::holds_alternative<int>(change.textDocument.version))
|
||||
file->version = std::get<int>(change.textDocument.version);
|
||||
|
||||
for (const lsTextDocumentContentChangeEvent& diff : change.contentChanges) {
|
||||
// Per the spec replace everything if the rangeLength and range are not set.
|
||||
|
Loading…
Reference in New Issue
Block a user