From bc0c391792286d500dcc32a0742f7119b7cd10c9 Mon Sep 17 00:00:00 2001 From: Eran Ifrah Date: Fri, 31 May 2024 09:15:30 +0300 Subject: [PATCH] - Rust plugin: change the default clippy command to: `cargo clippy --color always --all-features --all-targets -- -D warnings` - LSP plugin: when a broken LSP is found, in addition to the "Attempt to fix" button, add a "Cancel" button --- CodeFormatter/CodeFormatterManager.cpp | 38 +++++++------- LanguageServer/languageserver.cpp | 72 +++++++++++++------------- Rust/RustPlugin.cpp | 69 ++++++++++++------------ 3 files changed, 91 insertions(+), 88 deletions(-) diff --git a/CodeFormatter/CodeFormatterManager.cpp b/CodeFormatter/CodeFormatterManager.cpp index d9eedf1727..8cbdc38c95 100644 --- a/CodeFormatter/CodeFormatterManager.cpp +++ b/CodeFormatter/CodeFormatterManager.cpp @@ -22,8 +22,8 @@ CodeFormatterManager::~CodeFormatterManager() { clear(); } std::shared_ptr CodeFormatterManager::GetFormatter(const wxString& filepath) const { auto type = FileExtManager::GetType(filepath); - for(auto f : m_formatters) { - if(f->IsEnabled() && f->CanHandle(type)) { + for (auto f : m_formatters) { + if (f->IsEnabled() && f->CanHandle(type)) { return f; } } @@ -54,12 +54,12 @@ void CodeFormatterManager::push_back(GenericFormatter* formatter) size_t CodeFormatterManager::GetAllNames(wxArrayString* names) const { - if(!names) { + if (!names) { return 0; } names->reserve(m_formatters.size()); - for(auto f : m_formatters) { + for (auto f : m_formatters) { names->Add(f->GetName()); } return names->size(); @@ -70,12 +70,12 @@ void CodeFormatterManager::Load() wxFileName config_file{ clStandardPaths::Get().GetUserDataDir(), "code-formatters.json" }; config_file.AppendDir("config"); - if(!config_file.FileExists()) { + if (!config_file.FileExists()) { return; } JSON root{ config_file }; - if(!root.isOk() || !root.toElement().isArray()) { + if (!root.isOk() || !root.toElement().isArray()) { initialize_defaults(); return; } @@ -83,7 +83,7 @@ void CodeFormatterManager::Load() clear(); auto arr = root.toElement(); int count = arr.arraySize(); - for(int i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { GenericFormatter* fmtr = new GenericFormatter(); fmtr->FromJSON(arr[i]); push_back(fmtr); @@ -96,7 +96,7 @@ void CodeFormatterManager::Save() config_file.AppendDir("config"); JSON root{ cJSON_Array }; auto arr = root.toElement(); - for(auto fmtr : m_formatters) { + for (auto fmtr : m_formatters) { arr.arrayAppend(fmtr->ToJSON()); } root.save(config_file); @@ -104,8 +104,8 @@ void CodeFormatterManager::Save() std::shared_ptr CodeFormatterManager::GetFormatterByName(const wxString& name) const { - for(auto f : m_formatters) { - if(f->GetName() == name) { + for (auto f : m_formatters) { + if (f->GetName() == name) { return f; } } @@ -115,8 +115,8 @@ std::shared_ptr CodeFormatterManager::GetFormatterByName(const bool CodeFormatterManager::CanFormat(const wxString& filepath) const { auto file_type = FileExtManager::GetType(filepath); - for(auto f : m_formatters) { - if(f->IsEnabled() && f->CanHandle(file_type)) { + for (auto f : m_formatters) { + if (f->IsEnabled() && f->CanHandle(file_type)) { return true; } } @@ -126,12 +126,12 @@ bool CodeFormatterManager::CanFormat(const wxString& filepath) const bool CodeFormatterManager::CanFormatByContent(const wxString& content) const { FileExtManager::FileType file_type; - if(!FileExtManager::GetContentType(content, file_type)) { + if (!FileExtManager::GetContentType(content, file_type)) { return false; } - for(auto f : m_formatters) { - if(f->IsEnabled() && f->CanHandle(file_type)) { + for (auto f : m_formatters) { + if (f->IsEnabled() && f->CanHandle(file_type)) { return true; } } @@ -146,7 +146,7 @@ void CodeFormatterManager::RestoreDefaults() void CodeFormatterManager::ClearRemoteCommands() { - for(auto f : m_formatters) { + for (auto f : m_formatters) { f->SetRemoteCommand(wxEmptyString, wxEmptyString, {}); } } @@ -154,12 +154,12 @@ void CodeFormatterManager::ClearRemoteCommands() std::shared_ptr CodeFormatterManager::GetFormatterByContent(const wxString& content) const { FileExtManager::FileType type; - if(!FileExtManager::GetContentType(content, type)) { + if (!FileExtManager::GetContentType(content, type)) { return nullptr; } - for(auto f : m_formatters) { - if(f->IsEnabled() && f->CanHandle(type)) { + for (auto f : m_formatters) { + if (f->IsEnabled() && f->CanHandle(type)) { return f; } } diff --git a/LanguageServer/languageserver.cpp b/LanguageServer/languageserver.cpp index 2edf10d08a..272f4f240b 100644 --- a/LanguageServer/languageserver.cpp +++ b/LanguageServer/languageserver.cpp @@ -25,7 +25,7 @@ static LanguageServerPlugin* thePlugin = NULL; // Define the plugin entry point CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { - if(thePlugin == NULL) { + if (thePlugin == NULL) { thePlugin = new LanguageServerPlugin(manager); } return thePlugin; @@ -89,20 +89,22 @@ LanguageServerPlugin::~LanguageServerPlugin() { wxDELETE(m_servers); } void LanguageServerPlugin::CheckServers() { auto broken_lsps = GetBrokenLSPs(); - if(broken_lsps.empty()) { + if (broken_lsps.empty()) { return; } + clSYSTEM() << "The following LSPs contain paths to a non existing locations:" << broken_lsps << endl; // Show a notification message with a suggestion for a fix wxString message; message << "The following LSPs contain paths to a non existing locations: ["; - for(const auto& name : broken_lsps) { + for (const auto& name : broken_lsps) { message << name << ", "; } message.RemoveLast(2); message << "]"; - clGetManager()->DisplayMessage(message, wxICON_WARNING, { { XRCID("lsp-fix-paths"), _("Attempt to fix") } }); + clGetManager()->DisplayMessage(message, wxICON_WARNING, + { { wxID_CANCEL, _("Cancel") }, { XRCID("lsp-fix-paths"), _("Attempt to fix") } }); } void LanguageServerPlugin::CreateToolBar(clToolBarGeneric* toolbar) @@ -142,7 +144,7 @@ void LanguageServerPlugin::UnPlug() LanguageServerConfig::Get().Save(); // before this plugin is un-plugged we must remove the tab we added - if(!m_mgr->BookDeletePage(PaneId::BOTTOM_BAR, m_logView)) { + if (!m_mgr->BookDeletePage(PaneId::BOTTOM_BAR, m_logView)) { m_logView->Destroy(); } m_logView = nullptr; @@ -152,10 +154,10 @@ void LanguageServerPlugin::UnPlug() void LanguageServerPlugin::OnSettings(wxCommandEvent& e) { LanguageServerSettingsDlg dlg(EventNotifier::Get()->TopFrame(), false); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { // restart all language servers dlg.Save(); - if(m_servers) { + if (m_servers) { // Lets assume that we fixed something in the settings // and clear all the restart counters m_servers->ClearRestartCounters(); @@ -167,7 +169,7 @@ void LanguageServerPlugin::OnSettings(wxCommandEvent& e) void LanguageServerPlugin::OnRestartLSP(wxCommandEvent& e) { wxUnusedVar(e); - if(m_servers) { + if (m_servers) { m_servers->Reload(); } } @@ -179,14 +181,14 @@ void LanguageServerPlugin::OnInitDone(wxCommandEvent& event) bool force = false; const auto& servers = LanguageServerConfig::Get().GetServers(); - for(auto& server : servers) { - if(server.second.GetCommand().Contains(".codelite/lsp/clang-tools")) { + for (auto& server : servers) { + if (server.second.GetCommand().Contains(".codelite/lsp/clang-tools")) { force = true; break; } } - if(LanguageServerConfig::Get().GetServers().empty() || force) { + if (LanguageServerConfig::Get().GetServers().empty() || force) { LSP_DEBUG() << "Scanning..." << endl; std::thread thr( [=](LanguageServerPlugin* plugin) { @@ -194,7 +196,7 @@ void LanguageServerPlugin::OnInitDone(wxCommandEvent& event) LSPDetectorManager detector; LSP_DEBUG() << "***" << "Scanning for LSPs... ***" << endl; - if(detector.Scan(matches)) { + if (detector.Scan(matches)) { LSP_DEBUG() << " ******" << "found!" << endl; } @@ -224,17 +226,17 @@ void LanguageServerPlugin::OnEditorContextMenu(clContextMenuEvent& event) bool add_rename_symbol = lsp->IsRenameSupported(); // nothing to be done here - if(!add_find_symbol && !add_find_references && !add_rename_symbol) { + if (!add_find_symbol && !add_find_references && !add_rename_symbol) { return; } wxMenu* menu = event.GetMenu(); - if(add_find_references) { + if (add_find_references) { menu->PrependSeparator(); menu->Prepend(XRCID("lsp_find_references"), _("Find references")); } menu->PrependSeparator(); - if(add_rename_symbol) { + if (add_rename_symbol) { menu->Prepend(XRCID("lsp_rename_symbol"), _("Rename symbol")); } menu->Prepend(XRCID("lsp_find_symbol"), _("Find symbol")); @@ -289,7 +291,7 @@ void LanguageServerPlugin::ConfigureLSPs(const std::vector& { LSP_DEBUG() << " ******" << "ConfigureLSPs is called!" << endl; - if(lsps.empty()) { + if (lsps.empty()) { LSP_DEBUG() << "ConfigureLSPs: no LSPs found. Nothing to be done here" << endl; return; } @@ -297,24 +299,24 @@ void LanguageServerPlugin::ConfigureLSPs(const std::vector& LanguageServerConfig& config = LanguageServerConfig::Get(); // remove clangd installed under ~/.codelite/lsp/clang-tools wxArrayString serversToRemove; - for(const auto& server : config.GetServers()) { - if(server.second.GetCommand().Contains(".codelite/lsp/clang-tools")) { + for (const auto& server : config.GetServers()) { + if (server.second.GetCommand().Contains(".codelite/lsp/clang-tools")) { serversToRemove.Add(server.first); } } bool force = !serversToRemove.IsEmpty(); // remove all old entries - for(const auto& name : serversToRemove) { + for (const auto& name : serversToRemove) { LSP_SYSTEM() << "Removing broken LSP server:" << name << endl; config.RemoveServer(name); } LSP_DEBUG() << "ConfigureLSPs: there are currently" << config.GetServers().size() << "LSPs configured" << endl; - if(config.GetServers().empty() || force) { + if (config.GetServers().empty() || force) { LSP_DEBUG() << "No LSPs configured - auto configuring" << endl; // Only if the user did not configure LSP before, we configure it for him - for(auto lsp : lsps) { + for (auto lsp : lsps) { LanguageServerEntry entry; lsp->GetLanguageServerEntry(entry); config.AddServer(entry); @@ -322,7 +324,7 @@ void LanguageServerPlugin::ConfigureLSPs(const std::vector& } config.SetEnabled(true); config.Save(); - if(m_servers) { + if (m_servers) { m_servers->Reload(); } } @@ -380,7 +382,7 @@ void LanguageServerPlugin::OnLSPConfigure(clLanguageServerEvent& event) LanguageServerEntry* pentry = &entry; auto d = LanguageServerConfig::Get().GetServer(event.GetLspName()); - if(!d.IsNull()) { + if (!d.IsNull()) { LSP_DEBUG() << "an LSP with the same name:" << event.GetLspName() << "already exists. updating it" << endl; pentry = &d; } @@ -415,7 +417,7 @@ wxString LanguageServerPlugin::GetEditorFilePath(IEditor* editor) const { return void LanguageServerPlugin::OnLSPEnableServer(clLanguageServerEvent& event) { auto& lsp_config = LanguageServerConfig::Get().GetServer(event.GetLspName()); - if(lsp_config.IsNull()) { + if (lsp_config.IsNull()) { return; } lsp_config.SetEnabled(true); @@ -424,7 +426,7 @@ void LanguageServerPlugin::OnLSPEnableServer(clLanguageServerEvent& event) void LanguageServerPlugin::OnLSPDisableServer(clLanguageServerEvent& event) { auto& lsp_config = LanguageServerConfig::Get().GetServer(event.GetLspName()); - if(lsp_config.IsNull()) { + if (lsp_config.IsNull()) { return; } lsp_config.SetEnabled(false); @@ -436,7 +438,7 @@ void LanguageServerPlugin::LogMessage(const wxString& server_name, const wxStrin int ansi_colour_code = AnsiColours::NormalText(); wxString label = "T "; // trace - switch(log_leve) { + switch (log_leve) { case 1: ansi_colour_code = AnsiColours::Red(); // error label = "E "; @@ -474,27 +476,27 @@ void LanguageServerPlugin::OnFixLSPPaths(wxCommandEvent& event) wxUnusedVar(event); auto broken_lsps = GetBrokenLSPs(); - if(broken_lsps.empty()) { + if (broken_lsps.empty()) { return; } wxBusyCursor bc; std::vector matches; LSPDetectorManager detector; - if(detector.Scan(matches)) { + if (detector.Scan(matches)) { wxArrayString fixed; - for(const wxString& broken_lsp : broken_lsps) { + for (const wxString& broken_lsp : broken_lsps) { auto& lsp = LanguageServerConfig::Get().GetServer(broken_lsp); - if(lsp.IsNull()) { + if (lsp.IsNull()) { // Could not find it continue; } // Check to see if - for(size_t i = 0; i < matches.size(); ++i) { + for (size_t i = 0; i < matches.size(); ++i) { LanguageServerEntry entry; matches[i]->GetLanguageServerEntry(entry); - if(entry.GetName() == broken_lsp) { + if (entry.GetName() == broken_lsp) { lsp = entry; fixed.Add(broken_lsp); break; @@ -502,7 +504,7 @@ void LanguageServerPlugin::OnFixLSPPaths(wxCommandEvent& event) } } - if(!fixed.empty()) { + if (!fixed.empty()) { LanguageServerConfig::Get().Save(); m_servers->Reload(); } @@ -513,10 +515,10 @@ wxArrayString LanguageServerPlugin::GetBrokenLSPs() const { wxArrayString broken_lsps; const auto& servers = LanguageServerConfig::Get().GetServers(); - for(const auto& [name, server] : servers) { + for (const auto& [name, server] : servers) { auto argv = StringUtils::BuildArgv(server.GetCommand()); // Check that the first argument (the executable path) exists - if(server.IsEnabled() && argv.empty() || !wxFileName::FileExists(argv[0])) { + if (server.IsEnabled() && argv.empty() || !wxFileName::FileExists(argv[0])) { broken_lsps.push_back(name); } } diff --git a/Rust/RustPlugin.cpp b/Rust/RustPlugin.cpp index 3d2e7d5ccb..ba4d4465b5 100644 --- a/Rust/RustPlugin.cpp +++ b/Rust/RustPlugin.cpp @@ -54,7 +54,7 @@ static RustPlugin* thePlugin = NULL; // Define the plugin entry point CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { - if(thePlugin == 0) { + if (thePlugin == 0) { thePlugin = new RustPlugin(manager); } return thePlugin; @@ -119,13 +119,13 @@ void RustPlugin::OnRustWorkspaceFileCreated(clFileSystemEvent& event) wxFileName workspaceFile(event.GetPath()); wxFileName fnCargoToml(workspaceFile); fnCargoToml.SetFullName("Cargo.toml"); - if(fnCargoToml.FileExists()) { + if (fnCargoToml.FileExists()) { CargoToml cargoToml; const wxString& name = cargoToml.Load(fnCargoToml).GetName(); // update the build commands clFileSystemWorkspaceSettings settings; - if(!settings.Load(workspaceFile)) { + if (!settings.Load(workspaceFile)) { clWARNING() << "Failed to load file:" << workspaceFile << endl; return; } @@ -133,19 +133,20 @@ void RustPlugin::OnRustWorkspaceFileCreated(clFileSystemEvent& event) wxString cargo_exe = "cargo"; #ifdef __WXMSW__ clRustLocator rust_locator; - if(rust_locator.Locate()) { + if (rust_locator.Locate()) { cargo_exe = rust_locator.GetRustTool("cargo"); ::WrapWithQuotes(cargo_exe); } #endif auto debug = settings.GetConfig("Debug"); - if(debug) { + if (debug) { clDEBUG() << "Setting project preferences..." << endl; - debug->SetBuildTargets({ { "build", cargo_exe + " build --color always" }, - { "clean", cargo_exe + " clean --color always" }, - { "tests", cargo_exe + " test --color always" }, - { "clippy", cargo_exe + " clippy --color always" } }); + debug->SetBuildTargets( + { { "build", cargo_exe + " build --color always" }, + { "clean", cargo_exe + " clean --color always" }, + { "tests", cargo_exe + " test --color always" }, + { "clippy", cargo_exe + " clippy --color always --all-features --all-targets -- -D warnings" } }); wxFileName target_exe(workspaceFile.GetPath() + "/target/debug/" + name); #ifdef __WXMSW__ target_exe.SetExt("exe"); @@ -158,7 +159,7 @@ void RustPlugin::OnRustWorkspaceFileCreated(clFileSystemEvent& event) #if !defined(__WXMSW__) // use rust-gdb wxFileName rust_gdb = GetRustTool("rust-gdb"); - if(rust_gdb.IsOk()) { + if (rust_gdb.IsOk()) { env_str << "GDB=" << rust_gdb.GetFullPath() << "\n"; env_str << "PATH=" << rust_gdb.GetPath() << clPATH_SEPARATOR << "$PATH" << "\n"; @@ -171,7 +172,7 @@ void RustPlugin::OnRustWorkspaceFileCreated(clFileSystemEvent& event) gdb_python_module_directory.AppendDir("etc"); wxFileName gdb_exe = GetRustTool("gdb"); - if(gdb_exe.FileExists()) { + if (gdb_exe.FileExists()) { env_str << "RUST_GDB=" << gdb_exe.GetFullPath() << "\n"; env_str << "PATH=" << gdb_exe.GetPath() << clPATH_SEPARATOR << "$PATH\n"; } else { @@ -201,7 +202,7 @@ end gdbinit_content.Replace("%GDB_PYTHON_MODULE_DIRECTORY%", fixed_path); debug->SetDebuggerCommands(gdbinit_content); #endif - if(!env_str.empty()) { + if (!env_str.empty()) { debug->SetEnvironment(env_str); } AddRustcCompilerIfMissing(); @@ -214,18 +215,18 @@ end void RustPlugin::OnNewWorkspace(clCommandEvent& e) { e.Skip(); - if(e.GetString() == "Rust") { + if (e.GetString() == "Rust") { e.Skip(false); // Prompt the user for the folder to run 'cargo new' NewFileSystemWorkspaceDialog dlg(EventNotifier::Get()->TopFrame(), false /* do not auto update the name */); dlg.SetLabel(_("Select the folder to run 'cargo new'")); - if(dlg.ShowModal() != wxID_OK) { + if (dlg.ShowModal() != wxID_OK) { return; } EnvSetter env; wxString cargo_exe; - if(!ThePlatform->Which("cargo", &cargo_exe)) { + if (!ThePlatform->Which("cargo", &cargo_exe)) { wxMessageBox(_("Could not locate cargo in your PATH"), "CodeLite", wxICON_ERROR | wxCENTRE); return; } @@ -236,7 +237,7 @@ void RustPlugin::OnNewWorkspace(clCommandEvent& e) command << cargo_exe << " new " << dlg.GetWorkspaceName(); IProcess::Ptr_t process(::CreateSyncProcess(command, IProcessCreateDefault | IProcessCreateWithHiddenConsole, dlg.GetWorkspacePath())); - if(!process) { + if (!process) { clWARNING() << "failed to execute:" << command << endl; return; } @@ -245,7 +246,7 @@ void RustPlugin::OnNewWorkspace(clCommandEvent& e) process->WaitForTerminate(output); wxFileName cargoToml(dlg.GetWorkspacePath(), "Cargo.toml"); cargoToml.AppendDir(dlg.GetWorkspaceName()); - if(cargoToml.FileExists()) { + if (cargoToml.FileExists()) { // we successfully created a new cargo workspace, now, load it (using the standard file system // workspace) clFileSystemWorkspace::Get().New(cargoToml.GetPath(), cargoToml.GetDirs().Last()); @@ -256,7 +257,7 @@ void RustPlugin::OnNewWorkspace(clCommandEvent& e) wxString RustPlugin::GetRustTool(const wxString& toolname) const { clRustLocator locator; - if(!locator.Locate()) { + if (!locator.Locate()) { return wxEmptyString; } return locator.GetRustTool(toolname); @@ -264,7 +265,7 @@ wxString RustPlugin::GetRustTool(const wxString& toolname) const void RustPlugin::OnBuildErrorLineClicked(clBuildEvent& event) { - if(!clFileSystemWorkspace::Get().IsOpen()) { + if (!clFileSystemWorkspace::Get().IsOpen()) { event.Skip(); return; } @@ -273,7 +274,7 @@ void RustPlugin::OnBuildErrorLineClicked(clBuildEvent& event) clDEBUG() << "File:" << event.GetFileName() << endl; clDEBUG() << "Line number:" << event.GetLineNumber() << endl; - if(!FileExtManager::IsFileType(event.GetFileName(), FileExtManager::TypeRust)) { + if (!FileExtManager::IsFileType(event.GetFileName(), FileExtManager::TypeRust)) { clDEBUG() << "Not a rust file, Skip()" << endl; event.Skip(); return; @@ -285,7 +286,7 @@ void RustPlugin::OnBuildErrorLineClicked(clBuildEvent& event) // build the file path: // the compiler report the file in relative path to the `Cargo.toml` file wxString basepath; - if(m_cargoTomlFile.FileExists()) { + if (m_cargoTomlFile.FileExists()) { basepath = m_cargoTomlFile.GetPath(); clDEBUG() << "Build root dir is set to Cargo.toml path:" << basepath << endl; } else { @@ -294,20 +295,20 @@ void RustPlugin::OnBuildErrorLineClicked(clBuildEvent& event) } bool is_abspath = event.GetFileName().StartsWith("/") || wxFileName(event.GetFileName()).IsAbsolute(); - if(!is_abspath && basepath.empty()) { + if (!is_abspath && basepath.empty()) { // unable to determine the root folder event.Skip(); return; } - if(is_abspath) { + if (is_abspath) { basepath = event.GetFileName(); } else { basepath << "/" << event.GetFileName(); } wxFileName fnFile(basepath); - if(!fnFile.FileExists()) { + if (!fnFile.FileExists()) { event.Skip(true); // let others handle this return; } @@ -327,7 +328,7 @@ void RustPlugin::AddRustcCompilerIfMissing() { // Create new "rustc" compiler and place compiler patterns to use clDEBUG() << "Searching for rustc compiler..." << endl; - if(BuildSettingsConfigST::Get()->IsCompilerExist("rustc")) { + if (BuildSettingsConfigST::Get()->IsCompilerExist("rustc")) { clDEBUG() << "Compiler rustc already exists" << endl; return; } @@ -342,24 +343,24 @@ void RustPlugin::AddRustcCompilerIfMissing() void RustPlugin::OnBuildEnded(clBuildEvent& event) { event.Skip(); - if(!clFileSystemWorkspace::Get().IsOpen()) { + if (!clFileSystemWorkspace::Get().IsOpen()) { return; } wxFileName fnCargoToml(clFileSystemWorkspace::Get().GetFileName()); fnCargoToml.SetFullName("Cargo.toml"); wxString cargo_toml = fnCargoToml.GetFullPath(); - if(!wxFileName::FileExists(cargo_toml)) { + if (!wxFileName::FileExists(cargo_toml)) { return; } wxString new_digest = wxMD5::GetDigest(fnCargoToml); wxString old_digest; - if(m_cargoTomlDigest.count(cargo_toml)) { + if (m_cargoTomlDigest.count(cargo_toml)) { old_digest = m_cargoTomlDigest[cargo_toml]; } - if(new_digest != old_digest) { + if (new_digest != old_digest) { // restart is required clLanguageServerEvent restart_event(wxEVT_LSP_RESTART_ALL); EventNotifier::Get()->ProcessEvent(restart_event); @@ -370,19 +371,19 @@ void RustPlugin::OnBuildEnded(clBuildEvent& event) void RustPlugin::OnWorkspaceLoaded(clWorkspaceEvent& event) { event.Skip(); - if(!clFileSystemWorkspace::Get().IsOpen()) { + if (!clFileSystemWorkspace::Get().IsOpen()) { return; } wxFileName workspaceFile = clFileSystemWorkspace::Get().GetFileName(); wxFileName cargo_toml{ workspaceFile.GetPath(), "Cargo.toml" }; - if(cargo_toml.FileExists()) { + if (cargo_toml.FileExists()) { m_cargoTomlFile = cargo_toml; } else { // try the parent folder cargo_toml.RemoveLastDir(); - if(cargo_toml.FileExists()) { + if (cargo_toml.FileExists()) { m_cargoTomlFile = cargo_toml; } else { // We might placed our Cargo.toml in one of the children folers (1 level below) @@ -392,10 +393,10 @@ void RustPlugin::OnWorkspaceLoaded(clWorkspaceEvent& event) d.Open(workspace_path); wxString filename; - for(bool cont = d.GetFirst(&filename, wxEmptyString, wxDIR_DIRS); cont; cont = d.GetNext(&filename)) { + for (bool cont = d.GetFirst(&filename, wxEmptyString, wxDIR_DIRS); cont; cont = d.GetNext(&filename)) { cargo_toml = wxFileName(workspace_path, "Cargo.toml"); cargo_toml.AppendDir(filename); - if(cargo_toml.FileExists()) { + if (cargo_toml.FileExists()) { m_cargoTomlFile = cargo_toml; break; }