Debian Codegraph @

LspCpp/src/lsp/lsp_diagnostic.cpp

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