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 <doctest/doctest.h>
|
||||||
#include <loguru.hpp>
|
#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) {
|
void Reflect(Reader& visitor, lsRequestId& id) {
|
||||||
if (visitor.IsInt()) {
|
if (visitor.IsInt()) {
|
||||||
int v;
|
int v;
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
#include <variant.h>
|
#include <variant.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
|
||||||
#include <sstream>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
@ -254,10 +252,11 @@ struct lsTextDocumentIdentifier {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(lsTextDocumentIdentifier, uri);
|
MAKE_REFLECT_STRUCT(lsTextDocumentIdentifier, uri);
|
||||||
|
|
||||||
|
void Reflect(Reader& visitor, std::variant<std::monostate, int>& version);
|
||||||
struct lsVersionedTextDocumentIdentifier {
|
struct lsVersionedTextDocumentIdentifier {
|
||||||
lsDocumentUri uri;
|
lsDocumentUri uri;
|
||||||
// The version number of this document.
|
// The version number of this document. number | null
|
||||||
optional<int> version;
|
std::variant<std::monostate, int> version;
|
||||||
|
|
||||||
lsTextDocumentIdentifier AsTextDocumentIdentifier() const;
|
lsTextDocumentIdentifier AsTextDocumentIdentifier() const;
|
||||||
};
|
};
|
||||||
|
@ -160,6 +160,12 @@ void Reflect(Writer& visitor, bool& value);
|
|||||||
void Reflect(Reader& visitor, std::string& value);
|
void Reflect(Reader& visitor, std::string& value);
|
||||||
void Reflect(Writer& 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
|
// std::optional
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void Reflect(Reader& visitor, optional<T>& value) {
|
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); });
|
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
|
// API
|
||||||
|
|
||||||
std::string Serialize(SerializeFormat format, IndexFile& file);
|
std::string Serialize(SerializeFormat format, IndexFile& file);
|
||||||
|
@ -317,8 +317,9 @@ void WorkingFiles::OnChange(const lsTextDocumentDidChangeParams& change) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (change.textDocument.version)
|
// version: number | null
|
||||||
file->version = *change.textDocument.version;
|
if (std::holds_alternative<int>(change.textDocument.version))
|
||||||
|
file->version = std::get<int>(change.textDocument.version);
|
||||||
|
|
||||||
for (const lsTextDocumentContentChangeEvent& diff : change.contentChanges) {
|
for (const lsTextDocumentContentChangeEvent& diff : change.contentChanges) {
|
||||||
// Per the spec replace everything if the rangeLength and range are not set.
|
// Per the spec replace everything if the rangeLength and range are not set.
|
||||||
|
Loading…
Reference in New Issue
Block a user