| 1 |
#include "languageserver.h" |
| 2 |
|
| 3 |
#include "CompileCommandsGenerator.h" |
| 4 |
#include "LSPDetectorManager.hpp" |
| 5 |
#include "LanguageServerConfig.h" |
| 6 |
#include "LanguageServerSettingsDlg.h" |
| 7 |
#include "ServiceProviderManager.h" |
| 8 |
#include "cl_standard_paths.h" |
| 9 |
#include "event_notifier.h" |
| 10 |
#include "file_logger.h" |
| 11 |
#include "globals.h" |
| 12 |
#include "ieditor.h" |
| 13 |
|
| 14 |
#include <macros.h> |
| 15 |
#include <thread> |
| 16 |
#include <wx/app.h> |
| 17 |
#include <wx/datetime.h> |
| 18 |
#include <wx/stc/stc.h> |
| 19 |
#include <wx/xrc/xmlres.h> |
| 20 |
|
| 21 |
static LanguageServerPlugin* thePlugin = NULL; |
| 22 |
|
| 23 |
// Define the plugin entry point |
| 24 |
CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) |
| 25 |
{ |
| 26 |
if(thePlugin == NULL) { |
| 27 |
thePlugin = new LanguageServerPlugin(manager); |
| 28 |
} |
| 29 |
return thePlugin; |
| 30 |
} |
| 31 |
|
| 32 |
CL_PLUGIN_API PluginInfo* GetPluginInfo() |
| 33 |
{ |
| 34 |
static PluginInfo info; |
| 35 |
info.SetAuthor(wxT("Eran")); |
| 36 |
info.SetName(wxT("LanguageServerPlugin")); |
| 37 |
info.SetDescription(_("Support for Language Server Protocol (LSP)")); |
| 38 |
info.SetVersion(wxT("v1.0")); |
| 39 |
return &info; |
| 40 |
} |
| 41 |
|
| 42 |
CL_PLUGIN_API int GetPluginInterfaceVersion() { return PLUGIN_INTERFACE_VERSION; } |
| 43 |
|
| 44 |
LanguageServerPlugin::LanguageServerPlugin(IManager* manager) |
| 45 |
: IPlugin(manager) |
| 46 |
{ |
| 47 |
m_longName = _("Support for Language Server Protocol (LSP)"); |
| 48 |
m_shortName = wxT("LanguageServerPlugin"); |
| 49 |
|
| 50 |
// add log view |
| 51 |
m_logView = new LanguageServerLogView(m_mgr->GetOutputPaneNotebook()); |
| 52 |
auto outputBook = m_mgr->GetOutputPaneNotebook(); |
| 53 |
int bmp = outputBook->GetBitmaps()->Add("cog"); |
| 54 |
outputBook->AddPage(m_logView, _("Language Server"), false, bmp); |
| 55 |
m_tabToggler.reset(new clTabTogglerHelper(_("Language Server"), m_logView, "", NULL)); |
| 56 |
m_tabToggler->SetOutputTabBmp(bmp); |
| 57 |
|
| 58 |
// Load the configuration |
| 59 |
LanguageServerConfig::Get().Load(); |
| 60 |
m_servers.reset(new LanguageServerCluster(this)); |
| 61 |
EventNotifier::Get()->Bind(wxEVT_INIT_DONE, &LanguageServerPlugin::OnInitDone, this); |
| 62 |
EventNotifier::Get()->Bind(wxEVT_CONTEXT_MENU_EDITOR, &LanguageServerPlugin::OnEditorContextMenu, this); |
| 63 |
wxTheApp->Bind(wxEVT_MENU, &LanguageServerPlugin::OnSettings, this, XRCID("language-server-settings")); |
| 64 |
wxTheApp->Bind(wxEVT_MENU, &LanguageServerPlugin::OnRestartLSP, this, XRCID("language-server-restart")); |
| 65 |
|
| 66 |
EventNotifier::Get()->Bind(wxEVT_LSP_STOP_ALL, &LanguageServerPlugin::OnLSPStopAll, this); |
| 67 |
EventNotifier::Get()->Bind(wxEVT_LSP_START_ALL, &LanguageServerPlugin::OnLSPStartAll, this); |
| 68 |
EventNotifier::Get()->Bind(wxEVT_LSP_RESTART_ALL, &LanguageServerPlugin::OnLSPRestartAll, this); |
| 69 |
EventNotifier::Get()->Bind(wxEVT_LSP_STOP, &LanguageServerPlugin::OnLSPStopOne, this); |
| 70 |
EventNotifier::Get()->Bind(wxEVT_LSP_START, &LanguageServerPlugin::OnLSPStartOne, this); |
| 71 |
EventNotifier::Get()->Bind(wxEVT_LSP_RESTART, &LanguageServerPlugin::OnLSPRestartOne, this); |
| 72 |
EventNotifier::Get()->Bind(wxEVT_LSP_CONFIGURE, &LanguageServerPlugin::OnLSPConfigure, this); |
| 73 |
EventNotifier::Get()->Bind(wxEVT_LSP_DELETE, &LanguageServerPlugin::OnLSPDelete, this); |
| 74 |
EventNotifier::Get()->Bind(wxEVT_LSP_OPEN_SETTINGS_DLG, &LanguageServerPlugin::OnLSPShowSettingsDlg, this); |
| 75 |
EventNotifier::Get()->Bind(wxEVT_LSP_ENABLE_SERVER, &LanguageServerPlugin::OnLSPEnableServer, this); |
| 76 |
EventNotifier::Get()->Bind(wxEVT_LSP_DISABLE_SERVER, &LanguageServerPlugin::OnLSPDisableServer, this); |
| 77 |
EventNotifier::Get()->Bind(wxEVT_WORKSPACE_CLOSED, &LanguageServerPlugin::OnWorkspaceClosed, this); |
| 78 |
} |
| 79 |
|
| 80 |
LanguageServerPlugin::~LanguageServerPlugin() {} |
| 81 |
|
| 82 |
void LanguageServerPlugin::CreateToolBar(clToolBarGeneric* toolbar) |
| 83 |
{ |
| 84 |
// You can add items to the main toolbar here |
| 85 |
wxUnusedVar(toolbar); |
| 86 |
} |
| 87 |
|
| 88 |
void LanguageServerPlugin::CreatePluginMenu(wxMenu* pluginsMenu) |
| 89 |
{ |
| 90 |
wxMenu* menu = new wxMenu(); |
| 91 |
menu->Append(XRCID("language-server-settings"), _("Settings")); |
| 92 |
menu->Append(XRCID("language-server-restart"), _("Restart Language Servers")); |
| 93 |
pluginsMenu->Append(wxID_ANY, _("Language Server"), menu); |
| 94 |
} |
| 95 |
|
| 96 |
void LanguageServerPlugin::UnPlug() |
| 97 |
{ |
| 98 |
wxTheApp->Unbind(wxEVT_MENU, &LanguageServerPlugin::OnSettings, this, XRCID("language-server-settings")); |
| 99 |
wxTheApp->Unbind(wxEVT_MENU, &LanguageServerPlugin::OnRestartLSP, this, XRCID("language-server-restart")); |
| 100 |
EventNotifier::Get()->Unbind(wxEVT_INIT_DONE, &LanguageServerPlugin::OnInitDone, this); |
| 101 |
EventNotifier::Get()->Unbind(wxEVT_CONTEXT_MENU_EDITOR, &LanguageServerPlugin::OnEditorContextMenu, this); |
| 102 |
|
| 103 |
EventNotifier::Get()->Unbind(wxEVT_LSP_STOP_ALL, &LanguageServerPlugin::OnLSPStopAll, this); |
| 104 |
EventNotifier::Get()->Unbind(wxEVT_LSP_START_ALL, &LanguageServerPlugin::OnLSPStartAll, this); |
| 105 |
EventNotifier::Get()->Unbind(wxEVT_LSP_RESTART_ALL, &LanguageServerPlugin::OnLSPRestartAll, this); |
| 106 |
EventNotifier::Get()->Unbind(wxEVT_LSP_STOP, &LanguageServerPlugin::OnLSPStopOne, this); |
| 107 |
EventNotifier::Get()->Unbind(wxEVT_LSP_START, &LanguageServerPlugin::OnLSPStartOne, this); |
| 108 |
EventNotifier::Get()->Unbind(wxEVT_LSP_RESTART, &LanguageServerPlugin::OnLSPRestartOne, this); |
| 109 |
EventNotifier::Get()->Unbind(wxEVT_LSP_CONFIGURE, &LanguageServerPlugin::OnLSPConfigure, this); |
| 110 |
EventNotifier::Get()->Unbind(wxEVT_LSP_DELETE, &LanguageServerPlugin::OnLSPDelete, this); |
| 111 |
EventNotifier::Get()->Unbind(wxEVT_LSP_OPEN_SETTINGS_DLG, &LanguageServerPlugin::OnLSPShowSettingsDlg, this); |
| 112 |
EventNotifier::Get()->Unbind(wxEVT_LSP_ENABLE_SERVER, &LanguageServerPlugin::OnLSPEnableServer, this); |
| 113 |
EventNotifier::Get()->Unbind(wxEVT_LSP_DISABLE_SERVER, &LanguageServerPlugin::OnLSPDisableServer, this); |
| 114 |
EventNotifier::Get()->Unbind(wxEVT_WORKSPACE_CLOSED, &LanguageServerPlugin::OnWorkspaceClosed, this); |
| 115 |
|
| 116 |
LanguageServerConfig::Get().Save(); |
| 117 |
m_servers.reset(nullptr); |
| 118 |
|
| 119 |
// before this plugin is un-plugged we must remove the tab we added |
| 120 |
for(size_t i = 0; i < m_mgr->GetOutputPaneNotebook()->GetPageCount(); i++) { |
| 121 |
if(m_logView == m_mgr->GetOutputPaneNotebook()->GetPage(i)) { |
| 122 |
m_mgr->GetOutputPaneNotebook()->RemovePage(i); |
| 123 |
m_logView->Destroy(); |
| 124 |
break; |
| 125 |
} |
| 126 |
} |
| 127 |
} |
| 128 |
|
| 129 |
void LanguageServerPlugin::OnSettings(wxCommandEvent& e) |
| 130 |
{ |
| 131 |
LanguageServerSettingsDlg dlg(EventNotifier::Get()->TopFrame(), false); |
| 132 |
if(dlg.ShowModal() == wxID_OK) { |
| 133 |
// restart all language servers |
| 134 |
dlg.Save(); |
| 135 |
if(m_servers) { |
| 136 |
// Lets assume that we fixed something in the settings |
| 137 |
// and clear all the restart counters |
| 138 |
m_servers->ClearRestartCounters(); |
| 139 |
m_servers->Reload(); |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
void LanguageServerPlugin::OnRestartLSP(wxCommandEvent& e) |
| 145 |
{ |
| 146 |
wxUnusedVar(e); |
| 147 |
if(m_servers) { |
| 148 |
m_servers->Reload(); |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
void LanguageServerPlugin::OnInitDone(wxCommandEvent& event) |
| 153 |
{ |
| 154 |
event.Skip(); |
| 155 |
// launch a thread to locate any LSP installed on this machine |
| 156 |
|
| 157 |
bool force = false; |
| 158 |
const auto& servers = LanguageServerConfig::Get().GetServers(); |
| 159 |
for(auto& server : servers) { |
| 160 |
if(server.second.GetCommand().Contains(".codelite/lsp/clang-tools")) { |
| 161 |
force = true; |
| 162 |
break; |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
if(LanguageServerConfig::Get().GetServers().empty() || force) { |
| 167 |
clDEBUG() << "Scanning..." << clEndl; |
| 168 |
std::thread thr( |
| 169 |
[=](LanguageServerPlugin* plugin) { |
| 170 |
std::vector<LSPDetector::Ptr_t> matches; |
| 171 |
LSPDetectorManager detector; |
| 172 |
clDEBUG() << "***" |
| 173 |
<< "Scanning for LSPs... ***" << clEndl; |
| 174 |
if(detector.Scan(matches)) { |
| 175 |
clDEBUG() << " ******" |
| 176 |
<< "found!" << clEndl; |
| 177 |
} |
| 178 |
clDEBUG() << "***" |
| 179 |
<< "Scanning for LSPs... is done ***" << clEndl; |
| 180 |
clDEBUG() << "*** Calling ConfigureLSPs" << clEndl; |
| 181 |
plugin->CallAfter(&LanguageServerPlugin::ConfigureLSPs, matches); |
| 182 |
}, |
| 183 |
this); |
| 184 |
thr.detach(); |
| 185 |
} |
| 186 |
} |
| 187 |
|
| 188 |
void LanguageServerPlugin::OnEditorContextMenu(clContextMenuEvent& event) |
| 189 |
{ |
| 190 |
event.Skip(); |
| 191 |
CHECK_COND_RET(m_servers); |
| 192 |
|
| 193 |
IEditor* editor = clGetManager()->GetActiveEditor(); |
| 194 |
CHECK_PTR_RET(editor); |
| 195 |
|
| 196 |
LanguageServerProtocol::Ptr_t lsp = m_servers->GetServerForEditor(editor); |
| 197 |
CHECK_PTR_RET(lsp); |
| 198 |
|
| 199 |
bool add_find_symbol = !lsp->CanHandle(FileExtManager::TypePhp); |
| 200 |
bool add_find_references = lsp->IsReferencesSupported(); |
| 201 |
bool add_rename_symbol = lsp->IsRenameSupported(); |
| 202 |
|
| 203 |
// nothing to be done here |
| 204 |
if(!add_find_symbol && !add_find_references && !add_rename_symbol) { |
| 205 |
return; |
| 206 |
} |
| 207 |
|
| 208 |
wxMenu* menu = event.GetMenu(); |
| 209 |
if(add_find_references) { |
| 210 |
menu->PrependSeparator(); |
| 211 |
menu->Prepend(XRCID("lsp_find_references"), _("Find references")); |
| 212 |
} |
| 213 |
menu->PrependSeparator(); |
| 214 |
if(add_rename_symbol && false) { |
| 215 |
menu->Prepend(XRCID("lsp_rename_symbol"), _("Rename symbol")); |
| 216 |
} |
| 217 |
menu->Prepend(XRCID("lsp_find_symbol"), _("Find symbol")); |
| 218 |
|
| 219 |
// TODO: |
| 220 |
// add here "Find References" and "Rename Symbol" |
| 221 |
// menu entries if supported by the LSP |
| 222 |
// we always add them to the top of the list |
| 223 |
menu->Bind(wxEVT_MENU, &LanguageServerPlugin::OnMenuFindSymbol, this, XRCID("lsp_find_symbol")); |
| 224 |
menu->Bind(wxEVT_MENU, &LanguageServerPlugin::OnMenuFindReferences, this, XRCID("lsp_find_references")); |
| 225 |
menu->Bind(wxEVT_MENU, &LanguageServerPlugin::OnMenuRenameSymbol, this, XRCID("lsp_rename_symbol")); |
| 226 |
} |
| 227 |
|
| 228 |
void LanguageServerPlugin::OnMenuRenameSymbol(wxCommandEvent& event) {} |
| 229 |
|
| 230 |
void LanguageServerPlugin::OnMenuFindReferences(wxCommandEvent& event) |
| 231 |
{ |
| 232 |
wxUnusedVar(event); |
| 233 |
|
| 234 |
clDEBUG() << "OnMenuFindReferences is called" << endl; |
| 235 |
|
| 236 |
IEditor* editor = clGetManager()->GetActiveEditor(); |
| 237 |
CHECK_PTR_RET(editor); |
| 238 |
|
| 239 |
LanguageServerProtocol::Ptr_t lsp = m_servers->GetServerForEditor(editor); |
| 240 |
CHECK_PTR_RET(lsp); |
| 241 |
|
| 242 |
lsp->FindReferences(editor); |
| 243 |
} |
| 244 |
|
| 245 |
void LanguageServerPlugin::OnMenuFindSymbol(wxCommandEvent& event) |
| 246 |
{ |
| 247 |
IEditor* editor = clGetManager()->GetActiveEditor(); |
| 248 |
CHECK_PTR_RET(editor); |
| 249 |
|
| 250 |
clCodeCompletionEvent findEvent(wxEVT_CC_FIND_SYMBOL); |
| 251 |
findEvent.SetPosition(editor->GetCurrentPosition()); |
| 252 |
findEvent.SetFileName(editor->GetFileName().GetFullPath()); |
| 253 |
ServiceProviderManager::Get().AddPendingEvent(findEvent); |
| 254 |
} |
| 255 |
|
| 256 |
void LanguageServerPlugin::ConfigureLSPs(const std::vector<LSPDetector::Ptr_t>& lsps) |
| 257 |
{ |
| 258 |
clDEBUG() << " ******" |
| 259 |
<< "ConfigureLSPs is called!" << clEndl; |
| 260 |
if(lsps.empty()) { |
| 261 |
clDEBUG() << "ConfigureLSPs: no LSPs found. Nothing to be done here" << clEndl; |
| 262 |
return; |
| 263 |
} |
| 264 |
|
| 265 |
LanguageServerConfig& config = LanguageServerConfig::Get(); |
| 266 |
// remove clangd installed under ~/.codelite/lsp/clang-tools |
| 267 |
wxArrayString serversToRemove; |
| 268 |
for(const auto& server : config.GetServers()) { |
| 269 |
if(server.second.GetCommand().Contains(".codelite/lsp/clang-tools")) { |
| 270 |
serversToRemove.Add(server.first); |
| 271 |
} |
| 272 |
} |
| 273 |
|
| 274 |
bool force = !serversToRemove.IsEmpty(); |
| 275 |
// remove all old entries |
| 276 |
for(const auto& name : serversToRemove) { |
| 277 |
clSYSTEM() << "Removing broken LSP server:" << name << endl; |
| 278 |
config.RemoveServer(name); |
| 279 |
} |
| 280 |
|
| 281 |
clDEBUG() << "ConfigureLSPs: there are currently" << config.GetServers().size() << "LSPs configured" << clEndl; |
| 282 |
if(config.GetServers().empty() || force) { |
| 283 |
clDEBUG() << "No LSPs configured - auto configuring" << clEndl; |
| 284 |
// Only if the user did not configure LSP before, we configure it for him |
| 285 |
for(auto lsp : lsps) { |
| 286 |
LanguageServerEntry entry; |
| 287 |
lsp->GetLanguageServerEntry(entry); |
| 288 |
entry.SetEnabled(true); |
| 289 |
config.AddServer(entry); |
| 290 |
clDEBUG() << "Adding LSP:" << entry.GetName() << clEndl; |
| 291 |
} |
| 292 |
config.SetEnabled(true); |
| 293 |
config.Save(); |
| 294 |
if(m_servers) { |
| 295 |
m_servers->Reload(); |
| 296 |
} |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
void LanguageServerPlugin::OnLSPStopAll(clLanguageServerEvent& event) |
| 301 |
{ |
| 302 |
CHECK_PTR_RET(m_servers); |
| 303 |
m_servers->StopAll(); |
| 304 |
} |
| 305 |
|
| 306 |
void LanguageServerPlugin::OnLSPStartAll(clLanguageServerEvent& event) |
| 307 |
{ |
| 308 |
CHECK_PTR_RET(m_servers); |
| 309 |
m_servers->StartAll(); |
| 310 |
} |
| 311 |
|
| 312 |
void LanguageServerPlugin::OnLSPRestartAll(clLanguageServerEvent& event) |
| 313 |
{ |
| 314 |
clDEBUG() << "LSP: restarting all LSPs" << endl; |
| 315 |
CHECK_PTR_RET(m_servers); |
| 316 |
m_servers->StopAll(); |
| 317 |
m_servers->StartAll(); |
| 318 |
clDEBUG() << "LSP: restarting all LSPs...done" << endl; |
| 319 |
} |
| 320 |
|
| 321 |
void LanguageServerPlugin::OnLSPStopOne(clLanguageServerEvent& event) |
| 322 |
{ |
| 323 |
CHECK_PTR_RET(m_servers); |
| 324 |
LanguageServerProtocol::Ptr_t lsp = m_servers->GetServerByName(event.GetLspName()); |
| 325 |
CHECK_PTR_RET(lsp); |
| 326 |
lsp->Stop(); |
| 327 |
} |
| 328 |
|
| 329 |
void LanguageServerPlugin::OnLSPStartOne(clLanguageServerEvent& event) |
| 330 |
{ |
| 331 |
CHECK_PTR_RET(m_servers); |
| 332 |
auto lsp = m_servers->GetServerByName(event.GetLspName()); |
| 333 |
CHECK_PTR_RET(lsp); |
| 334 |
lsp->Start(); |
| 335 |
} |
| 336 |
|
| 337 |
void LanguageServerPlugin::OnLSPRestartOne(clLanguageServerEvent& event) |
| 338 |
{ |
| 339 |
CHECK_PTR_RET(m_servers); |
| 340 |
m_servers->RestartServer(event.GetLspName()); |
| 341 |
} |
| 342 |
|
| 343 |
void LanguageServerPlugin::OnLSPConfigure(clLanguageServerEvent& event) |
| 344 |
{ |
| 345 |
|
| 346 |
LanguageServerEntry entry; |
| 347 |
LanguageServerEntry* pentry = &entry; |
| 348 |
|
| 349 |
auto d = LanguageServerConfig::Get().GetServer(event.GetLspName()); |
| 350 |
if(d.IsValid()) { |
| 351 |
clDEBUG() << "an LSP with the same name:" << event.GetLspName() << "already exists. updating it" << endl; |
| 352 |
pentry = &d; |
| 353 |
} |
| 354 |
|
| 355 |
// Configure new LSP |
| 356 |
pentry->SetLanguages(event.GetLanguages()); |
| 357 |
pentry->SetName(event.GetLspName()); |
| 358 |
pentry->SetCommand(event.GetLspCommand()); |
| 359 |
pentry->SetDisaplayDiagnostics(event.GetFlags() & clLanguageServerEvent::kDisaplyDiags); |
| 360 |
pentry->SetConnectionString(event.GetConnectionString()); |
| 361 |
pentry->SetEnabled(event.GetFlags() & clLanguageServerEvent::kEnabled); |
| 362 |
pentry->SetPriority(event.GetPriority()); |
| 363 |
pentry->SetWorkingDirectory(event.GetRootUri()); |
| 364 |
LanguageServerConfig::Get().AddServer(*pentry); |
| 365 |
} |
| 366 |
|
| 367 |
void LanguageServerPlugin::OnLSPDelete(clLanguageServerEvent& event) |
| 368 |
{ |
| 369 |
CHECK_PTR_RET(m_servers); |
| 370 |
clDEBUG() << "Deleting server:" << event.GetLspName() << endl; |
| 371 |
m_servers->DeleteServer(event.GetLspName()); |
| 372 |
clDEBUG() << "Success" << endl; |
| 373 |
} |
| 374 |
|
| 375 |
void LanguageServerPlugin::OnLSPShowSettingsDlg(clLanguageServerEvent& event) |
| 376 |
{ |
| 377 |
wxCommandEvent dummy; |
| 378 |
OnSettings(dummy); |
| 379 |
} |
| 380 |
|
| 381 |
wxString LanguageServerPlugin::GetEditorFilePath(IEditor* editor) const { return editor->GetRemotePathOrLocal(); } |
| 382 |
|
| 383 |
void LanguageServerPlugin::OnLSPEnableServer(clLanguageServerEvent& event) |
| 384 |
{ |
| 385 |
auto& lsp_config = LanguageServerConfig::Get().GetServer(event.GetLspName()); |
| 386 |
if(!lsp_config.IsValid()) { |
| 387 |
return; |
| 388 |
} |
| 389 |
lsp_config.SetEnabled(true); |
| 390 |
} |
| 391 |
|
| 392 |
void LanguageServerPlugin::OnLSPDisableServer(clLanguageServerEvent& event) |
| 393 |
{ |
| 394 |
auto& lsp_config = LanguageServerConfig::Get().GetServer(event.GetLspName()); |
| 395 |
if(!lsp_config.IsValid()) { |
| 396 |
return; |
| 397 |
} |
| 398 |
lsp_config.SetEnabled(false); |
| 399 |
} |
| 400 |
|
| 401 |
void LanguageServerPlugin::LogMessage(const wxString& server_name, const wxString& message, int log_leve) |
| 402 |
{ |
| 403 |
auto& builder = m_logView->GetDvListCtrl()->GetBuilder(true); |
| 404 |
|
| 405 |
eAsciiColours ansi_colour_code = eAsciiColours::NORMAL_TEXT; |
| 406 |
wxString label = "T "; // trace |
| 407 |
switch(log_leve) { |
| 408 |
case 1: |
| 409 |
ansi_colour_code = eAsciiColours::RED; // error |
| 410 |
label = "E "; |
| 411 |
break; |
| 412 |
case 2: |
| 413 |
ansi_colour_code = eAsciiColours::YELLOW; // warning |
| 414 |
label = "W "; |
| 415 |
break; |
| 416 |
case 3: |
| 417 |
ansi_colour_code = eAsciiColours::GREEN; // info |
| 418 |
label = "I "; |
| 419 |
default: |
| 420 |
break; |
| 421 |
} |
| 422 |
|
| 423 |
builder.Add(label, ansi_colour_code); |
| 424 |
builder.Add(wxDateTime::Now().FormatISOTime() + " ", eAsciiColours::GRAY); |
| 425 |
builder.Add(server_name + " ", eAsciiColours::NORMAL_TEXT); |
| 426 |
builder.Add(message, eAsciiColours::NORMAL_TEXT); |
| 427 |
m_logView->GetDvListCtrl()->AddLine(builder.GetString(), false); |
| 428 |
m_logView->GetDvListCtrl()->ScrollToBottom(); |
| 429 |
} |
| 430 |
|
| 431 |
void LanguageServerPlugin::OnWorkspaceClosed(clWorkspaceEvent& event) |
| 432 |
{ |
| 433 |
event.Skip(); |
| 434 |
m_logView->GetDvListCtrl()->DeleteAllItems(); |
| 435 |
} |