| 1 |
#ifndef LSPEVENT_H |
| 2 |
#define LSPEVENT_H |
| 3 |
|
| 4 |
#include "LSP/CompletionItem.h" |
| 5 |
#include "LSP/basic_types.h" |
| 6 |
#include "LSP/json_rpc_params.h" |
| 7 |
#include "cl_command_event.h" |
| 8 |
#include "codelite_exports.h" |
| 9 |
|
| 10 |
#include <vector> |
| 11 |
|
| 12 |
#define LSP_LOG_ERROR 1 |
| 13 |
#define LSP_LOG_WARNING 2 |
| 14 |
#define LSP_LOG_INFO 3 |
| 15 |
#define LSP_LOG_LOG 4 |
| 16 |
|
| 17 |
class WXDLLIMPEXP_CL LSPEvent : public clCommandEvent |
| 18 |
{ |
| 19 |
public: |
| 20 |
// https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#messageType |
| 21 |
|
| 22 |
protected: |
| 23 |
LSP::Location m_location; |
| 24 |
wxString m_serverName; |
| 25 |
LSP::CompletionItem::Vec_t m_completions; |
| 26 |
LSP::SignatureHelp m_signatureHelp; |
| 27 |
LSP::Hover m_hover; |
| 28 |
std::vector<LSP::Diagnostic> m_diagnostics; |
| 29 |
std::vector<LSP::SymbolInformation> m_symbolsInformation; |
| 30 |
std::vector<LSP::SemanticTokenRange> m_semanticTokens; |
| 31 |
std::vector<LSP::Location> m_locations; // used by wxEVT_LSP_REFERENCES |
| 32 |
int m_logMessageSeverity = LSP_LOG_INFO; |
| 33 |
|
| 34 |
public: |
| 35 |
LSPEvent(wxEventType commandType = wxEVT_NULL, int winid = 0); |
| 36 |
LSPEvent(const LSPEvent& src); |
| 37 |
LSPEvent& operator=(const LSPEvent& other); |
| 38 |
virtual ~LSPEvent(); |
| 39 |
|
| 40 |
void SetLogMessageSeverity(int sev) { m_logMessageSeverity = sev; } |
| 41 |
int GetLogMessageSeverity() const { return m_logMessageSeverity; } |
| 42 |
|
| 43 |
void SetMessage(const wxString& message) { SetString(message); } |
| 44 |
wxString GetMessage() const { return GetString(); } |
| 45 |
|
| 46 |
void SetSemanticTokens(const std::vector<LSP::SemanticTokenRange>& semanticTokens) |
| 47 |
{ |
| 48 |
this->m_semanticTokens = semanticTokens; |
| 49 |
} |
| 50 |
const std::vector<LSP::SemanticTokenRange>& GetSemanticTokens() const { return m_semanticTokens; } |
| 51 |
|
| 52 |
LSPEvent& SetLocation(const LSP::Location& location) |
| 53 |
{ |
| 54 |
this->m_location = location; |
| 55 |
return *this; |
| 56 |
} |
| 57 |
const LSP::Location& GetLocation() const { return m_location; } |
| 58 |
LSP::Location& GetLocation() { return m_location; } |
| 59 |
wxEvent* Clone() const { return new LSPEvent(*this); } |
| 60 |
LSPEvent& SetServerName(const wxString& serverName) |
| 61 |
{ |
| 62 |
this->m_serverName = serverName; |
| 63 |
return *this; |
| 64 |
} |
| 65 |
const wxString& GetServerName() const { return m_serverName; } |
| 66 |
LSPEvent& SetCompletions(const LSP::CompletionItem::Vec_t& completions) |
| 67 |
{ |
| 68 |
this->m_completions = completions; |
| 69 |
return *this; |
| 70 |
} |
| 71 |
const LSP::CompletionItem::Vec_t& GetCompletions() const { return m_completions; } |
| 72 |
LSPEvent& SetSignatureHelp(const LSP::SignatureHelp& signatureHelp) |
| 73 |
{ |
| 74 |
this->m_signatureHelp = signatureHelp; |
| 75 |
return *this; |
| 76 |
} |
| 77 |
const LSP::SignatureHelp& GetSignatureHelp() const { return m_signatureHelp; } |
| 78 |
LSPEvent& SetHover(const LSP::Hover& hover) |
| 79 |
{ |
| 80 |
this->m_hover = hover; |
| 81 |
return *this; |
| 82 |
} |
| 83 |
const LSP::Hover& GetHover() const { return m_hover; } |
| 84 |
LSPEvent& SetDiagnostics(const std::vector<LSP::Diagnostic>& diagnostics) |
| 85 |
{ |
| 86 |
this->m_diagnostics = diagnostics; |
| 87 |
return *this; |
| 88 |
} |
| 89 |
const std::vector<LSP::Diagnostic>& GetDiagnostics() const { return m_diagnostics; } |
| 90 |
void SetSymbolsInformation(const std::vector<LSP::SymbolInformation>& symbolsInformation) |
| 91 |
{ |
| 92 |
this->m_symbolsInformation = symbolsInformation; |
| 93 |
} |
| 94 |
const std::vector<LSP::SymbolInformation>& GetSymbolsInformation() const { return m_symbolsInformation; } |
| 95 |
std::vector<LSP::SymbolInformation>& GetSymbolsInformation() { return m_symbolsInformation; } |
| 96 |
void SetLocations(const std::vector<LSP::Location>& locations) { this->m_locations = locations; } |
| 97 |
const std::vector<LSP::Location>& GetLocations() const { return m_locations; } |
| 98 |
std::vector<LSP::Location>& GetLocations() { return m_locations; } |
| 99 |
}; |
| 100 |
|
| 101 |
typedef void (wxEvtHandler::*LSPEventFunction)(LSPEvent&); |
| 102 |
#define LSPEventHandler(func) wxEVENT_HANDLER_CAST(LSPEventFunction, func) |
| 103 |
|
| 104 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_DEFINITION, LSPEvent); |
| 105 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_INITIALIZED, LSPEvent); |
| 106 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_COMPLETION_READY, LSPEvent); |
| 107 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_DOCUMENT_SYMBOLS_QUICK_OUTLINE, |
| 108 |
LSPEvent); // fired twice: m_owner && EventNotifier |
| 109 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_DOCUMENT_SYMBOLS_FOR_HIGHLIGHT, LSPEvent); |
| 110 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_DOCUMENT_SYMBOLS_OUTLINE_VIEW, LSPEvent); |
| 111 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_RESTART_NEEDED, LSPEvent); |
| 112 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_REPARSE_NEEDED, LSPEvent); |
| 113 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_METHOD_NOT_FOUND, LSPEvent); |
| 114 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_SIGNATURE_HELP, LSPEvent); |
| 115 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_HOVER, LSPEvent); |
| 116 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_SET_DIAGNOSTICS, LSPEvent); |
| 117 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_CLEAR_DIAGNOSTICS, LSPEvent); |
| 118 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_OPEN_FILE, LSPEvent); |
| 119 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_SEMANTICS, LSPEvent); |
| 120 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_LOGMESSAGE, LSPEvent); |
| 121 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_WORKSPACE_SYMBOLS, LSPEvent); // EventNotifier |
| 122 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_SYMBOL_DECLARATION_FOUND, LSPEvent); // EventNotifier |
| 123 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_SHOW_QUICK_OUTLINE_DLG, LSPEvent); |
| 124 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_REFERENCES, LSPEvent); // EventNotifier |
| 125 |
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CL, wxEVT_LSP_REFERENCES_INPROGRESS, LSPEvent); // EventNotifier |
| 126 |
|
| 127 |
#endif // LSPEVENT_H |