| 1 |
#ifndef LANGUAGESERVERENTRY_H |
| 2 |
#define LANGUAGESERVERENTRY_H |
| 3 |
|
| 4 |
#include "LSPNetwork.h" |
| 5 |
#include "asyncprocess.h" |
| 6 |
#include "cl_config.h" |
| 7 |
|
| 8 |
#include <map> |
| 9 |
#include <vector> |
| 10 |
#include <wx/string.h> |
| 11 |
#include <wxStringHash.h> |
| 12 |
|
| 13 |
class LanguageServerEntry |
| 14 |
{ |
| 15 |
bool m_enabled = true; |
| 16 |
wxString m_name; |
| 17 |
wxString m_exepath; |
| 18 |
wxString m_args; |
| 19 |
wxString m_workingDirectory; |
| 20 |
wxArrayString m_languages; |
| 21 |
wxString m_connectionString; |
| 22 |
int m_priority = 50; |
| 23 |
bool m_disaplayDiagnostics = true; |
| 24 |
wxString m_command; |
| 25 |
wxString m_remoteCommand; |
| 26 |
|
| 27 |
public: |
| 28 |
// use 'map' to keep the items sorted by name |
| 29 |
typedef std::map<wxString, LanguageServerEntry> Map_t; |
| 30 |
|
| 31 |
/** |
| 32 |
* @brief try to validate the LSP by checking that all paths do exists |
| 33 |
* @return |
| 34 |
*/ |
| 35 |
bool IsValid() const; |
| 36 |
|
| 37 |
public: |
| 38 |
virtual void FromJSON(const JSONItem& json); |
| 39 |
virtual JSONItem ToJSON() const; |
| 40 |
LanguageServerEntry(); |
| 41 |
virtual ~LanguageServerEntry(); |
| 42 |
|
| 43 |
void SetCommand(const wxString& command); |
| 44 |
wxString GetCommand(bool pretty = false) const; |
| 45 |
|
| 46 |
LanguageServerEntry& SetDisaplayDiagnostics(bool disaplayDiagnostics) |
| 47 |
{ |
| 48 |
this->m_disaplayDiagnostics = disaplayDiagnostics; |
| 49 |
return *this; |
| 50 |
} |
| 51 |
bool IsDisaplayDiagnostics() const { return m_disaplayDiagnostics; } |
| 52 |
LanguageServerEntry& SetConnectionString(const wxString& connectionString) |
| 53 |
{ |
| 54 |
this->m_connectionString = connectionString; |
| 55 |
return *this; |
| 56 |
} |
| 57 |
const wxString& GetConnectionString() const { return m_connectionString; } |
| 58 |
LanguageServerEntry& SetPriority(int priority) |
| 59 |
{ |
| 60 |
this->m_priority = priority; |
| 61 |
return *this; |
| 62 |
} |
| 63 |
int GetPriority() const { return m_priority; } |
| 64 |
LanguageServerEntry& SetEnabled(bool enabled) |
| 65 |
{ |
| 66 |
this->m_enabled = enabled; |
| 67 |
return *this; |
| 68 |
} |
| 69 |
bool IsEnabled() const { return m_enabled; } |
| 70 |
LanguageServerEntry& SetLanguages(const wxArrayString& languages) |
| 71 |
{ |
| 72 |
this->m_languages = languages; |
| 73 |
return *this; |
| 74 |
} |
| 75 |
const wxArrayString& GetLanguages() const { return m_languages; } |
| 76 |
LanguageServerEntry& SetWorkingDirectory(const wxString& workingDirectory) |
| 77 |
{ |
| 78 |
this->m_workingDirectory = workingDirectory; |
| 79 |
return *this; |
| 80 |
} |
| 81 |
const wxString& GetWorkingDirectory() const { return m_workingDirectory; } |
| 82 |
LanguageServerEntry& SetName(const wxString& name) |
| 83 |
{ |
| 84 |
this->m_name = name; |
| 85 |
return *this; |
| 86 |
} |
| 87 |
const wxString& GetName() const { return m_name; } |
| 88 |
eNetworkType GetNetType() const; |
| 89 |
bool IsAutoRestart() const; |
| 90 |
}; |
| 91 |
|
| 92 |
#endif // LANGUAGESERVERENTRY_H |