#ifndef RESPONSEMESSAGE_H #define RESPONSEMESSAGE_H #include "JSON.h" #include "LSP/Message.h" #include "LSP/basic_types.h" #include #include namespace LSP { class WXDLLIMPEXP_CL ResponseMessage : public LSP::Message { int m_id = wxNOT_FOUND; std::unique_ptr m_json; public: ResponseMessage(std::unique_ptr&& json); ~ResponseMessage() override; JSONItem ToJSON(const wxString& name) const override; void FromJSON(const JSONItem& json) override; std::string ToString() const override; ResponseMessage& SetId(int id) { this->m_id = id; return *this; } int GetId() const { return m_id; } bool IsOk() const { return m_json && m_json->isOk(); } std::unique_ptr take() { return std::move(m_json); } bool IsErrorResponse() const; bool Has(const wxString& property) const; JSONItem Get(const wxString& property) const; JSONItem operator[](const wxString& name) const { return Get(name); } /** * @brief is this a "textDocument/publishDiagnostics" message? */ bool IsPushDiagnostics() const { return Get("method").toString() == "textDocument/publishDiagnostics"; } /** * @brief return list of diagnostics */ std::vector GetDiagnostics() const; /** * @brief return the URI diagnostics */ wxString GetDiagnosticsUri() const; }; }; // namespace LSP #endif // RESPONSEMESSAGE_H