mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 08:35:08 +00:00
Change RequestId::value from int to std::string to allow non-numeric IDs.
This commit is contained in:
parent
990925d806
commit
eb752497e8
13
src/lsp.cc
13
src/lsp.cc
@ -26,16 +26,16 @@ namespace ccls {
|
|||||||
void Reflect(JsonReader &vis, RequestId &v) {
|
void Reflect(JsonReader &vis, RequestId &v) {
|
||||||
if (vis.m->IsInt64()) {
|
if (vis.m->IsInt64()) {
|
||||||
v.type = RequestId::kInt;
|
v.type = RequestId::kInt;
|
||||||
v.value = int(vis.m->GetInt64());
|
v.value = std::to_string(int(vis.m->GetInt64()));
|
||||||
} else if (vis.m->IsInt()) {
|
} else if (vis.m->IsInt()) {
|
||||||
v.type = RequestId::kInt;
|
v.type = RequestId::kInt;
|
||||||
v.value = vis.m->GetInt();
|
v.value = std::to_string(vis.m->GetInt());
|
||||||
} else if (vis.m->IsString()) {
|
} else if (vis.m->IsString()) {
|
||||||
v.type = RequestId::kString;
|
v.type = RequestId::kString;
|
||||||
v.value = atoll(vis.m->GetString());
|
v.value = vis.m->GetString();
|
||||||
} else {
|
} else {
|
||||||
v.type = RequestId::kNone;
|
v.type = RequestId::kNone;
|
||||||
v.value = -1;
|
v.value.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,11 +45,10 @@ void Reflect(JsonWriter &visitor, RequestId &value) {
|
|||||||
visitor.Null();
|
visitor.Null();
|
||||||
break;
|
break;
|
||||||
case RequestId::kInt:
|
case RequestId::kInt:
|
||||||
visitor.Int(value.value);
|
visitor.Int(atoll(value.value.c_str()));
|
||||||
break;
|
break;
|
||||||
case RequestId::kString:
|
case RequestId::kString:
|
||||||
auto s = std::to_string(value.value);
|
visitor.String(value.value.c_str(), value.value.size());
|
||||||
visitor.String(s.c_str(), s.size());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ limitations under the License.
|
|||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace ccls {
|
namespace ccls {
|
||||||
struct RequestId {
|
struct RequestId {
|
||||||
@ -31,7 +32,7 @@ struct RequestId {
|
|||||||
enum Type { kNone, kInt, kString };
|
enum Type { kNone, kInt, kString };
|
||||||
Type type = kNone;
|
Type type = kNone;
|
||||||
|
|
||||||
int value = -1;
|
std::string value;
|
||||||
|
|
||||||
bool Valid() const { return type != kNone; }
|
bool Valid() const { return type != kNone; }
|
||||||
};
|
};
|
||||||
|
@ -810,11 +810,10 @@ static void Reply(RequestId id, const char *key,
|
|||||||
w.Null();
|
w.Null();
|
||||||
break;
|
break;
|
||||||
case RequestId::kInt:
|
case RequestId::kInt:
|
||||||
w.Int(id.value);
|
w.Int(atoll(id.value.c_str()));
|
||||||
break;
|
break;
|
||||||
case RequestId::kString:
|
case RequestId::kString:
|
||||||
auto s = std::to_string(id.value);
|
w.String(id.value.c_str(), id.value.size());
|
||||||
w.String(s.c_str(), s.length());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
w.Key(key);
|
w.Key(key);
|
||||||
|
Loading…
Reference in New Issue
Block a user