blob: 308388da379e0c9c1204ec28fed73cc28c714a26 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#include "LibLsp/lsp/lsp_diagnostic.h"
bool lsDiagnostic::operator==(lsDiagnostic const& rhs) const
{
// Just check the important fields.
return range == rhs.range && message == rhs.message;
}
bool lsDiagnostic::operator!=(lsDiagnostic const& rhs) const
{
return !(*this == rhs);
}
std::string lsResponseError::ToString()
{
std::string info = "code:";
switch (code)
{
case lsErrorCodes::ParseError:
info += "ParseError\n";
break;
case lsErrorCodes::InvalidRequest:
info += "InvalidRequest\n";
break;
case lsErrorCodes::MethodNotFound:
info += "MethodNotFound\n";
break;
case lsErrorCodes::InvalidParams:
info += "InvalidParams\n";
break;
case lsErrorCodes::InternalError:
info += "InternalError\n";
break;
case lsErrorCodes::serverErrorStart:
info += "serverErrorStart\n";
break;
case lsErrorCodes::serverErrorEnd:
info += "serverErrorEnd\n";
break;
case lsErrorCodes::ServerNotInitialized:
info += "ServerNotInitialized\n";
break;
case lsErrorCodes::UnknownErrorCode:
info += "UnknownErrorCode\n";
break;
// Defined by the protocol.
case lsErrorCodes::RequestCancelled:
info += "RequestCancelled\n";
break;
default:
{
std::stringstream ss;
ss << "unknown code:" << (int32_t)code << std::endl;
info += ss.str();
}
break;
}
info += "message:" + message;
info += "\n";
if (data.has_value())
{
info += "data:" + data.value().Data();
info += "\n";
}
return info;
}
void lsResponseError::Write(Writer& visitor)
{
auto& value = *this;
int code2 = static_cast<int>(this->code);
visitor.StartObject();
REFLECT_MEMBER2("code", code2);
REFLECT_MEMBER(message);
visitor.EndObject();
}
|