Debian Codegraph @

CodeLite/LSP/ResponseMessage.h

raw
1 #ifndef RESPONSEMESSAGE_H
2 #define RESPONSEMESSAGE_H
3
4 #include "JSON.h"
5 #include "LSP/Message.h"
6 #include "LSP/basic_types.h"
7
8 #include <macros.h>
9 #include <wx/sharedptr.h>
10
11 namespace LSP
12 {
13
14 class WXDLLIMPEXP_CL ResponseMessage : public LSP::Message
15 {
16 int m_id = wxNOT_FOUND;
17 std::unique_ptr<JSON> m_json;
18
19 public:
20 ResponseMessage(std::unique_ptr<JSON>&& json);
21 ~ResponseMessage() override;
22 JSONItem ToJSON(const wxString& name) const override;
23 void FromJSON(const JSONItem& json) override;
24
25 std::string ToString() const override;
26 ResponseMessage& SetId(int id)
27 {
28 this->m_id = id;
29 return *this;
30 }
31 int GetId() const { return m_id; }
32 bool IsOk() const { return m_json && m_json->isOk(); }
33 std::unique_ptr<JSON> take() { return std::move(m_json); }
34
35 bool IsErrorResponse() const;
36 bool Has(const wxString& property) const;
37 JSONItem Get(const wxString& property) const;
38
39 JSONItem operator[](const wxString& name) const { return Get(name); }
40
41 /**
42 * @brief is this a "textDocument/publishDiagnostics" message?
43 */
44 bool IsPushDiagnostics() const { return Get("method").toString() == "textDocument/publishDiagnostics"; }
45
46 /**
47 * @brief return list of diagnostics
48 */
49 std::vector<LSP::Diagnostic> GetDiagnostics() const;
50 /**
51 * @brief return the URI diagnostics
52 */
53 wxString GetDiagnosticsUri() const;
54 };
55 }; // namespace LSP
56
57 #endif // RESPONSEMESSAGE_H