mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 17:41:58 +00:00
Fix MessagePackReader for Position/Range
Go out for dinner
This commit is contained in:
parent
a78c65fdbb
commit
541b1a7494
@ -1,4 +1,5 @@
|
|||||||
#include "position.h"
|
#include "position.h"
|
||||||
|
#include "serializers/msgpack.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Skips until the character immediately following |skip_after|.
|
// Skips until the character immediately following |skip_after|.
|
||||||
@ -143,16 +144,22 @@ bool Range::operator<(const Range& that) const {
|
|||||||
|
|
||||||
// Position
|
// Position
|
||||||
void Reflect(Reader& visitor, Position& value) {
|
void Reflect(Reader& visitor, Position& value) {
|
||||||
if (!visitor.IsString())
|
if (visitor.Format() == SerializeFormat::Json) {
|
||||||
value = Position();
|
|
||||||
else if (visitor.Format() == SerializeFormat::Json) {
|
|
||||||
std::string s = visitor.GetString();
|
std::string s = visitor.GetString();
|
||||||
value = Position(s.c_str());
|
value = Position(s.c_str());
|
||||||
} else {
|
} else {
|
||||||
REFLECT_MEMBER_START(2);
|
int i = 0;
|
||||||
Reflect(visitor, value.line);
|
// FIXME
|
||||||
Reflect(visitor, value.column);
|
static_cast<MessagePackReader&>(visitor).IterArray([&](Reader& entry) {
|
||||||
REFLECT_MEMBER_END();
|
switch (i++) {
|
||||||
|
case 0:
|
||||||
|
Reflect(entry, value.line);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
Reflect(entry, value.column);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Reflect(Writer& visitor, Position& value) {
|
void Reflect(Writer& visitor, Position& value) {
|
||||||
@ -169,18 +176,29 @@ void Reflect(Writer& visitor, Position& value) {
|
|||||||
|
|
||||||
// Range
|
// Range
|
||||||
void Reflect(Reader& visitor, Range& value) {
|
void Reflect(Reader& visitor, Range& value) {
|
||||||
if (!visitor.IsString())
|
if (visitor.Format() == SerializeFormat::Json) {
|
||||||
value = Range();
|
|
||||||
else if (visitor.Format() == SerializeFormat::Json) {
|
|
||||||
std::string s = visitor.GetString();
|
std::string s = visitor.GetString();
|
||||||
value = Range(s.c_str());
|
value = Range(s.c_str());
|
||||||
} else {
|
} else {
|
||||||
REFLECT_MEMBER_START(4);
|
int i = 0;
|
||||||
Reflect(visitor, value.start.line);
|
// FIXME
|
||||||
Reflect(visitor, value.start.column);
|
static_cast<MessagePackReader&>(visitor).IterArray([&](Reader& entry) {
|
||||||
Reflect(visitor, value.end.line);
|
switch (i++) {
|
||||||
Reflect(visitor, value.end.column);
|
case 0:
|
||||||
REFLECT_MEMBER_END();
|
Reflect(entry, value.start.line);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
Reflect(entry, value.start.column);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Reflect(entry, value.end.line);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Reflect(entry, value.end.column);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Reflect(Writer& visitor, Range& value) {
|
void Reflect(Writer& visitor, Range& value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user