diff --git a/AutoSave/AutoSaveDlg.cpp b/AutoSave/AutoSaveDlg.cpp index 4da517b072..78f81784d4 100644 --- a/AutoSave/AutoSaveDlg.cpp +++ b/AutoSave/AutoSaveDlg.cpp @@ -1,4 +1,5 @@ #include "AutoSaveDlg.h" + #include "AutoSaveSettings.h" AutoSaveDlg::AutoSaveDlg(wxWindow* parent) diff --git a/AutoSave/autosave.cpp b/AutoSave/autosave.cpp index b336a67027..634ffd2d8c 100644 --- a/AutoSave/autosave.cpp +++ b/AutoSave/autosave.cpp @@ -8,10 +8,7 @@ #include // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new AutoSave(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new AutoSave(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -54,7 +51,7 @@ void AutoSave::UnPlug() void AutoSave::OnSettings(wxCommandEvent& event) { AutoSaveDlg dlg(EventNotifier::Get()->TopFrame()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { // Update the settings UpdateTimers(); } @@ -64,7 +61,7 @@ void AutoSave::UpdateTimers() { DeleteTimer(); AutoSaveSettings conf = AutoSaveSettings::Load(); - if(!conf.HasFlag(AutoSaveSettings::kEnabled)) { + if (!conf.HasFlag(AutoSaveSettings::kEnabled)) { return; } @@ -79,11 +76,11 @@ void AutoSave::OnTimer(wxTimerEvent& event) m_mgr->GetAllEditors(editors); // Save every modified editor - for(auto editor : editors) { + for (auto editor : editors) { // Save modified files. However, don't attempt to try and save an "Untitled" document :/ bool local_file_and_exists = !editor->IsRemoteFile() && editor->GetFileName().FileExists(); bool is_remote = editor->IsRemoteFile(); - if(editor->IsEditorModified() && (local_file_and_exists || is_remote)) { + if (editor->IsEditorModified() && (local_file_and_exists || is_remote)) { editor->Save(); } } @@ -95,7 +92,7 @@ void AutoSave::OnTimer(wxTimerEvent& event) void AutoSave::DeleteTimer() { - if(m_timer) { + if (m_timer) { Unbind(wxEVT_TIMER, &AutoSave::OnTimer, this); m_timer->Stop(); } diff --git a/AutoSave/autosave.h b/AutoSave/autosave.h index 09aa6d52ff..0511a288bb 100644 --- a/AutoSave/autosave.h +++ b/AutoSave/autosave.h @@ -27,6 +27,7 @@ #define __AutoSave__ #include "plugin.h" + #include class AutoSave : public IPlugin @@ -39,7 +40,7 @@ class AutoSave : public IPlugin void UpdateTimers(); void DeleteTimer(); - + public: AutoSave(IManager* manager); ~AutoSave() override = default; diff --git a/CMakePlugin/CMake.cpp b/CMakePlugin/CMake.cpp index 50e91e537c..d3c8e8f829 100644 --- a/CMakePlugin/CMake.cpp +++ b/CMakePlugin/CMake.cpp @@ -118,10 +118,10 @@ CMake::CMake(const wxFileName& path) wxArrayString CMake::GetVersions() { - static const wxString VERSIONS[] = { "2.8.11", "2.8.10", "2.8.9", "2.8.8", "2.8.7", "2.8.6", "2.8.5", - "2.8.4", "2.8.3", "2.8.2", "2.8.1", "2.8.0", "2.6.4", "2.6.3", - "2.6.2", "2.6.1", "2.6.0", "2.4.8", "2.4.7", "2.4.6", "2.4.5", - "2.4.4", "2.4.3", "2.2.3", "2.0.6", "1.8.3" }; + static const wxString VERSIONS[] = {"2.8.11", "2.8.10", "2.8.9", "2.8.8", "2.8.7", "2.8.6", "2.8.5", + "2.8.4", "2.8.3", "2.8.2", "2.8.1", "2.8.0", "2.6.4", "2.6.3", + "2.6.2", "2.6.1", "2.6.0", "2.4.8", "2.4.7", "2.4.6", "2.4.5", + "2.4.4", "2.4.3", "2.2.3", "2.0.6", "1.8.3"}; return wxArrayString(sizeof(VERSIONS) / sizeof(VERSIONS[0]), VERSIONS); } diff --git a/CMakePlugin/CMake.h b/CMakePlugin/CMake.h index 818a47e81e..1c321c2afb 100644 --- a/CMakePlugin/CMake.h +++ b/CMakePlugin/CMake.h @@ -54,11 +54,11 @@ #include // wxWidgets -#include -#include #include -#include +#include #include +#include +#include #include /* ************************************************************************ */ diff --git a/CMakePlugin/CMakeBuilder.cpp b/CMakePlugin/CMakeBuilder.cpp index 9b3a202809..47a400b2ce 100644 --- a/CMakePlugin/CMakeBuilder.cpp +++ b/CMakePlugin/CMakeBuilder.cpp @@ -9,8 +9,12 @@ CMakeBuilder::CMakeBuilder() { } -bool CMakeBuilder::Export(const wxString& project, const wxString& confToBuild, const wxString& arguments, - bool isProjectOnly, bool force, wxString& errMsg) +bool CMakeBuilder::Export(const wxString& project, + const wxString& confToBuild, + const wxString& arguments, + bool isProjectOnly, + bool force, + wxString& errMsg) { wxUnusedVar(project); wxUnusedVar(confToBuild); @@ -38,8 +42,8 @@ wxString CMakeBuilder::GetBuildCommand(const wxString& project, const wxString& return command; } -wxString CMakeBuilder::GetPOCleanCommand(const wxString& project, const wxString& confToBuild, - const wxString& arguments) +wxString +CMakeBuilder::GetPOCleanCommand(const wxString& project, const wxString& confToBuild, const wxString& arguments) { wxString command; command << "cd " << GetProjectBuildFolder(project, true) << " && " << GetBuildToolCommand(project, confToBuild) @@ -47,16 +51,16 @@ wxString CMakeBuilder::GetPOCleanCommand(const wxString& project, const wxString return command; } -wxString CMakeBuilder::GetPOBuildCommand(const wxString& project, const wxString& confToBuild, - const wxString& arguments) +wxString +CMakeBuilder::GetPOBuildCommand(const wxString& project, const wxString& confToBuild, const wxString& arguments) { wxString command; command << "cd " << GetProjectBuildFolder(project, true) << " && " << GetBuildToolCommand(project, confToBuild); return command; } -wxString CMakeBuilder::GetPORebuildCommand(const wxString& project, const wxString& confToBuild, - const wxString& arguments) +wxString +CMakeBuilder::GetPORebuildCommand(const wxString& project, const wxString& confToBuild, const wxString& arguments) { wxString command; command << "cd " << GetProjectBuildFolder(project, true) << " && " << GetBuildToolCommand(project, confToBuild) @@ -64,14 +68,19 @@ wxString CMakeBuilder::GetPORebuildCommand(const wxString& project, const wxStri return command; } -wxString CMakeBuilder::GetSingleFileCmd(const wxString& project, const wxString& confToBuild, const wxString& arguments, +wxString CMakeBuilder::GetSingleFileCmd(const wxString& project, + const wxString& confToBuild, + const wxString& arguments, const wxString& fileName) { return wxEmptyString; } -wxString CMakeBuilder::GetPreprocessFileCmd(const wxString& project, const wxString& confToBuild, - const wxString& arguments, const wxString& fileName, wxString& errMsg) +wxString CMakeBuilder::GetPreprocessFileCmd(const wxString& project, + const wxString& confToBuild, + const wxString& arguments, + const wxString& fileName, + wxString& errMsg) { return wxEmptyString; } @@ -83,7 +92,9 @@ wxString CMakeBuilder::GetWorkspaceBuildFolder(bool wrapWithQuotes) fn.AppendDir(CMAKE_BUILD_FOLDER_PREFIX + workspaceConfig); wxString folder = fn.GetPath(); - if(wrapWithQuotes) { StringUtils::WrapWithQuotes(folder); } + if (wrapWithQuotes) { + StringUtils::WrapWithQuotes(folder); + } return folder; } @@ -107,14 +118,16 @@ wxString CMakeBuilder::GetProjectBuildFolder(const wxString& project, bool wrapW wxString CMakeBuilder::GetBuildToolCommand(const wxString& project, const wxString& confToBuild) const { BuildConfigPtr bldConf = clCxxWorkspaceST::Get()->GetProjBuildConf(project, confToBuild); - if(!bldConf) return wxEmptyString; + if (!bldConf) + return wxEmptyString; // The 'make' command is part of the compiler settings CompilerPtr compiler = bldConf->GetCompiler(); - if(!compiler) return wxEmptyString; + if (!compiler) + return wxEmptyString; wxString buildTool = compiler->GetTool("MAKE"); - if(buildTool.Lower().Contains("make")) { + if (buildTool.Lower().Contains("make")) { return buildTool + " -e "; } else { diff --git a/CMakePlugin/CMakeBuilder.h b/CMakePlugin/CMakeBuilder.h index c17f0ebb0a..35d884a717 100644 --- a/CMakePlugin/CMakeBuilder.h +++ b/CMakePlugin/CMakeBuilder.h @@ -23,8 +23,12 @@ class CMakeBuilder : public Builder * \param errMsg output * \return true on success, false otherwise. */ - virtual bool Export(const wxString& project, const wxString& confToBuild, const wxString& arguments, - bool isProjectOnly, bool force, wxString& errMsg); + virtual bool Export(const wxString& project, + const wxString& confToBuild, + const wxString& arguments, + bool isProjectOnly, + bool force, + wxString& errMsg); /** * Return the command that should be executed for performing the clean @@ -60,8 +64,10 @@ class CMakeBuilder : public Builder * \param errMsg [output] * \return the command */ - virtual wxString GetSingleFileCmd( - const wxString& project, const wxString& confToBuild, const wxString& arguments, const wxString& fileName); + virtual wxString GetSingleFileCmd(const wxString& project, + const wxString& confToBuild, + const wxString& arguments, + const wxString& fileName); /** * \brief create a command to execute for preprocessing single source file @@ -70,8 +76,11 @@ class CMakeBuilder : public Builder * \param errMsg [output] * \return the command */ - virtual wxString GetPreprocessFileCmd(const wxString& project, const wxString& confToBuild, - const wxString& arguments, const wxString& fileName, wxString& errMsg); + virtual wxString GetPreprocessFileCmd(const wxString& project, + const wxString& confToBuild, + const wxString& arguments, + const wxString& fileName, + wxString& errMsg); /** * @brief return the 'rebuild' command @@ -79,8 +88,8 @@ class CMakeBuilder : public Builder * @param confToBuild * @return */ - virtual wxString GetPORebuildCommand( - const wxString& project, const wxString& confToBuild, const wxString& arguments); + virtual wxString + GetPORebuildCommand(const wxString& project, const wxString& confToBuild, const wxString& arguments); }; #endif // CMAKEBUILDER_H diff --git a/CMakePlugin/CMakeConfiguration.h b/CMakePlugin/CMakeConfiguration.h index cb54777616..b8c055f423 100644 --- a/CMakePlugin/CMakeConfiguration.h +++ b/CMakePlugin/CMakeConfiguration.h @@ -51,8 +51,8 @@ /* ************************************************************************ */ // wxWidgets -#include #include +#include /* ************************************************************************ */ /* CLASSES */ diff --git a/CMakePlugin/CMakeGenerator.cpp b/CMakePlugin/CMakeGenerator.cpp index 84cb6af82f..501935d0b3 100644 --- a/CMakePlugin/CMakeGenerator.cpp +++ b/CMakePlugin/CMakeGenerator.cpp @@ -95,16 +95,19 @@ CMakeGenerator::CMakeGenerator() bool CMakeGenerator::CheckExists(const wxFileName& filename) { // Output file exists, overwrite? - if(filename.Exists()) { + if (filename.Exists()) { // Check to see if this file was generated by CodeLite wxString content; FileUtils::ReadFileContent(filename, content); - if(!content.StartsWith(CODELITE_CMAKE_PREFIX)) { + if (!content.StartsWith(CODELITE_CMAKE_PREFIX)) { wxString msg; msg << _("A custom ") << CMakePlugin::CMAKELISTS_FILE << _(" exists.\nWould you like to overwrite it?\n") << "( " << filename.GetFullPath() << " )"; wxStandardID answer = - ::PromptForYesNoDialogWithCheckbox(msg, "CMakePluginOverwriteDlg", _("Overwrite"), _("Don't Overwrite"), + ::PromptForYesNoDialogWithCheckbox(msg, + "CMakePluginOverwriteDlg", + _("Overwrite"), + _("Don't Overwrite"), _("Remember my answer and don't annoy me again"), wxYES_NO | wxCANCEL | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT); return (answer == wxID_YES); @@ -135,11 +138,11 @@ bool CMakeGenerator::Generate(ProjectPtr p) // Generate CMakeLists.txt file for each dependency project wxArrayString projectsArr = p->GetDependencies(buildConf->GetName()); - for(size_t i = 0; i < projectsArr.GetCount(); ++i) { + for (size_t i = 0; i < projectsArr.GetCount(); ++i) { ProjectPtr pProj = workspace->GetProject(projectsArr.Item(i)); CMakeGenerator generator; wxString cmakeFileContent = generator.GenerateProject(pProj, false); - if(!cmakeFileContent.IsEmpty()) { + if (!cmakeFileContent.IsEmpty()) { // Write the content to the file system wxFileName cmakelists(pProj->GetFileName()); cmakelists.SetFullName(CMakePlugin::CMAKELISTS_FILE); @@ -158,7 +161,7 @@ bool CMakeGenerator::Generate(ProjectPtr p) const wxFileName filename(p->GetFileName().GetPath(), CMakePlugin::CMAKELISTS_FILE); // Check for file existence and read any user code from the current CMakeLists.txt file - if(!CheckExists(filename)) + if (!CheckExists(filename)) return false; // File content @@ -187,7 +190,7 @@ bool CMakeGenerator::Generate(ProjectPtr p) fn.MakeRelativeTo(p->GetFileName().GetPath()); wxString workspacePath = fn.GetPath(false, wxPATH_UNIX); - if(workspacePath.IsEmpty()) { + if (workspacePath.IsEmpty()) { workspacePath = "."; } mainProjectContent << "set(CL_WORKSPACE_DIRECTORY " << workspacePath << ")\n"; @@ -210,12 +213,12 @@ bool CMakeGenerator::Generate(ProjectPtr p) wxString variables = workspace->GetEnvironmentVariables(); variables.Trim().Trim(false); - if(!variables.IsEmpty()) { + if (!variables.IsEmpty()) { // Split into a list of pairs for (const auto& line : wxStringTokenize(variables, "\n;")) { // Split into name, value pair const wxArrayString pair = wxSplit(line, '='); - if(pair.IsEmpty()) { + if (pair.IsEmpty()) { continue; } const wxString& name = pair[0]; @@ -266,7 +269,7 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co // Get the project build configuration and compiler BuildConfigPtr buildConf = project->GetBuildConfiguration(configName); - if(!buildConf) + if (!buildConf) return ""; wxArrayString cppSources, cSources, resourceFiles, asmSources; @@ -276,20 +279,20 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co asmSources.reserve(allFiles.size()); for (const auto& [_, file] : allFiles) { - if(!file->IsExcludeFromConfiguration(buildConf->GetName())) { + if (!file->IsExcludeFromConfiguration(buildConf->GetName())) { wxFileName fn(file->GetFilename()); // Append each file with the "${CMAKE_CURRENT_LIST_DIR}/" prefix wxString file_name; file_name << "${CMAKE_CURRENT_LIST_DIR}/" << file->GetFilenameRelpath(); file_name.Replace("\\", "/"); wxString fullname = fn.GetFullName(); - if(FileExtManager::GetType(fullname) == FileExtManager::TypeSourceC) { + if (FileExtManager::GetType(fullname) == FileExtManager::TypeSourceC) { cSources.Add(file_name); - } else if(FileExtManager::GetType(fullname) == FileExtManager::TypeSourceCpp) { + } else if (FileExtManager::GetType(fullname) == FileExtManager::TypeSourceCpp) { cppSources.Add(file_name); - } else if(FileExtManager::GetType(fullname) == FileExtManager::TypeResource) { + } else if (FileExtManager::GetType(fullname) == FileExtManager::TypeResource) { resourceFiles.Add(file_name); - } else if(FileExtManager::GetType(fullname) == FileExtManager::TypeAsm) { + } else if (FileExtManager::GetType(fullname) == FileExtManager::TypeAsm) { asmSources.Add(file_name); } } @@ -299,13 +302,13 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co wxString projectDir = project->GetFileName().GetPath(); // Sanity - if(!buildConf || buildConf->IsCustomBuild()) { + if (!buildConf || buildConf->IsCustomBuild()) { // no build config or custom build? return ""; } CompilerPtr compiler = buildConf->GetCompiler(); - if(!compiler) { + if (!compiler) { return ""; } @@ -314,23 +317,23 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co // Output file name wxFileName filename(projectDir, CMakePlugin::CMAKELISTS_FILE); - if(!CheckExists(filename)) + if (!CheckExists(filename)) return ""; // File content wxString content; - if(!topProject) { + if (!topProject) { content << Prefix(project); } - if(topProject) { + if (topProject) { // Add the dependencies wxArrayString projectsArr = project->GetDependencies(buildConf->GetName()); - if(!projectsArr.IsEmpty()) { + if (!projectsArr.IsEmpty()) { content << "## Add the dependencies\n"; } - for(size_t i = 0; i < projectsArr.GetCount(); ++i) { + for (size_t i = 0; i < projectsArr.GetCount(); ++i) { ProjectPtr pProj = clCxxWorkspaceST::Get()->GetProject(projectsArr.Item(i)); wxFileName fnProject = pProj->GetFileName(); fnProject.MakeRelativeTo(project->GetFileName().GetPath()); @@ -354,7 +357,7 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co { wxArrayString includes = ::wxStringTokenize(buildConf->GetIncludePath(), ";", wxTOKEN_STRTOK); content << "include_directories(\n"; - for(size_t i = 0; i < includes.GetCount(); ++i) { + for (size_t i = 0; i < includes.GetCount(); ++i) { wxString& includePath = includes.Item(i); includePath.Replace("\\", "/"); @@ -363,7 +366,7 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co includePath.Replace("$(WorkspacePath)", "${WORKSPACE_PATH}"); includePath.Replace("$(WorkspaceConfiguration)", "${CONFIGURATION_NAME}"); includePath.Replace("$(ProjectPath)", projectPathVariableValue); - if(includePath.IsEmpty()) { + if (includePath.IsEmpty()) { continue; } content << " " << includes.Item(i) << "\n"; @@ -397,12 +400,12 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co // Add preprocessor definitions { wxArrayString defines = project->GetPreProcessors(); - if(!defines.IsEmpty()) { + if (!defines.IsEmpty()) { content << "add_definitions(\n"; - for(size_t i = 0; i < defines.GetCount(); ++i) { + for (size_t i = 0; i < defines.GetCount(); ++i) { wxString& pp = defines.Item(i); pp.Trim().Trim(false); - if(pp.IsEmpty()) { + if (pp.IsEmpty()) { continue; } content << " -D" << pp << "\n"; @@ -456,7 +459,7 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co { wxString lib_paths = buildConf->GetLibPath(); // Get switch from compiler - if(compiler) { + if (compiler) { // Append global library paths lib_paths << ";" << compiler->GetGlobalLibPath(); } @@ -471,7 +474,7 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co lib_paths.Clear(); // Append modified values - for(size_t i = 0; i < lib_paths_list.GetCount(); ++i) { + for (size_t i = 0; i < lib_paths_list.GetCount(); ++i) { wxString libPath = lib_paths_list.Item(i); // Replace standard macros with CMake variables libPath.Replace("$(WorkspacePath)", "${WORKSPACE_PATH}"); @@ -487,39 +490,39 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co // Write sources { - if(!cSources.IsEmpty()) { + if (!cSources.IsEmpty()) { content << "# Define the C sources\n"; content << "set ( C_SRCS\n"; - for(size_t i = 0; i < cSources.GetCount(); ++i) { + for (size_t i = 0; i < cSources.GetCount(); ++i) { content << " " << cSources.Item(i) << "\n"; } content << ")\n\n"; } - if(!cppSources.IsEmpty()) { + if (!cppSources.IsEmpty()) { content << "# Define the CXX sources\n"; content << "set ( CXX_SRCS\n"; - for(size_t i = 0; i < cppSources.GetCount(); ++i) { + for (size_t i = 0; i < cppSources.GetCount(); ++i) { content << " " << cppSources.Item(i) << "\n"; } content << ")\n\n"; } - if(!resourceFiles.IsEmpty()) { + if (!resourceFiles.IsEmpty()) { content << "if(WIN32)\n"; content << " # Define the resource files\n"; content << " set ( RC_SRCS\n"; - for(size_t i = 0; i < resourceFiles.GetCount(); ++i) { + for (size_t i = 0; i < resourceFiles.GetCount(); ++i) { content << " " << resourceFiles.Item(i) << "\n"; } content << " )\n"; content << "endif(WIN32)\n\n"; } - if(!asmSources.IsEmpty()) { + if (!asmSources.IsEmpty()) { content << "# Define the ASM sources\n"; content << "set ( ASM_SRCS\n"; - for(size_t i = 0; i < asmSources.GetCount(); ++i) { + for (size_t i = 0; i < asmSources.GetCount(); ++i) { content << " " << asmSources.Item(i) << "\n"; } content << ")\n\n"; @@ -529,9 +532,9 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co // Add CXX compiler options { wxArrayString buildOptsArr = project->GetCXXCompilerOptions(); - if(!buildOptsArr.IsEmpty() && !cppSources.IsEmpty()) { + if (!buildOptsArr.IsEmpty() && !cppSources.IsEmpty()) { content << "set_source_files_properties(\n ${CXX_SRCS} PROPERTIES COMPILE_FLAGS \n \""; - for(size_t i = 0; i < buildOptsArr.GetCount(); ++i) { + for (size_t i = 0; i < buildOptsArr.GetCount(); ++i) { content << " " << buildOptsArr.Item(i); } content << "\")\n\n"; @@ -541,9 +544,9 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co // Add C compiler options { wxArrayString buildOptsArr = project->GetCCompilerOptions(); - if(!buildOptsArr.IsEmpty() && !cSources.IsEmpty()) { + if (!buildOptsArr.IsEmpty() && !cSources.IsEmpty()) { content << "set_source_files_properties(\n ${C_SRCS} PROPERTIES COMPILE_FLAGS \n \""; - for(size_t i = 0; i < buildOptsArr.GetCount(); ++i) { + for (size_t i = 0; i < buildOptsArr.GetCount(); ++i) { content << " " << buildOptsArr.Item(i); } content << "\")\n\n"; @@ -564,11 +567,11 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co // Get project type { wxString type = buildConf->GetProjectType(); - if(type == PROJECT_TYPE_EXECUTABLE) { + if (type == PROJECT_TYPE_EXECUTABLE) { content << "add_executable(" << project->GetName() << " ${RC_SRCS} ${CXX_SRCS} ${C_SRCS} ${ASM_SRCS})\n"; content << "target_link_libraries(" << project->GetName() << " ${LINK_OPTIONS})\n\n"; - } else if(type == PROJECT_TYPE_DYNAMIC_LIBRARY) { + } else if (type == PROJECT_TYPE_DYNAMIC_LIBRARY) { content << "add_library(" << project->GetName() << " SHARED ${RC_SRCS} ${CXX_SRCS} ${C_SRCS} ${ASM_SRCS})\n"; content << "target_link_libraries(" << project->GetName() << " ${LINK_OPTIONS})\n\n"; @@ -584,19 +587,19 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co libs.Trim().Trim(false); - if(!libs.IsEmpty()) { + if (!libs.IsEmpty()) { libs.Replace(";", "\n "); content << "target_link_libraries(" << project->GetName() << "\n " << libs << "\n)\n\n"; } } // set the dependencies for the top level project - if(topProject) { + if (topProject) { wxArrayString projects = project->GetDependencies(buildConf->GetName()); - if(!projects.IsEmpty()) { + if (!projects.IsEmpty()) { content << "\n"; content << "# Adding dependencies\n"; - for(size_t i = 0; i < projects.GetCount(); ++i) { + for (size_t i = 0; i < projects.GetCount(); ++i) { content << "add_dependencies(" << project->GetName() << " " << projects.Item(i) << ")\n"; } } @@ -613,15 +616,17 @@ wxString CMakeGenerator::GenerateProject(ProjectPtr project, bool topProject, co return content; } -void CMakeGenerator::AddBuildCommands(const wxString& buildType, const BuildCommandList& commands, ProjectPtr project, +void CMakeGenerator::AddBuildCommands(const wxString& buildType, + const BuildCommandList& commands, + ProjectPtr project, wxString& content) { - if(!commands.empty()) { + if (!commands.empty()) { wxString projectPathVariableValue; projectPathVariableValue << "${PROJECT_" << project->GetName() << "_PATH}"; content << "\n# Adding " << buildType << " commands\n"; for (const BuildCommand& buildCommand : commands) { - if(buildCommand.GetEnabled()) { + if (buildCommand.GetEnabled()) { wxString cmd = buildCommand.GetCommand(); cmd.Replace("$(WorkspacePath)", "${WORKSPACE_PATH}"); cmd.Replace("$(ProjectPath)", projectPathVariableValue); @@ -657,8 +662,8 @@ bool CMakeGenerator::CanGenerate(ProjectPtr project) // Read each of the CMakeLists.txt file in the array, and check if we can find our top level comment for (const wxFileName& fn : cmakelistsArr) { wxString content; - if(fn.Exists() && FileUtils::ReadFileContent(fn, content)) { - if(!content.StartsWith(CODELITE_CMAKE_PREFIX)) { + if (fn.Exists() && FileUtils::ReadFileContent(fn, content)) { + if (!content.StartsWith(CODELITE_CMAKE_PREFIX)) { return false; } } @@ -666,8 +671,8 @@ bool CMakeGenerator::CanGenerate(ProjectPtr project) return true; } -void CMakeGenerator::ExpandOptions(const wxString& options, wxString& content, wxArrayString& arrVars, - wxArrayString& arrOut, const wxString& indent) +void CMakeGenerator::ExpandOptions( + const wxString& options, wxString& content, wxArrayString& arrVars, wxArrayString& arrOut, const wxString& indent) { arrVars.clear(); arrOut.clear(); @@ -677,10 +682,10 @@ void CMakeGenerator::ExpandOptions(const wxString& options, wxString& content, w cmpOption.Trim().Trim(false); wxString tmp; // Expand backticks / $(shell ...) syntax supported by CodeLite - if(cmpOption.StartsWith(wxT("$(shell "), &tmp) || cmpOption.StartsWith(wxT("`"), &tmp)) { + if (cmpOption.StartsWith(wxT("$(shell "), &tmp) || cmpOption.StartsWith(wxT("`"), &tmp)) { cmpOption.swap(tmp); tmp.Clear(); - if(cmpOption.EndsWith(wxT(")"), &tmp) || cmpOption.EndsWith(wxT("`"), &tmp)) { + if (cmpOption.EndsWith(wxT(")"), &tmp) || cmpOption.EndsWith(wxT("`"), &tmp)) { cmpOption.swap(tmp); } @@ -710,7 +715,7 @@ wxString CMakeGenerator::Prefix(ProjectPtr project) content << CODELITE_CMAKE_PREFIX << "\n\n"; content << "cmake_minimum_required(VERSION 3.5)\n"; - + AddUserCodeSection(content, CMAKELISTS_USER_CODE_01_PREFIX, m_userBlock01); content << "enable_language(CXX C ASM)\n\n"; @@ -722,10 +727,10 @@ wxString CMakeGenerator::Prefix(ProjectPtr project) bool CMakeGenerator::IsCustomCMakeLists(const wxFileName& fn) { - if(fn.FileExists()) { + if (fn.FileExists()) { wxFileName fn; wxString content; - if(FileUtils::ReadFileContent(fn, content)) { + if (FileUtils::ReadFileContent(fn, content)) { return !content.StartsWith(CODELITE_CMAKE_PREFIX); } } @@ -741,18 +746,18 @@ void CMakeGenerator::ReadUserCode(const wxString& content) m_userBlock3.clear(); wxArrayString lines = ::wxStringTokenize(content, "\n", wxTOKEN_RET_DELIMS); - while(!lines.IsEmpty()) { + while (!lines.IsEmpty()) { const wxString& curline = lines.Item(0); lines.RemoveAt(0); - if(curline.StartsWith(CMAKELISTS_USER_CODE_1_PREFIX)) { + if (curline.StartsWith(CMAKELISTS_USER_CODE_1_PREFIX)) { ReadUntilEndOfUserBlock(lines, m_userBlock1); - } else if(curline.StartsWith(CMAKELISTS_USER_CODE_2_PREFIX)) { + } else if (curline.StartsWith(CMAKELISTS_USER_CODE_2_PREFIX)) { ReadUntilEndOfUserBlock(lines, m_userBlock2); - } else if(curline.StartsWith(CMAKELISTS_USER_CODE_3_PREFIX)) { + } else if (curline.StartsWith(CMAKELISTS_USER_CODE_3_PREFIX)) { ReadUntilEndOfUserBlock(lines, m_userBlock3); - } else if(curline.StartsWith(CMAKELISTS_USER_CODE_01_PREFIX)) { + } else if (curline.StartsWith(CMAKELISTS_USER_CODE_01_PREFIX)) { ReadUntilEndOfUserBlock(lines, m_userBlock01); - } else if(curline.StartsWith(CMAKELISTS_USER_CODE_02_PREFIX)) { + } else if (curline.StartsWith(CMAKELISTS_USER_CODE_02_PREFIX)) { ReadUntilEndOfUserBlock(lines, m_userBlock02); } } @@ -761,17 +766,17 @@ void CMakeGenerator::ReadUserCode(const wxString& content) void CMakeGenerator::ReadUntilEndOfUserBlock(wxArrayString& lines, wxString& content) { bool removeLf = false; - while(!lines.IsEmpty()) { + while (!lines.IsEmpty()) { const wxString& curline = lines.Item(0); lines.RemoveAt(0); - if(curline.StartsWith(CMAKELISTS_USER_CODE_END)) { + if (curline.StartsWith(CMAKELISTS_USER_CODE_END)) { return; } else { content << curline; // removeLf = true; } } - if(removeLf) { + if (removeLf) { content.RemoveLast(); } } @@ -781,7 +786,7 @@ void CMakeGenerator::AddUserCodeSection(wxString& content, const wxString& secti content << "\n"; content << "\n"; content << sectionPrefix << "\n"; - if(sectionCode.IsEmpty()) { + if (sectionCode.IsEmpty()) { content << "# Place your code here" << "\n"; } else { diff --git a/CMakePlugin/CMakeGenerator.h b/CMakePlugin/CMakeGenerator.h index 59f99ae817..fc058b6639 100644 --- a/CMakePlugin/CMakeGenerator.h +++ b/CMakePlugin/CMakeGenerator.h @@ -51,10 +51,10 @@ /* ************************************************************************ */ // CodeLite -#include "workspace.h" -#include "project.h" #include "build_config.h" #include "compiler.h" +#include "project.h" +#include "workspace.h" /* ************************************************************************ */ /* CLASSES */ @@ -73,8 +73,11 @@ class CMakeGenerator wxString m_userBlock3; protected: - void ExpandOptions(const wxString& options, wxString& content, wxArrayString& arrVars, wxArrayString& arrOut, - const wxString& indent = wxEmptyString); + void ExpandOptions(const wxString& options, + wxString& content, + wxArrayString& arrVars, + wxArrayString& arrOut, + const wxString& indent = wxEmptyString); wxString Prefix(ProjectPtr project); @@ -107,7 +110,7 @@ class CMakeGenerator void ReadUntilEndOfUserBlock(wxArrayString& lines, wxString& content); void AddUserCodeSection(wxString& content, const wxString& sectionPrefix, const wxString& sectionCode = ""); - + /** * @brief add pre|post build commands to the generated CMakeLists.txt file * @param buildType can be POST_BUILD, PRE_BUILD or PRE_LINK string diff --git a/CMakePlugin/CMakeHelpTab.cpp b/CMakePlugin/CMakeHelpTab.cpp index e0d3029cf2..36dc5d9d43 100644 --- a/CMakePlugin/CMakeHelpTab.cpp +++ b/CMakePlugin/CMakeHelpTab.cpp @@ -111,7 +111,7 @@ void CMakeHelpTab::OnInsert(wxCommandEvent& event) IEditor* editor = manager->GetActiveEditor(); // No active editor - if(!editor) + if (!editor) return; // Insert value @@ -150,7 +150,7 @@ void CMakeHelpTab::OnSelect(wxCommandEvent& event) std::map::const_iterator it = m_data->find(name); // Data found - if(it != m_data->end()) { + if (it != m_data->end()) { CreateHelpPage(it->second, name); } } @@ -162,7 +162,7 @@ void CMakeHelpTab::OnReload(wxCommandEvent& event) wxUnusedVar(event); wxASSERT(m_plugin->GetCMake()); - if(!m_plugin->GetCMake()->IsOk()) { + if (!m_plugin->GetCMake()->IsOk()) { wxMessageBox(_("CMake application path is invalid!"), wxMessageBoxCaptionStr, wxOK | wxCENTER | wxICON_ERROR); return; } @@ -177,7 +177,7 @@ void CMakeHelpTab::ListAll() // Remove old data m_listBoxList->Clear(); - if(!m_data) + if (!m_data) return; // Foreach data and store names into list @@ -195,7 +195,7 @@ void CMakeHelpTab::ListFiltered(const wxString& search) // Remove old data m_listBoxList->Clear(); - if(!m_data) + if (!m_data) return; // Foreach data and store names into list @@ -213,7 +213,7 @@ void CMakeHelpTab::ListFiltered(const wxString& search) void CMakeHelpTab::OnThreadStart(wxThreadEvent& event) { // Show gauge - if(!m_gaugeLoad->IsShown()) { + if (!m_gaugeLoad->IsShown()) { m_gaugeLoad->Show(); Layout(); } @@ -245,7 +245,7 @@ void CMakeHelpTab::OnThreadDone(wxThreadEvent& event) void CMakeHelpTab::OnClose(wxCloseEvent& event) { // Wait for thread - if(GetThread() && GetThread()->IsRunning()) + if (GetThread() && GetThread()->IsRunning()) GetThread()->Wait(); Destroy(); @@ -268,7 +268,7 @@ void CMakeHelpTab::ShowTopic(int topic) const CMake* cmake = m_plugin->GetCMake(); wxASSERT(cmake); - switch(topic) { + switch (topic) { default: m_data = NULL; break; @@ -302,7 +302,7 @@ void CMakeHelpTab::ShowTopic(int topic) void CMakeHelpTab::PublishData() { // The background thread must not working now - if(GetThread() && GetThread()->IsRunning()) + if (GetThread() && GetThread()->IsRunning()) return; // Set CMake version @@ -330,20 +330,20 @@ wxThread::ExitCode CMakeHelpTab::Entry() void CMakeHelpTab::LoadData(bool force) { // Thread is busy - if(GetThread() && GetThread()->IsRunning()) { + if (GetThread() && GetThread()->IsRunning()) { return; } // Invalid cmake executable wxASSERT(m_plugin->GetCMake()); - if(!m_plugin->GetCMake()->IsOk()) { + if (!m_plugin->GetCMake()->IsOk()) { return; } m_force = force; // Create a new joinable thread - if(CreateThread(wxTHREAD_JOINABLE) != wxTHREAD_NO_ERROR) { + if (CreateThread(wxTHREAD_JOINABLE) != wxTHREAD_NO_ERROR) { clERROR() << "Could not create the worker thread!" << endl; return; } @@ -352,7 +352,7 @@ void CMakeHelpTab::LoadData(bool force) wxASSERT(GetThread()); // Run the thread - if(GetThread()->Run() != wxTHREAD_NO_ERROR) { + if (GetThread()->Run() != wxTHREAD_NO_ERROR) { clERROR() << "Could not run the worker thread!" << endl; return; } @@ -383,7 +383,7 @@ void CMakeHelpTab::Update(int value) void CMakeHelpTab::Inc(int value) { // There is nothing to add - if(!value) + if (!value) return; Update(m_progress + value); @@ -395,10 +395,10 @@ void CMakeHelpTab::Done() { AddPendingEvent(wxThreadEvent(EVT_THREAD_DONE)); } void CMakeHelpTab::Stop() { - if(GetThread() && GetThread()->IsAlive()) { + if (GetThread() && GetThread()->IsAlive()) { GetThread()->Delete(NULL, wxTHREAD_WAIT_BLOCK); - } else if(GetThread()) { + } else if (GetThread()) { GetThread()->Wait(wxTHREAD_WAIT_BLOCK); } } @@ -423,12 +423,12 @@ void CMakeHelpTab::CreateHelpPage(const wxString& content, const wxString& subje // use markdown fnCMakeHelpFile.SetFullName("CMakeHelp.md"); - if(!FileUtils::WriteFileContent(fnCMakeHelpFile, text)) + if (!FileUtils::WriteFileContent(fnCMakeHelpFile, text)) return; - if(manager->OpenFile(fnCMakeHelpFile.GetFullPath())) { + if (manager->OpenFile(fnCMakeHelpFile.GetFullPath())) { IEditor* activeEditor = manager->GetActiveEditor(); - if(activeEditor && activeEditor->GetFileName().GetFullPath() == fnCMakeHelpFile.GetFullPath()) { + if (activeEditor && activeEditor->GetFileName().GetFullPath() == fnCMakeHelpFile.GetFullPath()) { activeEditor->GetCtrl()->SetEditable(true); activeEditor->OpenFile(); activeEditor->GetCtrl()->SetFirstVisibleLine(0); diff --git a/CMakePlugin/CMakeProjectSettings.h b/CMakePlugin/CMakeProjectSettings.h index 651474b4c6..1ed14a013b 100644 --- a/CMakePlugin/CMakeProjectSettings.h +++ b/CMakePlugin/CMakeProjectSettings.h @@ -54,8 +54,8 @@ #include // wxWidgets -#include #include +#include /* ************************************************************************ */ /* CLASSES */ @@ -92,20 +92,23 @@ class CMakeProjectSettings /// Configure arguments. wxArrayString arguments; - /// Name of parent project. /// Parent project should have proper CMake configuration. wxString parentProject; - /** * @brief Constructor. */ CMakeProjectSettings() - : enabled(false), sourceDirectory("$(ProjectPath)"), buildDirectory("build") - , generator(), buildType(), arguments(), parentProject() - {} - + : enabled(false) + , sourceDirectory("$(ProjectPath)") + , buildDirectory("build") + , generator() + , buildType() + , arguments() + , parentProject() + { + } }; /* ************************************************************************ */ diff --git a/CMakePlugin/CMakeSettingsDialog.cpp b/CMakePlugin/CMakeSettingsDialog.cpp index 59cc6b5562..6687dfc909 100644 --- a/CMakePlugin/CMakeSettingsDialog.cpp +++ b/CMakePlugin/CMakeSettingsDialog.cpp @@ -78,7 +78,6 @@ CMakeSettingsDialog::CMakeSettingsDialog(wxWindow* parent, CMakePlugin* plugin) CMakeSettingsDialog::~CMakeSettingsDialog() { // Save window layout - } /* ************************************************************************ */ diff --git a/CMakePlugin/CMakeSettingsDialog.h b/CMakePlugin/CMakeSettingsDialog.h index 879719089c..f344aceb7c 100644 --- a/CMakePlugin/CMakeSettingsDialog.h +++ b/CMakePlugin/CMakeSettingsDialog.h @@ -69,10 +69,8 @@ class CMakePlugin; class CMakeSettingsDialog : public CMakeSettingsDialogBase { -// Public Ctors & Dtors + // Public Ctors & Dtors public: - - /** * @brief Create a CMake settings dialog * @@ -81,67 +79,47 @@ class CMakeSettingsDialog : public CMakeSettingsDialogBase */ explicit CMakeSettingsDialog(wxWindow* parent, CMakePlugin* plugin); - /** * @brief Destructor. */ virtual ~CMakeSettingsDialog(); - -// Public Accessors + // Public Accessors public: - - /** * @brief Returns path to cmake program. * * @return */ - wxString GetCMakePath() const { - return m_filePickerProgram->GetPath(); - } - + wxString GetCMakePath() const { return m_filePickerProgram->GetPath(); } /** * @brief Returns selected default generator. * * @return */ - wxString GetDefaultGenerator() const { - return m_choiceDefaultGenerator->GetStringSelection(); - } + wxString GetDefaultGenerator() const { return m_choiceDefaultGenerator->GetStringSelection(); } - -// Public Mutators + // Public Mutators public: - - /** * @brief Set path to CMake progam. * * @param path */ - void SetCMakePath(const wxString& path) { - m_filePickerProgram->SetPath(path); - } - + void SetCMakePath(const wxString& path) { m_filePickerProgram->SetPath(path); } /** * @brief Change default generator. * * @param generator New default generator. */ - void SetDefaultGenerator(const wxString& generator) { - m_choiceDefaultGenerator->SetStringSelection(generator); - } + void SetDefaultGenerator(const wxString& generator) { m_choiceDefaultGenerator->SetStringSelection(generator); } - -// Private Data Members + // Private Data Members private: - /// Pointer to CMakePlugin. CMakePlugin* const m_plugin; - }; /* ************************************************************************ */ diff --git a/CMakePlugin/CMakeSettingsManager.cpp b/CMakePlugin/CMakeSettingsManager.cpp index e8a5a534ff..9bae6f7eda 100644 --- a/CMakePlugin/CMakeSettingsManager.cpp +++ b/CMakePlugin/CMakeSettingsManager.cpp @@ -76,12 +76,12 @@ CMakeSettingsManager::CMakeSettingsManager(CMakePlugin* plugin) CMakeProjectSettingsMap* CMakeSettingsManager::GetProjectSettings(const wxString& project, bool create) { - if(create) { + if (create) { return &(m_projectSettings[project]); } else { std::map::iterator it = m_projectSettings.find(project); - if(it == m_projectSettings.end()) + if (it == m_projectSettings.end()) return NULL; return &(it->second); @@ -94,7 +94,7 @@ const CMakeProjectSettingsMap* CMakeSettingsManager::GetProjectSettings(const wx { std::map::const_iterator it = m_projectSettings.find(project); - if(it == m_projectSettings.end()) + if (it == m_projectSettings.end()) return NULL; return &(it->second); @@ -102,13 +102,13 @@ const CMakeProjectSettingsMap* CMakeSettingsManager::GetProjectSettings(const wx /* ************************************************************************ */ -CMakeProjectSettings* CMakeSettingsManager::GetProjectSettings(const wxString& project, const wxString& config, - bool create) +CMakeProjectSettings* +CMakeSettingsManager::GetProjectSettings(const wxString& project, const wxString& config, bool create) { // Get project settings CMakeProjectSettingsMap* settings = GetProjectSettings(project, create); - if(create) { + if (create) { // GetProjectSettings should create the new one wxASSERT(settings); @@ -116,14 +116,14 @@ CMakeProjectSettings* CMakeSettingsManager::GetProjectSettings(const wxString& p return &(*settings)[config]; } else { // Not found - if(!settings) + if (!settings) return NULL; // Find configuration CMakeProjectSettingsMap::iterator it = settings->find(config); // Not found - if(it == settings->end()) + if (it == settings->end()) return NULL; return &(it->second); @@ -139,14 +139,14 @@ const CMakeProjectSettings* CMakeSettingsManager::GetProjectSettings(const wxStr const CMakeProjectSettingsMap* settings = GetProjectSettings(project); // Not found - if(!settings) + if (!settings) return NULL; // Find configuration CMakeProjectSettingsMap::const_iterator it = settings->find(config); // Not found - if(it == settings->end()) + if (it == settings->end()) return NULL; return &(it->second); @@ -177,14 +177,14 @@ void CMakeSettingsManager::SaveProject(const wxString& name) wxString err; ProjectPtr project = workspace->FindProjectByName(name, err); - if(!project) + if (!project) return; // Find project settings std::map::const_iterator itSettings = m_projectSettings.find(name); // Ehm... - if(itSettings == m_projectSettings.end()) + if (itSettings == m_projectSettings.end()) return; // Create JSON object @@ -235,7 +235,7 @@ void CMakeSettingsManager::LoadProject(const wxString& name) wxString err; ProjectPtr project = workspace->FindProjectByName(name, err); - if(!project) + if (!project) return; // Find for project or create new one diff --git a/CMakePlugin/CMakeSettingsManager.h b/CMakePlugin/CMakeSettingsManager.h index 7cb603e57a..55992098c4 100644 --- a/CMakePlugin/CMakeSettingsManager.h +++ b/CMakePlugin/CMakeSettingsManager.h @@ -54,8 +54,8 @@ #include // wxWidgets -#include #include +#include // CMakePlugin #include "CMakeProjectSettings.h" @@ -82,10 +82,8 @@ class CMakePlugin; class CMakeSettingsManager { -// Public Ctors + // Public Ctors public: - - /** * @brief Create settings manager. * @@ -93,11 +91,8 @@ class CMakeSettingsManager */ explicit CMakeSettingsManager(CMakePlugin* plugin); - -// Public Accessors + // Public Accessors public: - - /** * @brief Returns all project configurations. * @@ -107,9 +102,7 @@ class CMakeSettingsManager * @return A pointer to project settings for specific config or * nullptr if config doesn't exists. */ - CMakeProjectSettingsMap* GetProjectSettings(const wxString& project, - bool create = false); - + CMakeProjectSettingsMap* GetProjectSettings(const wxString& project, bool create = false); /** * @brief Returns all project configurations. @@ -121,7 +114,6 @@ class CMakeSettingsManager */ const CMakeProjectSettingsMap* GetProjectSettings(const wxString& project) const; - /** * @brief Return project configuration for given config. * @@ -132,10 +124,7 @@ class CMakeSettingsManager * @return A pointer to project settings for specific config or * nullptr if config doesn't exists. */ - CMakeProjectSettings* GetProjectSettings(const wxString& project, - const wxString& config, - bool create = false); - + CMakeProjectSettings* GetProjectSettings(const wxString& project, const wxString& config, bool create = false); /** * @brief Return project configuration for given config. @@ -146,25 +135,20 @@ class CMakeSettingsManager * @return A pointer to project settings for specific config or * nullptr if config doesn't exists. */ - const CMakeProjectSettings* GetProjectSettings(const wxString& project, - const wxString& config) const; + const CMakeProjectSettings* GetProjectSettings(const wxString& project, const wxString& config) const; -// Public Operations + // Public Operations public: - - /** * @brief Save all settings. */ void Save() { SaveProjects(); } - /** * @brief Save all projects settings. */ void SaveProjects(); - /** * @brief Save project settings. * @@ -172,19 +156,16 @@ class CMakeSettingsManager */ void SaveProject(const wxString& name); - /** * @brief Load all settings. */ void Load() { LoadProjects(); } - /** * @brief Load all projects settings. */ void LoadProjects(); - /** * @brief Load project settings. * @@ -192,17 +173,13 @@ class CMakeSettingsManager */ void LoadProject(const wxString& name); - -// Private Data Members + // Private Data Members private: - - /// CMake plugin pointer. CMakePlugin* const m_plugin; /// Settings for all projects. std::map m_projectSettings; - }; /* ************************************************************************ */ diff --git a/CallGraph/callgraph.cpp b/CallGraph/callgraph.cpp index fd425ba901..e2b0630866 100644 --- a/CallGraph/callgraph.cpp +++ b/CallGraph/callgraph.cpp @@ -45,10 +45,7 @@ */ // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new CallGraph(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new CallGraph(manager); } wxString wxbuildinfo() { @@ -90,26 +87,32 @@ CallGraph::CallGraph(IManager* manager) m_longName = _("Create application call graph from profiling information provided by gprof tool."); m_shortName = wxT("CallGraph"); - m_mgr->GetTheApp()->Connect(XRCID("cg_settings"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(CallGraph::OnSettings), NULL, this); - m_mgr->GetTheApp()->Connect(XRCID("cg_about"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(CallGraph::OnAbout), NULL, this); + m_mgr->GetTheApp()->Connect( + XRCID("cg_settings"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CallGraph::OnSettings), NULL, this); + m_mgr->GetTheApp()->Connect( + XRCID("cg_about"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CallGraph::OnAbout), NULL, this); - m_mgr->GetTheApp()->Connect(XRCID("cg_show_callgraph"), wxEVT_COMMAND_TOOL_CLICKED, - wxCommandEventHandler(CallGraph::OnShowCallGraph), NULL, this); + m_mgr->GetTheApp()->Connect(XRCID("cg_show_callgraph"), + wxEVT_COMMAND_TOOL_CLICKED, + wxCommandEventHandler(CallGraph::OnShowCallGraph), + NULL, + this); } //---- DTOR ------------------------------------------------------------------- CallGraph::~CallGraph() { - m_mgr->GetTheApp()->Disconnect(XRCID("cg_settings"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(CallGraph::OnSettings), NULL, this); - m_mgr->GetTheApp()->Disconnect(XRCID("cg_about"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(CallGraph::OnAbout), NULL, this); - - m_mgr->GetTheApp()->Disconnect(XRCID("cg_show_callgraph"), wxEVT_COMMAND_TOOL_CLICKED, - wxCommandEventHandler(CallGraph::OnShowCallGraph), NULL, this); + m_mgr->GetTheApp()->Disconnect( + XRCID("cg_settings"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CallGraph::OnSettings), NULL, this); + m_mgr->GetTheApp()->Disconnect( + XRCID("cg_about"), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(CallGraph::OnAbout), NULL, this); + + m_mgr->GetTheApp()->Disconnect(XRCID("cg_show_callgraph"), + wxEVT_COMMAND_TOOL_CLICKED, + wxCommandEventHandler(CallGraph::OnShowCallGraph), + NULL, + this); } //----------------------------------------------------------------------------- @@ -122,8 +125,11 @@ void CallGraph::CreatePluginMenu(wxMenu* pluginsMenu) // You can use the below code a snippet: wxMenu* menu = new wxMenu(); wxMenuItem* item(NULL); - item = new wxMenuItem(menu, XRCID("cg_show_callgraph"), _("Show call graph"), - _("Show call graph for selected/active project"), wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("cg_show_callgraph"), + _("Show call graph"), + _("Show call graph for selected/active project"), + wxITEM_NORMAL); menu->Append(item); menu->AppendSeparator(); item = new wxMenuItem(menu, XRCID("cg_settings"), _("Settings..."), wxEmptyString, wxITEM_NORMAL); @@ -141,8 +147,11 @@ wxMenu* CallGraph::CreateProjectPopMenu() wxMenu* menu = new wxMenu(); wxMenuItem* item(NULL); - item = new wxMenuItem(menu, XRCID("cg_show_callgraph"), _("Show call graph"), - _("Show call graph for selected project"), wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("cg_show_callgraph"), + _("Show call graph"), + _("Show call graph for selected project"), + wxITEM_NORMAL); menu->Append(item); return menu; @@ -152,21 +161,21 @@ wxMenu* CallGraph::CreateProjectPopMenu() void CallGraph::HookPopupMenu(wxMenu* menu, MenuType type) { - if(type == MenuTypeEditor) { + if (type == MenuTypeEditor) { // TODO::Append items for the editor context menu - } else if(type == MenuTypeFileExplorer) { + } else if (type == MenuTypeFileExplorer) { // TODO::Append items for the file explorer context menu - } else if(type == MenuTypeFileView_Workspace) { + } else if (type == MenuTypeFileView_Workspace) { // TODO::Append items for the file view / workspace context menu - } else if(type == MenuTypeFileView_Project) { + } else if (type == MenuTypeFileView_Project) { // TODO::Append items for the file view/Project context menu - if(!menu->FindItem(XRCID("cg_show_callgraph_popup"))) { + if (!menu->FindItem(XRCID("cg_show_callgraph_popup"))) { menu->PrependSeparator(); menu->Prepend(XRCID("cg_show_callgraph_popup"), _("Call Graph"), CreateProjectPopMenu()); } - } else if(type == MenuTypeFileView_Folder) { + } else if (type == MenuTypeFileView_Folder) { // TODO::Append items for the file view/Virtual folder context menu - } else if(type == MenuTypeFileView_File) { + } else if (type == MenuTypeFileView_File) { // TODO::Append items for the file view/file context menu } } @@ -208,7 +217,7 @@ wxString CallGraph::LocateApp(const wxString& app_name) { wxArrayString out; wxExecute("which " + app_name, out); - if(out.GetCount() == 1) + if (out.GetCount() == 1) return out[0]; else return ""; @@ -224,7 +233,8 @@ wxString CallGraph::GetGprofPath() wxString gprofPath = confData.GetGprofPath(); - if(!gprofPath.IsEmpty()) return gprofPath; + if (!gprofPath.IsEmpty()) + return gprofPath; #ifdef __WXMSW__ return wxEmptyString; @@ -247,7 +257,8 @@ wxString CallGraph::GetDotPath() wxString dotPath = confData.GetDotPath(); - if(!dotPath.IsEmpty()) return dotPath; + if (!dotPath.IsEmpty()) + return dotPath; #ifdef __WXMSW__ return wxEmptyString; @@ -272,12 +283,13 @@ void CallGraph::OnShowCallGraph(wxCommandEvent& event) config_tool->ReadObject(wxT("CallGraph"), &confData); - if(!wxFileExists(GetGprofPath()) || !wxFileExists(GetDotPath())) - return MessageBox(_T("Failed to locate required tools (gprof, dot). Please check the plugin settings."), - wxICON_ERROR); + if (!wxFileExists(GetGprofPath()) || !wxFileExists(GetDotPath())) + return MessageBox( + _T("Failed to locate required tools (gprof, dot). Please check the plugin settings."), wxICON_ERROR); clCxxWorkspace* ws = m_mgr->GetWorkspace(); - if(!ws) return MessageBox(_("Unable to get opened workspace."), wxICON_ERROR); + if (!ws) + return MessageBox(_("Unable to get opened workspace."), wxICON_ERROR); wxFileName ws_cfn = ws->GetWorkspaceFileName(); @@ -288,16 +300,19 @@ void CallGraph::OnShowCallGraph(wxCommandEvent& event) wxString projPath = proj->GetProjectPath(); BuildMatrixPtr mtx = ws->GetBuildMatrix(); - if(!mtx) return MessageBox(_("Unable to get current build matrix."), wxICON_ERROR); + if (!mtx) + return MessageBox(_("Unable to get current build matrix."), wxICON_ERROR); wxString build_config_name = mtx->GetSelectedConfigurationName(); BuildConfigPtr bldConf = ws->GetProjBuildConf(projectName, build_config_name); - if(!bldConf) return MessageBox(_("Unable to get opened workspace."), wxICON_ERROR); + if (!bldConf) + return MessageBox(_("Unable to get opened workspace."), wxICON_ERROR); wxString projOutputFn = macro->Expand(bldConf->GetOutputFileName(), m_mgr, projectName, build_config_name); #ifdef __WXMSW__ - if(!projOutputFn.Lower().EndsWith(wxT(".exe"))) projOutputFn += wxT(".exe"); + if (!projOutputFn.Lower().EndsWith(wxT(".exe"))) + projOutputFn += wxT(".exe"); #endif //__WXMSW__ wxFileName cfn(projPath + wxFileName::GetPathSeparator() + projOutputFn); @@ -308,22 +323,25 @@ void CallGraph::OnShowCallGraph(wxCommandEvent& event) // check source binary exists wxString bin_fpath = cfn.GetFullPath(); - if(!cfn.Exists()) { + if (!cfn.Exists()) { bin_fpath = wxFileSelector(_("Please select the binary to analyze"), base_path, "", ""); - if(bin_fpath.IsEmpty()) return MessageBox(_("selected binary was canceled"), wxICON_ERROR); + if (bin_fpath.IsEmpty()) + return MessageBox(_("selected binary was canceled"), wxICON_ERROR); cfn.Assign(bin_fpath, wxPATH_NATIVE); } - if(!cfn.IsFileExecutable()) return MessageBox(_("bin/exe isn't executable"), wxICON_ERROR); + if (!cfn.IsFileExecutable()) + return MessageBox(_("bin/exe isn't executable"), wxICON_ERROR); // check 'gmon.out' file exists wxFileName gmon_cfn(cfn.GetPath() + wxFileName::GetPathSeparator() + GMON_FILENAME_OUT); gmon_cfn.Normalize(); wxString gmonfn = gmon_cfn.GetFullPath(); - if(!gmon_cfn.Exists()) { + if (!gmon_cfn.Exists()) { gmonfn = wxFileSelector(_("Please select the gprof file"), gmon_cfn.GetPath(), "gmon", "out"); - if(gmonfn.IsEmpty()) return MessageBox(_("selected gprof was canceled"), wxICON_ERROR); + if (gmonfn.IsEmpty()) + return MessageBox(_("selected gprof was canceled"), wxICON_ERROR); gmon_cfn.Assign(gmonfn, wxPATH_NATIVE); } @@ -339,7 +357,7 @@ void CallGraph::OnShowCallGraph(wxCommandEvent& event) // on sync returns 0 (success), -1 (failure / "couldn't be started") wxInputStream* process_is = proc->GetInputStream(); - if(!process_is || !process_is->CanRead()) + if (!process_is || !process_is->CanRead()) return MessageBox(_("wxProcess::GetInputStream() can't be opened, aborting"), wxICON_ERROR); // start parsing and writing to dot language file @@ -360,14 +378,18 @@ void CallGraph::OnShowCallGraph(wxCommandEvent& event) int suggestedThreshold = pgp.GetSuggestedNodeThreshold(); - if(suggestedThreshold <= conf.GetTresholdNode()) { + if (suggestedThreshold <= conf.GetTresholdNode()) { suggestedThreshold = conf.GetTresholdNode(); dotWriter.SetDotWriterFromDialogSettings(m_mgr); } else { - dotWriter.SetDotWriterFromDetails(conf.GetColorsNode(), conf.GetColorsEdge(), suggestedThreshold, - conf.GetTresholdEdge(), conf.GetHideParams(), conf.GetStripParams(), + dotWriter.SetDotWriterFromDetails(conf.GetColorsNode(), + conf.GetColorsEdge(), + suggestedThreshold, + conf.GetTresholdEdge(), + conf.GetHideParams(), + conf.GetStripParams(), conf.GetHideNamespaces()); wxString suggest_msg = wxString::Format(_("The CallGraph plugin has suggested node threshold %d to speed-up " @@ -384,7 +406,8 @@ void CallGraph::OnShowCallGraph(wxCommandEvent& event) cfn.AppendDir(CALLGRAPH_DIR); cfn.Normalize(); - if(!cfn.DirExists()) cfn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); + if (!cfn.DirExists()) + cfn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); cfn.SetFullName(DOT_FILENAME_TXT); wxString dot_fn = cfn.GetFullPath(); @@ -395,20 +418,21 @@ void CallGraph::OnShowCallGraph(wxCommandEvent& event) wxString output_png_fn = cfn.GetFullPath(); // delete any existing PNG - if(wxFileExists(output_png_fn)) clRemoveFile(output_png_fn); + if (wxFileExists(output_png_fn)) + clRemoveFile(output_png_fn); const wxString cmddot_ln = wxString::Format(R"("%s" -Tpng -o"%s" "%s")", GetDotPath(), output_png_fn, dot_fn); wxExecute(cmddot_ln, wxEXEC_SYNC | wxEXEC_HIDE_CONSOLE); - if(!wxFileExists(output_png_fn)) + if (!wxFileExists(output_png_fn)) return MessageBox(_("Failed to open file CallGraph.png. Please check the project settings, rebuild the project " "and try again."), wxICON_INFORMATION); // show image and create table in the editor tab page - uicallgraphpanel* panel = new uicallgraphpanel(m_mgr->GetEditorPaneNotebook(), m_mgr, output_png_fn, base_path, - suggestedThreshold, &(pgp.lines)); + uicallgraphpanel* panel = new uicallgraphpanel( + m_mgr->GetEditorPaneNotebook(), m_mgr, output_png_fn, base_path, suggestedThreshold, &(pgp.lines)); wxString tstamp = wxDateTime::Now().Format(wxT(" %Y-%m-%d %H:%M:%S")); diff --git a/CallGraph/callgraph.h b/CallGraph/callgraph.h index d1e97ac749..af9f8b30a3 100644 --- a/CallGraph/callgraph.h +++ b/CallGraph/callgraph.h @@ -38,14 +38,15 @@ #include "plugin.h" // -#include -#include -#include #include "confcallgraph.h" -#include "gprofparser.h" #include "dotwriter.h" +#include "gprofparser.h" #include "static.h" +#include +#include +#include + /** * @class CallGraph * @brief Class define structure for plugin interface. diff --git a/CallGraph/confcallgraph.cpp b/CallGraph/confcallgraph.cpp index 6bb0cfb66b..edbdd620fe 100644 --- a/CallGraph/confcallgraph.cpp +++ b/CallGraph/confcallgraph.cpp @@ -26,46 +26,46 @@ #include "confcallgraph.h" ConfCallGraph::ConfCallGraph() -: m_gprofPath(wxT("")), -m_dotPath(wxT("")), -m_colorsNode(1), -m_colorsEdge(1), -m_tresholdNode(0), -m_tresholdEdge(0), -m_boxHideParams(false), -m_boxStripParams(false), -m_boxHideNamespaces(false) + : m_gprofPath(wxT("")) + , m_dotPath(wxT("")) + , m_colorsNode(1) + , m_colorsEdge(1) + , m_tresholdNode(0) + , m_tresholdEdge(0) + , m_boxHideParams(false) + , m_boxStripParams(false) + , m_boxHideNamespaces(false) { } void ConfCallGraph::DeSerialize(Archive& arch) { - arch.Read(wxT("m_gprofPath"), m_gprofPath); - arch.Read(wxT("m_dotPath"), m_dotPath); - - arch.Read(wxT("m_colorsNode"), m_colorsNode); - arch.Read(wxT("m_colorsEdge"), m_colorsEdge); - - arch.Read(wxT("m_tresholdNode"), m_tresholdNode); - arch.Read(wxT("m_tresholdEdge"), m_tresholdEdge); - - arch.Read(wxT("m_boxHideParams"), m_boxHideParams); - arch.Read(wxT("m_boxHideNamespaces"), m_boxHideNamespaces); - arch.Read(wxT("m_boxStripParams"), m_boxStripParams); + arch.Read(wxT("m_gprofPath"), m_gprofPath); + arch.Read(wxT("m_dotPath"), m_dotPath); + + arch.Read(wxT("m_colorsNode"), m_colorsNode); + arch.Read(wxT("m_colorsEdge"), m_colorsEdge); + + arch.Read(wxT("m_tresholdNode"), m_tresholdNode); + arch.Read(wxT("m_tresholdEdge"), m_tresholdEdge); + + arch.Read(wxT("m_boxHideParams"), m_boxHideParams); + arch.Read(wxT("m_boxHideNamespaces"), m_boxHideNamespaces); + arch.Read(wxT("m_boxStripParams"), m_boxStripParams); } void ConfCallGraph::Serialize(Archive& arch) { - arch.Write(wxT("m_gprofPath"), m_gprofPath); - arch.Write(wxT("m_dotPath"), m_dotPath); - - arch.Write(wxT("m_colorsNode"), m_colorsNode); - arch.Write(wxT("m_colorsEdge"), m_colorsEdge); - - arch.Write(wxT("m_tresholdNode"), m_tresholdNode); - arch.Write(wxT("m_tresholdEdge"), m_tresholdEdge); - - arch.Write(wxT("m_boxHideParams"), m_boxHideParams); - arch.Write(wxT("m_boxHideNamespaces"), m_boxHideNamespaces); - arch.Write(wxT("m_boxStripParams"), m_boxStripParams); + arch.Write(wxT("m_gprofPath"), m_gprofPath); + arch.Write(wxT("m_dotPath"), m_dotPath); + + arch.Write(wxT("m_colorsNode"), m_colorsNode); + arch.Write(wxT("m_colorsEdge"), m_colorsEdge); + + arch.Write(wxT("m_tresholdNode"), m_tresholdNode); + arch.Write(wxT("m_tresholdEdge"), m_tresholdEdge); + + arch.Write(wxT("m_boxHideParams"), m_boxHideParams); + arch.Write(wxT("m_boxHideNamespaces"), m_boxHideNamespaces); + arch.Write(wxT("m_boxStripParams"), m_boxStripParams); } diff --git a/CallGraph/confcallgraph.h b/CallGraph/confcallgraph.h index 27fbe18f86..716f6df4c0 100644 --- a/CallGraph/confcallgraph.h +++ b/CallGraph/confcallgraph.h @@ -28,7 +28,7 @@ * Purpose: Header to store values. * Author: Vaclav Sprucek * Created: 2012-03-04 - * Copyright: Vaclav Sprucek + * Copyright: Vaclav Sprucek * License: wxWidgets license (www.wxwidgets.org) * Notes: **************************************************************/ @@ -37,115 +37,79 @@ #define __confcallgraph__ #include "serialized_object.h" -#include + +#include /** * @class ConfCallGraph * @brief Class define structure for save settings of dialog. */ class ConfCallGraph : public SerializedObject { - wxString m_gprofPath; - wxString m_dotPath; - - int m_colorsNode; - int m_colorsEdge; - - int m_tresholdNode; - int m_tresholdEdge; - - bool m_boxHideParams; - bool m_boxStripParams; - bool m_boxHideNamespaces; + wxString m_gprofPath; + wxString m_dotPath; + + int m_colorsNode; + int m_colorsEdge; + + int m_tresholdNode; + int m_tresholdEdge; + + bool m_boxHideParams; + bool m_boxStripParams; + bool m_boxHideNamespaces; public: - /** - * @brief Default constructor. - */ - ConfCallGraph(); - /** - * @brief Default destructor. - */ + /** + * @brief Default constructor. + */ + ConfCallGraph(); + /** + * @brief Default destructor. + */ virtual ~ConfCallGraph() = default; public: - virtual void DeSerialize(Archive &arch); - virtual void Serialize(Archive &arch); - // - // - // - // just wxStrings are pointers - void SetGprofPath(const wxString& gprofPath) { - this->m_gprofPath = gprofPath; - } - - void SetDotPath(const wxString& dotPath) { - this->m_dotPath = dotPath; - } - - void SetColorsNode(int colorsNode){ - this->m_colorsNode = colorsNode; - } - - void SetColorsEdge(int colorsEdge){ - this->m_colorsEdge = colorsEdge; - } - - void SetTresholdNode(int trashNode){ - this->m_tresholdNode = trashNode; - } - - void SetTresholdEdge(int trashEdge){ - this->m_tresholdEdge = trashEdge; - } - - void SetHideParams(bool hide){ - this->m_boxHideParams = hide; - } - - void SetStripParams(bool hide){ - this->m_boxStripParams = hide; - } - void SetHideNamespaces(bool hide){ - this->m_boxHideNamespaces = hide; - } - - //////////////////////////////////////////// - // just wxStrings are pointers - const wxString& GetGprofPath() const { - return m_gprofPath; - } - - const wxString& GetDotPath() const { - return m_dotPath; - } - - int GetColorsNode() { - return m_colorsNode; - } - - int GetColorsEdge() { - return m_colorsEdge; - } - - int GetTresholdNode() { - return m_tresholdNode; - } - - int GetTresholdEdge() { - return m_tresholdEdge; - } - - bool GetHideParams() { - return m_boxHideParams; - } - - bool GetStripParams() { - return m_boxStripParams; - } - - bool GetHideNamespaces() { - return m_boxHideNamespaces; - } - + virtual void DeSerialize(Archive& arch); + virtual void Serialize(Archive& arch); + // + // + // + // just wxStrings are pointers + void SetGprofPath(const wxString& gprofPath) { this->m_gprofPath = gprofPath; } + + void SetDotPath(const wxString& dotPath) { this->m_dotPath = dotPath; } + + void SetColorsNode(int colorsNode) { this->m_colorsNode = colorsNode; } + + void SetColorsEdge(int colorsEdge) { this->m_colorsEdge = colorsEdge; } + + void SetTresholdNode(int trashNode) { this->m_tresholdNode = trashNode; } + + void SetTresholdEdge(int trashEdge) { this->m_tresholdEdge = trashEdge; } + + void SetHideParams(bool hide) { this->m_boxHideParams = hide; } + + void SetStripParams(bool hide) { this->m_boxStripParams = hide; } + void SetHideNamespaces(bool hide) { this->m_boxHideNamespaces = hide; } + + //////////////////////////////////////////// + // just wxStrings are pointers + const wxString& GetGprofPath() const { return m_gprofPath; } + + const wxString& GetDotPath() const { return m_dotPath; } + + int GetColorsNode() { return m_colorsNode; } + + int GetColorsEdge() { return m_colorsEdge; } + + int GetTresholdNode() { return m_tresholdNode; } + + int GetTresholdEdge() { return m_tresholdEdge; } + + bool GetHideParams() { return m_boxHideParams; } + + bool GetStripParams() { return m_boxStripParams; } + + bool GetHideNamespaces() { return m_boxHideNamespaces; } }; #endif // __confcallgraph__ diff --git a/CallGraph/dotwriter.cpp b/CallGraph/dotwriter.cpp index f91c526fcf..6fca1e5b1a 100644 --- a/CallGraph/dotwriter.cpp +++ b/CallGraph/dotwriter.cpp @@ -73,13 +73,8 @@ void DotWriter::SetDotWriterFromDialogSettings(IManager* mgr) dwstripparams = confData.GetStripParams(); } -void DotWriter::SetDotWriterFromDetails(int colnode, - int coledge, - int thrnode, - int thredge, - bool hideparams, - bool stripparams, - bool hidenamespaces) +void DotWriter::SetDotWriterFromDetails( + int colnode, int coledge, int thrnode, int thredge, bool hideparams, bool stripparams, bool hidenamespaces) { dwcn = colnode; dwce = coledge; @@ -97,7 +92,8 @@ void DotWriter::WriteToDotLanguage() bool is_node = false; wxArrayInt index_pl_nodes; - if(mlines == NULL) return; + if (mlines == NULL) + return; graph = wxT("graph [ranksep=\"0.25\", fontname=") + fontname + wxT(", nodesep=\"0.125\"];"); @@ -112,10 +108,10 @@ void DotWriter::WriteToDotLanguage() LineParserList::compatibility_iterator it = mlines->GetFirst(); - while(it) { + while (it) { LineParser* line = it->GetData(); - if(line->pline && wxRound(line->time) >= dwtn) { + if (line->pline && wxRound(line->time) >= dwtn) { is_node = true; index_pl_nodes.Add(line->index); dlabel = wxString::Format(wxT("%i"), line->index); @@ -132,7 +128,8 @@ void DotWriter::WriteToDotLanguage() dlabel += wxString::Format(wxT("%.2f"), line->self + line->children); dlabel += wxT("s)"); dlabel += wxT("\\n"); - if(line->called0 != -1) dlabel += wxString::Format(wxT("%i"), line->called0) + wxT("x"); + if (line->called0 != -1) + dlabel += wxString::Format(wxT("%i"), line->called0) + wxT("x"); // if(line->recursive) // dlabel += wxT(" (") + wxString::Format(wxT("%i"),line->called0 + line->called1) + wxT("x)"); dlabel += wxT("\",fontcolor=\""); @@ -153,18 +150,19 @@ void DotWriter::WriteToDotLanguage() float max_time = -2; - while(it) { + while (it) { LineParser* line = it->GetData(); - if(max_time < line->time) max_time = line->time; + if (max_time < line->time) + max_time = line->time; - if(line->pline) { + if (line->pline) { pl_index = line->index; // index for primary node pl_time = line->time; // time for primary node } - if(line->child && IsInArray(line->nameid, index_pl_nodes) && IsInArray(pl_index, index_pl_nodes) && - (wxRound(pl_time) >= dwte)) { + if (line->child && IsInArray(line->nameid, index_pl_nodes) && IsInArray(pl_index, index_pl_nodes) && + (wxRound(pl_time) >= dwte)) { dedge = wxString::Format(wxT("%i"), pl_index); dedge += wxT(" -> "); dedge += wxString::Format(wxT("%i"), line->nameid); @@ -188,7 +186,7 @@ void DotWriter::WriteToDotLanguage() } m_OutputString += end_graph; - if(!is_node) { // if the call graph is empty create new graph with label node + if (!is_node) { // if the call graph is empty create new graph with label node m_OutputString = wxT("digraph e {0 [label="); m_OutputString += wxString::Format(_("\"The call-graph is empty; the node threshold ceiling is %d !\""), wxRound(max_time)); @@ -207,39 +205,39 @@ bool DotWriter::SendToDotAppOutputDirectory(const wxString& dot_fn) wxString DotWriter::OptionsShortNameAndParameters(const wxString& name) { - if((dwhidenamespaces || dwhideparams) && name.Contains(wxT('(')) && name.Contains(wxT(')'))) { + if ((dwhidenamespaces || dwhideparams) && name.Contains(wxT('(')) && name.Contains(wxT(')'))) { wxString out = name; - if(dwhidenamespaces) { + if (dwhidenamespaces) { wxRegEx re; // remove STL int start, end; - while(GetOuterTemplate(out, &start, &end)) { + while (GetOuterTemplate(out, &start, &end)) { out.Replace(out.Mid(start, end - start + 1), wxT("%STL%")); } out.Replace(wxT("%STL%"), wxT("<...>")); // remove namespace - if(re.Compile(wxT("::[a-zA-Z_~]+[a-zA-Z_0-9 colorSelect(dwc); - if(dwc == 1) { + if (dwc == 1) { colorSelect[0].downIndex = 0; colorSelect[0].upIndex = 100; colorSelect[0].indexColor = 0; - } else if(dwc == 2) { + } else if (dwc == 2) { colorSelect[0].downIndex = 0; colorSelect[0].upIndex = 50; colorSelect[0].indexColor = 0; colorSelect[1].downIndex = 51; colorSelect[1].upIndex = 100; colorSelect[1].indexColor = 9; - } else if(dwc > 2 && dwc < 11) { + } else if (dwc > 2 && dwc < 11) { int numInterval = dwc - 1; float stepInterval = 8.0 / (float)numInterval; float lenInterval = 100.0 / (float)dwc; @@ -282,19 +280,19 @@ int DotWriter::ReturnIndexForColor(float time, int dwc) float restAdd = (float)afterModulo / numInterval; float addValue = 0.0; - for(int i = 0; i < dwc; i++) { + for (int i = 0; i < dwc; i++) { addValue += restAdd; - if(i == 0) { + if (i == 0) { colorSelect[i].downIndex = 0; colorSelect[i].upIndex = (int)lenInterval; colorSelect[i].indexColor = 0; - } else if(i == (dwc - 1)) { + } else if (i == (dwc - 1)) { colorSelect[i].downIndex = colorSelect[i - 1].upIndex + 1; colorSelect[i].upIndex = 100; colorSelect[i].indexColor = 9; - } else if(i > 0 && i < (dwc - 1)) { + } else if (i > 0 && i < (dwc - 1)) { int addValueNext = 0; - if(0.8 < addValue && addValue < 1.2) { + if (0.8 < addValue && addValue < 1.2) { addValueNext = 1; addValue = 0; } @@ -306,8 +304,8 @@ int DotWriter::ReturnIndexForColor(float time, int dwc) } } - for(int i = 0; i < dwc; i++) { - if((int)colorSelect[i].downIndex <= (int)time && (int)time <= (int)colorSelect[i].upIndex) { + for (int i = 0; i < dwc; i++) { + if ((int)colorSelect[i].downIndex <= (int)time && (int)time <= (int)colorSelect[i].upIndex) { index = (int)colorSelect[i].indexColor; break; } @@ -317,22 +315,31 @@ int DotWriter::ReturnIndexForColor(float time, int dwc) wxString DotWriter::DefineColorForNodeEdge(int index) { - wxString colors[10] = { wxT("#006837"), wxT("#1a9850"), wxT("#66bd63"), wxT("#a6d96a"), wxT("#d9ef8b"), - wxT("#fee08b"), wxT("#fdae61"), wxT("#f46d43"), wxT("#d73027"), wxT("#a50026") }; + wxString colors[10] = {wxT("#006837"), + wxT("#1a9850"), + wxT("#66bd63"), + wxT("#a6d96a"), + wxT("#d9ef8b"), + wxT("#fee08b"), + wxT("#fdae61"), + wxT("#f46d43"), + wxT("#d73027"), + wxT("#a50026")}; return colors[index]; } bool DotWriter::IsInArray(int index, const wxArrayInt& arr) { - for(unsigned int i = 0; i < arr.GetCount(); i++) { - if(arr.Item(i) == index) return true; + for (unsigned int i = 0; i < arr.GetCount(); i++) { + if (arr.Item(i) == index) + return true; } return false; } wxString DotWriter::DefineColorForLabel(int index) { - if((index < 3) || (index > 6)) { + if ((index < 3) || (index > 6)) { return cwhite; } else { return cblack; @@ -346,11 +353,13 @@ bool DotWriter::GetOuterTemplate(const wxString& txt, int* start, int* end) for (auto c : txt) { if (c == wxT('<')) { - if(cnt == 0) *start = pos; + if (cnt == 0) + *start = pos; cnt++; } else if (c == wxT('>')) { cnt--; - if(cnt == 0) *end = pos; + if (cnt == 0) + *end = pos; return true; } pos++; diff --git a/CallGraph/dotwriter.h b/CallGraph/dotwriter.h index 579d2cbefa..2a099361fd 100644 --- a/CallGraph/dotwriter.h +++ b/CallGraph/dotwriter.h @@ -33,120 +33,123 @@ * Notes: **************************************************************/ -#include "lineparser.h" #include "confcallgraph.h" +#include "lineparser.h" #include "plugin.h" #include "static.h" -#include + +#include +#include +#include #include #include -#include -#include -#include +#include /** * @class DotWriter * @brief Class write data from lineparser structure to dot language. */ class DotWriter -{ +{ private: - wxString graph, end_graph, begin_graph; - wxString style, shape, fontname; - wxString cwhite, cblack; - wxString dlabel, dedge, hedge, hnode; - LineParserList *mlines; - wxString m_OutputString; - bool m_writedotfileFlag; - bool dwhideparams; - bool dwstripparams; - bool dwhidenamespaces; - int dwcn; - int dwce; - int dwtn; - int dwte; - + wxString graph, end_graph, begin_graph; + wxString style, shape, fontname; + wxString cwhite, cblack; + wxString dlabel, dedge, hedge, hnode; + LineParserList* mlines; + wxString m_OutputString; + bool m_writedotfileFlag; + bool dwhideparams; + bool dwstripparams; + bool dwhidenamespaces; + int dwcn; + int dwce; + int dwtn; + int dwte; + protected: - /** - * @brief Object confData type ConfCallGraph with stored configuration data. - */ - ConfCallGraph confData; - - /** - * @brief Get positions of STL template signs - * @param txt - * @param start - * @param end - * @return - */ - bool GetOuterTemplate(const wxString& txt, int *start, int *end); + /** + * @brief Object confData type ConfCallGraph with stored configuration data. + */ + ConfCallGraph confData; + + /** + * @brief Get positions of STL template signs + * @param txt + * @param start + * @param end + * @return + */ + bool GetOuterTemplate(const wxString& txt, int* start, int* end); public: - /** - * @brief Default constructor. - */ - DotWriter(); - /** - * @brief Default destructor. - */ + /** + * @brief Default constructor. + */ + DotWriter(); + /** + * @brief Default destructor. + */ ~DotWriter() = default; - /** - * @brief Function sets object DotWriter and assign the pointer pLines. - * @param pLines - */ - void SetLineParser(LineParserList *pLines); - /** - * @brief Function sets object DotWriter from stored configuration data. - * @param mgr - */ - void SetDotWriterFromDialogSettings(IManager *mgr); - - /** - * @brief Function sets object DotWriter from given data. - * @param colnode - * @param coledge - * @param thrnode - * @param thredge - * @param hideparams - * @param stripparams - * @param hidenamespaces - */ - void SetDotWriterFromDetails(int colnode, int coledge, int thrnode, int thredge, bool hideparams, bool stripparams, bool hidenamespaces); - // - /** - * @brief Function create data in the DOT language and prepare it to write. - */ - void WriteToDotLanguage(); - /** - * @brief Function write data in the DOT language to file dot.txt. - * @param path for file where write file with DOT language. - */ - bool SendToDotAppOutputDirectory(const wxString& path); - - /** - * @brief Function return string modified by the options in the dialog settings of the plugin. - * @param name of the function stored in the list of objects. - */ - wxString OptionsShortNameAndParameters(const wxString& name); - /** - * @brief Function return string of color by the index value. - * @param index of the color, this value return function ReturnIndexForColor. - * */ - wxString DefineColorForNodeEdge(int index); - /** - * @brief Function return string of color by the index value. - * @param index of the color, this value return function ReturnIndexForColor. - */ - wxString DefineColorForLabel(int index); - /** - * @brief Function return bool value if index exists in the array. - * @param index of the function stored in the list of objects. - * @param array of index by nodes added to the call graph. - */ - bool IsInArray(int index, const wxArrayInt& array); - /** - * @brief Function return optimal index for color by the value time and options in the dialog settings of the plugin. - * @param time of the function stored in the list of objects. - * @param dwc is value from dialog settings node level colors - */ - int ReturnIndexForColor(float time, int dwc); + /** + * @brief Function sets object DotWriter and assign the pointer pLines. + * @param pLines + */ + void SetLineParser(LineParserList* pLines); + /** + * @brief Function sets object DotWriter from stored configuration data. + * @param mgr + */ + void SetDotWriterFromDialogSettings(IManager* mgr); + + /** + * @brief Function sets object DotWriter from given data. + * @param colnode + * @param coledge + * @param thrnode + * @param thredge + * @param hideparams + * @param stripparams + * @param hidenamespaces + */ + void SetDotWriterFromDetails( + int colnode, int coledge, int thrnode, int thredge, bool hideparams, bool stripparams, bool hidenamespaces); + // + /** + * @brief Function create data in the DOT language and prepare it to write. + */ + void WriteToDotLanguage(); + /** + * @brief Function write data in the DOT language to file dot.txt. + * @param path for file where write file with DOT language. + */ + bool SendToDotAppOutputDirectory(const wxString& path); + + /** + * @brief Function return string modified by the options in the dialog settings of the plugin. + * @param name of the function stored in the list of objects. + */ + wxString OptionsShortNameAndParameters(const wxString& name); + /** + * @brief Function return string of color by the index value. + * @param index of the color, this value return function ReturnIndexForColor. + * */ + wxString DefineColorForNodeEdge(int index); + /** + * @brief Function return string of color by the index value. + * @param index of the color, this value return function ReturnIndexForColor. + */ + wxString DefineColorForLabel(int index); + /** + * @brief Function return bool value if index exists in the array. + * @param index of the function stored in the list of objects. + * @param array of index by nodes added to the call graph. + */ + bool IsInArray(int index, const wxArrayInt& array); + /** + * @brief Function return optimal index for color by the value time and options in the dialog settings of the + * plugin. + * @param time of the function stored in the list of objects. + * @param dwc is value from dialog settings node level colors + */ + int ReturnIndexForColor(float time, int dwc); }; \ No newline at end of file diff --git a/CallGraph/gprofparser.cpp b/CallGraph/gprofparser.cpp index d4299bdc54..f9070e470e 100644 --- a/CallGraph/gprofparser.cpp +++ b/CallGraph/gprofparser.cpp @@ -24,6 +24,7 @@ ////////////////////////////////////////////////////////////////////////////// #include "gprofparser.h" + #include #include #include @@ -32,268 +33,332 @@ int cmpint(int* a, int* b) { return *b - *a; } GprofParser::GprofParser() { - lineheader = false; - primaryline = false; - nameLen = 0; - nameandid = NULL; - isdot = false; - iscycle = false; - islom = false; - isplus = false; - isspontaneous = false; - lines.DeleteContents(true); - lines.Clear(); + lineheader = false; + primaryline = false; + nameLen = 0; + nameandid = NULL; + isdot = false; + iscycle = false; + islom = false; + isplus = false; + isspontaneous = false; + lines.DeleteContents(true); + lines.Clear(); }; GprofParser::~GprofParser() { - lines.DeleteContents(true); - lines.Clear(); + lines.DeleteContents(true); + lines.Clear(); }; -void GprofParser::GprofParserStream(wxInputStream *gprof_output) +void GprofParser::GprofParserStream(wxInputStream* gprof_output) { - wxRegEx re; - readlinetext = wxT(""); - readlinetexttemp = wxT(""); - wxCSConv conv( wxT("ISO-8859-1") ); - wxTextInputStream text(*gprof_output);//, wxT(" \t"), conv); - //wxFileOutputStream out( wxT("DEBUG.TXT") ); - //wxTextOutputStream tout( out ); - - isspontaneous = false; - calls.clear(); - - while(!gprof_output->Eof()) { - readlinetext = text.ReadLine(); - //tout.WriteString( readlinetext + wxT("\n") ); - nameLen = readlinetext.Len(); - - if(readlinetext != wxT("")) { - if(readlinetext == wxT("index % time self children called name")) { - lineheader = true; - } else if (readlinetext[0] == wxT('-')) { - primaryline = false; - continue; - } else if (readlinetext.Contains(wxT(""))) { - isspontaneous = true; - continue; - } else if (lineheader) { - delete [] nameandid; - nameandid = new char[nameLen + 1]; // dynam array for pointer nameandid - memset(nameandid, 0, nameLen + 1); - - LineParser *line = new LineParser(); - - //inicializace struktury - line->called0 = -1; - line->called1 = -1; - line->child = false; - line->children = -1; - line->cycle = false; - line->cycleid = -1; - line->index = -1; - line->name = wxT(""); - line->nameid = -1; - line->parents = false; - line->pline = false; - line->recursive = false; - line->self = -1; - line->time = -1; - - if(re.Compile(wxT("[ ]{2,}")) && re.Matches( readlinetext )) { - re.Replace(&readlinetext, wxT(" ")); - } - - if (readlinetext.Contains(wxT("."))) isdot = true; - else isdot = false; - - if (readlinetext.Contains(wxT("cycle"))) iscycle = true; - else iscycle = false; - - //if (readlinetext.Contains(wxT("/"))) islom = true; - if(re.Compile( wxT("[0-9]+/[0-9]+"), wxRE_ADVANCED) && re.Matches( readlinetext)) islom = true; - else islom = false; - - //if (readlinetext.Contains(wxT("+"))) isplus = true; - if(re.Compile( wxT("([0-9]+)\\+([0-9]+)"), wxRE_ADVANCED) && re.Matches( readlinetext)) { - isplus = true; - //readlinetext.Replace( wxT("+"), wxT(" ") ); - re.Replace(&readlinetext, wxT("\\1 \\2")); - } - else isplus = false; - - wxString dot = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); - readlinetext.Replace( wxT("."), dot ); - - if ((readlinetext[0] == '[') && (readlinetext[(readlinetext.length()) - 1] == ']')) { - primaryline = true; - // - if(iscycle && isplus) { // [3] 91.71 1.77 0.00 1+5 [3] - //warning - sscanf((const char*)readlinetext.mb_str(conv),"[%d] %f %f %f %d %d [%d]",&line->index,&line->time,&line->self,&line->children,&line->called0,&line->called1,&line->cycleid,&line->nameid); - line->name = wxT("whole"); - line->parents = false; - line->pline = true; - line->child = false; - line->cycle = true; - line->recursive = true; - } else if(iscycle) { // [5] 38.86 0.75 0 1 a [5] - sscanf((const char*)readlinetext.mb_str(conv),"[%d] %f %f %f %d %[^\n]s",&line->index,&line->time,&line->self,&line->children,&line->called0,nameandid); - - wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? - line->name = readlinesubtext.BeforeFirst(wxT('<')); - wxSscanf(readlinesubtext.AfterFirst(wxT('<')).BeforeFirst(wxT('>')),wxT("cycle %d"), &line->cycleid); - //line->cycleid = readlinesubtext.AfterFirst('<').BeforeFirst('>'); - wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')),wxT("%d"),&line->nameid); - - line->parents = false; - line->pline = true; - line->child = false; - line->cycle = true; - line->recursive = false; - } else if(isplus) { //[4] 3.7 0.00 0.01 1+6 quicksort(int*, int, int) [4] - sscanf((const char*)readlinetext.mb_str(conv),"[%d] %f %f %f %d %d %[^\n]s",&line->index,&line->time,&line->self,&line->children,&line->called0,&line->called1,nameandid); - // - wxString readlinesubtext(nameandid, conv); - // - line->name = readlinesubtext.BeforeFirst(wxT('[')); - // - wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')),wxT("%d"),&line->nameid); - line->parents = false; - line->pline = true; - line->child = false; - line->cycle = false; - line->recursive = true; - } else if (isspontaneous) { // || !readlinetext.Contains(wxT('('))) // [3] 100.0 0.00 0.03 %d - neni main [3] - //special case (probably appears after 'spontaneous' - sscanf((const char*)readlinetext.mb_str(conv),"[%d] %f %f %f %[^\n]s",&line->index,&line->time,&line->self,&line->children,nameandid); - // - wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? - line->name = readlinesubtext.BeforeFirst(wxT('[')); - // - wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')),wxT("%d"),&line->nameid); - line->parents = false; - line->pline = true; - line->child = false; - line->cycle = false; - line->recursive = false; - - isspontaneous = false; - } else { //[2] 100.00 0.16 1.77 1 main [2] - sscanf((const char*)readlinetext.mb_str(conv),"[%d] %f %f %f %d %[^\n]s",&line->index,&line->time,&line->self,&line->children,&line->called0,nameandid); - // - wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? - line->name = readlinesubtext.BeforeFirst(wxT('[')); - // - wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')),wxT("%d"),&line->nameid); - line->parents = false; - line->pline = true; - line->child = false; - line->cycle = false; - line->recursive = false; - - } - } else { //parents and children - if(iscycle && !islom) { //3 a [5] - // warning - sscanf((const char*)readlinetext.mb_str(conv),"%d %[^\n]s",&line->called0,nameandid); - wxString readlinesubtext(nameandid, conv); - line->name = readlinesubtext.BeforeFirst(wxT('<')); - wxSscanf(readlinesubtext.AfterFirst(wxT('<')).BeforeFirst(wxT('>')),wxT("cycle %d"), &line->cycleid); - //line->cycleid = readlinesubtext.AfterFirst('<').BeforeFirst('>'); - wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')),wxT("%d"),&line->nameid); - - line->cycle = true; - line->recursive = false; - - } else if(!iscycle && islom) { // 0 0 6/6 c [6] - sscanf((const char*)readlinetext.mb_str(conv),"%f %f %d/%d %[^\n]s",&line->self,&line->children,&line->called0,&line->called1,nameandid); - wxString readlinesubtext(nameandid, conv); - line->name = (wxString)readlinesubtext.BeforeFirst(wxT('[')); - wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')),wxT("%d"),&line->nameid); - - line->cycle = false; - line->recursive = false; - // - } else if(iscycle && islom) { //1.77 0 1/1 a [5] - sscanf((const char*)readlinetext.mb_str(conv),"%f %f %d/%d %[^\n]s",&line->self,&line->children,&line->called0,&line->called1,nameandid); - wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? - line->name = readlinesubtext.BeforeFirst(wxT('<')); - wxSscanf(readlinesubtext.AfterFirst(wxT('<')).BeforeFirst(wxT('>')),wxT("cycle %d"), &line->cycleid); - //line->cycleid = readlinesubtext.AfterFirst('<').BeforeFirst('>'); - wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')),wxT("%d"),&line->nameid); - - line->cycle = true; - line->recursive = false; - - } else if(!iscycle && !islom && !isdot) { //15 faktorial(int) [8] - sscanf((const char*)readlinetext.mb_str(conv),"%d %[^\n]s",&line->called0,nameandid); - wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? - line->name = readlinesubtext.BeforeFirst(wxT('[')); - wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')),wxT("%d"),&line->nameid); - - line->cycle = false; - line->recursive = true; - - } - /*else if(!iscycle && !islom) - { - sscanf((const char*)readlinetext.mb_str(conv),"%f %f %d %[^\n]s",&line->self,&line->children,&line->called0,nameandid); - // - wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? - line->name = readlinesubtext.BeforeFirst('['); - // - wxSscanf(readlinesubtext.AfterFirst('[').BeforeFirst(']'),"%d",&line->nameid); - - line->cycle = false; - line->recursive = false; - // - }*/ - - if (primaryline) { - line->parents = false; - line->pline = false; - line->child = true; - } else { - line->parents = true; - line->pline = false; - line->child = false; - } - } - - lines.Append( line ); - calls[ wxRound(line->time) ] = calls[ wxRound(line->time) ] + 1; - } - } else if (lineheader) { - break; - } - } - - delete [] nameandid; + wxRegEx re; + readlinetext = wxT(""); + readlinetexttemp = wxT(""); + wxCSConv conv(wxT("ISO-8859-1")); + wxTextInputStream text(*gprof_output); //, wxT(" \t"), conv); + // wxFileOutputStream out( wxT("DEBUG.TXT") ); + // wxTextOutputStream tout( out ); + + isspontaneous = false; + calls.clear(); + + while (!gprof_output->Eof()) { + readlinetext = text.ReadLine(); + // tout.WriteString( readlinetext + wxT("\n") ); + nameLen = readlinetext.Len(); + + if (readlinetext != wxT("")) { + if (readlinetext == wxT("index % time self children called name")) { + lineheader = true; + } else if (readlinetext[0] == wxT('-')) { + primaryline = false; + continue; + } else if (readlinetext.Contains(wxT(""))) { + isspontaneous = true; + continue; + } else if (lineheader) { + delete[] nameandid; + nameandid = new char[nameLen + 1]; // dynam array for pointer nameandid + memset(nameandid, 0, nameLen + 1); + + LineParser* line = new LineParser(); + + // inicializace struktury + line->called0 = -1; + line->called1 = -1; + line->child = false; + line->children = -1; + line->cycle = false; + line->cycleid = -1; + line->index = -1; + line->name = wxT(""); + line->nameid = -1; + line->parents = false; + line->pline = false; + line->recursive = false; + line->self = -1; + line->time = -1; + + if (re.Compile(wxT("[ ]{2,}")) && re.Matches(readlinetext)) { + re.Replace(&readlinetext, wxT(" ")); + } + + if (readlinetext.Contains(wxT("."))) + isdot = true; + else + isdot = false; + + if (readlinetext.Contains(wxT("cycle"))) + iscycle = true; + else + iscycle = false; + + // if (readlinetext.Contains(wxT("/"))) islom = true; + if (re.Compile(wxT("[0-9]+/[0-9]+"), wxRE_ADVANCED) && re.Matches(readlinetext)) + islom = true; + else + islom = false; + + // if (readlinetext.Contains(wxT("+"))) isplus = true; + if (re.Compile(wxT("([0-9]+)\\+([0-9]+)"), wxRE_ADVANCED) && re.Matches(readlinetext)) { + isplus = true; + // readlinetext.Replace( wxT("+"), wxT(" ") ); + re.Replace(&readlinetext, wxT("\\1 \\2")); + } else + isplus = false; + + wxString dot = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); + readlinetext.Replace(wxT("."), dot); + + if ((readlinetext[0] == '[') && (readlinetext[(readlinetext.length()) - 1] == ']')) { + primaryline = true; + // + if (iscycle && isplus) { // [3] 91.71 1.77 0.00 1+5 [3] + // warning + sscanf((const char*)readlinetext.mb_str(conv), + "[%d] %f %f %f %d %d [%d]", + &line->index, + &line->time, + &line->self, + &line->children, + &line->called0, + &line->called1, + &line->cycleid, + &line->nameid); + line->name = wxT("whole"); + line->parents = false; + line->pline = true; + line->child = false; + line->cycle = true; + line->recursive = true; + } else if (iscycle) { // [5] 38.86 0.75 0 1 a [5] + sscanf((const char*)readlinetext.mb_str(conv), + "[%d] %f %f %f %d %[^\n]s", + &line->index, + &line->time, + &line->self, + &line->children, + &line->called0, + nameandid); + + wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? + line->name = readlinesubtext.BeforeFirst(wxT('<')); + wxSscanf(readlinesubtext.AfterFirst(wxT('<')).BeforeFirst(wxT('>')), + wxT("cycle %d"), + &line->cycleid); + // line->cycleid = readlinesubtext.AfterFirst('<').BeforeFirst('>'); + wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')), wxT("%d"), &line->nameid); + + line->parents = false; + line->pline = true; + line->child = false; + line->cycle = true; + line->recursive = false; + } else if (isplus) { //[4] 3.7 0.00 0.01 1+6 quicksort(int*, int, int) [4] + sscanf((const char*)readlinetext.mb_str(conv), + "[%d] %f %f %f %d %d %[^\n]s", + &line->index, + &line->time, + &line->self, + &line->children, + &line->called0, + &line->called1, + nameandid); + // + wxString readlinesubtext(nameandid, conv); + // + line->name = readlinesubtext.BeforeFirst(wxT('[')); + // + wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')), wxT("%d"), &line->nameid); + line->parents = false; + line->pline = true; + line->child = false; + line->cycle = false; + line->recursive = true; + } else if (isspontaneous) { // || !readlinetext.Contains(wxT('('))) // [3] 100.0 0.00 0.03 + // %d - neni main [3] + // special case (probably appears after 'spontaneous' + sscanf((const char*)readlinetext.mb_str(conv), + "[%d] %f %f %f %[^\n]s", + &line->index, + &line->time, + &line->self, + &line->children, + nameandid); + // + wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? + line->name = readlinesubtext.BeforeFirst(wxT('[')); + // + wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')), wxT("%d"), &line->nameid); + line->parents = false; + line->pline = true; + line->child = false; + line->cycle = false; + line->recursive = false; + + isspontaneous = false; + } else { //[2] 100.00 0.16 1.77 1 main [2] + sscanf((const char*)readlinetext.mb_str(conv), + "[%d] %f %f %f %d %[^\n]s", + &line->index, + &line->time, + &line->self, + &line->children, + &line->called0, + nameandid); + // + wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? + line->name = readlinesubtext.BeforeFirst(wxT('[')); + // + wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')), wxT("%d"), &line->nameid); + line->parents = false; + line->pline = true; + line->child = false; + line->cycle = false; + line->recursive = false; + } + } else { // parents and children + if (iscycle && !islom) { // 3 a [5] + // warning + sscanf((const char*)readlinetext.mb_str(conv), "%d %[^\n]s", &line->called0, nameandid); + wxString readlinesubtext(nameandid, conv); + line->name = readlinesubtext.BeforeFirst(wxT('<')); + wxSscanf(readlinesubtext.AfterFirst(wxT('<')).BeforeFirst(wxT('>')), + wxT("cycle %d"), + &line->cycleid); + // line->cycleid = readlinesubtext.AfterFirst('<').BeforeFirst('>'); + wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')), wxT("%d"), &line->nameid); + + line->cycle = true; + line->recursive = false; + + } else if (!iscycle && islom) { // 0 0 6/6 c [6] + sscanf((const char*)readlinetext.mb_str(conv), + "%f %f %d/%d %[^\n]s", + &line->self, + &line->children, + &line->called0, + &line->called1, + nameandid); + wxString readlinesubtext(nameandid, conv); + line->name = (wxString)readlinesubtext.BeforeFirst(wxT('[')); + wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')), wxT("%d"), &line->nameid); + + line->cycle = false; + line->recursive = false; + // + } else if (iscycle && islom) { // 1.77 0 1/1 a [5] + sscanf((const char*)readlinetext.mb_str(conv), + "%f %f %d/%d %[^\n]s", + &line->self, + &line->children, + &line->called0, + &line->called1, + nameandid); + wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? + line->name = readlinesubtext.BeforeFirst(wxT('<')); + wxSscanf(readlinesubtext.AfterFirst(wxT('<')).BeforeFirst(wxT('>')), + wxT("cycle %d"), + &line->cycleid); + // line->cycleid = readlinesubtext.AfterFirst('<').BeforeFirst('>'); + wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')), wxT("%d"), &line->nameid); + + line->cycle = true; + line->recursive = false; + + } else if (!iscycle && !islom && !isdot) { // 15 faktorial(int) [8] + sscanf((const char*)readlinetext.mb_str(conv), "%d %[^\n]s", &line->called0, nameandid); + wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? + line->name = readlinesubtext.BeforeFirst(wxT('[')); + wxSscanf(readlinesubtext.AfterFirst(wxT('[')).BeforeFirst(wxT(']')), wxT("%d"), &line->nameid); + + line->cycle = false; + line->recursive = true; + } + /*else if(!iscycle && !islom) + { + sscanf((const char*)readlinetext.mb_str(conv),"%f %f %d + %[^\n]s",&line->self,&line->children,&line->called0,nameandid); + // + wxString readlinesubtext(nameandid, conv); // musi byt kodovani ? + line->name = readlinesubtext.BeforeFirst('['); + // + wxSscanf(readlinesubtext.AfterFirst('[').BeforeFirst(']'),"%d",&line->nameid); + + line->cycle = false; + line->recursive = false; + // + }*/ + + if (primaryline) { + line->parents = false; + line->pline = false; + line->child = true; + } else { + line->parents = true; + line->pline = false; + line->child = false; + } + } + + lines.Append(line); + calls[wxRound(line->time)] = calls[wxRound(line->time)] + 1; + } + } else if (lineheader) { + break; + } + } + + delete[] nameandid; } int GprofParser::GetSuggestedNodeThreshold() { - sortedCalls.Clear(); - - for (const auto& p : calls) - sortedCalls.Add(p.first); - - sortedCalls.Sort(cmpint); - int totalCount = 0; - int minCallTime = INT_MAX; - - for( size_t i = 0; i < sortedCalls.GetCount() && totalCount < 100; ++i ) - { - totalCount += calls[ sortedCalls[i] ]; - if( totalCount < 100 && sortedCalls[i] < minCallTime ) minCallTime = sortedCalls[i]; - } - - if( minCallTime < 0 ) minCallTime = 0; - else if( minCallTime > 100 ) minCallTime = 100; - - if( sortedCalls.GetCount() > 1 && totalCount >= 100 ) return minCallTime; - else - return -1; + sortedCalls.Clear(); + + for (const auto& p : calls) + sortedCalls.Add(p.first); + + sortedCalls.Sort(cmpint); + int totalCount = 0; + int minCallTime = INT_MAX; + + for (size_t i = 0; i < sortedCalls.GetCount() && totalCount < 100; ++i) { + totalCount += calls[sortedCalls[i]]; + if (totalCount < 100 && sortedCalls[i] < minCallTime) + minCallTime = sortedCalls[i]; + } + + if (minCallTime < 0) + minCallTime = 0; + else if (minCallTime > 100) + minCallTime = 100; + + if (sortedCalls.GetCount() > 1 && totalCount >= 100) + return minCallTime; + else + return -1; } diff --git a/CallGraph/gprofparser.h b/CallGraph/gprofparser.h index d0d4ffa313..5f31037657 100644 --- a/CallGraph/gprofparser.h +++ b/CallGraph/gprofparser.h @@ -25,21 +25,21 @@ /*************************************************************** * Name: gprofparser.h - * Purpose: Header to create stream parser from gprof. + * Purpose: Header to create stream parser from gprof. * Author: Vaclav Sprucek * Created: 2012-03-04 - * Copyright: Vaclav Sprucek + * Copyright: Vaclav Sprucek * License: wxWidgets license (www.wxwidgets.org) * Notes: **************************************************************/ -#include -#include +#include "lineparser.h" + +#include #include +#include #include -#include - -#include "lineparser.h" +#include WX_DECLARE_HASH_MAP(int, int, wxIntegerHash, wxIntegerEqual, OccurrenceMap); @@ -50,41 +50,42 @@ WX_DECLARE_HASH_MAP(int, int, wxIntegerHash, wxIntegerEqual, OccurrenceMap); class GprofParser { private: - wxString readlinetext; - wxString readlinetexttemp; - bool lineheader; - bool primaryline; - int nameLen; - char *nameandid; - bool isdot; - bool iscycle; - bool islom; - bool isplus; - bool isspontaneous; - - OccurrenceMap calls; - wxArrayInt sortedCalls; - + wxString readlinetext; + wxString readlinetexttemp; + bool lineheader; + bool primaryline; + int nameLen; + char* nameandid; + bool isdot; + bool iscycle; + bool islom; + bool isplus; + bool isspontaneous; + + OccurrenceMap calls; + wxArrayInt sortedCalls; + public: - /** - * @brief Default constructor. - */ - GprofParser(); - /** - * @brief Default destructor. - */ - ~GprofParser(); - /** - * @brief List lines type LineParserList. - */ - LineParserList lines; - /** - * @brief Function is reading the input stream from gprof application and scan the rows to save to collection of objects lines. - * @param m_pInputStream pointer of type wxInputStream. - */ - void GprofParserStream(wxInputStream *m_pInputStream); - /** - * @brief Suggest call diagram's node threshold so no more than 100 items should be displayed at once. - */ - int GetSuggestedNodeThreshold(); + /** + * @brief Default constructor. + */ + GprofParser(); + /** + * @brief Default destructor. + */ + ~GprofParser(); + /** + * @brief List lines type LineParserList. + */ + LineParserList lines; + /** + * @brief Function is reading the input stream from gprof application and scan the rows to save to collection of + * objects lines. + * @param m_pInputStream pointer of type wxInputStream. + */ + void GprofParserStream(wxInputStream* m_pInputStream); + /** + * @brief Suggest call diagram's node threshold so no more than 100 items should be displayed at once. + */ + int GetSuggestedNodeThreshold(); }; diff --git a/CallGraph/lineparser.cpp b/CallGraph/lineparser.cpp index 08b55d9931..ee9d01d1f3 100644 --- a/CallGraph/lineparser.cpp +++ b/CallGraph/lineparser.cpp @@ -31,22 +31,22 @@ WX_DEFINE_LIST(LineParserList); LineParser* LineParser::Clone() const { - LineParser *newline = new LineParser(); - - newline->index = this->index; - newline->time = this->time; - newline->self = this->self; - newline->children = this->children; - newline->called0 = this->called0; - newline->called1 = this->called1; - newline->name = this->name; - newline->nameid = this->nameid; - newline->parents = this->parents; - newline->pline = this->pline; - newline->child = this->child; - newline->cycle = this->cycle; - newline->recursive = this->recursive; - newline->cycleid = this->cycleid; - - return newline; + LineParser* newline = new LineParser(); + + newline->index = this->index; + newline->time = this->time; + newline->self = this->self; + newline->children = this->children; + newline->called0 = this->called0; + newline->called1 = this->called1; + newline->name = this->name; + newline->nameid = this->nameid; + newline->parents = this->parents; + newline->pline = this->pline; + newline->child = this->child; + newline->cycle = this->cycle; + newline->recursive = this->recursive; + newline->cycleid = this->cycleid; + + return newline; } diff --git a/CallGraph/lineparser.h b/CallGraph/lineparser.h index b9c403e5c2..62e357e540 100644 --- a/CallGraph/lineparser.h +++ b/CallGraph/lineparser.h @@ -36,33 +36,33 @@ #ifndef _LINEPARSER_H__ #define _LINEPARSER_H__ -#include #include +#include /** * @class LineParser * @brief Class define structure for data structure. */ class LineParser -{ +{ public: - int index; - float time; - float self; - float children; - int called0; - int called1; - wxString name; - int nameid; - bool parents; // input to primary line - not used in call graph - bool pline; // primary line - bool child; // output from primary line - bool cycle; - bool recursive; - int cycleid; - - LineParser* Clone() const; + int index; + float time; + float self; + float children; + int called0; + int called1; + wxString name; + int nameid; + bool parents; // input to primary line - not used in call graph + bool pline; // primary line + bool child; // output from primary line + bool cycle; + bool recursive; + int cycleid; + + LineParser* Clone() const; }; -WX_DECLARE_LIST( LineParser, LineParserList ); +WX_DECLARE_LIST(LineParser, LineParserList); #endif \ No newline at end of file diff --git a/CallGraph/uicallgraphpanel.cpp b/CallGraph/uicallgraphpanel.cpp index 039f4f6634..064a5aebab 100644 --- a/CallGraph/uicallgraphpanel.cpp +++ b/CallGraph/uicallgraphpanel.cpp @@ -23,18 +23,24 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// +#include "uicallgraphpanel.h" + #include "callgraph.h" #include "fileutils.h" -#include "uicallgraphpanel.h" #include "workspace.h" + #include #include #include #include #include -uicallgraphpanel::uicallgraphpanel(wxWindow* parent, IManager* mgr, const wxString& imagepath, - const wxString& projectpath, int suggestedThreshold, LineParserList* pLines) +uicallgraphpanel::uicallgraphpanel(wxWindow* parent, + IManager* mgr, + const wxString& imagepath, + const wxString& projectpath, + int suggestedThreshold, + LineParserList* pLines) : uicallgraph(parent) { m_mgr = mgr; @@ -50,10 +56,12 @@ uicallgraphpanel::uicallgraphpanel(wxWindow* parent, IManager* mgr, const wxStri for (const auto lineParser : *pLines) m_lines.Append(lineParser->Clone()); - if(m_bmpOrig.LoadFile(m_pathimage, wxBITMAP_TYPE_PNG)) UpdateImage(); + if (m_bmpOrig.LoadFile(m_pathimage, wxBITMAP_TYPE_PNG)) + UpdateImage(); m_mgr->GetConfigTool()->ReadObject(wxT("CallGraph"), &confData); - if(suggestedThreshold == -1) suggestedThreshold = confData.GetTresholdNode(); + if (suggestedThreshold == -1) + suggestedThreshold = confData.GetTresholdNode(); CreateAndInserDataToTable(suggestedThreshold); @@ -83,10 +91,15 @@ void uicallgraphpanel::OnSaveCallGraph(wxCommandEvent& event) { // wxString projectName = m_mgr->GetWorkspace()->GetActiveProjectName(); - wxFileDialog saveFileDialog(this, _("Save call graph..."), wxT(""), wxT("CallGraph"), - wxT("png files (*.png)|*.png"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT); + wxFileDialog saveFileDialog(this, + _("Save call graph..."), + wxT(""), + wxT("CallGraph"), + wxT("png files (*.png)|*.png"), + wxFD_SAVE | wxFD_OVERWRITE_PROMPT); - if(saveFileDialog.ShowModal() == wxID_CANCEL) return; + if (saveFileDialog.ShowModal() == wxID_CANCEL) + return; m_bmpOrig.SaveFile(saveFileDialog.GetPath(), wxBITMAP_TYPE_PNG); } @@ -103,12 +116,13 @@ int uicallgraphpanel::CreateAndInserDataToTable(int node_thr) int nr = 0; float max_time = -2; - while(it) { + while (it) { LineParser* line = it->GetData(); - if(max_time < line->time) max_time = line->time; + if (max_time < line->time) + max_time = line->time; - if(line->pline && wxRound(line->time) >= node_thr) { + if (line->pline && wxRound(line->time) >= node_thr) { m_grid->AppendRows(1, true); // name time % self children called m_grid->SetCellValue(nr, 0, line->name); @@ -116,9 +130,10 @@ int uicallgraphpanel::CreateAndInserDataToTable(int node_thr) m_grid->SetCellValue(nr, 2, wxString::Format(wxT("%.2f"), line->self + line->children)); int callsum; - if(line->called0 != -1) { + if (line->called0 != -1) { callsum = line->called0; - if(line->called1 != -1) callsum += line->called1; + if (line->called1 != -1) + callsum += line->called1; } else callsum = 1; @@ -133,13 +148,18 @@ int uicallgraphpanel::CreateAndInserDataToTable(int node_thr) void uicallgraphpanel::OnRefreshClick(wxCommandEvent& event) { - if(m_grid->GetNumberRows()) m_grid->DeleteRows(0, (m_grid->GetNumberRows() - 1)); + if (m_grid->GetNumberRows()) + m_grid->DeleteRows(0, (m_grid->GetNumberRows() - 1)); // write to output png file DotWriter dw; dw.SetLineParser(&m_lines); - dw.SetDotWriterFromDetails(confData.GetColorsNode(), confData.GetColorsEdge(), m_spinNT->GetValue(), - m_spinET->GetValue(), m_checkBoxHP->GetValue(), confData.GetStripParams(), + dw.SetDotWriterFromDetails(confData.GetColorsNode(), + confData.GetColorsEdge(), + m_spinNT->GetValue(), + m_spinET->GetValue(), + m_checkBoxHP->GetValue(), + confData.GetStripParams(), m_checkBoxHN->GetValue()); dw.WriteToDotLanguage(); @@ -151,8 +171,10 @@ void uicallgraphpanel::OnRefreshClick(wxCommandEvent& event) wxString dot_fn = cfn.GetFullPath(); bool ok = dw.SendToDotAppOutputDirectory(dot_fn); - if(ok) { // delete any existing PNG - if(wxFileExists(m_pathimage)) { clRemoveFile(m_pathimage); } + if (ok) { // delete any existing PNG + if (wxFileExists(m_pathimage)) { + clRemoveFile(m_pathimage); + } wxString cmddot_ln; @@ -160,11 +182,13 @@ void uicallgraphpanel::OnRefreshClick(wxCommandEvent& event) wxExecute(cmddot_ln, wxEXEC_SYNC | wxEXEC_HIDE_CONSOLE); - if(m_bmpOrig.LoadFile(m_pathimage, wxBITMAP_TYPE_PNG)) UpdateImage(); + if (m_bmpOrig.LoadFile(m_pathimage, wxBITMAP_TYPE_PNG)) + UpdateImage(); } else wxMessageBox(_("CallGraph failed to save file with DOT language, please build the project again."), - wxT("CallGraph"), wxOK | wxICON_INFORMATION); + wxT("CallGraph"), + wxOK | wxICON_INFORMATION); // update call table CreateAndInserDataToTable(m_spinNT->GetValue()); @@ -174,9 +198,9 @@ void uicallgraphpanel::UpdateImage() { wxBusyCursor busy; - if(m_bmpOrig.IsOk()) { + if (m_bmpOrig.IsOk()) { wxImage img = m_bmpOrig.ConvertToImage(); - if(img.IsOk()) { + if (img.IsOk()) { img.Rescale(m_bmpOrig.GetWidth() * m_scale, m_bmpOrig.GetHeight() * m_scale, wxIMAGE_QUALITY_HIGH); m_bmpScaled = wxBitmap(img); @@ -200,7 +224,7 @@ void uicallgraphpanel::OnLeftDown(wxMouseEvent& event) void uicallgraphpanel::OnMouseMove(wxMouseEvent& event) { - if(event.LeftIsDown()) { + if (event.LeftIsDown()) { int dx, dy; m_scrolledWindow->GetScrollPixelsPerUnit(&dx, &dy); m_scrolledWindow->Scroll(m_viewPortOrigin.x + (m_startigPoint.x - event.GetPosition().x) / dx, @@ -211,11 +235,11 @@ void uicallgraphpanel::OnLeftUp(wxMouseEvent& event) { m_scrolledWindow->SetCurs void uicallgraphpanel::OnMouseWheel(wxMouseEvent& event) { - if(event.ControlDown()) { + if (event.ControlDown()) { m_scale += (float)event.GetWheelRotation() / (event.GetWheelDelta() * 10); - if(m_scale < 0.1) + if (m_scale < 0.1) m_scale = 0.1; - else if(m_scale > 1) + else if (m_scale > 1) m_scale = 1; UpdateImage(); } @@ -228,9 +252,9 @@ void uicallgraphpanel::OnZoom100(wxCommandEvent& event) m_scale = xscale < yscale ? xscale : yscale; - if(m_scale < 0.1) + if (m_scale < 0.1) m_scale = 0.1; - else if(m_scale > 1) + else if (m_scale > 1) m_scale = 1; UpdateImage(); } @@ -238,14 +262,16 @@ void uicallgraphpanel::OnZoom100(wxCommandEvent& event) void uicallgraphpanel::OnZoomIn(wxCommandEvent& event) { m_scale = m_scale + 0.1; - if(m_scale > 1) m_scale = 1; + if (m_scale > 1) + m_scale = 1; UpdateImage(); } void uicallgraphpanel::OnZoomOut(wxCommandEvent& event) { m_scale = m_scale - 0.1; - if(m_scale < 0.1) m_scale = 0.1; + if (m_scale < 0.1) + m_scale = 0.1; UpdateImage(); } diff --git a/CallGraph/uicallgraphpanel.h b/CallGraph/uicallgraphpanel.h index a9bd716fab..9befc854b7 100644 --- a/CallGraph/uicallgraphpanel.h +++ b/CallGraph/uicallgraphpanel.h @@ -36,46 +36,50 @@ #ifndef UICALLGRAPHPANEL_H #define UICALLGRAPHPANEL_H -#include "lineparser.h" #include "confcallgraph.h" +#include "lineparser.h" #include "plugin.h" #include "uicallgraph.h" // Base class: uicallgraph - class uicallgraphpanel : public uicallgraph { public: - uicallgraphpanel(wxWindow *parent, IManager *mgr, const wxString& imagepath, const wxString& projectpath, int suggestedThreshold, LineParserList *pLines); - virtual ~uicallgraphpanel(); + uicallgraphpanel(wxWindow* parent, + IManager* mgr, + const wxString& imagepath, + const wxString& projectpath, + int suggestedThreshold, + LineParserList* pLines); + virtual ~uicallgraphpanel(); protected: - virtual void OnPaint(wxPaintEvent& event); - virtual void OnSaveCallGraph(wxCommandEvent& event); - virtual void OnClosePanel(wxCommandEvent& event); - virtual void OnRefreshClick(wxCommandEvent& event); - virtual void OnLeftDown(wxMouseEvent& event); - virtual void OnLeftUp(wxMouseEvent& event); - virtual void OnMouseMove(wxMouseEvent& event); - virtual void OnMouseWheel(wxMouseEvent& event); - virtual void OnZoom100(wxCommandEvent& event); - virtual void OnZoomIn(wxCommandEvent& event); - virtual void OnZoomOut(wxCommandEvent& event); - virtual void OnZoomOriginal(wxCommandEvent& event); + virtual void OnPaint(wxPaintEvent& event); + virtual void OnSaveCallGraph(wxCommandEvent& event); + virtual void OnClosePanel(wxCommandEvent& event); + virtual void OnRefreshClick(wxCommandEvent& event); + virtual void OnLeftDown(wxMouseEvent& event); + virtual void OnLeftUp(wxMouseEvent& event); + virtual void OnMouseMove(wxMouseEvent& event); + virtual void OnMouseWheel(wxMouseEvent& event); + virtual void OnZoom100(wxCommandEvent& event); + virtual void OnZoomIn(wxCommandEvent& event); + virtual void OnZoomOut(wxCommandEvent& event); + virtual void OnZoomOriginal(wxCommandEvent& event); - int CreateAndInserDataToTable(int nodethr); // returns min_threshold - void UpdateImage(); + int CreateAndInserDataToTable(int nodethr); // returns min_threshold + void UpdateImage(); - wxBitmap m_bmpOrig; - wxBitmap m_bmpScaled; - IManager *m_mgr; - wxString m_pathimage; - wxString m_pathproject; - LineParserList m_lines; - ConfCallGraph confData; // stored configuration data - wxPoint m_viewPortOrigin; - wxPoint m_startigPoint; - float m_scale; + wxBitmap m_bmpOrig; + wxBitmap m_bmpScaled; + IManager* m_mgr; + wxString m_pathimage; + wxString m_pathproject; + LineParserList m_lines; + ConfCallGraph confData; // stored configuration data + wxPoint m_viewPortOrigin; + wxPoint m_startigPoint; + float m_scale; }; #endif // UICALLGRAPHPANEL_H diff --git a/CallGraph/uisettingsdlg.cpp b/CallGraph/uisettingsdlg.cpp index 17f6209b1d..57f07c1628 100644 --- a/CallGraph/uisettingsdlg.cpp +++ b/CallGraph/uisettingsdlg.cpp @@ -23,15 +23,17 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#include "imanager.h" -#include "callgraph.h" #include "uisettingsdlg.h" -#include + +#include "callgraph.h" +#include "imanager.h" #include "windowattrmanager.h" +#include + uisettingsdlg::uisettingsdlg(wxWindow* parent, IManager* mgr) //, CallGraph *plugin ) - : uisettings(parent), - m_mgr(mgr) + : uisettings(parent) + , m_mgr(mgr) { // ConfCallGraph confData; // read last stored value for paths gprof and dot @@ -46,8 +48,10 @@ uisettingsdlg::uisettingsdlg(wxWindow* parent, IManager* mgr) //, CallGraph *plu m_checkBox_Parameters->SetValue(confData.GetStripParams()); m_checkBox_Namespaces->SetValue(confData.GetHideNamespaces()); // - if(m_checkBox_Names->IsChecked()) m_checkBox_Parameters->Disable(); - if(m_checkBox_Parameters->IsChecked()) m_checkBox_Names->Disable(); + if (m_checkBox_Names->IsChecked()) + m_checkBox_Parameters->Disable(); + if (m_checkBox_Parameters->IsChecked()) + m_checkBox_Names->Disable(); // GetSizer()->Fit(this); @@ -65,7 +69,7 @@ void uisettingsdlg::OnButton_click_select_gprof(wxCommandEvent& event) wxFileSelectorDefaultWildcardStr, 0, this); - if(!new_gprof_path.IsEmpty()) { + if (!new_gprof_path.IsEmpty()) { m_textCtrl_path_gprof->SetValue(new_gprof_path); } } @@ -80,7 +84,7 @@ void uisettingsdlg::OnButton_click_select_dot(wxCommandEvent& event) wxFileSelectorDefaultWildcardStr, 0, this); - if(!new_dot_path.IsEmpty()) { + if (!new_dot_path.IsEmpty()) { m_textCtrl_path_dot->SetValue(new_dot_path); } } @@ -102,7 +106,7 @@ void uisettingsdlg::OnButton_click_ok(wxCommandEvent& event) m_mgr->GetConfigTool()->WriteObject(wxT("CallGraph"), &confData); - if((wxFileExists(m_textCtrl_path_gprof->GetValue())) && (wxFileExists(m_textCtrl_path_dot->GetValue()))) { + if ((wxFileExists(m_textCtrl_path_gprof->GetValue())) && (wxFileExists(m_textCtrl_path_dot->GetValue()))) { EndModal(wxID_OK); } else { wxMessageBox(_("Please check the external tools' paths settings."), @@ -122,7 +126,7 @@ void uisettingsdlg::OnButton_click_cancel(wxCommandEvent& event) void uisettingsdlg::OnCheckName(wxCommandEvent& event) { - if(m_checkBox_Names->IsChecked()) + if (m_checkBox_Names->IsChecked()) m_checkBox_Parameters->Disable(); else m_checkBox_Parameters->Enable(); @@ -130,7 +134,7 @@ void uisettingsdlg::OnCheckName(wxCommandEvent& event) void uisettingsdlg::OnCheckParam(wxCommandEvent& event) { - if(m_checkBox_Parameters->IsChecked()) + if (m_checkBox_Parameters->IsChecked()) m_checkBox_Names->Disable(); else m_checkBox_Names->Enable(); diff --git a/CallGraph/uisettingsdlg.h b/CallGraph/uisettingsdlg.h index f271773301..2677e7c641 100644 --- a/CallGraph/uisettingsdlg.h +++ b/CallGraph/uisettingsdlg.h @@ -28,7 +28,7 @@ * Purpose: Header to create settings dialog for plugin. * Author: Václav Špruček * Created: 2012-03-04 - * Copyright: Václav Špruček + * Copyright: Václav Špruček * License: wxWidgets license (www.wxwidgets.org) * Notes: **************************************************************/ @@ -39,31 +39,31 @@ #include "confcallgraph.h" #include "uisettings.h" -#include #include +#include class IManager; -//class CallGraph; +// class CallGraph; class uisettingsdlg : public uisettings { - IManager *m_mgr; - //CallGraph *m_mplugin; - + IManager* m_mgr; + // CallGraph *m_mplugin; + protected: - // Handlers for FormBuildSettingsBaseDlg events. - void OnButton_click_select_gprof( wxCommandEvent& event ); - void OnButton_click_select_dot( wxCommandEvent& event ); - void OnButton_click_ok( wxCommandEvent& event ); - void OnButton_click_cancel( wxCommandEvent& event ); - void OnCheckName( wxCommandEvent& event ); - void OnCheckParam( wxCommandEvent& event ); - // - ConfCallGraph confData; - + // Handlers for FormBuildSettingsBaseDlg events. + void OnButton_click_select_gprof(wxCommandEvent& event); + void OnButton_click_select_dot(wxCommandEvent& event); + void OnButton_click_ok(wxCommandEvent& event); + void OnButton_click_cancel(wxCommandEvent& event); + void OnCheckName(wxCommandEvent& event); + void OnCheckParam(wxCommandEvent& event); + // + ConfCallGraph confData; + public: - /** Constructor */ - uisettingsdlg( wxWindow* parent, IManager *mgr);//, CallGraph *plugin ); + /** Constructor */ + uisettingsdlg(wxWindow* parent, IManager* mgr); //, CallGraph *plugin ); virtual ~uisettingsdlg() = default; }; diff --git a/CodeFormatter/CodeFormatterManager.cpp b/CodeFormatter/CodeFormatterManager.cpp index 8b63ef3fd1..d71affb045 100644 --- a/CodeFormatter/CodeFormatterManager.cpp +++ b/CodeFormatter/CodeFormatterManager.cpp @@ -59,14 +59,14 @@ wxArrayString CodeFormatterManager::GetAllNames() const void CodeFormatterManager::Load() { - wxFileName config_file{ clStandardPaths::Get().GetUserDataDir(), "code-formatters.json" }; + wxFileName config_file{clStandardPaths::Get().GetUserDataDir(), "code-formatters.json"}; config_file.AppendDir("config"); if (!config_file.FileExists()) { return; } - JSON root{ config_file }; + JSON root{config_file}; if (!root.isOk() || !root.toElement().isArray()) { initialize_defaults(); return; @@ -84,7 +84,7 @@ void CodeFormatterManager::Load() void CodeFormatterManager::Save() { - wxFileName config_file{ clStandardPaths::Get().GetUserDataDir(), "code-formatters.json" }; + wxFileName config_file{clStandardPaths::Get().GetUserDataDir(), "code-formatters.json"}; config_file.AppendDir("config"); JSON root{JsonType::Array}; auto arr = root.toElement(); diff --git a/CodeFormatter/FormatterPage.cpp b/CodeFormatter/FormatterPage.cpp index 09bc266af6..a19a97a04e 100644 --- a/CodeFormatter/FormatterPage.cpp +++ b/CodeFormatter/FormatterPage.cpp @@ -7,7 +7,7 @@ [this](const wxString& label, const wxAny& value) { \ wxUnusedVar(label); \ wxString str_value; \ - if(value.GetAs(&str_value)) { \ + if (value.GetAs(&str_value)) { \ m_cur_formatter->SETTER_METHOD(str_value); \ } \ } @@ -16,7 +16,7 @@ [this](const wxString& label, const wxAny& value) { \ wxUnusedVar(label); \ bool bool_value; \ - if(value.GetAs(&bool_value)) { \ + if (value.GetAs(&bool_value)) { \ m_cur_formatter->SETTER_METHOD(bool_value); \ } \ } @@ -25,7 +25,7 @@ [this](const wxString& label, const wxAny& value) { \ wxUnusedVar(label); \ wxString str_value; \ - if(value.GetAs(&str_value)) { \ + if (value.GetAs(&str_value)) { \ m_cur_formatter->SetLanguages(wxStringTokenize(str_value, ";", wxTOKEN_STRTOK)); \ } \ } diff --git a/CodeFormatter/GenericFormatter.cpp b/CodeFormatter/GenericFormatter.cpp index 6b7430f807..34240f2e3d 100644 --- a/CodeFormatter/GenericFormatter.cpp +++ b/CodeFormatter/GenericFormatter.cpp @@ -93,9 +93,9 @@ wxString GenericFormatter::GetCommandAsString() const { return join_array(m_comm bool GenericFormatter::SyncFormat(const wxString& cmd, const wxString& wd, bool inplace_formatter, wxString* output) { // save the current directory - clDirChanger cd{ wd }; + clDirChanger cd{wd}; auto envlist = CreateLocalEnv(); - EnvSetter setter{ envlist.get() }; + EnvSetter setter{envlist.get()}; bool res = ProcUtils::ShellExecSync(cmd, output) == 0; if (inplace_formatter) { output->clear(); @@ -106,18 +106,18 @@ bool GenericFormatter::SyncFormat(const wxString& cmd, const wxString& wd, bool /** * @brief format source file using background thread, when the formatting is done, fire an event to the sink object */ -void GenericFormatter::AsyncFormat(const wxString& cmd, const wxString& wd, const wxString& filepath, - bool inplace_formatter, wxEvtHandler* sink) +void GenericFormatter::AsyncFormat( + const wxString& cmd, const wxString& wd, const wxString& filepath, bool inplace_formatter, wxEvtHandler* sink) { - clDirChanger cd{ wd }; + clDirChanger cd{wd}; // Apply environment auto envlist = CreateLocalEnv(); - EnvSetter setter{ envlist.get() }; + EnvSetter setter{envlist.get()}; long pid = wxNOT_FOUND; if (ProcUtils::ShellExecAsync(cmd, &pid, this)) { - m_pid_commands.insert({ pid, CommandMetadata{ cmd, filepath, sink } }); + m_pid_commands.insert({pid, CommandMetadata{cmd, filepath, sink}}); } } @@ -162,7 +162,7 @@ bool GenericFormatter::FormatRemoteFile(const wxString& filepath, wxEvtHandler* clDEBUG() << "Calling:" << cmd << endl; clSFTPManager::Get().AsyncExecute(this, clRemoteHost::Instance()->GetActiveAccount(), cmd, wd, nullptr); - m_inFlightFiles.push_back({ filepath, sink }); + m_inFlightFiles.push_back({filepath, sink}); #else wxUnusedVar(filepath); wxUnusedVar(sink); @@ -186,7 +186,7 @@ bool GenericFormatter::FormatString(const wxString& content, const wxString& ful fullpath_linux_style.Replace("\\", "/"); wxString dirpart = fullpath_linux_style.BeforeLast('/'); - clTempFile tmpfile{ dirpart, "txt" }; + clTempFile tmpfile{dirpart, "txt"}; if (!tmpfile.Write(content)) { clWARNING() << "failed to write content to temp file:" << tmpfile.GetFullPath() << endl; @@ -256,8 +256,8 @@ void GenericFormatter::OnAsyncShellProcessTerminated(clShellProcessEvent& event) // notify the sink that formatting is done if (command_data.m_sink) { - clSourceFormatEvent format_completed_event{ IsInplaceFormatter() ? wxEVT_FORMAT_INPLACE_COMPELTED - : wxEVT_FORMAT_COMPELTED }; + clSourceFormatEvent format_completed_event{IsInplaceFormatter() ? wxEVT_FORMAT_INPLACE_COMPELTED + : wxEVT_FORMAT_COMPELTED}; format_completed_event.SetFormattedString(IsInplaceFormatter() ? "" : event.GetOutput()); format_completed_event.SetFileName(command_data.m_filepath); command_data.m_sink->QueueEvent(format_completed_event.Clone()); @@ -273,7 +273,7 @@ void GenericFormatter::OnRemoteCommandStdout(clCommandEvent& event) if (!IsInplaceFormatter()) { const wxString& filepath = m_inFlightFiles.front().first; - clSourceFormatEvent format_completed_event{ wxEVT_FORMAT_COMPELTED }; + clSourceFormatEvent format_completed_event{wxEVT_FORMAT_COMPELTED}; format_completed_event.SetFormattedString(wxString::FromUTF8(event.GetStringRaw())); format_completed_event.SetFileName(filepath); m_inFlightFiles.front().second->AddPendingEvent(format_completed_event); @@ -297,7 +297,7 @@ void GenericFormatter::OnRemoteCommandDone(clCommandEvent& event) auto sink = m_inFlightFiles.front().second; if (IsInplaceFormatter()) { const wxString& filepath = m_inFlightFiles.front().first; - clSourceFormatEvent format_completed_event{ wxEVT_FORMAT_INPLACE_COMPELTED }; + clSourceFormatEvent format_completed_event{wxEVT_FORMAT_INPLACE_COMPELTED}; format_completed_event.SetFileName(filepath); sink->AddPendingEvent(format_completed_event); } @@ -316,7 +316,7 @@ void GenericFormatter::OnRemoteCommandError(clCommandEvent& event) std::unique_ptr GenericFormatter::CreateLocalEnv() { - std::unique_ptr env{ new clEnvList_t }; + std::unique_ptr env{new clEnvList_t}; if (clFileSystemWorkspace::Get().IsOpen()) { env.reset(new clEnvList_t(clFileSystemWorkspace::Get().GetEnvironment())); } diff --git a/CodeFormatter/PHPFormatterBuffer.cpp b/CodeFormatter/PHPFormatterBuffer.cpp index 3e2441a888..46f7fc0c07 100644 --- a/CodeFormatter/PHPFormatterBuffer.cpp +++ b/CodeFormatter/PHPFormatterBuffer.cpp @@ -13,7 +13,7 @@ struct PHPScannerCollectWhitespace { , m_oldState(false) { m_userdata = ::phpLexerGetUserData(scanner); - if(m_userdata) { + if (m_userdata) { m_oldState = m_userdata->IsCollectingWhitespace(); m_userdata->SetCollectingWhitespace(true); } @@ -21,7 +21,7 @@ struct PHPScannerCollectWhitespace { ~PHPScannerCollectWhitespace() { - if(m_userdata) { + if (m_userdata) { m_userdata->SetCollectingWhitespace(m_oldState); } } @@ -43,136 +43,136 @@ PHPFormatterBuffer::PHPFormatterBuffer(const wxString& buffer, const PHPFormatte PHPFormatterBuffer::~PHPFormatterBuffer() { - if(m_scanner) { + if (m_scanner) { ::phpLexerDestroy(&m_scanner); } } PHPFormatterBuffer& PHPFormatterBuffer::ProcessToken(const phpLexerToken& token) { - if(::phpLexerIsPHPCode(m_scanner)) { + if (::phpLexerIsPHPCode(m_scanner)) { // Inside PHP tags - if(m_insideHereDoc) { + if (m_insideHereDoc) { m_buffer << token.Text(); - if(token.type == kPHP_T_END_HEREDOC) { + if (token.type == kPHP_T_END_HEREDOC) { AppendEOL(); - if(m_options.flags & kPFF_BreakAfterHeredoc) { + if (m_options.flags & kPFF_BreakAfterHeredoc) { AppendEOL(); } m_insideHereDoc = false; } - } else if(token.type == kPHP_T_OPEN_TAG) { + } else if (token.type == kPHP_T_OPEN_TAG) { m_openTagWithEcho = false; m_buffer << token.Text(); AppendEOL(); - } else if(token.type == kPHP_T_OPEN_TAG_WITH_ECHO) { + } else if (token.type == kPHP_T_OPEN_TAG_WITH_ECHO) { m_openTagWithEcho = true; m_buffer << token.Text() << " "; - } else if(token.type == '{') { + } else if (token.type == '{') { HandleOpenCurlyBrace(); - } else if(token.type == kPHP_T_VARIABLE) { + } else if (token.type == kPHP_T_VARIABLE) { m_buffer << token.Text() << " "; - } else if(token.type == kPHP_T_FOREACH) { + } else if (token.type == kPHP_T_FOREACH) { m_buffer << token.Text() << " "; - if(m_options.flags & kPFF_BreakBeforeForeach) { + if (m_options.flags & kPFF_BreakBeforeForeach) { InsertSeparatorLine(); } - } else if(token.type == kPHP_T_ELSE || token.type == kPHP_T_ELSEIF) { - if(m_options.flags & kPFF_ElseOnSameLineAsClosingCurlyBrace && m_lastToken.type == '}') { + } else if (token.type == kPHP_T_ELSE || token.type == kPHP_T_ELSEIF) { + if (m_options.flags & kPFF_ElseOnSameLineAsClosingCurlyBrace && m_lastToken.type == '}') { ReverseClearUntilFind("}"); m_buffer << " " << token.Text() << " "; } else { m_buffer << token.Text() << " "; } - } else if(token.type == kPHP_T_WHILE) { + } else if (token.type == kPHP_T_WHILE) { m_buffer << token.Text() << " "; - if(m_options.flags & kPFF_BreakBeforeWhile) { + if (m_options.flags & kPFF_BreakBeforeWhile) { InsertSeparatorLine(); } - } else if(token.type == kPHP_T_CLASS || token.type == kPHP_T_ENUM) { - if(m_options.flags & kPFF_BreakBeforeClass) { + } else if (token.type == kPHP_T_CLASS || token.type == kPHP_T_ENUM) { + if (m_options.flags & kPFF_BreakBeforeClass) { InsertSeparatorLine(); } m_buffer << token.Text() << " "; - } else if(token.type == kPHP_T_FUNCTION) { + } else if (token.type == kPHP_T_FUNCTION) { // Found a function m_buffer << token.Text() << " "; - if(m_lastCommentLine != token.lineNumber) { + if (m_lastCommentLine != token.lineNumber) { // this function has no comment associated with it - if(m_options.flags & kPFF_BreakBeforeFunction) { + if (m_options.flags & kPFF_BreakBeforeFunction) { // But don't insert new line separator if this keyword // was found in a statement like: // use function A as B; - if(m_lastToken.type != kPHP_T_USE) { + if (m_lastToken.type != kPHP_T_USE) { // Look backward until we find the last EOL // and insert another one... InsertSeparatorLine(); } } } - } else if(token.type == kPHP_T_START_HEREDOC) { + } else if (token.type == kPHP_T_START_HEREDOC) { RemoveLastSpace(); m_buffer << token.Text(); m_insideHereDoc = true; - } else if(token.type == kPHP_T_FOR) { + } else if (token.type == kPHP_T_FOR) { // for(;;) is a special case where // we don't insert new line after semi-colon m_insideForStatement = true; m_buffer << token.Text(); - } else if(token.type == '(' && m_insideForStatement) { + } else if (token.type == '(' && m_insideForStatement) { m_forDepth++; m_buffer << token.Text(); - } else if(token.type == ')' && m_insideForStatement) { + } else if (token.type == ')' && m_insideForStatement) { m_forDepth--; - if(m_forDepth == 0) { + if (m_forDepth == 0) { m_insideForStatement = false; } m_buffer << token.Text(); - } else if(token.type == '(' || token.type == '[') { + } else if (token.type == '(' || token.type == '[') { RemoveLastSpace(); m_buffer << token.Text(); - if(m_options.flags & kPFF_VerticalArrays && token.type == '(' && m_lastToken.type == kPHP_T_ARRAY && - m_parenDepth == 1) { + if (m_options.flags & kPFF_VerticalArrays && token.type == '(' && m_lastToken.type == kPHP_T_ARRAY && + m_parenDepth == 1) { ProcessArray('(', ')'); } - } else if(token.type == ')') { + } else if (token.type == ')') { RemoveLastSpace(); m_buffer << token.Text(); - } else if(token.type == ']') { + } else if (token.type == ']') { RemoveLastSpace(); m_buffer << token.Text() << " "; - } else if(token.type == ';') { + } else if (token.type == ';') { RemoveLastSpace(); m_buffer << token.Text(); AppendEOL(); - } else if(token.type == '}') { + } else if (token.type == '}') { UnIndent(); m_buffer << token.Text(); AppendEOL(kDepthDec); - } else if(token.type == ',') { + } else if (token.type == ',') { RemoveLastSpace(); m_buffer << token.Text() << " "; - } else if(token.type == '.') { + } else if (token.type == '.') { m_buffer << token.Text() << " "; - if(m_options.flags & kPFF_BreakAfterStringConcatentation && (m_parenDepth == 1)) { + if (m_options.flags & kPFF_BreakAfterStringConcatentation && (m_parenDepth == 1)) { // inside a function call wxString whitespace = GetIndentationToLast('('); if (!whitespace.IsEmpty()) { @@ -180,22 +180,22 @@ PHPFormatterBuffer& PHPFormatterBuffer::ProcessToken(const phpLexerToken& token) m_buffer << whitespace; } } - } else if(token.type == '&') { + } else if (token.type == '&') { // attach reference to the next token m_buffer << token.Text(); - } else if(token.type == kPHP_T_CXX_COMMENT) { + } else if (token.type == kPHP_T_CXX_COMMENT) { // C++ style comment ("//") // AppendEOL(); m_buffer << token.Text(); AppendEOL(); m_lastCommentLine = token.lineNumber + 1; - } else if(token.type == kPHP_T_C_COMMENT) { + } else if (token.type == kPHP_T_C_COMMENT) { // Doxygen style comment: we first format it to match // the current indentation + line ending before adding // it to the current buffer - if(m_parenDepth == 0) { + if (m_parenDepth == 0) { AppendEOL(); m_buffer << FormatDoxyComment(token.Text()); AppendEOL(); @@ -204,17 +204,17 @@ PHPFormatterBuffer& PHPFormatterBuffer::ProcessToken(const phpLexerToken& token) m_buffer << token.Text() << " "; } - } else if(token.type == kPHP_T_OBJECT_OPERATOR || token.type == kPHP_T_PAAMAYIM_NEKUDOTAYIM) { + } else if (token.type == kPHP_T_OBJECT_OPERATOR || token.type == kPHP_T_PAAMAYIM_NEKUDOTAYIM) { // -> operator or :: RemoveLastSpace(); m_buffer << token.Text(); - } else if(token.type == '!') { + } else if (token.type == '!') { // don't add extra space after the NOT operator m_buffer << token.Text(); - } else if(token.type == kPHP_T_NS_SEPARATOR) { - if(m_lastToken.type == kPHP_T_IDENTIFIER) { + } else if (token.type == kPHP_T_NS_SEPARATOR) { + if (m_lastToken.type == kPHP_T_IDENTIFIER) { RemoveLastSpace(); } m_buffer << token.Text(); @@ -226,7 +226,7 @@ PHPFormatterBuffer& PHPFormatterBuffer::ProcessToken(const phpLexerToken& token) m_lastToken = token; } else { - if(token.type == kPHP_T_CLOSE_TAG && !m_openTagWithEcho) { + if (token.type == kPHP_T_CLOSE_TAG && !m_openTagWithEcho) { AppendEOL(); } m_buffer << token.Text(); @@ -244,10 +244,10 @@ void PHPFormatterBuffer::HandleOpenCurlyBrace() void PHPFormatterBuffer::AppendEOL(eDepthCommand depth) { m_buffer << m_options.eol; - switch(depth) { + switch (depth) { case kDepthDec: --m_depth; - if(m_depth < 0) + if (m_depth < 0) m_depth = 0; break; case kDepthIncTemporarily: @@ -258,9 +258,9 @@ void PHPFormatterBuffer::AppendEOL(eDepthCommand depth) break; } m_buffer << GetIndent(); - if(kDepthIncTemporarily == depth) { + if (kDepthIncTemporarily == depth) { --m_depth; - if(m_depth < 0) + if (m_depth < 0) m_depth = 0; } } @@ -268,31 +268,31 @@ void PHPFormatterBuffer::AppendEOL(eDepthCommand depth) void PHPFormatterBuffer::UnIndent() { - if(IsUseTabs() && !m_buffer.IsEmpty() && m_buffer.Last() == '\t') { + if (IsUseTabs() && !m_buffer.IsEmpty() && m_buffer.Last() == '\t') { m_buffer.RemoveLast(); - } else if(!IsUseTabs() && (m_buffer.length() >= m_options.indentSize) && - m_buffer.Mid(m_buffer.length() - m_options.indentSize) == wxString(' ', m_options.indentSize)) { + } else if (!IsUseTabs() && (m_buffer.length() >= m_options.indentSize) && + m_buffer.Mid(m_buffer.length() - m_options.indentSize) == wxString(' ', m_options.indentSize)) { m_buffer.RemoveLast(m_options.indentSize); } } void PHPFormatterBuffer::RemoveLastSpace() { - if(!m_buffer.IsEmpty() && m_buffer.Last() == ' ') { + if (!m_buffer.IsEmpty() && m_buffer.Last() == ' ') { m_buffer.RemoveLast(); } } wxString PHPFormatterBuffer::FormatDoxyComment(const wxString& comment) { - if(m_parenDepth == 0) { + if (m_parenDepth == 0) { wxString formattedBlock; wxString indent = GetIndent(); wxArrayString lines = ::wxStringTokenize(comment, "\n", wxTOKEN_STRTOK); - for(size_t i = 0; i < lines.GetCount(); ++i) { + for (size_t i = 0; i < lines.GetCount(); ++i) { lines.Item(i).Trim().Trim(false); - if(i) { + if (i) { // prepend space + the indent string for every line except for the first line lines.Item(i).Prepend(" "); lines.Item(i).Prepend(indent); @@ -308,7 +308,7 @@ wxString PHPFormatterBuffer::FormatDoxyComment(const wxString& comment) } wxString& PHPFormatterBuffer::GetIndent() { - if(IsUseTabs()) { + if (IsUseTabs()) { m_indentString = wxString('\t', m_depth); } else { m_indentString = wxString(' ', m_depth * m_options.indentSize); @@ -319,7 +319,7 @@ wxString& PHPFormatterBuffer::GetIndent() void PHPFormatterBuffer::InsertSeparatorLine() { size_t where = m_buffer.rfind(m_options.eol); - if(where != wxString::npos) { + if (where != wxString::npos) { m_buffer.insert(where, m_options.eol); } } @@ -327,7 +327,7 @@ void PHPFormatterBuffer::InsertSeparatorLine() void PHPFormatterBuffer::ReverseClearUntilFind(const wxString& delim) { size_t where = m_buffer.rfind(delim); - if(where != wxString::npos) { + if (where != wxString::npos) { m_buffer = m_buffer.Mid(0, where + delim.length()); } } @@ -338,9 +338,9 @@ void PHPFormatterBuffer::format() phpLexerToken::Vet_t sequence; m_stack.push(sequence); m_sequence = &m_stack.top(); - while(NextToken(token)) { + while (NextToken(token)) { phpLexerToken nextToken; - if(::phpLexerIsPHPCode(m_scanner)) { + if (::phpLexerIsPHPCode(m_scanner)) { ProcessToken(token); // @@ -358,35 +358,36 @@ void PHPFormatterBuffer::format() // // - if(token.type == '(') { + if (token.type == '(') { // Create new stack m_stack.push(phpLexerToken::Vet_t()); m_sequence = &m_stack.top(); } - if(token.type == ')') { + if (token.type == ')') { // switch back to the previous sequence - if(m_stack.size() >= 2) { + if (m_stack.size() >= 2) { m_stack.pop(); m_sequence = &m_stack.top(); } - if(!m_sequence->empty()) { + if (!m_sequence->empty()) { phpLexerToken lastToken = m_sequence->at(m_sequence->size() - 1); // The following tokens are usually followed by an open brace - if(lastToken.type == kPHP_T_IF || lastToken.type == kPHP_T_FOR || lastToken.type == kPHP_T_ELSEIF || - lastToken.type == kPHP_T_FOREACH || lastToken.type == kPHP_T_WHILE) { + if (lastToken.type == kPHP_T_IF || lastToken.type == kPHP_T_FOR || + lastToken.type == kPHP_T_ELSEIF || lastToken.type == kPHP_T_FOREACH || + lastToken.type == kPHP_T_WHILE) { // Peek at the next char - if(PeekToken(nextToken)) { - if(nextToken.type != '{' && !nextToken.IsAnyComment()) { + if (PeekToken(nextToken)) { + if (nextToken.type != '{' && !nextToken.IsAnyComment()) { // Increase the depth but only temporarily for the next statement AppendEOL(kDepthIncTemporarily); } } } } - } else if(token.type == kPHP_T_ELSE) { + } else if (token.type == kPHP_T_ELSE) { // Check for 'else ' (without an open curly braces) - if(PeekToken(nextToken) && nextToken.type != '{' && nextToken.type != kPHP_T_IF) { + if (PeekToken(nextToken) && nextToken.type != '{' && nextToken.type != kPHP_T_IF) { AppendEOL(kDepthIncTemporarily); } @@ -401,11 +402,11 @@ void PHPFormatterBuffer::format() bool PHPFormatterBuffer::NextToken(phpLexerToken& token) { - if(m_tokensBuffer.empty()) { + if (m_tokensBuffer.empty()) { bool res = ::phpLexerNext(m_scanner, token); - if(token.type == '(') { + if (token.type == '(') { ++m_parenDepth; - } else if(token.type == ')') { + } else if (token.type == ')') { --m_parenDepth; } return res; @@ -419,7 +420,7 @@ bool PHPFormatterBuffer::NextToken(phpLexerToken& token) bool PHPFormatterBuffer::PeekToken(phpLexerToken& token) { - if(!::phpLexerNext(m_scanner, token)) + if (!::phpLexerNext(m_scanner, token)) return false; m_tokensBuffer.push_back(token); return true; @@ -429,9 +430,9 @@ wxString PHPFormatterBuffer::GetIndentationToLast(wxChar ch) { wxString whitespace; wxString workingBuffer = m_buffer; - if(ch != '\n') { + if (ch != '\n') { int startPos = m_buffer.Find(ch, true); - if(startPos != wxNOT_FOUND) { + if (startPos != wxNOT_FOUND) { workingBuffer = m_buffer.Mid(0, startPos + 1); } else { return GetIndent(); @@ -440,11 +441,11 @@ wxString PHPFormatterBuffer::GetIndentationToLast(wxChar ch) int where = workingBuffer.Find('\n', true); // did we find our match on the previous line? - if(where != wxNOT_FOUND) { + if (where != wxNOT_FOUND) { // Build the whitespace wxString buff = workingBuffer.Mid(where + 1); - while(!buff.IsEmpty()) { - if(buff.at(0) == '\t') { + while (!buff.IsEmpty()) { + if (buff.at(0) == '\t') { // replace tab with 4 spaces whitespace << wxString(' ', m_options.indentSize); } else { @@ -454,7 +455,7 @@ wxString PHPFormatterBuffer::GetIndentationToLast(wxChar ch) } } - if(m_options.flags & kPFF_UseTabs) { + if (m_options.flags & kPFF_UseTabs) { int tabsCount = (whitespace.length() / m_options.indentSize); int extraSpaces = (whitespace.length() % m_options.indentSize); whitespace.clear(); @@ -474,30 +475,30 @@ void PHPFormatterBuffer::ProcessArray(int openParen, int closingChar) phpLexerToken token; // PHPScannerCollectWhitespace whitespaceCollector(m_scanner); - while(NextToken(token)) { - if(::phpLexerIsPHPCode(m_scanner)) { + while (NextToken(token)) { + if (::phpLexerIsPHPCode(m_scanner)) { // inside PHP block - if(token.type == openParen) { + if (token.type == openParen) { ++depth; RemoveLastSpace(); m_buffer << token.Text(); - } else if(token.type == closingChar) { + } else if (token.type == closingChar) { --depth; RemoveLastSpace(); m_buffer << token.Text(); - if(depth == 0) + if (depth == 0) break; - } else if(token.type == ',') { + } else if (token.type == ',') { // New line RemoveLastSpace(); m_buffer << token.Text(); m_buffer << m_options.eol; m_buffer << whitespace; - } else if(token.type == '(' || token.type == ')' || token.type == kPHP_T_OBJECT_OPERATOR || - token.type == kPHP_T_PAAMAYIM_NEKUDOTAYIM || token.type == kPHP_T_NS_SEPARATOR || - token.type == kPHP_T_VARIABLE || token.type == '[' || token.type == ']') { + } else if (token.type == '(' || token.type == ')' || token.type == kPHP_T_OBJECT_OPERATOR || + token.type == kPHP_T_PAAMAYIM_NEKUDOTAYIM || token.type == kPHP_T_NS_SEPARATOR || + token.type == kPHP_T_VARIABLE || token.type == '[' || token.type == ']') { RemoveLastSpace(); m_buffer << token.Text(); @@ -507,7 +508,7 @@ void PHPFormatterBuffer::ProcessArray(int openParen, int closingChar) } else { // Non PHP code, copy text as is - if(token.type == kPHP_T_CLOSE_TAG && !m_openTagWithEcho) { + if (token.type == kPHP_T_CLOSE_TAG && !m_openTagWithEcho) { AppendEOL(); } m_buffer << token.Text(); diff --git a/CodeFormatter/fmtBlack.cpp b/CodeFormatter/fmtBlack.cpp index 7b082c3477..906cd49f48 100644 --- a/CodeFormatter/fmtBlack.cpp +++ b/CodeFormatter/fmtBlack.cpp @@ -5,14 +5,14 @@ fmtBlack::fmtBlack() { SetName("black"); - SetFileTypes({ FileExtManager::TypePython }); + SetFileTypes({FileExtManager::TypePython}); SetDescription(_("The uncompromising python code formatter")); SetShortDescription(_("black - a python formatter")); SetConfigFilepath(wxEmptyString); SetInplaceFormatter(true); // local command - const auto black_exe = ThePlatform->WhichWithVersion("black", { 20, 19, 18, 17, 16, 15, 14, 13, 12 }); - SetCommand({ black_exe.value_or("black"), "--line-length", "80", R"#("$(CurrentFileRelPath)")#" }); + const auto black_exe = ThePlatform->WhichWithVersion("black", {20, 19, 18, 17, 16, 15, 14, 13, 12}); + SetCommand({black_exe.value_or("black"), "--line-length", "80", R"#("$(CurrentFileRelPath)")#"}); SetEnabled(black_exe.has_value()); } diff --git a/CodeFormatter/fmtCMakeFormat.cpp b/CodeFormatter/fmtCMakeFormat.cpp index 5140feb8cc..5faae24d82 100644 --- a/CodeFormatter/fmtCMakeFormat.cpp +++ b/CodeFormatter/fmtCMakeFormat.cpp @@ -5,7 +5,7 @@ fmtCMakeFormat::fmtCMakeFormat() { SetName("cmake-format"); - SetFileTypes({ FileExtManager::TypeCMake }); + SetFileTypes({FileExtManager::TypeCMake}); SetDescription(_("Parse cmake listfiles and format them nicely")); SetShortDescription(_("cmake-format - a CMake formatter")); SetConfigFilepath("$(WorkspacePath)/.cmake-format"); @@ -13,6 +13,7 @@ fmtCMakeFormat::fmtCMakeFormat() // local command const auto cmake_format = ThePlatform->Which("cmake-format"); - SetCommand({ cmake_format.value_or("cmake-format"), R"#(--line-width=120 --tab-size=4 -i "$(CurrentFileFullPath)")#" }); + SetCommand( + {cmake_format.value_or("cmake-format"), R"#(--line-width=120 --tab-size=4 -i "$(CurrentFileFullPath)")#"}); SetEnabled(cmake_format.has_value()); } diff --git a/CodeFormatter/fmtJQ.cpp b/CodeFormatter/fmtJQ.cpp index f9d50ca3f3..aac98f95ed 100644 --- a/CodeFormatter/fmtJQ.cpp +++ b/CodeFormatter/fmtJQ.cpp @@ -7,14 +7,17 @@ fmtJQ::fmtJQ() SetName("jq"); // handle all known JSON files - SetFileTypes({ FileExtManager::TypeJSON, FileExtManager::TypeWorkspaceFileSystem, - FileExtManager::TypeWorkspaceDocker, FileExtManager::TypeWxCrafter, - FileExtManager::TypeWorkspaceNodeJS, FileExtManager::TypeWorkspacePHP }); + SetFileTypes({FileExtManager::TypeJSON, + FileExtManager::TypeWorkspaceFileSystem, + FileExtManager::TypeWorkspaceDocker, + FileExtManager::TypeWxCrafter, + FileExtManager::TypeWorkspaceNodeJS, + FileExtManager::TypeWorkspacePHP}); SetDescription(_("commandline JSON processor")); SetShortDescription(_("jq - a json formatter")); const auto jq_exe = ThePlatform->Which("jq"); - SetCommand({ jq_exe.value_or("jq"), ".", "-S", R"#("$(CurrentFileRelPath)")#" }); + SetCommand({jq_exe.value_or("jq"), ".", "-S", R"#("$(CurrentFileRelPath)")#"}); SetEnabled(jq_exe.has_value()); } diff --git a/CodeFormatter/fmtPHPCBF.cpp b/CodeFormatter/fmtPHPCBF.cpp index fae7ca4cc4..a617f48311 100644 --- a/CodeFormatter/fmtPHPCBF.cpp +++ b/CodeFormatter/fmtPHPCBF.cpp @@ -5,13 +5,13 @@ fmtPHPCBF::fmtPHPCBF() { SetName("PHPCBF"); - SetFileTypes({ FileExtManager::TypePhp }); + SetFileTypes({FileExtManager::TypePhp}); SetDescription(_("PHP Code Beautifier and Fixer")); SetShortDescription(_("PHP formatter")); SetInplaceFormatter(true); SetEnabled(false); const auto php_exe = ThePlatform->Which("php"); - SetCommand({ php_exe.value_or("php"), "$(WorkspacePath)/vendor/bin/phpcbf", "-q", R"#("$(CurrentFileRelPath)")#" }); + SetCommand({php_exe.value_or("php"), "$(WorkspacePath)/vendor/bin/phpcbf", "-q", R"#("$(CurrentFileRelPath)")#"}); SetEnabled(php_exe.has_value()); } diff --git a/CodeFormatter/fmtPHPCSFixer.cpp b/CodeFormatter/fmtPHPCSFixer.cpp index c504482c08..274ca2da73 100644 --- a/CodeFormatter/fmtPHPCSFixer.cpp +++ b/CodeFormatter/fmtPHPCSFixer.cpp @@ -5,7 +5,7 @@ fmtPHPCSFixer::fmtPHPCSFixer() { SetName("PHP-CS-Fixer"); - SetFileTypes({ FileExtManager::TypePhp }); + SetFileTypes({FileExtManager::TypePhp}); SetDescription(_("The PHP Coding Standards Fixer")); SetShortDescription(_("PHP formatter")); SetInplaceFormatter(true); @@ -13,10 +13,10 @@ fmtPHPCSFixer::fmtPHPCSFixer() SetConfigFilepath("$(WorkspacePath)/.php-cs-fixer.dist.php"); const auto php_exe = ThePlatform->Which("php"); - SetCommand({ php_exe.value_or("php"), - "$(WorkspacePath)/tools/php-cs-fixer/vendor/bin/php-cs-fixer", - "fix", - "--quiet", - R"#("$(CurrentFileRelPath)")#" }); + SetCommand({php_exe.value_or("php"), + "$(WorkspacePath)/tools/php-cs-fixer/vendor/bin/php-cs-fixer", + "fix", + "--quiet", + R"#("$(CurrentFileRelPath)")#"}); SetEnabled(php_exe.has_value()); } diff --git a/CodeFormatter/fmtRustfmt.cpp b/CodeFormatter/fmtRustfmt.cpp index 5aae6b1cb6..50de6ff882 100644 --- a/CodeFormatter/fmtRustfmt.cpp +++ b/CodeFormatter/fmtRustfmt.cpp @@ -5,7 +5,7 @@ fmtRustfmt::fmtRustfmt() { SetName("rustfmt"); - SetFileTypes({ FileExtManager::TypeRust }); + SetFileTypes({FileExtManager::TypeRust}); SetDescription(_("Format Rust code")); SetShortDescription(_("Rust formatter")); SetInplaceFormatter(true); @@ -13,6 +13,6 @@ fmtRustfmt::fmtRustfmt() // local command const auto rustfmt_exe = ThePlatform->Which("rustfmt"); - SetCommand({ rustfmt_exe.value_or("rustfmt"), "--edition", "2021", R"#("$(CurrentFileRelPath)")#" }); + SetCommand({rustfmt_exe.value_or("rustfmt"), "--edition", "2021", R"#("$(CurrentFileRelPath)")#"}); SetEnabled(rustfmt_exe.has_value()); } diff --git a/CodeFormatter/fmtXmlLint.cpp b/CodeFormatter/fmtXmlLint.cpp index 54edabfd55..8cc9732601 100644 --- a/CodeFormatter/fmtXmlLint.cpp +++ b/CodeFormatter/fmtXmlLint.cpp @@ -5,10 +5,10 @@ fmtXmlLint::fmtXmlLint() { SetName("xmllint"); - SetFileTypes({ FileExtManager::TypeXRC, FileExtManager::TypeXml }); + SetFileTypes({FileExtManager::TypeXRC, FileExtManager::TypeXml}); SetDescription(_("xmllint - command line XML tool")); SetShortDescription(_("Xml formatter")); const auto xml_lint_exe = ThePlatform->Which("xmllint"); - SetCommand({ xml_lint_exe.value_or("xmllint"), "--format", R"#("$(CurrentFileRelPath)")#" }); + SetCommand({xml_lint_exe.value_or("xmllint"), "--format", R"#("$(CurrentFileRelPath)")#"}); SetEnabled(xml_lint_exe.has_value()); } diff --git a/CodeFormatter/fmtYQ.cpp b/CodeFormatter/fmtYQ.cpp index 48e5a8bf95..51b8bd67e1 100644 --- a/CodeFormatter/fmtYQ.cpp +++ b/CodeFormatter/fmtYQ.cpp @@ -9,12 +9,12 @@ fmtYQ::fmtYQ() SetName("yq"); // handle all known JSON files - SetFileTypes({ FileExtManager::TypeYAML }); + SetFileTypes({FileExtManager::TypeYAML}); SetDescription(_("commandline YAML processor")); SetShortDescription(_("Yaml formatter")); const auto yq_exe = ThePlatform->Which("yq"); - SetCommand({ yq_exe.value_or("yq"), ".", R"#("$(CurrentFileRelPath)")#" }); + SetCommand({yq_exe.value_or("yq"), ".", R"#("$(CurrentFileRelPath)")#"}); SetEnabled(yq_exe.has_value()); } diff --git a/CodeLiteDiff/NewFileComparison.cpp b/CodeLiteDiff/NewFileComparison.cpp index c42e51f998..17cf54efe2 100644 --- a/CodeLiteDiff/NewFileComparison.cpp +++ b/CodeLiteDiff/NewFileComparison.cpp @@ -1,10 +1,12 @@ #include "NewFileComparison.h" -#include -#include -#include "ieditor.h" + #include "globals.h" +#include "ieditor.h" #include "imanager.h" +#include +#include + NewFileComparison::NewFileComparison(wxWindow* parent, const wxFileName& leftFile) : NewFileComparisonBase(parent) { @@ -12,7 +14,7 @@ NewFileComparison::NewFileComparison(wxWindow* parent, const wxFileName& leftFil clGetManager()->GetAllEditors(editors); m_textCtrlLeftFile->ChangeValue(leftFile.GetFullPath()); for (IEditor* editor : editors) { - if(editor->GetFileName() != leftFile) { + if (editor->GetFileName() != leftFile) { m_listBox16->Append(editor->GetFileName().GetFullPath()); } } @@ -22,10 +24,10 @@ void NewFileComparison::OnBrowse(wxCommandEvent& event) { static wxString lastPath; wxString initialPath; - m_textCtrlFileName->IsEmpty() ? initialPath = lastPath : initialPath = - wxFileName(m_textCtrlFileName->GetValue()).GetPath(); + m_textCtrlFileName->IsEmpty() ? initialPath = lastPath + : initialPath = wxFileName(m_textCtrlFileName->GetValue()).GetPath(); wxString file = wxFileSelector(_("Select file:"), initialPath); - if(!file.IsEmpty()) { + if (!file.IsEmpty()) { wxFileName selectedFile(file); lastPath = selectedFile.GetPath(); m_textCtrlFileName->ChangeValue(selectedFile.GetFullPath()); diff --git a/CodeLiteDiff/NewFileComparison.h b/CodeLiteDiff/NewFileComparison.h index 2ecace31c5..741e494b21 100644 --- a/CodeLiteDiff/NewFileComparison.h +++ b/CodeLiteDiff/NewFileComparison.h @@ -1,6 +1,7 @@ #ifndef NEWFILECOMPARISON_H #define NEWFILECOMPARISON_H #include "CodeLiteDiff_UI.h" + #include class NewFileComparison : public NewFileComparisonBase diff --git a/CodeLiteDiff/codelitediff.h b/CodeLiteDiff/codelitediff.h index 1dfa691a84..63e2676657 100644 --- a/CodeLiteDiff/codelitediff.h +++ b/CodeLiteDiff/codelitediff.h @@ -26,8 +26,9 @@ #ifndef __CodeLiteDiff__ #define __CodeLiteDiff__ -#include "plugin.h" #include "cl_command_event.h" +#include "plugin.h" + #include class CodeLiteDiff : public IPlugin diff --git a/ContinuousBuild/continuousbuild.cpp b/ContinuousBuild/continuousbuild.cpp index 39c1c4573c..2db96161b4 100644 --- a/ContinuousBuild/continuousbuild.cpp +++ b/ContinuousBuild/continuousbuild.cpp @@ -38,10 +38,7 @@ #include "workspace.h" // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new ContinuousBuild(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new ContinuousBuild(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -71,10 +68,10 @@ ContinuousBuild::ContinuousBuild(IManager* manager) m_topWin = m_mgr->GetTheApp(); EventNotifier::Get()->Connect(wxEVT_FILE_SAVED, clCommandEventHandler(ContinuousBuild::OnFileSaved), NULL, this); - EventNotifier::Get()->Connect(wxEVT_FILE_SAVE_BY_BUILD_START, - wxCommandEventHandler(ContinuousBuild::OnIgnoreFileSaved), NULL, this); - EventNotifier::Get()->Connect(wxEVT_FILE_SAVE_BY_BUILD_END, - wxCommandEventHandler(ContinuousBuild::OnStopIgnoreFileSaved), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_FILE_SAVE_BY_BUILD_START, wxCommandEventHandler(ContinuousBuild::OnIgnoreFileSaved), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_FILE_SAVE_BY_BUILD_END, wxCommandEventHandler(ContinuousBuild::OnStopIgnoreFileSaved), NULL, this); Bind(wxEVT_ASYNC_PROCESS_OUTPUT, &ContinuousBuild::OnBuildProcessOutput, this); Bind(wxEVT_ASYNC_PROCESS_TERMINATED, &ContinuousBuild::OnBuildProcessEnded, this); } @@ -96,16 +93,16 @@ void ContinuousBuild::HookPopupMenu(wxMenu* menu, MenuType type) void ContinuousBuild::UnPlug() { m_tabHelper.reset(); - if(!m_mgr->BookDeletePage(PaneId::BOTTOM_BAR, m_view)) { + if (!m_mgr->BookDeletePage(PaneId::BOTTOM_BAR, m_view)) { m_view->Destroy(); } m_view = nullptr; EventNotifier::Get()->Disconnect(wxEVT_FILE_SAVED, clCommandEventHandler(ContinuousBuild::OnFileSaved), NULL, this); - EventNotifier::Get()->Disconnect(wxEVT_FILE_SAVE_BY_BUILD_START, - wxCommandEventHandler(ContinuousBuild::OnIgnoreFileSaved), NULL, this); - EventNotifier::Get()->Disconnect(wxEVT_FILE_SAVE_BY_BUILD_END, - wxCommandEventHandler(ContinuousBuild::OnStopIgnoreFileSaved), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_FILE_SAVE_BY_BUILD_START, wxCommandEventHandler(ContinuousBuild::OnIgnoreFileSaved), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_FILE_SAVE_BY_BUILD_END, wxCommandEventHandler(ContinuousBuild::OnStopIgnoreFileSaved), NULL, this); } void ContinuousBuild::OnFileSaved(clCommandEvent& e) @@ -113,7 +110,7 @@ void ContinuousBuild::OnFileSaved(clCommandEvent& e) e.Skip(); clDEBUG1() << "ContinuousBuild::OnFileSaved"; // Don't build while the main build is in progress - if(m_buildInProgress) { + if (m_buildInProgress) { clDEBUG() << "Build already in progress, skipping"; return; } @@ -121,7 +118,7 @@ void ContinuousBuild::OnFileSaved(clCommandEvent& e) ContinuousBuildConf conf; m_mgr->GetConfigTool()->ReadObject(wxT("ContinousBuildConf"), &conf); - if(conf.GetEnabled()) { + if (conf.GetEnabled()) { DoBuild(e.GetString()); } else { clDEBUG1() << "ContinuousBuild is disabled"; @@ -132,14 +129,14 @@ void ContinuousBuild::DoBuild(const wxString& fileName) { clDEBUG() << "ContinuousBuild::DoBuild is called"; // Make sure a workspace is opened - if(!m_mgr->IsWorkspaceOpen()) { + if (!m_mgr->IsWorkspaceOpen()) { clDEBUG() << "ContinuousBuild::DoBuild: No workspace opened!"; return; } // Filter non source files FileExtManager::FileType type = FileExtManager::GetType(fileName); - switch(type) { + switch (type) { case FileExtManager::TypeSourceC: case FileExtManager::TypeSourceCpp: case FileExtManager::TypeResource: @@ -152,33 +149,33 @@ void ContinuousBuild::DoBuild(const wxString& fileName) } wxString projectName = m_mgr->GetProjectNameByFile(fileName); - if(projectName.IsEmpty()) { + if (projectName.IsEmpty()) { clDEBUG() << "ContinuousBuild::DoBuild: project name is empty"; return; } wxString errMsg; ProjectPtr project = m_mgr->GetWorkspace()->FindProjectByName(projectName, errMsg); - if(!project) { + if (!project) { clDEBUG() << "Could not find project for file"; return; } // get the selected configuration to be build BuildConfigPtr bldConf = m_mgr->GetWorkspace()->GetProjBuildConf(project->GetName(), wxEmptyString); - if(!bldConf) { + if (!bldConf) { clDEBUG() << "Failed to locate build configuration\n" << endl; return; } BuilderPtr builder = bldConf->GetBuilder(); - if(!builder) { + if (!builder) { clDEBUG() << "Failed to located builder\n" << endl; return; } // Only normal file builds are supported - if(bldConf->IsCustomBuild()) { + if (bldConf->IsCustomBuild()) { clDEBUG() << "Build is custom. Skipping\n" << endl; return; } @@ -187,9 +184,9 @@ void ContinuousBuild::DoBuild(const wxString& fileName) wxString cmd = builder->GetSingleFileCmd(projectName, bldConf->GetName(), bldConf->GetBuildSystemArguments(), fileName); - if(m_buildProcess.IsBusy()) { + if (m_buildProcess.IsBusy()) { // add the build to the queue - if(m_files.Index(fileName) == wxNOT_FOUND) { + if (m_files.Index(fileName) == wxNOT_FOUND) { m_files.Add(fileName); // update the UI @@ -209,7 +206,7 @@ void ContinuousBuild::DoBuild(const wxString& fileName) EnvSetter env(NULL, NULL, projectName, bldConf->GetName()); clDEBUG() << "Continuous build:" << cmd << endl; - if(!m_buildProcess.Execute(cmd, fileName, project->GetFileName().GetPath(), this)) + if (!m_buildProcess.Execute(cmd, fileName, project->GetFileName().GetPath(), this)) return; // Set some messages @@ -230,7 +227,7 @@ void ContinuousBuild::OnBuildProcessEnded(clProcessEvent& e) EventNotifier::Get()->AddPendingEvent(event); int exitCode(-1); - if(IProcess::GetProcessExitCode(pid, exitCode) && exitCode != 0) { + if (IProcess::GetProcessExitCode(pid, exitCode) && exitCode != 0) { m_view->AddFailedFile(m_buildProcess.GetFileName()); } @@ -238,7 +235,7 @@ void ContinuousBuild::OnBuildProcessEnded(clProcessEvent& e) m_buildProcess.Stop(); // if the queue is not empty, start another build - if(m_files.IsEmpty() == false) { + if (m_files.IsEmpty() == false) { wxString fileName = m_files.Item(0); m_files.RemoveAt(0); diff --git a/ContinuousBuild/continuousbuild.h b/ContinuousBuild/continuousbuild.h index d02cc1bbac..cc5edb0d96 100644 --- a/ContinuousBuild/continuousbuild.h +++ b/ContinuousBuild/continuousbuild.h @@ -26,11 +26,11 @@ #ifndef __ContinuousBuild__ #define __ContinuousBuild__ -#include "plugin.h" #include "buildprocess.h" -#include "compiler.h" -#include "cl_command_event.h" #include "clTabTogglerHelper.h" +#include "cl_command_event.h" +#include "compiler.h" +#include "plugin.h" class wxEvtHandler; class ContinuousBuildPane; @@ -44,7 +44,7 @@ class ContinuousBuild : public IPlugin wxArrayString m_files; bool m_buildInProgress; clTabTogglerHelper::Ptr_t m_tabHelper; - + public: void DoBuild(const wxString& fileName); diff --git a/ContinuousBuild/continuousbuildconf.h b/ContinuousBuild/continuousbuildconf.h index 4123aca25d..c6c5334ceb 100644 --- a/ContinuousBuild/continuousbuildconf.h +++ b/ContinuousBuild/continuousbuildconf.h @@ -30,19 +30,19 @@ class ContinuousBuildConf : public SerializedObject { - bool m_enabled; - size_t m_parallelProcesses; + bool m_enabled; + size_t m_parallelProcesses; public: - ContinuousBuildConf(); - virtual ~ContinuousBuildConf() = default; + ContinuousBuildConf(); + virtual ~ContinuousBuildConf() = default; public: - virtual void DeSerialize(Archive &arch); - virtual void Serialize(Archive &arch); - void SetEnabled(bool enabled) { this->m_enabled = enabled; } - void SetParallelProcesses(size_t parallelProcesses) { this->m_parallelProcesses = parallelProcesses; } - bool GetEnabled() const { return m_enabled; } - size_t GetParallelProcesses() const { return m_parallelProcesses; } + virtual void DeSerialize(Archive& arch); + virtual void Serialize(Archive& arch); + void SetEnabled(bool enabled) { this->m_enabled = enabled; } + void SetParallelProcesses(size_t parallelProcesses) { this->m_parallelProcesses = parallelProcesses; } + bool GetEnabled() const { return m_enabled; } + size_t GetParallelProcesses() const { return m_parallelProcesses; } }; #endif // __continuousbuildconf__ diff --git a/ContinuousBuild/continuousbuildpane.cpp b/ContinuousBuild/continuousbuildpane.cpp index 0f883c9d10..893104d611 100644 --- a/ContinuousBuild/continuousbuildpane.cpp +++ b/ContinuousBuild/continuousbuildpane.cpp @@ -58,14 +58,14 @@ void ContinuousBuildPane::OnStopUI(wxUpdateUIEvent& event) void ContinuousBuildPane::RemoveFile(const wxString& file) { int where = m_listBoxQueue->FindString(file); - if(where != wxNOT_FOUND) { + if (where != wxNOT_FOUND) { m_listBoxQueue->Delete((unsigned int)where); } } void ContinuousBuildPane::AddFile(const wxString& file) { - if(m_listBoxQueue->FindString(file) == wxNOT_FOUND) { + if (m_listBoxQueue->FindString(file) == wxNOT_FOUND) { m_listBoxQueue->Append(file); } } @@ -78,15 +78,12 @@ void ContinuousBuildPane::ClearAll() void ContinuousBuildPane::AddFailedFile(const wxString& file) { - if(m_listBoxFailedFiles->FindString(file) == wxNOT_FOUND) { + if (m_listBoxFailedFiles->FindString(file) == wxNOT_FOUND) { m_listBoxFailedFiles->Append(file); } } -void ContinuousBuildPane::OnEnableContBuildUI(wxUpdateUIEvent& event) -{ - event.Enable(m_checkBox1->IsChecked()); -} +void ContinuousBuildPane::OnEnableContBuildUI(wxUpdateUIEvent& event) { event.Enable(m_checkBox1->IsChecked()); } void ContinuousBuildPane::OnEnableCB(wxCommandEvent& event) { diff --git a/Copyright/copyrights_options_dlg.cpp b/Copyright/copyrights_options_dlg.cpp index 2fdde3033d..ba9391ab9e 100644 --- a/Copyright/copyrights_options_dlg.cpp +++ b/Copyright/copyrights_options_dlg.cpp @@ -1,70 +1,71 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : copyrights_options_dlg.cpp -// +// copyright : (C) 2008 by Eran Ifrah +// file name : copyrights_options_dlg.cpp +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - #include "copyrights_options_dlg.h" -#include +#include "copyrights_options_dlg.h" + #include "copyrightsconfigdata.h" #include "iconfigtool.h" -CopyrightsOptionsDlg::CopyrightsOptionsDlg( wxWindow* parent, IConfigTool *config ) - : CopyrightsOptionsBaseDlg( parent ) - , m_conf(config) +#include + +CopyrightsOptionsDlg::CopyrightsOptionsDlg(wxWindow* parent, IConfigTool* config) + : CopyrightsOptionsBaseDlg(parent) + , m_conf(config) { - CopyrightsConfigData data; - m_conf->ReadObject(wxT("CopyrightsConfig"), &data); - - m_textCtrlFileMaksing->SetValue( data.GetFileMasking()); - m_textCtrlFileName->SetValue(data.GetTemplateFilename()); - m_checkBoxBackup->SetValue( data.GetBackupFiles() ); - m_textCtrlIgnoreString->SetValue( data.GetIgnoreString() ); - m_textCtrlFileName->SetFocus(); - - Centre(); + CopyrightsConfigData data; + m_conf->ReadObject(wxT("CopyrightsConfig"), &data); + + m_textCtrlFileMaksing->SetValue(data.GetFileMasking()); + m_textCtrlFileName->SetValue(data.GetTemplateFilename()); + m_checkBoxBackup->SetValue(data.GetBackupFiles()); + m_textCtrlIgnoreString->SetValue(data.GetIgnoreString()); + m_textCtrlFileName->SetFocus(); + + Centre(); } -void CopyrightsOptionsDlg::OnSelectFile( wxCommandEvent& event ) +void CopyrightsOptionsDlg::OnSelectFile(wxCommandEvent& event) { - // open file selection - wxFileDialog *dlg = new wxFileDialog(this, _("Choose a file:")); - if(dlg->ShowModal() == wxID_OK) - { - // Get the dirname - wxString path = dlg->GetPath(); - m_textCtrlFileName->SetValue(path); - } - dlg->Destroy(); + // open file selection + wxFileDialog* dlg = new wxFileDialog(this, _("Choose a file:")); + if (dlg->ShowModal() == wxID_OK) { + // Get the dirname + wxString path = dlg->GetPath(); + m_textCtrlFileName->SetValue(path); + } + dlg->Destroy(); } void CopyrightsOptionsDlg::OnButtonSave(wxCommandEvent& event) { - wxUnusedVar(event); + wxUnusedVar(event); - CopyrightsConfigData data; - data.SetFileMasking( m_textCtrlFileMaksing->GetValue() ); - data.SetTemplateFilename( m_textCtrlFileName->GetValue() ); - data.SetBackupFiles( m_checkBoxBackup->IsChecked() ); - data.SetIgnoreString( m_textCtrlIgnoreString->GetValue() ); - m_conf->WriteObject(wxT("CopyrightsConfig"), &data); - EndModal(wxID_OK); + CopyrightsConfigData data; + data.SetFileMasking(m_textCtrlFileMaksing->GetValue()); + data.SetTemplateFilename(m_textCtrlFileName->GetValue()); + data.SetBackupFiles(m_checkBoxBackup->IsChecked()); + data.SetIgnoreString(m_textCtrlIgnoreString->GetValue()); + m_conf->WriteObject(wxT("CopyrightsConfig"), &data); + EndModal(wxID_OK); } diff --git a/Copyright/copyrights_options_dlg.h b/Copyright/copyrights_options_dlg.h index 6127e3e778..1a0b793d8c 100644 --- a/Copyright/copyrights_options_dlg.h +++ b/Copyright/copyrights_options_dlg.h @@ -1,50 +1,52 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : copyrights_options_dlg.h -// +// copyright : (C) 2008 by Eran Ifrah +// file name : copyrights_options_dlg.h +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - #ifndef __copyrights_options_dlg__ -#define __copyrights_options_dlg__ - -/** -@file -Subclass of CopyrightsOptionsBaseDlg, which is generated by wxFormBuilder. -*/ - -#include "copyrights_options_base_dlg.h" +#ifndef __copyrights_options_dlg__ +#define __copyrights_options_dlg__ + +/** +@file +Subclass of CopyrightsOptionsBaseDlg, which is generated by wxFormBuilder. +*/ + +#include "copyrights_options_base_dlg.h" class IConfigTool; - -/** Implementing CopyrightsOptionsBaseDlg */ -class CopyrightsOptionsDlg : public CopyrightsOptionsBaseDlg + +/** Implementing CopyrightsOptionsBaseDlg */ +class CopyrightsOptionsDlg : public CopyrightsOptionsBaseDlg { - IConfigTool *m_conf; -protected: - // Handlers for CopyrightsOptionsBaseDlg events. - void OnSelectFile( wxCommandEvent& event ); - void OnButtonSave( wxCommandEvent &event ); -public: - /** Constructor */ - CopyrightsOptionsDlg( wxWindow* parent, IConfigTool *config ); -}; - -#endif // __copyrights_options_dlg__ + IConfigTool* m_conf; + +protected: + // Handlers for CopyrightsOptionsBaseDlg events. + void OnSelectFile(wxCommandEvent& event); + void OnButtonSave(wxCommandEvent& event); + +public: + /** Constructor */ + CopyrightsOptionsDlg(wxWindow* parent, IConfigTool* config); +}; + +#endif // __copyrights_options_dlg__ diff --git a/Copyright/copyrights_proj_sel_dlg.cpp b/Copyright/copyrights_proj_sel_dlg.cpp index 171b601068..3424560649 100644 --- a/Copyright/copyrights_proj_sel_dlg.cpp +++ b/Copyright/copyrights_proj_sel_dlg.cpp @@ -1,61 +1,62 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : copyrights_proj_sel_dlg.cpp -// +// copyright : (C) 2008 by Eran Ifrah +// file name : copyrights_proj_sel_dlg.cpp +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - #include "copyrights_proj_sel_dlg.h" +#include "copyrights_proj_sel_dlg.h" + #include "workspace.h" - -CopyrightsProjectSelDlg::CopyrightsProjectSelDlg( wxWindow* parent, clCxxWorkspace *wsp ) -: CopyrightsProjectSelBaseDlg( parent ) + +CopyrightsProjectSelDlg::CopyrightsProjectSelDlg(wxWindow* parent, clCxxWorkspace* wsp) + : CopyrightsProjectSelBaseDlg(parent) { - wxArrayString projects; - wsp->GetProjectList( projects ); - - for(size_t i=0; iAppend(projects.Item(i)); - m_checkListProjects->Check((unsigned int)pos, true); - } - m_checkListProjects->SetFocus(); + wxArrayString projects; + wsp->GetProjectList(projects); + + for (size_t i = 0; i < projects.GetCount(); i++) { + int pos = m_checkListProjects->Append(projects.Item(i)); + m_checkListProjects->Check((unsigned int)pos, true); + } + m_checkListProjects->SetFocus(); } - + void CopyrightsProjectSelDlg::OnCheckAll(wxCommandEvent& e) { - for(size_t i=0; iGetCount(); i++){ - m_checkListProjects->Check((unsigned int)i, true); - } + for (size_t i = 0; i < m_checkListProjects->GetCount(); i++) { + m_checkListProjects->Check((unsigned int)i, true); + } } void CopyrightsProjectSelDlg::OnUnCheckAll(wxCommandEvent& e) { - for(size_t i=0; iGetCount(); i++){ - m_checkListProjects->Check((unsigned int)i, false); - } + for (size_t i = 0; i < m_checkListProjects->GetCount(); i++) { + m_checkListProjects->Check((unsigned int)i, false); + } } void CopyrightsProjectSelDlg::GetProjects(wxArrayString& projects) { - for(size_t i=0; iGetCount(); i++){ - if(m_checkListProjects->IsChecked((unsigned int)i)) { - projects.Add(m_checkListProjects->GetString((unsigned int)i)); - } - } + for (size_t i = 0; i < m_checkListProjects->GetCount(); i++) { + if (m_checkListProjects->IsChecked((unsigned int)i)) { + projects.Add(m_checkListProjects->GetString((unsigned int)i)); + } + } } diff --git a/Copyright/copyrights_proj_sel_dlg.h b/Copyright/copyrights_proj_sel_dlg.h index 100a1786ae..582be001c2 100644 --- a/Copyright/copyrights_proj_sel_dlg.h +++ b/Copyright/copyrights_proj_sel_dlg.h @@ -1,48 +1,48 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : copyrights_proj_sel_dlg.h -// +// copyright : (C) 2008 by Eran Ifrah +// file name : copyrights_proj_sel_dlg.h +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - #ifndef __copyrights_proj_sel_dlg__ -#define __copyrights_proj_sel_dlg__ - -/** -@file -Subclass of CopyrightsProjectSelBaseDlg, which is generated by wxFormBuilder. -*/ - -#include "copyrights_proj_sel_base_dlg.h" -class clCxxWorkspace; -/** Implementing CopyrightsProjectSelBaseDlg */ -class CopyrightsProjectSelDlg : public CopyrightsProjectSelBaseDlg +#ifndef __copyrights_proj_sel_dlg__ +#define __copyrights_proj_sel_dlg__ + +/** +@file +Subclass of CopyrightsProjectSelBaseDlg, which is generated by wxFormBuilder. +*/ + +#include "copyrights_proj_sel_base_dlg.h" +class clCxxWorkspace; +/** Implementing CopyrightsProjectSelBaseDlg */ +class CopyrightsProjectSelDlg : public CopyrightsProjectSelBaseDlg { protected: - void OnUnCheckAll(wxCommandEvent &e); - void OnCheckAll(wxCommandEvent &e); - -public: - /** Constructor */ - CopyrightsProjectSelDlg( wxWindow* parent, clCxxWorkspace *wsp ); - void GetProjects(wxArrayString &projects); -}; - -#endif // __copyrights_proj_sel_dlg__ + void OnUnCheckAll(wxCommandEvent& e); + void OnCheckAll(wxCommandEvent& e); + +public: + /** Constructor */ + CopyrightsProjectSelDlg(wxWindow* parent, clCxxWorkspace* wsp); + void GetProjects(wxArrayString& projects); +}; + +#endif // __copyrights_proj_sel_dlg__ diff --git a/Copyright/copyrightsconfigdata.cpp b/Copyright/copyrightsconfigdata.cpp index 05b8ccb015..f6df78488a 100644 --- a/Copyright/copyrightsconfigdata.cpp +++ b/Copyright/copyrightsconfigdata.cpp @@ -1,47 +1,48 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : copyrightsconfigdata.cpp -// +// copyright : (C) 2008 by Eran Ifrah +// file name : copyrightsconfigdata.cpp +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - #include "copyrightsconfigdata.h" -CopyrightsConfigData::CopyrightsConfigData() -: m_templateFilename(wxEmptyString) -, m_fileMasking(wxT("*.h;*.hpp;*.h++")) -, m_backupFiles(true) +#include "copyrightsconfigdata.h" + +CopyrightsConfigData::CopyrightsConfigData() + : m_templateFilename(wxEmptyString) + , m_fileMasking(wxT("*.h;*.hpp;*.h++")) + , m_backupFiles(true) { } void CopyrightsConfigData::DeSerialize(Archive& arch) { - arch.Read(wxT("m_templateFilename"), m_templateFilename); - arch.Read(wxT("m_fileMasking"), m_fileMasking); - arch.Read(wxT("m_backupFiles"), m_backupFiles); - arch.Read(wxT("m_ignoreString"), m_ignoreString); + arch.Read(wxT("m_templateFilename"), m_templateFilename); + arch.Read(wxT("m_fileMasking"), m_fileMasking); + arch.Read(wxT("m_backupFiles"), m_backupFiles); + arch.Read(wxT("m_ignoreString"), m_ignoreString); } void CopyrightsConfigData::Serialize(Archive& arch) { - arch.Write(wxT("m_templateFilename"), m_templateFilename); - arch.Write(wxT("m_fileMasking"), m_fileMasking); - arch.Write(wxT("m_backupFiles"), m_backupFiles); - arch.Write(wxT("m_ignoreString"), m_ignoreString); + arch.Write(wxT("m_templateFilename"), m_templateFilename); + arch.Write(wxT("m_fileMasking"), m_fileMasking); + arch.Write(wxT("m_backupFiles"), m_backupFiles); + arch.Write(wxT("m_ignoreString"), m_ignoreString); } diff --git a/Copyright/copyrightsconfigdata.h b/Copyright/copyrightsconfigdata.h index c78ff79b1f..87a60699ac 100644 --- a/Copyright/copyrightsconfigdata.h +++ b/Copyright/copyrightsconfigdata.h @@ -29,42 +29,29 @@ class CopyrightsConfigData : public SerializedObject { - wxString m_templateFilename; - wxString m_fileMasking; - bool m_backupFiles; - wxString m_ignoreString; + wxString m_templateFilename; + wxString m_fileMasking; + bool m_backupFiles; + wxString m_ignoreString; public: - CopyrightsConfigData(); - virtual ~CopyrightsConfigData() = default; + CopyrightsConfigData(); + virtual ~CopyrightsConfigData() = default; public: - virtual void DeSerialize(Archive &arch); - virtual void Serialize(Archive &arch); + virtual void DeSerialize(Archive& arch); + virtual void Serialize(Archive& arch); + // Setters + void SetFileMasking(const wxString& fileMasking) { this->m_fileMasking = fileMasking; } + void SetTemplateFilename(const wxString& templateFilename) { this->m_templateFilename = templateFilename; } + void SetBackupFiles(bool backupFiles) { this->m_backupFiles = backupFiles; } - //Setters - void SetFileMasking(const wxString& fileMasking) { - this->m_fileMasking = fileMasking; - } - void SetTemplateFilename(const wxString& templateFilename) { - this->m_templateFilename = templateFilename; - } - void SetBackupFiles(bool backupFiles) { this->m_backupFiles = backupFiles; } - - //Getters - const wxString& GetFileMasking() const { - return m_fileMasking; - } - const wxString& GetTemplateFilename() const { - return m_templateFilename; - } - bool GetBackupFiles() const { return m_backupFiles; } - void SetIgnoreString(const wxString& ignoreString) { - this->m_ignoreString = ignoreString; - } - const wxString& GetIgnoreString() const { - return m_ignoreString; - } + // Getters + const wxString& GetFileMasking() const { return m_fileMasking; } + const wxString& GetTemplateFilename() const { return m_templateFilename; } + bool GetBackupFiles() const { return m_backupFiles; } + void SetIgnoreString(const wxString& ignoreString) { this->m_ignoreString = ignoreString; } + const wxString& GetIgnoreString() const { return m_ignoreString; } }; #endif // __copyrightsconfigdata__ diff --git a/CxxParser/cl_typedef.h b/CxxParser/cl_typedef.h index 70979ca5c0..8a5b59255f 100644 --- a/CxxParser/cl_typedef.h +++ b/CxxParser/cl_typedef.h @@ -1,41 +1,43 @@ #ifndef TYPEDEF_H #define TYPEDEF_H -#include #include "variable.h" +#include + #ifndef WXDLLIMPEXP_CL -#ifdef WXMAKINGDLL_CL -# define WXDLLIMPEXP_CL __declspec(dllexport) -#elif defined(WXUSINGDLL_CL) -# define WXDLLIMPEXP_CL __declspec(dllimport) -#else // not making nor using DLL -# define WXDLLIMPEXP_CL +#ifdef WXMAKINGDLL_CL +#define WXDLLIMPEXP_CL __declspec(dllexport) +#elif defined(WXUSINGDLL_CL) +#define WXDLLIMPEXP_CL __declspec(dllimport) +#else // not making nor using DLL +#define WXDLLIMPEXP_CL #endif #endif - class WXDLLIMPEXP_CL clTypedef { public: - std::string m_name; - Variable m_realType; - + std::string m_name; + Variable m_realType; + public: - clTypedef() {} - ~clTypedef() {} - - void print() const { - printf("Name: %s\n", m_name.c_str()); - m_realType.Print(); - } - - void clear() { - m_realType.Reset(); - m_name.clear(); - } + clTypedef() {} + ~clTypedef() {} + + void print() const + { + printf("Name: %s\n", m_name.c_str()); + m_realType.Print(); + } + + void clear() + { + m_realType.Reset(); + m_name.clear(); + } }; using clTypedefList = std::list; diff --git a/CxxParser/code_completion_api.h b/CxxParser/code_completion_api.h index d9ba93f09d..8262c185f7 100644 --- a/CxxParser/code_completion_api.h +++ b/CxxParser/code_completion_api.h @@ -1,19 +1,29 @@ #ifndef CODE_COMPLETION_API_H #define CODE_COMPLETION_API_H -#include "cl_typedef.h" -#include "variable.h" -#include "function.h" -#include "expression_result.h" - -extern WXDLLIMPEXP_CL std::string get_scope_name(const std::string &in, std::vector &additionlNS, const std::map &ignoreTokens); -extern WXDLLIMPEXP_CL void get_variables(const std::string &in, VariableList &li, const std::map &ignoreMap, bool isUsedWithinFunc); -extern WXDLLIMPEXP_CL bool is_primitive_type(const std::string &in); -extern WXDLLIMPEXP_CL void get_functions(const std::string &in, FunctionList &li, const std::map &ignoreTokens); -extern WXDLLIMPEXP_CL void get_typedefs(const std::string &in, clTypedefList &li); -extern WXDLLIMPEXP_CL ExpressionResult &parse_expression(const std::string &in); -extern WXDLLIMPEXP_CL bool setLexerInput(const std::string &in, const std::map &ignoreTokens); -extern WXDLLIMPEXP_CL void cl_scope_lex_clean(); +#include "cl_typedef.h" +#include "expression_result.h" +#include "function.h" +#include "variable.h" + +#include +#include +#include + +extern WXDLLIMPEXP_CL std::string get_scope_name(const std::string& in, + std::vector& additionlNS, + const std::map& ignoreTokens); +extern WXDLLIMPEXP_CL void get_variables(const std::string& in, + VariableList& li, + const std::map& ignoreMap, + bool isUsedWithinFunc); +extern WXDLLIMPEXP_CL bool is_primitive_type(const std::string& in); +extern WXDLLIMPEXP_CL void +get_functions(const std::string& in, FunctionList& li, const std::map& ignoreTokens); +extern WXDLLIMPEXP_CL void get_typedefs(const std::string& in, clTypedefList& li); +extern WXDLLIMPEXP_CL ExpressionResult& parse_expression(const std::string& in); +extern WXDLLIMPEXP_CL bool setLexerInput(const std::string& in, const std::map& ignoreTokens); +extern WXDLLIMPEXP_CL void cl_scope_lex_clean(); // We don't use WXDLLIMPEXP_CL intentionally to avoid people using these members/functions // directly @@ -27,21 +37,14 @@ class WXDLLIMPEXP_CL CppLexer using StringMap_t = std::map; public: - CppLexer(const std::string& str) { + CppLexer(const std::string& str) + { StringMap_t dummy; ::setLexerInput(str, dummy); } - ~CppLexer() { - ::cl_scope_lex_clean(); - } - int lex() const { - return cl_scope_lex(); - } - int line_number() const { - return cl_scope_lineno; - } - std::string text() const { - return cl_scope_text; - } + ~CppLexer() { ::cl_scope_lex_clean(); } + int lex() const { return cl_scope_lex(); } + int line_number() const { return cl_scope_lineno; } + std::string text() const { return cl_scope_text; } }; #endif // CODECOMPLETION_API_H diff --git a/CxxParser/expression_result.cpp b/CxxParser/expression_result.cpp index 2ad3692ee5..7cffa2a207 100644 --- a/CxxParser/expression_result.cpp +++ b/CxxParser/expression_result.cpp @@ -2,40 +2,36 @@ #define BOOL_TO_STR(b) b ? "true" : "false" -ExpressionResult::ExpressionResult() -{ - Reset(); -} +ExpressionResult::ExpressionResult() { Reset(); } -void ExpressionResult::Print() -{ - printf("%s\n", ToString().c_str()); -} +void ExpressionResult::Print() { printf("%s\n", ToString().c_str()); } std::string ExpressionResult::ToString() const { - char tmp[256]; - sprintf(tmp, "{m_name:%s, m_isFunc:%s, m_isTemplate:%s, m_isThis:%s, m_isaType:%s, m_isPtr:%s, m_scope:%s, m_templateInitList:%s}", - m_name.c_str(), - BOOL_TO_STR(m_isFunc), - BOOL_TO_STR(m_isTemplate), - BOOL_TO_STR(m_isThis), - BOOL_TO_STR(m_isaType), - BOOL_TO_STR(m_isPtr), - m_scope.c_str(), - m_templateInitList.c_str()); - return tmp; + char tmp[256]; + sprintf(tmp, + "{m_name:%s, m_isFunc:%s, m_isTemplate:%s, m_isThis:%s, m_isaType:%s, m_isPtr:%s, m_scope:%s, " + "m_templateInitList:%s}", + m_name.c_str(), + BOOL_TO_STR(m_isFunc), + BOOL_TO_STR(m_isTemplate), + BOOL_TO_STR(m_isThis), + BOOL_TO_STR(m_isaType), + BOOL_TO_STR(m_isPtr), + m_scope.c_str(), + m_templateInitList.c_str()); + return tmp; } void ExpressionResult::Reset() { - m_isFunc = false; - m_name = ""; - m_isThis = false; - m_isaType = false; - m_isPtr = false; - m_scope = ""; - m_isTemplate = false; - m_isGlobalScope = false; - m_templateInitList = ""; + m_isFunc = false; + m_name = ""; + m_isThis = false; + m_isaType = false; + m_isPtr = false; + m_scope = ""; + m_isTemplate = false; + m_isGlobalScope = false; + m_templateInitList = ""; } diff --git a/CxxParser/expression_result.h b/CxxParser/expression_result.h index 222538b7b2..7570422341 100644 --- a/CxxParser/expression_result.h +++ b/CxxParser/expression_result.h @@ -6,36 +6,34 @@ #ifndef WXDLLIMPEXP_CL -#ifdef WXMAKINGDLL_CL -# define WXDLLIMPEXP_CL __declspec(dllexport) -#elif defined(WXUSINGDLL_CL) -# define WXDLLIMPEXP_CL __declspec(dllimport) -#else // not making nor using DLL -# define WXDLLIMPEXP_CL +#ifdef WXMAKINGDLL_CL +#define WXDLLIMPEXP_CL __declspec(dllexport) +#elif defined(WXUSINGDLL_CL) +#define WXDLLIMPEXP_CL __declspec(dllimport) +#else // not making nor using DLL +#define WXDLLIMPEXP_CL #endif #endif - class WXDLLIMPEXP_CL ExpressionResult { public: - - bool m_isFunc; - std::string m_name; - bool m_isThis; - bool m_isaType; - bool m_isPtr; - std::string m_scope; - bool m_isTemplate; - std::string m_templateInitList; - bool m_isGlobalScope; + bool m_isFunc; + std::string m_name; + bool m_isThis; + bool m_isaType; + bool m_isPtr; + std::string m_scope; + bool m_isTemplate; + std::string m_templateInitList; + bool m_isGlobalScope; public: - ExpressionResult(); - virtual ~ExpressionResult() = default; - void Reset(); - void Print(); - std::string ToString() const; + ExpressionResult(); + virtual ~ExpressionResult() = default; + void Reset(); + void Print(); + std::string ToString() const; }; -#endif //EXPRESSION_RESULT_H +#endif // EXPRESSION_RESULT_H diff --git a/CxxParser/function.h b/CxxParser/function.h index 9ca07d3021..3f1c98b957 100644 --- a/CxxParser/function.h +++ b/CxxParser/function.h @@ -23,7 +23,7 @@ class WXDLLIMPEXP_CL clFunction { public: std::string m_name; - std::string m_scope; // functions' scope + std::string m_scope; // functions' scope std::string m_retrunValusConst; // is the return value a const? std::string m_signature; Variable m_returnValue; @@ -33,7 +33,7 @@ class WXDLLIMPEXP_CL clFunction bool m_isConst; bool m_isFinal; std::string m_throws; - + public: clFunction(); virtual ~clFunction() = default; diff --git a/CxxParser/main.cpp b/CxxParser/main.cpp index c6a89d05db..4366692dd1 100644 --- a/CxxParser/main.cpp +++ b/CxxParser/main.cpp @@ -1,120 +1,115 @@ -//test the parser -#include -#include -#include -#include -#include -#include +// test the parser #include "code_completion_api.h" -void testScopeParser(char *buf); -void testVarParser(char *buf); -void testTypedefParser(char *buf); -void testExprParser(char *buf); -void testFuncParser(char *buf); -void testPureLexer(const char *buf); -void testIsPrimitive(char *buf); +#include -char *loadFile(const char *fileName); +void testScopeParser(char* buf); +void testVarParser(char* buf); +void testTypedefParser(char* buf); +void testExprParser(char* buf); +void testFuncParser(char* buf); +void testPureLexer(const char* buf); +void testIsPrimitive(char* buf); + +char* loadFile(const char* fileName); int main() { - char *buf = loadFile("../Debug/test.h"); - //testPureLexer( buf ); - //print the scope name - //testScopeParser(buf); + char* buf = loadFile("../Debug/test.h"); + // testPureLexer( buf ); + // print the scope name + // testScopeParser(buf); testVarParser(buf); - //testExprParser(buf); - //testFuncParser(buf); - //testTypedefParser(buf); - //testIsPrimitive(buf); - //testFuncParser(buf); + // testExprParser(buf); + // testFuncParser(buf); + // testTypedefParser(buf); + // testIsPrimitive(buf); + // testFuncParser(buf); free(buf); } -void testPureLexer( const char* buf ) +void testPureLexer(const char* buf) { - CppLexer lexer( buf ); - while ( lexer.lex() != 0 ) { + CppLexer lexer(buf); + while (lexer.lex() != 0) { printf("%s | %d\n", lexer.text().c_str(), lexer.line_number()); } } -void testIsPrimitive(char *buf) +void testIsPrimitive(char* buf) { printf("===== Testing is_primitive_type ======\n"); printf("%d\n", is_primitive_type(buf) ? 1 : 0); } -void testFuncParser(char *buf) +void testFuncParser(char* buf) { printf("===== Testing function parser ======\n"); -// time_t start = GetTickCount(); + // time_t start = GetTickCount(); FunctionList li; - //fflush(stdout); + // fflush(stdout); std::map ignoreTokens; get_functions(buf, li, ignoreTokens); -// time_t end = GetTickCount(); + // time_t end = GetTickCount(); for (const clFunction& f : li) { - //test the var parser on the function argument list: + // test the var parser on the function argument list: f.Print(); - //testVarParser((char*)f.m_signature.c_str()); + // testVarParser((char*)f.m_signature.c_str()); printf("%s\n", f.m_name.c_str()); } -// printf("total time: %d\n", end-start); + // printf("total time: %d\n", end-start); printf("matches found: %d\n", (int)li.size()); } -void testExprParser(char *buf) +void testExprParser(char* buf) { printf("===== Testing expression parser ======\n"); ExpressionResult res = parse_expression(buf); res.Print(); } -void testScopeParser(char *buf) +void testScopeParser(char* buf) { printf("===== Testing Scope parser ======\n"); -// time_t start = GetTickCount(); + // time_t start = GetTickCount(); std::vector additionNS; std::map ignoreTokens; ignoreTokens["wxT"] = true; std::string scope = get_scope_name(buf, additionNS, ignoreTokens); -// time_t end = GetTickCount(); -// printf("total time: %d\n", end-start); + // time_t end = GetTickCount(); + // printf("total time: %d\n", end-start); printf("scope name=%s\n", scope.c_str()); - for (size_t i=0; i ignoreTokens; get_variables(buf, li, ignoreTokens, true); -// time_t end = GetTickCount(); + // time_t end = GetTickCount(); for (const Variable& var : li) { var.Print(); } -// printf("total time: %d\n", end-start); + // printf("total time: %d\n", end-start); printf("matches found: %d\n", (int)li.size()); } -void testTypedefParser(char *buf) +void testTypedefParser(char* buf) { printf("===== Testing Typedef parser ======\n"); clTypedefList li; - std::map ignoreTokens; get_typedefs(buf, li); for (const clTypedef& var : li) { @@ -126,11 +121,11 @@ void testTypedefParser(char *buf) //------------------------------------------------------- // Help function //------------------------------------------------------- -char *loadFile(const char *fileName) +char* loadFile(const char* fileName) { - FILE *fp; + FILE* fp; long len; - char *buf = NULL; + char* buf = NULL; fp = fopen(fileName, "rb"); if (!fp) { @@ -138,22 +133,22 @@ char *loadFile(const char *fileName) return NULL; } - //read the whole file - fseek(fp, 0, SEEK_END); //go to end - len = ftell(fp); //get position at end (length) - fseek(fp, 0, SEEK_SET); //go to beginning - buf = (char *)malloc(len+1); //malloc buffer + // read the whole file + fseek(fp, 0, SEEK_END); // go to end + len = ftell(fp); // get position at end (length) + fseek(fp, 0, SEEK_SET); // go to beginning + buf = (char*)malloc(len + 1); // malloc buffer - //read into buffer + // read into buffer long bytes = fread(buf, sizeof(char), len, fp); - //printf("read: %ld\n", bytes); + // printf("read: %ld\n", bytes); if (bytes != len) { fclose(fp); printf("failed to read from file 'test.h': %s\n", strerror(errno)); return NULL; } - buf[len] = 0; // make it null terminated string + buf[len] = 0; // make it null terminated string fclose(fp); return buf; } diff --git a/CxxParser/variable.cpp b/CxxParser/variable.cpp index 0b3c4ca77f..8180271165 100644 --- a/CxxParser/variable.cpp +++ b/CxxParser/variable.cpp @@ -2,10 +2,7 @@ #include -void Variable::Reset() -{ - *this = Variable(); -} +void Variable::Reset() { *this = Variable(); } void Variable::Print() const { diff --git a/abbreviation/abbreviation.cpp b/abbreviation/abbreviation.cpp index 1359e3c827..5d73b7fbd6 100644 --- a/abbreviation/abbreviation.cpp +++ b/abbreviation/abbreviation.cpp @@ -25,7 +25,6 @@ #include "abbreviation.h" - #include "Keyboard/clKeyboardManager.h" #include "abbreviationentry.h" #include "abbreviationssettingsdlg.h" @@ -84,8 +83,11 @@ void AbbreviationPlugin::CreatePluginMenu(wxMenu* pluginsMenu) wxMenu* menu = new wxMenu(); wxMenuItem* item(nullptr); - item = new wxMenuItem(menu, XRCID("abbrev_insert"), _("Show abbreviations completion box"), - _("Show abbreviations completion box"), wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("abbrev_insert"), + _("Show abbreviations completion box"), + _("Show abbreviations completion box"), + wxITEM_NORMAL); menu->Append(item); menu->AppendSeparator(); item = new wxMenuItem(menu, XRCID("abbrev_settings"), _("Settings..."), _("Settings..."), wxITEM_NORMAL); @@ -193,8 +195,8 @@ void AbbreviationPlugin::InitDefaults() jsonData.SetEntries(entries); m_config.WriteItem(jsonData); } - clKeyboardManager::Get()->AddAccelerator("abbrev_insert", _("Abbreviations"), - _("Show abbreviations completion box"), "Ctrl-Alt-SPACE"); + clKeyboardManager::Get()->AddAccelerator( + "abbrev_insert", _("Abbreviations"), _("Show abbreviations completion box"), "Ctrl-Alt-SPACE"); } bool AbbreviationPlugin::InsertExpansion(const wxString& abbreviation) @@ -317,7 +319,7 @@ void AbbreviationPlugin::OnShowAbbreviations(wxCommandEvent& e) wxStyledTextCtrl* ctrl = editor->GetCtrl(); const auto V = GetAbbreviations(editor->GetWordAtPosition(editor->GetCurrentPosition())); if (!V.empty()) { - wxCodeCompletionBoxManager::Get().ShowCompletionBox(ctrl, V, wxCodeCompletionBox::kRefreshOnKeyType, - wxNOT_FOUND); + wxCodeCompletionBoxManager::Get().ShowCompletionBox( + ctrl, V, wxCodeCompletionBox::kRefreshOnKeyType, wxNOT_FOUND); } } diff --git a/codelite_echo/main.c b/codelite_echo/main.c index f10e4cf665..3b54470c1d 100644 --- a/codelite_echo/main.c +++ b/codelite_echo/main.c @@ -1,6 +1,6 @@ #include -#include #include +#include #ifndef WIN32 #include @@ -13,8 +13,8 @@ int main(int argc, char** argv) { int i = 1; - for(; i < argc; ++i) { - if(strstr(argv[i], " ") || strstr(argv[i], "\t")) { + for (; i < argc; ++i) { + if (strstr(argv[i], " ") || strstr(argv[i], "\t")) { // escape with double quotes fprintf(stdout, "\"%s\" ", argv[i]); } else { @@ -24,9 +24,9 @@ int main(int argc, char** argv) } fprintf(stdout, "\r\n"); fflush(stdout); - + #ifdef WIN32 - Sleep(SECONDS_TO_SLEEP*1000); // Under Windows its in ms + Sleep(SECONDS_TO_SLEEP * 1000); // Under Windows its in ms #else sleep(SECONDS_TO_SLEEP); // sleep for 100 seconds #endif diff --git a/codelite_make/cl_make_generator_app.cpp b/codelite_make/cl_make_generator_app.cpp index 3cca9739be..ff0ee533fb 100644 --- a/codelite_make/cl_make_generator_app.cpp +++ b/codelite_make/cl_make_generator_app.cpp @@ -15,31 +15,46 @@ IMPLEMENT_APP_CONSOLE(clMakeGeneratorApp) static const wxCmdLineEntryDesc g_cmdDesc[] = { - { wxCMD_LINE_SWITCH, "h", "help", "show this help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP }, - { wxCMD_LINE_OPTION, "w", "workspace", "CodeLite workspace file", wxCMD_LINE_VAL_STRING, - wxCMD_LINE_OPTION_MANDATORY }, - { wxCMD_LINE_OPTION, "c", "config", "Workspace configuration name to use", wxCMD_LINE_VAL_STRING, - wxCMD_LINE_OPTION_MANDATORY }, - { wxCMD_LINE_OPTION, "d", "command", - "Which command to run? possible values are: build, clean or rebuild. The default is to build" }, - { wxCMD_LINE_OPTION, "p", "project", - "Project to build, if non given CodeLite will build the active project as defined in the workspace", - wxCMD_LINE_VAL_STRING }, - { wxCMD_LINE_SWITCH, "v", "verbose", "Run in verbose mode and print all log lines to the stdout/stderr" }, - { wxCMD_LINE_SWITCH, "j", "json", - "Generate compile_commands.json for this workspace and exit. If not specified, compile_commands.json is " - "generated as part of the build process" }, - { wxCMD_LINE_SWITCH, "f", "compile-flags", "Generate compile_flags.txt for this workspace and exit" }, - { wxCMD_LINE_SWITCH, "e", "execute", "Instead of printing the command line, execute it" }, - { wxCMD_LINE_OPTION, "s", "settings", - "The full path of the build_settings.xml file.\n" - "By default, codelite-make will load the compiler definitions from\n" - "%appdata%\\CodeLite\\config\\build_settings.xml (or the equivalent path on\n" - "Unix systems). Passing -s|--settings will override the default search\n" - "location", - wxCMD_LINE_VAL_STRING }, - { wxCMD_LINE_NONE } -}; + {wxCMD_LINE_SWITCH, "h", "help", "show this help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP}, + {wxCMD_LINE_OPTION, + "w", + "workspace", + "CodeLite workspace file", + wxCMD_LINE_VAL_STRING, + wxCMD_LINE_OPTION_MANDATORY}, + {wxCMD_LINE_OPTION, + "c", + "config", + "Workspace configuration name to use", + wxCMD_LINE_VAL_STRING, + wxCMD_LINE_OPTION_MANDATORY}, + {wxCMD_LINE_OPTION, + "d", + "command", + "Which command to run? possible values are: build, clean or rebuild. The default is to build"}, + {wxCMD_LINE_OPTION, + "p", + "project", + "Project to build, if non given CodeLite will build the active project as defined in the workspace", + wxCMD_LINE_VAL_STRING}, + {wxCMD_LINE_SWITCH, "v", "verbose", "Run in verbose mode and print all log lines to the stdout/stderr"}, + {wxCMD_LINE_SWITCH, + "j", + "json", + "Generate compile_commands.json for this workspace and exit. If not specified, compile_commands.json is " + "generated as part of the build process"}, + {wxCMD_LINE_SWITCH, "f", "compile-flags", "Generate compile_flags.txt for this workspace and exit"}, + {wxCMD_LINE_SWITCH, "e", "execute", "Instead of printing the command line, execute it"}, + {wxCMD_LINE_OPTION, + "s", + "settings", + "The full path of the build_settings.xml file.\n" + "By default, codelite-make will load the compiler definitions from\n" + "%appdata%\\CodeLite\\config\\build_settings.xml (or the equivalent path on\n" + "Unix systems). Passing -s|--settings will override the default search\n" + "location", + wxCMD_LINE_VAL_STRING}, + {wxCMD_LINE_NONE}}; clMakeGeneratorApp::clMakeGeneratorApp() : m_verbose(false) @@ -60,42 +75,42 @@ bool clMakeGeneratorApp::OnInit() SetAppName("codelite"); wxLog::EnableLogging(false); wxCmdLineParser parser(wxAppConsole::argc, wxAppConsole::argv); - if(!DoParseCommandLine(parser)) + if (!DoParseCommandLine(parser)) return false; // Load compilers settings - if(!BuildSettingsConfigST::Get()->Load("2.1", m_buildSettingsXml)) { + if (!BuildSettingsConfigST::Get()->Load("2.1", m_buildSettingsXml)) { Error("Could not load build settings configuration object (Version 2.1 / build_settings.xml)"); return false; } wxFileName fnWorkspace(m_workspaceFile); - if(fnWorkspace.IsRelative()) { + if (fnWorkspace.IsRelative()) { fnWorkspace.MakeAbsolute(m_workingDirectory); } Info(wxString() << "-- Generating makefile for workspace file " << fnWorkspace.GetFullPath()); wxString errmsg; - if(!clCxxWorkspaceST::Get()->OpenWorkspace(fnWorkspace.GetFullPath(), errmsg)) { + if (!clCxxWorkspaceST::Get()->OpenWorkspace(fnWorkspace.GetFullPath(), errmsg)) { Error(wxString() << "Error while loading workspace: " << fnWorkspace.GetFullPath() << ". " << errmsg); return false; } - if(m_project.IsEmpty()) { + if (m_project.IsEmpty()) { m_project = clCxxWorkspaceST::Get()->GetActiveProjectName(); } // Set the active project to the configuration set the by the user BuildMatrixPtr buildMatrix = clCxxWorkspaceST::Get()->GetBuildMatrix(); WorkspaceConfigurationPtr workspaceConfig = buildMatrix->GetConfigurationByName(m_configuration); - if(!workspaceConfig) { + if (!workspaceConfig) { Error(wxString() << "Could not find workspace configuration: " << m_configuration); return false; } const WorkspaceConfiguration::ConfigMappingList& mapping = workspaceConfig->GetMapping(); WorkspaceConfiguration::ConfigMappingList::const_iterator iter = std::find_if( mapping.begin(), mapping.end(), [&](const ConfigMappingEntry& entry) { return entry.m_project == m_project; }); - if(iter == mapping.end()) { + if (iter == mapping.end()) { Error(wxString() << "Unable to locate a project configuration that matches the workspace configuration '" << m_configuration << "'"); return false; @@ -107,14 +122,14 @@ bool clMakeGeneratorApp::OnInit() // Which makefile should we create? BuilderGnuMake builder; ProjectPtr project = clCxxWorkspaceST::Get()->FindProjectByName(m_project, errmsg); - if(!project) { + if (!project) { Error(wxString() << "Could not find project " << m_project << ". " << errmsg); return false; } // Load the build configuration BuildConfigPtr bldConf = clCxxWorkspaceST::Get()->GetProjBuildConf(m_project, projectConfiguration); - if(!bldConf) { + if (!bldConf) { Error(wxString() << "Could not find configuration " << projectConfiguration << " for project " << m_project); return false; } @@ -122,26 +137,26 @@ bool clMakeGeneratorApp::OnInit() // First, generate the compile_commands.json DoGenerateCompileCommands(); - if(this->m_generateCompileCommands || this->m_generateCompilerFlags) { + if (this->m_generateCompileCommands || this->m_generateCompilerFlags) { // If the --json flag was passed, exit now Bye(); } else { - if(bldConf->IsCustomBuild()) { + if (bldConf->IsCustomBuild()) { Notice(wxString() << "Configuration " << projectConfiguration << " for project " << m_project << " is using a custom build - will not generate makefile"); Notice(wxString() << "Instead, here is the command line to use:"); wxString command; - wxString workingDirectory = MacroManager::Instance()->Expand(bldConf->GetCustomBuildWorkingDir(), NULL, - m_project, bldConf->GetName()); - if(wxFileName::DirExists(workingDirectory) == false) { + wxString workingDirectory = MacroManager::Instance()->Expand( + bldConf->GetCustomBuildWorkingDir(), NULL, m_project, bldConf->GetName()); + if (wxFileName::DirExists(workingDirectory) == false) { Info(wxString() << "-- Creating build directory: " << workingDirectory); wxFileName::Mkdir(workingDirectory, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); } command << "cd " << workingDirectory << " && " - << MacroManager::Instance()->Expand(bldConf->GetCustomBuildCmd(), NULL, m_project, - bldConf->GetName()); + << MacroManager::Instance()->Expand( + bldConf->GetCustomBuildCmd(), NULL, m_project, bldConf->GetName()); Out(command); - if(m_executeCommand) { + if (m_executeCommand) { CallAfter(&clMakeGeneratorApp::DoExecCommand, command); } else { Bye(); @@ -156,7 +171,7 @@ bool clMakeGeneratorApp::OnInit() } wxString commandToRun; - switch(m_commandType) { + switch (m_commandType) { case kBuild: commandToRun = builder.GetBuildCommand(m_project, projectConfiguration, args); break; @@ -171,7 +186,7 @@ bool clMakeGeneratorApp::OnInit() } wxString workspace_path = fnWorkspace.GetPath(); - if(workspace_path.Contains(" ") || workspace_path.Contains("\t")) { + if (workspace_path.Contains(" ") || workspace_path.Contains("\t")) { workspace_path.Prepend("\"").Append("\""); } @@ -179,7 +194,7 @@ bool clMakeGeneratorApp::OnInit() wxString command; command << "cd " << workspace_path << " && " << commandToRun; - if(m_executeCommand) { + if (m_executeCommand) { CallAfter(&clMakeGeneratorApp::DoExecCommand, command); } else { @@ -197,20 +212,20 @@ bool clMakeGeneratorApp::DoParseCommandLine(wxCmdLineParser& parser) parser.AddUsageText(_("A makefile generator based on codelite's workspace")); int res = parser.Parse(false); - if(res == wxNOT_FOUND) + if (res == wxNOT_FOUND) return false; - if(!parser.Found("w", &m_workspaceFile)) { + if (!parser.Found("w", &m_workspaceFile)) { parser.Usage(); return false; } - if(!parser.Found("c", &m_configuration)) { + if (!parser.Found("c", &m_configuration)) { parser.Usage(); return false; } - if(parser.Found("e")) { + if (parser.Found("e")) { m_executeCommand = true; } @@ -219,12 +234,12 @@ bool clMakeGeneratorApp::DoParseCommandLine(wxCmdLineParser& parser) m_generateCompilerFlags = (parser.FoundSwitch("f") == wxCMD_SWITCH_ON); wxString command; - if(parser.Found("d", &command)) { - if(command == "build") { + if (parser.Found("d", &command)) { + if (command == "build") { m_commandType = kBuild; - } else if(command == "rebuild") { + } else if (command == "rebuild") { m_commandType = kRebuild; - } else if(command == "clean") { + } else if (command == "clean") { m_commandType = kClean; } else { parser.Usage(); @@ -254,7 +269,7 @@ void clMakeGeneratorApp::Error(const wxString& msg) void clMakeGeneratorApp::Notice(const wxString& msg) { - if(m_verbose) { + if (m_verbose) { wxString e; e << "[NOTICE] " << msg; wxFprintf(stderr, "%s\n", e); @@ -263,7 +278,7 @@ void clMakeGeneratorApp::Notice(const wxString& msg) void clMakeGeneratorApp::Info(const wxString& msg) { - if(m_verbose) { + if (m_verbose) { wxString e; e << "[INFO ] " << msg; wxFprintf(stdout, "%s\n", e); diff --git a/codelite_make/cl_make_generator_app.h b/codelite_make/cl_make_generator_app.h index a15403b814..74f0b36ff3 100644 --- a/codelite_make/cl_make_generator_app.h +++ b/codelite_make/cl_make_generator_app.h @@ -21,7 +21,7 @@ class clMakeGeneratorApp : public wxAppConsole eCommandType m_commandType; wxString m_buildSettingsXml; bool m_generateCompileCommands; - bool m_generateCompilerFlags = false; + bool m_generateCompilerFlags = false; protected: bool DoParseCommandLine(wxCmdLineParser& parser); @@ -32,7 +32,7 @@ class clMakeGeneratorApp : public wxAppConsole void Info(const wxString& msg); void Out(const wxString& msg); void Bye(); - + public: clMakeGeneratorApp(); virtual ~clMakeGeneratorApp() = default; diff --git a/codelite_makedir/makedir.cpp b/codelite_makedir/makedir.cpp index a6ee77c9d9..c02f7e3abb 100644 --- a/codelite_makedir/makedir.cpp +++ b/codelite_makedir/makedir.cpp @@ -7,13 +7,13 @@ #include //wxString #include -static const wxCmdLineEntryDesc cmdLineDesc[] = { { wxCMD_LINE_PARAM, - NULL, - NULL, - "Directory name", - wxCMD_LINE_VAL_STRING, - wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL }, - { wxCMD_LINE_NONE } }; +static const wxCmdLineEntryDesc cmdLineDesc[] = {{wxCMD_LINE_PARAM, + NULL, + NULL, + "Directory name", + wxCMD_LINE_VAL_STRING, + wxCMD_LINE_PARAM_MULTIPLE | wxCMD_LINE_PARAM_OPTIONAL}, + {wxCMD_LINE_NONE}}; int main(int argc, char** argv) { diff --git a/codelite_vim/VimSettingsDlg.cpp b/codelite_vim/VimSettingsDlg.cpp index fb03cb4611..9908e52ef6 100644 --- a/codelite_vim/VimSettingsDlg.cpp +++ b/codelite_vim/VimSettingsDlg.cpp @@ -1,4 +1,5 @@ #include "VimSettingsDlg.h" + #include "VimSettings.h" VimSettingsDlg::VimSettingsDlg(wxWindow* parent) diff --git a/codelite_vim/codelite_vim.cpp b/codelite_vim/codelite_vim.cpp index 693c1a40cf..c15be25e31 100644 --- a/codelite_vim/codelite_vim.cpp +++ b/codelite_vim/codelite_vim.cpp @@ -1,9 +1,11 @@ +#include "codelite_vim.h" + #include "VimSettings.h" #include "VimSettingsDlg.h" -#include "codelite_vim.h" #include "event_notifier.h" #include "macros.h" #include "vim_manager.h" + #include #include #include @@ -12,10 +14,7 @@ #include // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new CodeliteVim(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new CodeliteVim(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -61,7 +60,7 @@ void CodeliteVim::UnPlug() void CodeliteVim::onVimSetting(wxCommandEvent& event) { VimSettingsDlg dlg(EventNotifier::Get()->TopFrame()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { // Store the settings m_settings.SetEnabled(dlg.GetCheckBoxEnabled()->IsChecked()).Save(); m_vimM->SettingsUpdated(); diff --git a/codelite_vim/codelite_vim.h b/codelite_vim/codelite_vim.h index 114e730eb8..d6d6cec4ef 100644 --- a/codelite_vim/codelite_vim.h +++ b/codelite_vim/codelite_vim.h @@ -1,8 +1,8 @@ #ifndef __CodeliteVim__ #define __CodeliteVim__ -#include "plugin.h" #include "VimSettings.h" +#include "plugin.h" class VimManager; @@ -27,7 +27,7 @@ class CodeliteVim : public IPlugin /** * @brief Unplug the plugin. Perform here any cleanup needed - * (e.g. unbind events, destroy allocated windows) + * (e.g. unbind events, destroy allocated windows) */ void UnPlug() override; diff --git a/codelite_vim/vimCommands.cpp b/codelite_vim/vimCommands.cpp index 80ec9e9889..e7a5b05d1c 100644 --- a/codelite_vim/vimCommands.cpp +++ b/codelite_vim/vimCommands.cpp @@ -3034,7 +3034,8 @@ long VimCommand::goToMatchingParenthesis(long start_pos) return (indenting_level == 0) ? pos : -1; } -bool VimCommand::findMatchingParenthesis(wxChar lch, wxChar rch, long minPos, long maxPos, long& leftPos, long& rightPos) +bool VimCommand::findMatchingParenthesis( + wxChar lch, wxChar rch, long minPos, long maxPos, long& leftPos, long& rightPos) { long curPos = m_ctrl->GetCurrentPos(); int level = 1; diff --git a/codelite_vim/vim_manager.h b/codelite_vim/vim_manager.h index 9c1fa76eea..8bb6e1e97c 100644 --- a/codelite_vim/vim_manager.h +++ b/codelite_vim/vim_manager.h @@ -10,6 +10,7 @@ #include "imanager.h" #include "macros.h" #include "vimCommands.h" + #include #include /*Experimental*/ diff --git a/codelitephp/PHPParser/PHPSetterGetterEntry.cpp b/codelitephp/PHPParser/PHPSetterGetterEntry.cpp index 2fd68c5fda..ba516f038a 100644 --- a/codelitephp/PHPParser/PHPSetterGetterEntry.cpp +++ b/codelitephp/PHPParser/PHPSetterGetterEntry.cpp @@ -15,9 +15,9 @@ wxString PHPSetterGetterEntry::GetGetter(size_t flags) const wxString nameWithDollar = m_entry->GetShortName(); wxString prefix; - if(!(flags & kSG_NoPrefix)) { + if (!(flags & kSG_NoPrefix)) { prefix = (flags & kSG_StartWithLowercase) ? "get" : "Get"; - if(m_entry->Cast()->IsBoolean()) { + if (m_entry->Cast()->IsBoolean()) { // A boolean member, use "is" as the prefix for the getter prefix = (flags & kSG_StartWithLowercase) ? "is" : "Is"; } @@ -28,7 +28,7 @@ wxString PHPSetterGetterEntry::GetGetter(size_t flags) const FormatName(functionName, flags); functionName.Prepend(prefix); - if(flags & kSG_NameOnly) { + if (flags & kSG_NameOnly) { return functionName; } @@ -56,7 +56,7 @@ wxString PHPSetterGetterEntry::GetSetter(const wxString& scope, size_t flags) co prefix = (flags & kSG_StartWithLowercase) ? "set" : "Set"; functionName.Prepend(prefix); - if(flags & kSG_NameOnly) { + if (flags & kSG_NameOnly) { return functionName; } @@ -66,7 +66,7 @@ wxString PHPSetterGetterEntry::GetSetter(const wxString& scope, size_t flags) co << " * @param " << m_entry->Cast()->GetTypeHint() << " " << m_entry->GetShortName() << "\n"; - if(flags & kSG_ReturnThis) { + if (flags & kSG_ReturnThis) { body << " *\n"; body << " * @return " << scope << "\n"; } @@ -74,7 +74,7 @@ wxString PHPSetterGetterEntry::GetSetter(const wxString& scope, size_t flags) co << " public function " << functionName << "(" << nameWithDollar << ")\n" << " {\n" << " $this->" << nameNoDollar << " = " << nameWithDollar << ";\n"; - if(flags & kSG_ReturnThis) { + if (flags & kSG_ReturnThis) { body << "\n" << " return $this;\n"; } @@ -84,10 +84,10 @@ wxString PHPSetterGetterEntry::GetSetter(const wxString& scope, size_t flags) co void PHPSetterGetterEntry::FormatName(wxString& name, size_t flags) const { - if(name.StartsWith(wxT("m_"))) { + if (name.StartsWith(wxT("m_"))) { name = name.Mid(2); - } else if(name.StartsWith(wxT("_"))) { + } else if (name.StartsWith(wxT("_"))) { name = name.Mid(1); } @@ -97,18 +97,18 @@ void PHPSetterGetterEntry::FormatName(wxString& name, size_t flags) const wxStringTokenizer tkz(name, wxT("_")); name.Clear(); size_t count = 0; - while(tkz.HasMoreTokens()) { + while (tkz.HasMoreTokens()) { wxString token = tkz.NextToken(); wxString pre = token.Mid(0, 1); token.Remove(0, 1); - if(usingPrefix) { + if (usingPrefix) { pre.MakeUpper(); } else { // No prefix - if(startWithUppercase && count == 0) { + if (startWithUppercase && count == 0) { pre.MakeUpper(); - } else if(count) { + } else if (count) { pre.MakeUpper(); } } diff --git a/codelitephp/PHPParser/PHPTerminal.cpp b/codelitephp/PHPParser/PHPTerminal.cpp index 84a1859fbf..c45b1f391d 100644 --- a/codelitephp/PHPParser/PHPTerminal.cpp +++ b/codelitephp/PHPParser/PHPTerminal.cpp @@ -1,13 +1,14 @@ #include "PHPTerminal.h" -#include "lexer_configuration.h" + #include "ColoursAndFontsManager.h" +#include "lexer_configuration.h" #include "windowattrmanager.h" PHPTerminal::PHPTerminal(wxWindow* parent) : TerminalEmulatorFrame(parent) { LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexer("php"); - if(lexer) { + if (lexer) { lexer->Apply(GetTerminalUI()->GetTerminalOutputWindow()); } SetSize(300, 300); diff --git a/codelitephp/PHPParser/PHPUserWorkspace.cpp b/codelitephp/PHPParser/PHPUserWorkspace.cpp index b888816aa0..6c47739722 100644 --- a/codelitephp/PHPParser/PHPUserWorkspace.cpp +++ b/codelitephp/PHPParser/PHPUserWorkspace.cpp @@ -10,10 +10,10 @@ PHPUserWorkspace::PHPUserWorkspace(const wxString& workspacePath) wxFileName PHPUserWorkspace::GetFileName() const { - wxFileName workspaceFile( m_workspacePath ); + wxFileName workspaceFile(m_workspacePath); wxFileName fn(workspaceFile.GetPath(), workspaceFile.GetFullName() + "." + ::clGetUserName()); fn.AppendDir(".codelite"); - if ( !fn.FileExists() ) { + if (!fn.FileExists()) { fn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); } return fn; @@ -25,13 +25,13 @@ PHPUserWorkspace& PHPUserWorkspace::Load() JSON root(fn); JSONItem element = root.toElement(); m_breakpoints.clear(); - + JSONItem bpArr = element.namedObject("m_breakpoints"); int bpcount = bpArr.arraySize(); - for( int i=0; i class PHPUserWorkspace { XDebugBreakpoint::List_t m_breakpoints; - wxString m_workspacePath; - + wxString m_workspacePath; + protected: wxFileName GetFileName() const; public: - PHPUserWorkspace(const wxString &workspacePath); + PHPUserWorkspace(const wxString& workspacePath); virtual ~PHPUserWorkspace() = default; PHPUserWorkspace& Load(); PHPUserWorkspace& Save(); - PHPUserWorkspace& SetBreakpoints(const XDebugBreakpoint::List_t& breakpoints) { + PHPUserWorkspace& SetBreakpoints(const XDebugBreakpoint::List_t& breakpoints) + { this->m_breakpoints = breakpoints; return *this; } - const XDebugBreakpoint::List_t& GetBreakpoints() const { - return m_breakpoints; - } + const XDebugBreakpoint::List_t& GetBreakpoints() const { return m_breakpoints; } }; #endif // PHPUSERWORKSPACE_H diff --git a/codelitephp/PHPParser/PHPWrokspaceStorageInterface.h b/codelitephp/PHPParser/PHPWrokspaceStorageInterface.h index 61c046f735..3e29348b4b 100644 --- a/codelitephp/PHPParser/PHPWrokspaceStorageInterface.h +++ b/codelitephp/PHPParser/PHPWrokspaceStorageInterface.h @@ -26,15 +26,15 @@ #ifndef PHPWROKSPACE_STORAGE_INTERFACE_H #define PHPWROKSPACE_STORAGE_INTERFACE_H +#include +#include #include #include -#include -#include struct FileInfo { wxFileName filename; - wxString folder; - size_t flags; + wxString folder; + size_t flags; }; using FileArray_t = std::vector; diff --git a/codelitephp/PHPParser/XDebugBreakpoint.h b/codelitephp/PHPParser/XDebugBreakpoint.h index 11265e4f34..a08a2bc817 100644 --- a/codelitephp/PHPParser/XDebugBreakpoint.h +++ b/codelitephp/PHPParser/XDebugBreakpoint.h @@ -27,6 +27,7 @@ #define XDEBUGBREAKPOINT_H #include "JSON.h" + #include #include diff --git a/codelitephp/PHPParser/php_configuration_data.cpp b/codelitephp/PHPParser/php_configuration_data.cpp index d1ab192bc4..7b3f1d8d00 100644 --- a/codelitephp/PHPParser/php_configuration_data.cpp +++ b/codelitephp/PHPParser/php_configuration_data.cpp @@ -34,7 +34,9 @@ void PHPConfigurationData::FromJSON(const JSONItem& json) // xdebug IDE can not be an empty string, or else debugging in command line // will not work - if(m_xdebugIdeKey.IsEmpty()) { m_xdebugIdeKey = "codeliteide"; } + if (m_xdebugIdeKey.IsEmpty()) { + m_xdebugIdeKey = "codeliteide"; + } m_ccIncludePath = json.namedObject("m_ccIncludePath").toArrayString(); } @@ -55,20 +57,24 @@ JSONItem PHPConfigurationData::ToJSON() const wxString PHPConfigurationData::GetIncludePathsAsString() const { wxString str; - for(size_t i = 0; i < GetIncludePaths().GetCount(); i++) { + for (size_t i = 0; i < GetIncludePaths().GetCount(); i++) { str << GetIncludePaths().Item(i) << wxT("\n"); } - if(str.IsEmpty() == false) { str.RemoveLast(); } + if (str.IsEmpty() == false) { + str.RemoveLast(); + } return str; } wxString PHPConfigurationData::GetCCIncludePathsAsString() const { wxString str; - for(size_t i = 0; i < m_ccIncludePath.GetCount(); i++) { + for (size_t i = 0; i < m_ccIncludePath.GetCount(); i++) { str << m_ccIncludePath.Item(i) << wxT("\n"); } - if(str.IsEmpty() == false) { str.RemoveLast(); } + if (str.IsEmpty() == false) { + str.RemoveLast(); + } return str; } diff --git a/codelitephp/PHPParser/php_configuration_data.h b/codelitephp/PHPParser/php_configuration_data.h index 8e7277e757..75d0561019 100644 --- a/codelitephp/PHPParser/php_configuration_data.h +++ b/codelitephp/PHPParser/php_configuration_data.h @@ -69,7 +69,7 @@ class PHPConfigurationData : public clConfigItem int GetWorkspaceType() const { return m_workspaceType; } PHPConfigurationData& EnableFlag(size_t flag, bool b) { - if(b) { + if (b) { m_flags |= flag; } else { m_flags &= ~flag; diff --git a/codelitephp/PHPParser/php_event.cpp b/codelitephp/PHPParser/php_event.cpp index 9a390587a5..07c61ebada 100644 --- a/codelitephp/PHPParser/php_event.cpp +++ b/codelitephp/PHPParser/php_event.cpp @@ -18,7 +18,4 @@ PHPEvent::PHPEvent(wxEventType commandType, int winid) { } -wxEvent* PHPEvent::Clone() const -{ - return new PHPEvent(*this); -} +wxEvent* PHPEvent::Clone() const { return new PHPEvent(*this); } diff --git a/codelitephp/PHPParser/php_event.h b/codelitephp/PHPParser/php_event.h index f27d876822..011b8459ef 100644 --- a/codelitephp/PHPParser/php_event.h +++ b/codelitephp/PHPParser/php_event.h @@ -30,11 +30,11 @@ class PHPEvent : public clCommandEvent { - wxString m_oldFilename; + wxString m_oldFilename; wxArrayString m_fileList; - wxString m_url; - bool m_useDefaultBrowser = false; - int m_lineNumber = -1; + wxString m_url; + bool m_useDefaultBrowser = false; + int m_lineNumber = -1; public: PHPEvent(wxEventType commandType = wxEVT_NULL, int winid = 0); @@ -42,44 +42,23 @@ class PHPEvent : public clCommandEvent PHPEvent& operator=(const PHPEvent&) = delete; ~PHPEvent() override = default; - wxEvent *Clone() const override; - void SetLineNumber(int lineNumber) { - this->m_lineNumber = lineNumber; - } - int GetLineNumber() const { - return m_lineNumber; - } - void SetFileList(const wxArrayString& fileList) { - this->m_fileList = fileList; - } - const wxArrayString& getFileList() const { - return m_fileList; - } - - void SetOldFilename(const wxString& oldFilename) { - this->m_oldFilename = oldFilename; - } - - const wxString& GetOldFilename() const { - return m_oldFilename; - } - void SetUrl(const wxString& url) { - this->m_url = url; - } - const wxString& GetUrl() const { - return m_url; - } - void SetUseDefaultBrowser(bool useDefaultBrowser) { - this->m_useDefaultBrowser = useDefaultBrowser; - } - bool IsUseDefaultBrowser() const { - return m_useDefaultBrowser; - } + wxEvent* Clone() const override; + void SetLineNumber(int lineNumber) { this->m_lineNumber = lineNumber; } + int GetLineNumber() const { return m_lineNumber; } + void SetFileList(const wxArrayString& fileList) { this->m_fileList = fileList; } + const wxArrayString& getFileList() const { return m_fileList; } + + void SetOldFilename(const wxString& oldFilename) { this->m_oldFilename = oldFilename; } + + const wxString& GetOldFilename() const { return m_oldFilename; } + void SetUrl(const wxString& url) { this->m_url = url; } + const wxString& GetUrl() const { return m_url; } + void SetUseDefaultBrowser(bool useDefaultBrowser) { this->m_useDefaultBrowser = useDefaultBrowser; } + bool IsUseDefaultBrowser() const { return m_useDefaultBrowser; } }; using PHPEventFunction = void (wxEvtHandler::*)(PHPEvent&); -#define PHPEventHandler(func) \ - wxEVENT_HANDLER_CAST(PHPEventFunction, func) +#define PHPEventHandler(func) wxEVENT_HANDLER_CAST(PHPEventFunction, func) wxDECLARE_EVENT(wxEVT_PHP_FILE_RENAMED, PHPEvent); wxDECLARE_EVENT(wxEVT_PHP_FILES_REMOVED, PHPEvent); diff --git a/codelitephp/PHPParser/php_parser_thread.h b/codelitephp/PHPParser/php_parser_thread.h index 235d397433..a1fdf01816 100644 --- a/codelitephp/PHPParser/php_parser_thread.h +++ b/codelitephp/PHPParser/php_parser_thread.h @@ -28,7 +28,6 @@ #include - class PHPParserThreadRequest : public ThreadRequest { public: @@ -37,13 +36,13 @@ class PHPParserThreadRequest : public ThreadRequest kParseWorkspaceFilesQuick, kParseSingleFile, }; - + ePHPParserThreadRequestType requestType; wxArrayString files; wxString workspaceFile; wxString file; wxArrayString frameworksPaths; - + public: PHPParserThreadRequest(ePHPParserThreadRequestType type) : requestType(type) @@ -56,7 +55,7 @@ class PHPParserThread : public WorkerThread { static PHPParserThread* ms_instance; static bool ms_goingDown; - + public: static PHPParserThread* Instance(); static void Release(); diff --git a/codelitephp/PHPParser/php_project.cpp b/codelitephp/PHPParser/php_project.cpp index 9cec045ddb..69b68a35b0 100644 --- a/codelitephp/PHPParser/php_project.cpp +++ b/codelitephp/PHPParser/php_project.cpp @@ -151,8 +151,8 @@ void PHPProject::FolderDeleted(const wxString& name, bool notify) updatedArray.Alloc(m_files.size()); deletedFiles.Alloc(m_files.size()); - for(size_t i = 0; i < m_files.GetCount(); ++i) { - if(!m_files.Item(i).StartsWith(name)) { + for (size_t i = 0; i < m_files.GetCount(); ++i) { + if (!m_files.Item(i).StartsWith(name)) { updatedArray.Add(m_files.Item(i)); } else { deletedFiles.Add(m_files.Item(i)); @@ -166,7 +166,7 @@ void PHPProject::FolderDeleted(const wxString& name, bool notify) // Update the list m_files.swap(updatedArray); m_files.Sort(); - if(notify) { + if (notify) { clCommandEvent event(wxEVT_PROJ_FILE_REMOVED); event.SetStrings(deletedFiles); EventNotifier::Get()->AddPendingEvent(event); @@ -176,9 +176,11 @@ void PHPProject::FolderDeleted(const wxString& name, bool notify) void PHPProject::FileRenamed(const wxString& oldname, const wxString& newname, bool notify) { int where = m_files.Index(oldname); - if(where != wxNOT_FOUND) { m_files.Item(where) = newname; } + if (where != wxNOT_FOUND) { + m_files.Item(where) = newname; + } - if(notify && (where != wxNOT_FOUND)) { + if (notify && (where != wxNOT_FOUND)) { { wxArrayString arr; arr.Add(oldname); @@ -211,15 +213,18 @@ void PHPProject::SynchWithFileSystem() void PHPProject::FilesDeleted(const wxArrayString& files, bool notify) { - if(files.IsEmpty()) return; + if (files.IsEmpty()) + return; // Normalize the folder name by using wxFileName - for(size_t i = 0; i < files.GetCount(); ++i) { + for (size_t i = 0; i < files.GetCount(); ++i) { int where = m_files.Index(files.Item(i)); - if(where != wxNOT_FOUND) { m_files.RemoveAt(where); } + if (where != wxNOT_FOUND) { + m_files.RemoveAt(where); + } } - if(notify) { + if (notify) { clCommandEvent event(wxEVT_PROJ_FILE_REMOVED); event.SetStrings(files); EventNotifier::Get()->AddPendingEvent(event); @@ -233,12 +238,12 @@ bool PHPProject::HasFile(const wxFileName& filename) const void PHPProject::FileAdded(const wxString& filename, bool notify) { - if(m_files.Index(filename) == wxNOT_FOUND) { + if (m_files.Index(filename) == wxNOT_FOUND) { m_files.Add(filename); m_files.Sort(); } - if(notify) { + if (notify) { clCommandEvent event(wxEVT_PROJ_FILE_ADDED); wxArrayString files; files.Add(filename); @@ -250,7 +255,7 @@ void PHPProject::FileAdded(const wxString& filename, bool notify) void PHPProject::FolderAdded(const wxString& folderpath) { wxFileName fakeFile(folderpath, FOLDER_MARKER); - if(m_files.Index(fakeFile.GetFullPath()) == wxNOT_FOUND) { + if (m_files.Index(fakeFile.GetFullPath()) == wxNOT_FOUND) { m_files.Add(fakeFile.GetFullPath()); m_files.Sort(); } diff --git a/codelitephp/PHPParser/php_project.h b/codelitephp/PHPParser/php_project.h index d350608495..c8913a7516 100644 --- a/codelitephp/PHPParser/php_project.h +++ b/codelitephp/PHPParser/php_project.h @@ -97,12 +97,12 @@ class PHPProject : public wxEvtHandler * @brief return a list of all project files (fullpath) */ wxArrayString& GetFiles(wxProgressDialog* progress); - + /** * @brief set the project files */ void SetFiles(const wxArrayString& files); - + /** * @brief return a list of all project files (fullpath) */ @@ -154,7 +154,7 @@ class PHPProject : public wxEvtHandler /** * @brief sync the projec with the file system. But do this in a background thread * Once this function is done, it fires an event wxEVT_PHP_PROJECT_FILES_SYNCED - * @owner owner the class that will receive the start/end events. If no provided (i.e. NULL is passed) + * @owner owner the class that will receive the start/end events. If no provided (i.e. NULL is passed) * the current project object will receive them */ void SyncWithFileSystemAsync(wxEvtHandler* owner = NULL); diff --git a/codelitephp/PHPParser/php_project_settings_data.h b/codelitephp/PHPParser/php_project_settings_data.h index c63de5ee32..950a85387d 100644 --- a/codelitephp/PHPParser/php_project_settings_data.h +++ b/codelitephp/PHPParser/php_project_settings_data.h @@ -69,7 +69,7 @@ class PHPProjectSettingsData void EnableFlag(int flag, bool b) { - if(b) { + if (b) { m_flags |= flag; } else { m_flags &= ~flag; diff --git a/codelitephp/PHPParser/php_strings.h b/codelitephp/PHPParser/php_strings.h index 02ef03269f..99d9ad32fc 100644 --- a/codelitephp/PHPParser/php_strings.h +++ b/codelitephp/PHPParser/php_strings.h @@ -26,19 +26,19 @@ #ifndef PHP_STRINGS_H #define PHP_STRINGS_H -#include -#include #include +#include +#include #define FRAME static_cast(static_cast(wxApp::GetInstance())->GetTopWindow()) -namespace PHPStrings { +namespace PHPStrings +{ -const wxString PHP_WORKSPACE_EXT = wxT("workspace"); +const wxString PHP_WORKSPACE_EXT = wxT("workspace"); const wxString PHP_WORKSPACE_VIEW_TITLE = wxT("PHP"); const wxString PHP_WORKSPACE_VIEW_LABEL = _("PHP"); -}; +}; // namespace PHPStrings #endif // PHP_STRINGS_H - diff --git a/codelitephp/PHPParser/php_utils.cpp b/codelitephp/PHPParser/php_utils.cpp index aeb462b459..03a2e86518 100644 --- a/codelitephp/PHPParser/php_utils.cpp +++ b/codelitephp/PHPParser/php_utils.cpp @@ -13,26 +13,26 @@ bool IsPHPCommentOrString(int styleAtPos) { - if((styleAtPos == wxSTC_HPHP_HSTRING) || (styleAtPos == wxSTC_HPHP_SIMPLESTRING) || - (styleAtPos == wxSTC_HPHP_COMMENT) || (styleAtPos == wxSTC_HPHP_COMMENTLINE)) + if ((styleAtPos == wxSTC_HPHP_HSTRING) || (styleAtPos == wxSTC_HPHP_SIMPLESTRING) || + (styleAtPos == wxSTC_HPHP_COMMENT) || (styleAtPos == wxSTC_HPHP_COMMENTLINE)) return true; return false; } bool IsPHPSection(int styleAtPos) { - if((styleAtPos == wxSTC_HPHP_DEFAULT) || (styleAtPos == wxSTC_HPHP_HSTRING) || - (styleAtPos == wxSTC_HPHP_SIMPLESTRING) || (styleAtPos == wxSTC_HPHP_WORD) || - (styleAtPos == wxSTC_HPHP_NUMBER) || (styleAtPos == wxSTC_HPHP_VARIABLE) || (styleAtPos == wxSTC_HPHP_COMMENT) || - (styleAtPos == wxSTC_HPHP_COMMENTLINE) || (styleAtPos == wxSTC_HPHP_HSTRING_VARIABLE) || - (styleAtPos == wxSTC_HPHP_OPERATOR)) + if ((styleAtPos == wxSTC_HPHP_DEFAULT) || (styleAtPos == wxSTC_HPHP_HSTRING) || + (styleAtPos == wxSTC_HPHP_SIMPLESTRING) || (styleAtPos == wxSTC_HPHP_WORD) || + (styleAtPos == wxSTC_HPHP_NUMBER) || (styleAtPos == wxSTC_HPHP_VARIABLE) || + (styleAtPos == wxSTC_HPHP_COMMENT) || (styleAtPos == wxSTC_HPHP_COMMENTLINE) || + (styleAtPos == wxSTC_HPHP_HSTRING_VARIABLE) || (styleAtPos == wxSTC_HPHP_OPERATOR)) return true; return false; } bool IsPHPFile(IEditor* editor) { - if(!editor) { + if (!editor) { return false; } wxStyledTextCtrl* ctrl = editor->GetCtrl(); @@ -76,7 +76,7 @@ wxString URIToFileName(const wxString& uriFileName) filename.StartsWith(FILE_SCHEME, &filename); #ifdef __WXMSW__ - if(filename.StartsWith("/")) { + if (filename.StartsWith("/")) { filename.Remove(0, 1); } #endif @@ -88,11 +88,11 @@ static wxString URIEncode(const wxString& inputStr) { return StringUtils::Encode wxString FileNameToURI(const wxString& filename) { wxString sourceFullPath = wxFileName(filename).GetFullPath(); - if(!sourceFullPath.StartsWith(FILE_SCHEME)) { + if (!sourceFullPath.StartsWith(FILE_SCHEME)) { sourceFullPath.Prepend(FILE_SCHEME); } sourceFullPath.Replace("\\", "/"); - while(sourceFullPath.Replace("//", "/")) {} + while (sourceFullPath.Replace("//", "/")) {} // wxURI uri(sourceFullPath); sourceFullPath = URIEncode(sourceFullPath); sourceFullPath.Replace("file:", FILE_SCHEME); @@ -110,12 +110,12 @@ static void DecodeFileName(wxString& filename) { filename = StringUtils::DecodeU wxString MapRemoteFileToLocalFile(const wxString& remoteFile) { // Check that a workspace is opened - if(!PHPWorkspace::Get()->IsOpen()) + if (!PHPWorkspace::Get()->IsOpen()) return remoteFile; // Sanity PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetActiveProject(); - if(!pProject) + if (!pProject) return remoteFile; // Map filename file attribute returned by xdebug to local filename @@ -127,7 +127,7 @@ wxString MapRemoteFileToLocalFile(const wxString& remoteFile) // On Windows, the file is returned like (after removing the file://) // /C:/Http/htdocs/file.php - remote the leading "/" wxRegEx reMSWPrefix("/[a-zA-Z]{1}:/"); - if(reMSWPrefix.IsValid() && reMSWPrefix.Matches(filename)) { + if (reMSWPrefix.IsValid() && reMSWPrefix.Matches(filename)) { // Windows file filename.Remove(0, 1); } @@ -136,7 +136,7 @@ wxString MapRemoteFileToLocalFile(const wxString& remoteFile) DecodeFileName(filename); // First check if the remote file exists locally - if(wxFileName(filename).Exists()) { + if (wxFileName(filename).Exists()) { return wxFileName(filename).GetFullPath(); } diff --git a/codelitephp/PHPParser/php_utils.h b/codelitephp/PHPParser/php_utils.h index 200441b265..ffd31994a7 100644 --- a/codelitephp/PHPParser/php_utils.h +++ b/codelitephp/PHPParser/php_utils.h @@ -23,44 +23,43 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef PHP_UTILS_H -#define PHP_UTILS_H - -#include "ieditor.h" - -#include - -/** - * @brief return true of the editor holds a file of type PHP - */ -bool IsPHPFile(IEditor* editor); - -/** - * @brief return true if this is a PHP file - */ -bool IsPHPFileByExt(const wxString& fileName); - -bool IsPHPSection(int styleAtPos ); -bool IsPHPCommentOrString(int styleAtPos); - -#define FILE_SCHEME "file://" - -/** - * @brief convert file in the URI format: file:///path/to/file to -> /path/to/file - */ -wxString URIToFileName(const wxString &uriFileName); - -/** - * @brief convert filename to URI file format - */ -wxString FileNameToURI(const wxString &filename); - -/** - * @brief encode a string into base64 - */ -wxString Base64Encode(const wxString &str); - -wxString MapRemoteFileToLocalFile(const wxString &remoteFile); - -#endif // PHP_UTILS - +#ifndef PHP_UTILS_H +#define PHP_UTILS_H + +#include "ieditor.h" + +#include + +/** + * @brief return true of the editor holds a file of type PHP + */ +bool IsPHPFile(IEditor* editor); + +/** + * @brief return true if this is a PHP file + */ +bool IsPHPFileByExt(const wxString& fileName); + +bool IsPHPSection(int styleAtPos); +bool IsPHPCommentOrString(int styleAtPos); + +#define FILE_SCHEME "file://" + +/** + * @brief convert file in the URI format: file:///path/to/file to -> /path/to/file + */ +wxString URIToFileName(const wxString& uriFileName); + +/** + * @brief convert filename to URI file format + */ +wxString FileNameToURI(const wxString& filename); + +/** + * @brief encode a string into base64 + */ +wxString Base64Encode(const wxString& str); + +wxString MapRemoteFileToLocalFile(const wxString& remoteFile); + +#endif // PHP_UTILS diff --git a/codelitephp/PHPParser/phpexecutor.cpp b/codelitephp/PHPParser/phpexecutor.cpp index 3e144d817e..8d08dfd943 100644 --- a/codelitephp/PHPParser/phpexecutor.cpp +++ b/codelitephp/PHPParser/phpexecutor.cpp @@ -18,13 +18,15 @@ #include #include -bool PHPExecutor::Exec(const wxString& projectName, const wxString& urlOrFilePath, const wxString& xdebugSessionName, +bool PHPExecutor::Exec(const wxString& projectName, + const wxString& urlOrFilePath, + const wxString& xdebugSessionName, bool neverPauseOnExit) { PHPProject::Ptr_t proj = PHPWorkspace::Get()->GetProject(projectName); CHECK_PTR_RET_FALSE(proj); - if(proj->GetSettings().GetRunAs() == PHPProjectSettingsData::kRunAsWebsite) { + if (proj->GetSettings().GetRunAs() == PHPProjectSettingsData::kRunAsWebsite) { return RunRUL(proj, urlOrFilePath, xdebugSessionName); } else { @@ -43,7 +45,7 @@ bool PHPExecutor::RunRUL(PHPProject::Ptr_t pProject, const wxString& urlToRun, c wxString url; wxString queryStrnig = uri.GetQuery(); - if(queryStrnig.IsEmpty() && !xdebugSessionName.IsEmpty()) { + if (queryStrnig.IsEmpty() && !xdebugSessionName.IsEmpty()) { // no query string was provided by the user url << uri.BuildURI() << "?XDEBUG_SESSION_START=" << xdebugSessionName; @@ -58,24 +60,28 @@ bool PHPExecutor::RunRUL(PHPProject::Ptr_t pProject, const wxString& urlToRun, c return true; } -bool PHPExecutor::DoRunCLI(const wxString& script, PHPProject::Ptr_t proj, const wxString& xdebugSessionName, +bool PHPExecutor::DoRunCLI(const wxString& script, + PHPProject::Ptr_t proj, + const wxString& xdebugSessionName, bool neverPauseOnExit) { - if(IsRunning()) { - ::wxMessageBox(_("Another process is already running"), wxT("CodeLite"), wxOK | wxICON_INFORMATION, + if (IsRunning()) { + ::wxMessageBox(_("Another process is already running"), + wxT("CodeLite"), + wxOK | wxICON_INFORMATION, wxTheApp->GetTopWindow()); return false; } wxString errmsg; auto [php, cmd] = DoGetCLICommand(script, proj, errmsg); - if(php.empty() || cmd.empty()) { + if (php.empty() || cmd.empty()) { ::wxMessageBox(errmsg, wxT("CodeLite"), wxOK | wxICON_INFORMATION, wxTheApp->GetTopWindow()); return false; } wxString wd; - if(proj) { + if (proj) { const PHPProjectSettingsData& data = proj->GetSettings(); wd = data.GetWorkingDirectory(); } @@ -86,7 +92,7 @@ bool PHPExecutor::DoRunCLI(const wxString& script, PHPProject::Ptr_t proj, const // Apply the environment variables // export XDEBUG_CONFIG="idekey=session_name remote_host=localhost profiler_enable=1" wxStringMap_t om; - if(!xdebugSessionName.IsEmpty()) { + if (!xdebugSessionName.IsEmpty()) { PHPConfigurationData phpGlobalSettings; phpGlobalSettings.Load(); @@ -101,7 +107,7 @@ bool PHPExecutor::DoRunCLI(const wxString& script, PHPProject::Ptr_t proj, const EnvSetter serrter(&om); // Execute the command - if(!xdebugSessionName.IsEmpty()) { + if (!xdebugSessionName.IsEmpty()) { // debugging return m_terminal.ExecuteNoConsole(cmd, wd); } else { @@ -119,7 +125,7 @@ bool PHPExecutor::RunScript(const wxString& script, wxString& php_output) { wxString errmsg; auto [php, cmd] = DoGetCLICommand(script, PHPProject::Ptr_t(NULL), errmsg); - if(cmd.IsEmpty()) { + if (cmd.IsEmpty()) { ::wxMessageBox(errmsg, wxT("CodeLite"), wxOK | wxICON_INFORMATION, wxTheApp->GetTopWindow()); return false; } @@ -132,8 +138,8 @@ bool PHPExecutor::RunScript(const wxString& script, wxString& php_output) return true; } -std::pair PHPExecutor::DoGetCLICommand(const wxString& script, PHPProject::Ptr_t proj, - wxString& errmsg) +std::pair +PHPExecutor::DoGetCLICommand(const wxString& script, PHPProject::Ptr_t proj, wxString& errmsg) { wxArrayString args; wxString php; @@ -144,7 +150,7 @@ std::pair PHPExecutor::DoGetCLICommand(const wxString& scrip PHPConfigurationData globalConf; globalConf.Load(); - if(proj) { + if (proj) { const PHPProjectSettingsData& data = proj->GetSettings(); args = ::wxStringTokenize(data.GetArgs(), wxT("\n\r"), wxTOKEN_STRTOK); includePath = data.GetIncludePathAsArray(); @@ -160,18 +166,18 @@ std::pair PHPExecutor::DoGetCLICommand(const wxString& scrip } ini.Trim().Trim(false); - if(ini.Contains(" ")) { + if (ini.Contains(" ")) { ini.Prepend("\"").Append("\""); } - if(index.empty()) { + if (index.empty()) { errmsg = _("Please set an index file to execute in the project settings"); return {}; } - if(php.empty()) { + if (php.empty()) { php = globalConf.GetPhpExe(); - if(php.empty()) { + if (php.empty()) { errmsg = _("Could not find any PHP binary to execute. Please set one in from: 'PHP | Settings'"); return {}; } @@ -184,7 +190,7 @@ std::pair PHPExecutor::DoGetCLICommand(const wxString& scrip wxString cmd; php = StringUtils::WrapWithDoubleQuotes(php); - if(!ini.empty()) { + if (!ini.empty()) { cmd << " -c " << ini << " "; } @@ -192,9 +198,9 @@ std::pair PHPExecutor::DoGetCLICommand(const wxString& scrip cmd << wxT(" -d html_errors=Off "); // add the include path - if(includePath.empty() == false) { + if (includePath.empty() == false) { cmd << wxT("-d include_path=\""); - for(size_t i = 0; i < includePath.GetCount(); i++) { + for (size_t i = 0; i < includePath.GetCount(); i++) { cmd << includePath.Item(i) << clPlatform::PathSeparator; } cmd << wxT("\" "); @@ -203,16 +209,16 @@ std::pair PHPExecutor::DoGetCLICommand(const wxString& scrip StringUtils::WrapWithQuotes(index); cmd << index; - if(!args.empty()) { + if (!args.empty()) { cmd << " "; } // set the program arguments to run (after the index file is set) - if(!args.empty()) { - for(const wxString& arg : args) { + if (!args.empty()) { + for (const wxString& arg : args) { cmd << StringUtils::WrapWithDoubleQuotes(arg) << " "; } cmd.RemoveLast(); } - return { php, cmd }; + return {php, cmd}; } diff --git a/codelitephp/PHPParser/phpexecutor.h b/codelitephp/PHPParser/phpexecutor.h index 38b67d9743..08ad7259e6 100644 --- a/codelitephp/PHPParser/phpexecutor.h +++ b/codelitephp/PHPParser/phpexecutor.h @@ -38,8 +38,8 @@ class PHPExecutor : public wxEvtHandler protected: bool RunRUL(PHPProject::Ptr_t pProject, const wxString& urlToRun, const wxString& xdebugSessionName); - bool DoRunCLI(const wxString& script, PHPProject::Ptr_t proj, const wxString& xdebugSessionName, - bool neverPauseOnExit); + bool + DoRunCLI(const wxString& script, PHPProject::Ptr_t proj, const wxString& xdebugSessionName, bool neverPauseOnExit); std::pair DoGetCLICommand(const wxString& script, PHPProject::Ptr_t proj, wxString& errmsg); public: @@ -53,7 +53,9 @@ class PHPExecutor : public wxEvtHandler * @param neverPauseOnExit should we display a console with message 'Hit any key?' * @return true on success, false otherwise */ - bool Exec(const wxString& projectName, const wxString& urlOrFilePath, const wxString& xdebugSessionName, + bool Exec(const wxString& projectName, + const wxString& urlOrFilePath, + const wxString& xdebugSessionName, bool neverPauseOnExit); /** * @brief return true if a script is currently being executed using this instance diff --git a/codelitephp/php-plugin/FileMappingDlg.h b/codelitephp/php-plugin/FileMappingDlg.h index e95e4a241b..f9977b985e 100644 --- a/codelitephp/php-plugin/FileMappingDlg.h +++ b/codelitephp/php-plugin/FileMappingDlg.h @@ -23,33 +23,25 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef FILEMAPPINGDLG_H -#define FILEMAPPINGDLG_H -#include "php_ui.h" - -class FileMappingDlg : public FileMappingDlgBase -{ -public: - FileMappingDlg(wxWindow* parent); - virtual ~FileMappingDlg() = default; - - wxString GetSourceFolder() const { - return m_dirPickerSource->GetPath(); - } - - wxString GetTargetFolder() const { - return m_textCtrlRemote->GetValue(); - } - - void SetSourceFolder( const wxString &path) { - m_dirPickerSource->SetPath( path ); - } - - void SetTargetFolder( const wxString &path) { - m_textCtrlRemote->ChangeValue( path ); - } - -protected: - virtual void OnOkUI(wxUpdateUIEvent& event); -}; -#endif // FILEMAPPINGDLG_H +#ifndef FILEMAPPINGDLG_H +#define FILEMAPPINGDLG_H +#include "php_ui.h" + +class FileMappingDlg : public FileMappingDlgBase +{ +public: + FileMappingDlg(wxWindow* parent); + virtual ~FileMappingDlg() = default; + + wxString GetSourceFolder() const { return m_dirPickerSource->GetPath(); } + + wxString GetTargetFolder() const { return m_textCtrlRemote->GetValue(); } + + void SetSourceFolder(const wxString& path) { m_dirPickerSource->SetPath(path); } + + void SetTargetFolder(const wxString& path) { m_textCtrlRemote->ChangeValue(path); } + +protected: + virtual void OnOkUI(wxUpdateUIEvent& event); +}; +#endif // FILEMAPPINGDLG_H diff --git a/codelitephp/php-plugin/NewPHPClass.cpp b/codelitephp/php-plugin/NewPHPClass.cpp index 946c4a0fba..a93f27269b 100644 --- a/codelitephp/php-plugin/NewPHPClass.cpp +++ b/codelitephp/php-plugin/NewPHPClass.cpp @@ -20,15 +20,19 @@ PHPClassDetails NewPHPClass::GetDetails() const { PHPClassDetails pcd; size_t flags = 0; - if(m_checkBoxCtor->IsChecked()) flags |= PHPClassDetails::GEN_CTOR; - if(m_checkBoxDtor->IsChecked()) flags |= PHPClassDetails::GEN_DTOR; - if(m_checkBoxSingleton->IsChecked()) flags |= PHPClassDetails::GEN_SINGLETON; - if(m_checkBoxFolderPerNamespace->IsChecked()) flags |= PHPClassDetails::GEN_FOLDER_PER_NAMESPACE; + if (m_checkBoxCtor->IsChecked()) + flags |= PHPClassDetails::GEN_CTOR; + if (m_checkBoxDtor->IsChecked()) + flags |= PHPClassDetails::GEN_DTOR; + if (m_checkBoxSingleton->IsChecked()) + flags |= PHPClassDetails::GEN_SINGLETON; + if (m_checkBoxFolderPerNamespace->IsChecked()) + flags |= PHPClassDetails::GEN_FOLDER_PER_NAMESPACE; pcd.SetFlags(flags); wxString filepath; filepath << m_outputPath << wxFILE_SEP_PATH; - if(pcd.GetFlags() & PHPClassDetails::GEN_FOLDER_PER_NAMESPACE) { + if (pcd.GetFlags() & PHPClassDetails::GEN_FOLDER_PER_NAMESPACE) { filepath << m_textCtrlNamespace->GetValue() << wxFILE_SEP_PATH; } filepath << m_textCtrlClassName->GetValue() << ".php"; @@ -64,7 +68,7 @@ void NewPHPClass::OnEditExtends(wxCommandEvent& event) _("Edit Class Extends"), ::wxJoin(::wxSplit(m_textCtrlExtends->GetValue(), ','), '\n'), wxTE_MULTILINE | wxTextEntryDialogStyle); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { m_textCtrlExtends->ChangeValue(::wxJoin(::wxSplit(dlg.GetValue(), '\n'), ',')); } } @@ -77,7 +81,7 @@ void NewPHPClass::OnEditImplements(wxCommandEvent& event) ::wxJoin(::wxSplit(m_textCtrlImplements->GetValue(), ','), '\n'), wxTE_MULTILINE | wxTextEntryDialogStyle); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { m_textCtrlImplements->ChangeValue(::wxJoin(::wxSplit(dlg.GetValue(), '\n'), ',')); } } @@ -85,7 +89,7 @@ void NewPHPClass::OnEditImplements(wxCommandEvent& event) wxString PHPClassDetails::ToString(const wxString& EOL, const wxString& indent) const { wxString classString; - if(!GetNamespace().IsEmpty()) { + if (!GetNamespace().IsEmpty()) { classString << "namespace " << GetNamespace() << ";" << EOL << EOL; } @@ -95,46 +99,46 @@ wxString PHPClassDetails::ToString(const wxString& EOL, const wxString& indent) const wxArrayString& extends = GetExtends(); const wxArrayString& implements = GetImplements(); - if(!extends.IsEmpty()) { + if (!extends.IsEmpty()) { classString << "extends "; - for(size_t i = 0; i < extends.GetCount(); ++i) { + for (size_t i = 0; i < extends.GetCount(); ++i) { classString << extends.Item(i) << ", "; } classString.RemoveLast(2).Append(" "); } - if(!implements.IsEmpty()) { + if (!implements.IsEmpty()) { classString << "implements "; - for(size_t i = 0; i < implements.GetCount(); ++i) { + for (size_t i = 0; i < implements.GetCount(); ++i) { classString << implements.Item(i) << ", "; } classString.RemoveLast(2).Append(" "); } - classString << EOL << "{" << EOL; + classString << EOL << "{" << EOL; - if(IsClass() && (GetFlags() & GEN_SINGLETON)) { + if (IsClass() && (GetFlags() & GEN_SINGLETON)) { classString << indent << "/** @var self */" << EOL; classString << indent << "protected static $instance;" << EOL; } - if(IsClass() && (GetFlags() & (GEN_CTOR | GEN_SINGLETON))) { - if(GetFlags() & GEN_SINGLETON) { + if (IsClass() && (GetFlags() & (GEN_CTOR | GEN_SINGLETON))) { + if (GetFlags() & GEN_SINGLETON) { classString << EOL; } - if(GetFlags() & GEN_SINGLETON) { + if (GetFlags() & GEN_SINGLETON) { classString << indent << "protected function __construct()" << EOL; } else { classString << indent << "public function __construct()" << EOL; } classString << indent << "{" << EOL; - if(!(GetFlags() & GEN_SINGLETON)) { + if (!(GetFlags() & GEN_SINGLETON)) { classString << indent << indent << EOL; } classString << indent << "}" << EOL; } - if(IsClass() && (GetFlags() & GEN_DTOR)) { + if (IsClass() && (GetFlags() & GEN_DTOR)) { if (GetFlags() & (GEN_CTOR | GEN_SINGLETON)) { classString << EOL; } @@ -144,7 +148,7 @@ wxString PHPClassDetails::ToString(const wxString& EOL, const wxString& indent) classString << indent << "}" << EOL; } - if(IsClass() && (GetFlags() & GEN_SINGLETON)) { + if (IsClass() && (GetFlags() & GEN_SINGLETON)) { classString << EOL; classString << indent << "/**" << EOL; classString << indent << " * @return self" << EOL; diff --git a/codelitephp/php-plugin/NewPHPClass.h b/codelitephp/php-plugin/NewPHPClass.h index 2531a94edd..c73a28aa49 100644 --- a/codelitephp/php-plugin/NewPHPClass.h +++ b/codelitephp/php-plugin/NewPHPClass.h @@ -27,6 +27,7 @@ #define NEWPHPCLASS_H #include "new_class.h" + #include // -------------------------------------------------------------------------------------- @@ -36,72 +37,46 @@ class PHPClassDetails { public: enum { - GEN_CTOR = 0x00000001, - GEN_DTOR = 0x00000002, - GEN_SINGLETON = 0x00000004, + GEN_CTOR = 0x00000001, + GEN_DTOR = 0x00000002, + GEN_SINGLETON = 0x00000004, GEN_FOLDER_PER_NAMESPACE = 0x00000008, }; protected: wxFileName m_filepath; - wxString m_name; - wxString m_classNamespace; - size_t m_flags; - wxString m_type; + wxString m_name; + wxString m_classNamespace; + size_t m_flags; + wxString m_type; wxArrayString m_extends; wxArrayString m_implements; public: - PHPClassDetails() : m_flags(0), m_type("class") {} + PHPClassDetails() + : m_flags(0) + , m_type("class") + { + } virtual ~PHPClassDetails() = default; wxString ToString(const wxString& EOL, const wxString& indent) const; - void SetType(const wxString& type) { - this->m_type = type; - } - void SetExtends(const wxArrayString& extends) { - this->m_extends = extends; - } - void SetImplements(const wxArrayString& implements) { - this->m_implements = implements; - } - const wxArrayString& GetExtends() const { - return m_extends; - } - const wxArrayString& GetImplements() const { - return m_implements; - } - const wxString& GetType() const { - return m_type; - } - void SetClassNamespace(const wxString& classNamespace) { - this->m_classNamespace = classNamespace; - } - const wxString& GetNamespace() const { - return m_classNamespace; - } - void SetName(const wxString& name) { - this->m_name = name; - } - const wxString& GetName() const { - return m_name; - } - void SetFilepath(const wxFileName& filepath) { - this->m_filepath = filepath; - } - const wxFileName& GetFilepath() const { - return m_filepath; - } - void SetFlags(size_t flags) { - this->m_flags = flags; - } - size_t GetFlags() const { - return m_flags; - } + void SetType(const wxString& type) { this->m_type = type; } + void SetExtends(const wxArrayString& extends) { this->m_extends = extends; } + void SetImplements(const wxArrayString& implements) { this->m_implements = implements; } + const wxArrayString& GetExtends() const { return m_extends; } + const wxArrayString& GetImplements() const { return m_implements; } + const wxString& GetType() const { return m_type; } + void SetClassNamespace(const wxString& classNamespace) { this->m_classNamespace = classNamespace; } + const wxString& GetNamespace() const { return m_classNamespace; } + void SetName(const wxString& name) { this->m_name = name; } + const wxString& GetName() const { return m_name; } + void SetFilepath(const wxFileName& filepath) { this->m_filepath = filepath; } + const wxFileName& GetFilepath() const { return m_filepath; } + void SetFlags(size_t flags) { this->m_flags = flags; } + size_t GetFlags() const { return m_flags; } - bool IsClass() const { - return GetType() == "class"; - } + bool IsClass() const { return GetType() == "class"; } }; // -------------------------------------------------------------------------------------- @@ -110,8 +85,9 @@ class PHPClassDetails class NewPHPClass : public NewPHPClassBase { wxString m_outputPath; + public: - NewPHPClass(wxWindow* parent, const wxString &classPath); + NewPHPClass(wxWindow* parent, const wxString& classPath); virtual ~NewPHPClass() = default; protected: diff --git a/codelitephp/php-plugin/NewPHPProjectWizard.cpp b/codelitephp/php-plugin/NewPHPProjectWizard.cpp index 69beff2310..e062107ca0 100644 --- a/codelitephp/php-plugin/NewPHPProjectWizard.cpp +++ b/codelitephp/php-plugin/NewPHPProjectWizard.cpp @@ -1,8 +1,10 @@ #include "NewPHPProjectWizard.h" -#include -#include "php_workspace.h" -#include "php_project.h" + #include "php_configuration_data.h" +#include "php_project.h" +#include "php_workspace.h" + +#include #include NewPHPProjectWizard::NewPHPProjectWizard(wxWindow* parent, bool createProjectFromWorkspaceFolder) @@ -13,7 +15,7 @@ NewPHPProjectWizard::NewPHPProjectWizard(wxWindow* parent, bool createProjectFro PHPConfigurationData conf; conf.Load(); m_filePickerPhpExe->SetPath(conf.GetPhpExe()); - if(createProjectFromWorkspaceFolder) { + if (createProjectFromWorkspaceFolder) { m_radioBoxCreateMethod->SetSelection(1); } m_dirPickerPath->SetPath(PHPWorkspace::Get()->GetFilename().GetPath()); @@ -24,16 +26,16 @@ void NewPHPProjectWizard::OnFinish(wxWizardEvent& event) { event.Skip(); } void NewPHPProjectWizard::OnPageChanging(wxWizardEvent& event) { event.Skip(); - if(event.GetDirection() && event.GetPage() == m_wizardPageCreateMethod) { - if(m_radioBoxCreateMethod->GetSelection() == 0) { + if (event.GetDirection() && event.GetPage() == m_wizardPageCreateMethod) { + if (m_radioBoxCreateMethod->GetSelection() == 0) { // empty project m_checkBoxSeparateFolder->Show(true); } else { m_checkBoxSeparateFolder->Show(false); } - } else if(event.GetDirection() && event.GetPage() == m_wizardPageProjectDetails) { + } else if (event.GetDirection() && event.GetPage() == m_wizardPageProjectDetails) { wxFileName projectFilePath(m_textCtrlPreview->GetValue()); - if(!PHPWorkspace::Get()->CanCreateProjectAtPath(projectFilePath, true)) { + if (!PHPWorkspace::Get()->CanCreateProjectAtPath(projectFilePath, true)) { event.Skip(false); event.Veto(); return; @@ -45,7 +47,7 @@ void NewPHPProjectWizard::DoUpdateProjectFolder() { // Build the file name wxFileName fn(m_dirPickerPath->GetPath(), ""); - if(m_checkBoxSeparateFolder->IsShown() && m_checkBoxSeparateFolder->IsChecked()) { + if (m_checkBoxSeparateFolder->IsShown() && m_checkBoxSeparateFolder->IsChecked()) { fn.AppendDir(m_textCtrlName->GetValue()); } fn.SetName(m_textCtrlName->GetValue()); @@ -55,9 +57,9 @@ void NewPHPProjectWizard::DoUpdateProjectFolder() void NewPHPProjectWizard::OnDirSelected(wxFileDirPickerEvent& event) { - if(!m_nameModified) { + if (!m_nameModified) { wxFileName path(event.GetPath(), ""); - if(!path.GetDirs().IsEmpty()) { + if (!path.GetDirs().IsEmpty()) { m_textCtrlName->ChangeValue(path.GetDirs().Last()); } } @@ -88,11 +90,12 @@ void NewPHPProjectWizard::OnCheckSeparateFolder(wxCommandEvent& event) { DoUpdat void NewPHPProjectWizard::OnBrowseForCCFolder(wxCommandEvent& event) { wxString path = ::wxDirSelector(); - if(path.IsEmpty()) return; + if (path.IsEmpty()) + return; wxString currentContent = m_textCtrlCCPaths->GetValue(); wxArrayString paths = ::wxStringTokenize(currentContent, "\n", wxTOKEN_STRTOK); - if(paths.Index(path) == wxNOT_FOUND) { + if (paths.Index(path) == wxNOT_FOUND) { paths.Add(path); } paths.Sort(); diff --git a/codelitephp/php-plugin/NewPHPProjectWizard.h b/codelitephp/php-plugin/NewPHPProjectWizard.h index cf8e4da46c..e699d71204 100644 --- a/codelitephp/php-plugin/NewPHPProjectWizard.h +++ b/codelitephp/php-plugin/NewPHPProjectWizard.h @@ -25,9 +25,9 @@ #ifndef NEWPHPPROJECTWIZARD_H #define NEWPHPPROJECTWIZARD_H -#include "php_ui.h" #include "php_project.h" #include "php_project_settings_data.h" +#include "php_ui.h" class NewPHPProjectWizard : public NewPHPProjectWizardBase { @@ -41,7 +41,7 @@ class NewPHPProjectWizard : public NewPHPProjectWizardBase int GetProjectType() const { - if(m_choiceProjectType->GetStringSelection() == "Run project as command line") { + if (m_choiceProjectType->GetStringSelection() == "Run project as command line") { return PHPProjectSettingsData::kRunAsCLI; } else { return PHPProjectSettingsData::kRunAsWebsite; diff --git a/codelitephp/php-plugin/PHPDebugStartDlg.cpp b/codelitephp/php-plugin/PHPDebugStartDlg.cpp index f02b93a80c..0c1cc63995 100644 --- a/codelitephp/php-plugin/PHPDebugStartDlg.cpp +++ b/codelitephp/php-plugin/PHPDebugStartDlg.cpp @@ -1,6 +1,7 @@ #include "PHPDebugStartDlg.h" -#include "windowattrmanager.h" + #include "imanager.h" +#include "windowattrmanager.h" PHPDebugStartDlg::PHPDebugStartDlg(wxWindow* parent, PHPProject::Ptr_t pProject, IManager* manager) : PHPDebugStartDlgBase(parent) @@ -14,7 +15,7 @@ PHPDebugStartDlg::PHPDebugStartDlg(wxWindow* parent, PHPProject::Ptr_t pProject, m_simpleBook->SetEffect(wxSHOW_EFFECT_NONE); #endif - if(settings.GetRunAs() == PHPProjectSettingsData::kRunAsWebsite) { + if (settings.GetRunAs() == PHPProjectSettingsData::kRunAsWebsite) { m_choice->Select(0); m_simpleBook->SetSelection(0); } else { @@ -22,14 +23,14 @@ PHPDebugStartDlg::PHPDebugStartDlg(wxWindow* parent, PHPProject::Ptr_t pProject, m_simpleBook->SetSelection(1); } GetComboBoxURL()->Append(settings.GetProjectURL()); - if(GetComboBoxURL()->GetCount()) { + if (GetComboBoxURL()->GetCount()) { GetComboBoxURL()->SetSelection(0); } GetCheckBoxDebugActiveEditor()->SetValue(settings.HasFlag(PHPProjectSettingsData::kOpt_RunCurrentEditor)); wxString fileToRun; - if(m_manager->GetActiveEditor() && GetCheckBoxDebugActiveEditor()->IsChecked()) { + if (m_manager->GetActiveEditor() && GetCheckBoxDebugActiveEditor()->IsChecked()) { fileToRun = m_manager->GetActiveEditor()->GetFileName().GetFullPath(); } else { fileToRun = settings.GetIndexFile(); @@ -46,22 +47,21 @@ PHPDebugStartDlg::~PHPDebugStartDlg() settings.EnableFlag(PHPProjectSettingsData::kOpt_RunCurrentEditor, GetCheckBoxDebugActiveEditor()->IsChecked()); settings.SetIndexFile(GetTextCtrlScriptToDebug()->GetValue()); settings.SetProjectURL(GetComboBoxURL()->GetValue()); - settings.SetRunAs(m_choice->GetSelection() == 0 ? PHPProjectSettingsData::kRunAsWebsite : - PHPProjectSettingsData::kRunAsCLI); + settings.SetRunAs(m_choice->GetSelection() == 0 ? PHPProjectSettingsData::kRunAsWebsite + : PHPProjectSettingsData::kRunAsCLI); m_project->Save(); - } void PHPDebugStartDlg::OnDebugMethodChanged(wxCommandEvent& event) { event.Skip(); - if(event.GetSelection() == 0) { + if (event.GetSelection() == 0) { // Debug URL - CallAfter( &PHPDebugStartDlg::SetBookSelection, 0); + CallAfter(&PHPDebugStartDlg::SetBookSelection, 0); m_project->GetSettings().SetRunAs(PHPProjectSettingsData::kRunAsWebsite); } else { // Command line script - CallAfter( &PHPDebugStartDlg::SetBookSelection, 1); + CallAfter(&PHPDebugStartDlg::SetBookSelection, 1); m_project->GetSettings().SetRunAs(PHPProjectSettingsData::kRunAsCLI); } } @@ -73,7 +73,7 @@ void PHPDebugStartDlg::OnScriptToDebugUI(wxUpdateUIEvent& event) void PHPDebugStartDlg::OnUseActiveEditor(wxCommandEvent& event) { - if(m_manager->GetActiveEditor()) { + if (m_manager->GetActiveEditor()) { GetTextCtrlScriptToDebug()->ChangeValue(m_manager->GetActiveEditor()->GetFileName().GetFullPath()); } } @@ -82,7 +82,7 @@ void PHPDebugStartDlg::OnOkUI(wxUpdateUIEvent& event) { event.Enable(!GetPath(). wxString PHPDebugStartDlg::GetPath() const { - if(m_choice->GetSelection() == 0) { + if (m_choice->GetSelection() == 0) { // URL return m_comboBoxURL->GetValue(); } else { diff --git a/codelitephp/php-plugin/PHPDebugStartDlg.h b/codelitephp/php-plugin/PHPDebugStartDlg.h index 2a337f98dd..abe7eab5f6 100644 --- a/codelitephp/php-plugin/PHPDebugStartDlg.h +++ b/codelitephp/php-plugin/PHPDebugStartDlg.h @@ -25,21 +25,22 @@ #ifndef PHPDEBUGSTARTDLG_H #define PHPDEBUGSTARTDLG_H -#include "php_ui.h" #include "php_project.h" +#include "php_ui.h" class PHPDebugStartDlg : public PHPDebugStartDlgBase { PHPProject::Ptr_t m_project; IManager* m_manager; + protected: void SetBookSelection(int sel) { m_simpleBook->SetSelection(sel); } - + public: PHPDebugStartDlg(wxWindow* parent, PHPProject::Ptr_t pProject, IManager* manager); virtual ~PHPDebugStartDlg(); wxString GetPath() const; - + protected: virtual void OnOkUI(wxUpdateUIEvent& event); virtual void OnUseActiveEditor(wxCommandEvent& event); diff --git a/codelitephp/php-plugin/PHPXDebugSetupWizard.cpp b/codelitephp/php-plugin/PHPXDebugSetupWizard.cpp index e625a36f89..21562c3aaf 100644 --- a/codelitephp/php-plugin/PHPXDebugSetupWizard.cpp +++ b/codelitephp/php-plugin/PHPXDebugSetupWizard.cpp @@ -1,4 +1,5 @@ #include "PHPXDebugSetupWizard.h" + #include "php_configuration_data.h" PHPXDebugSetupWizard::PHPXDebugSetupWizard(wxWindow* parent) @@ -6,7 +7,7 @@ PHPXDebugSetupWizard::PHPXDebugSetupWizard(wxWindow* parent) { PHPConfigurationData conf; conf.Load(); - + m_textCtrlIP->ChangeValue(conf.GetXdebugHost()); m_textCtrlKey->ChangeValue(conf.GetXdebugIdeKey()); m_textCtrlPort->ChangeValue(wxString() << conf.GetXdebugPort()); @@ -15,7 +16,7 @@ PHPXDebugSetupWizard::PHPXDebugSetupWizard(wxWindow* parent) void PHPXDebugSetupWizard::OnPageChanging(wxWizardEvent& event) { event.Skip(); - if(event.GetDirection() && event.GetPage() == m_wizardPageIDEKey) { + if (event.GetDirection() && event.GetPage() == m_wizardPageIDEKey) { // build the text to copy wxString content; content << "xdebug.remote_enable=1\n"; diff --git a/codelitephp/php-plugin/PhpSFTPHandler.cpp b/codelitephp/php-plugin/PhpSFTPHandler.cpp index b8fa5ad800..f9e79c0377 100644 --- a/codelitephp/php-plugin/PhpSFTPHandler.cpp +++ b/codelitephp/php-plugin/PhpSFTPHandler.cpp @@ -30,7 +30,7 @@ PhpSFTPHandler::~PhpSFTPHandler() void PhpSFTPHandler::OnFileSaved(clCommandEvent& e) { e.Skip(); - if(!PHPWorkspace::Get()->IsOpen()) { + if (!PHPWorkspace::Get()->IsOpen()) { return; } DoSyncFileWithRemote(e.GetFileName()); @@ -39,14 +39,14 @@ void PhpSFTPHandler::OnFileSaved(clCommandEvent& e) void PhpSFTPHandler::OnReplaceInFiles(clFileSystemEvent& e) { e.Skip(); - if(!PHPWorkspace::Get()->IsOpen()) { + if (!PHPWorkspace::Get()->IsOpen()) { return; } SSHWorkspaceSettings settings; settings.Load(); - if(!EnsureAccountExists(settings)) { + if (!EnsureAccountExists(settings)) { return; } @@ -59,20 +59,20 @@ void PhpSFTPHandler::OnReplaceInFiles(clFileSystemEvent& e) void PhpSFTPHandler::OnFileRenamed(clFileSystemEvent& e) { e.Skip(); - if(!PHPWorkspace::Get()->IsOpen()) { + if (!PHPWorkspace::Get()->IsOpen()) { return; } SSHWorkspaceSettings settings; settings.Load(); - if(!EnsureAccountExists(settings)) { + if (!EnsureAccountExists(settings)) { return; } wxString oldPath = GetRemotePath(settings, e.GetPath()); wxString newPath = GetRemotePath(settings, e.GetNewpath()); - if(oldPath.IsEmpty() || newPath.IsEmpty()) { + if (oldPath.IsEmpty() || newPath.IsEmpty()) { return; } @@ -90,7 +90,7 @@ void PhpSFTPHandler::DoSyncFileWithRemote(const wxFileName& localFile) { // Check to see if we got a remote-upload setup PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProjectForFile(localFile); - if(!pProject) { + if (!pProject) { // Not a workspace file clDEBUG() << localFile << "is not a PHP workspace file, will not sync it with remote" << clEndl; return; @@ -99,13 +99,13 @@ void PhpSFTPHandler::DoSyncFileWithRemote(const wxFileName& localFile) SSHWorkspaceSettings workspaceSettings; workspaceSettings.Load(); - if(!EnsureAccountExists(workspaceSettings)) { + if (!EnsureAccountExists(workspaceSettings)) { return; } // Convert the local path to remote path wxString remotePath = GetRemotePath(workspaceSettings, localFile.GetFullPath()); - if(remotePath.IsEmpty()) { + if (remotePath.IsEmpty()) { return; } @@ -119,7 +119,7 @@ void PhpSFTPHandler::DoSyncFileWithRemote(const wxFileName& localFile) wxString PhpSFTPHandler::GetRemotePath(const SSHWorkspaceSettings& sshSettings, const wxString& localpath) const { - if(!sshSettings.IsRemoteUploadEnabled()) { + if (!sshSettings.IsRemoteUploadEnabled()) { return ""; } wxFileName fnLocalFile = localpath; @@ -131,25 +131,25 @@ wxString PhpSFTPHandler::GetRemotePath(const SSHWorkspaceSettings& sshSettings, void PhpSFTPHandler::OnFileDeleted(clFileSystemEvent& e) { e.Skip(); - if(!PHPWorkspace::Get()->IsOpen()) { + if (!PHPWorkspace::Get()->IsOpen()) { return; } SSHWorkspaceSettings settings; settings.Load(); - if(!EnsureAccountExists(settings)) { + if (!EnsureAccountExists(settings)) { return; } const wxArrayString& paths = e.GetPaths(); - if(paths.IsEmpty()) { + if (paths.IsEmpty()) { return; } for (const auto& path : paths) { wxString remotePath = GetRemotePath(settings, path); - if(remotePath.IsEmpty()) { + if (remotePath.IsEmpty()) { return; } @@ -164,7 +164,7 @@ void PhpSFTPHandler::OnFileDeleted(clFileSystemEvent& e) bool PhpSFTPHandler::EnsureAccountExists(SSHWorkspaceSettings& workspaceSettings) { // Do we need to sync? - if(!(workspaceSettings.IsRemoteUploadSet() && workspaceSettings.IsRemoteUploadEnabled())) { + if (!(workspaceSettings.IsRemoteUploadSet() && workspaceSettings.IsRemoteUploadEnabled())) { return false; } @@ -173,7 +173,7 @@ bool PhpSFTPHandler::EnsureAccountExists(SSHWorkspaceSettings& workspaceSettings // Try to locate hte SSH account for this workspace SSHAccountInfo account; - if(!sftpSettings.GetAccount(workspaceSettings.GetAccount(), account)) { + if (!sftpSettings.GetAccount(workspaceSettings.GetAccount(), account)) { // Failed to locate the SSH account, disable sync wxString msg; msg << _("Failed to locate SSH account: ") << workspaceSettings.GetAccount() << "\n"; diff --git a/codelitephp/php-plugin/PhpSFTPHandler.h b/codelitephp/php-plugin/PhpSFTPHandler.h index bb72f80dda..27953d3bfc 100644 --- a/codelitephp/php-plugin/PhpSFTPHandler.h +++ b/codelitephp/php-plugin/PhpSFTPHandler.h @@ -20,7 +20,7 @@ class PhpSFTPHandler : public wxEvtHandler void DoSyncFileWithRemote(const wxFileName& localFile); wxString GetRemotePath(const SSHWorkspaceSettings& sshSettings, const wxString& localpath) const; bool EnsureAccountExists(SSHWorkspaceSettings& workspaceSettings); - + public: PhpSFTPHandler(); virtual ~PhpSFTPHandler(); @@ -31,6 +31,6 @@ class PhpSFTPHandler : public wxEvtHandler void OnFileDeleted(clFileSystemEvent& e); }; -#endif //USE_SFTP +#endif // USE_SFTP #endif // PHPSFTPHANDLER_H diff --git a/codelitephp/php-plugin/XDebugBreakpointCmdHandler.cpp b/codelitephp/php-plugin/XDebugBreakpointCmdHandler.cpp index bdaacbf7de..073c5b22d1 100644 --- a/codelitephp/php-plugin/XDebugBreakpointCmdHandler.cpp +++ b/codelitephp/php-plugin/XDebugBreakpointCmdHandler.cpp @@ -8,7 +8,8 @@ #include -XDebugBreakpointCmdHandler::XDebugBreakpointCmdHandler(XDebugManager* mgr, int transactionId, +XDebugBreakpointCmdHandler::XDebugBreakpointCmdHandler(XDebugManager* mgr, + int transactionId, XDebugBreakpoint& breakpoint) : XDebugCommandHandler(mgr, transactionId) , m_breakpoint(breakpoint) @@ -19,7 +20,7 @@ void XDebugBreakpointCmdHandler::Process(const wxXmlNode* response) { // Breakpoint assigned successfully (or not) wxString breakpointId = response->GetAttribute("id"); - if(!breakpointId.IsEmpty()) { + if (!breakpointId.IsEmpty()) { long bpid(wxNOT_FOUND); breakpointId.ToCLong(&bpid); m_breakpoint.SetBreakpointId(bpid); diff --git a/codelitephp/php-plugin/XDebugBreakpointCmdHandler.h b/codelitephp/php-plugin/XDebugBreakpointCmdHandler.h index ecd6a567aa..38a65ec7b4 100644 --- a/codelitephp/php-plugin/XDebugBreakpointCmdHandler.h +++ b/codelitephp/php-plugin/XDebugBreakpointCmdHandler.h @@ -26,17 +26,17 @@ #ifndef XDEBUGBREAKPOINTCMDHANDLER_H #define XDEBUGBREAKPOINTCMDHANDLER_H -#include "XDebugCommandHandler.h" #include "XDebugBreakpoint.h" +#include "XDebugCommandHandler.h" class wxXmlNode; class wxSocketBase; class XDebugBreakpointCmdHandler : public XDebugCommandHandler { - XDebugBreakpoint &m_breakpoint; - + XDebugBreakpoint& m_breakpoint; + public: - XDebugBreakpointCmdHandler(XDebugManager* mgr, int transactionId, XDebugBreakpoint &breakpoint); + XDebugBreakpointCmdHandler(XDebugManager* mgr, int transactionId, XDebugBreakpoint& breakpoint); virtual ~XDebugBreakpointCmdHandler() = default; virtual void Process(const wxXmlNode* response); diff --git a/codelitephp/php-plugin/XDebugCommThread.cpp b/codelitephp/php-plugin/XDebugCommThread.cpp index c3361e3ddb..b679f2530e 100644 --- a/codelitephp/php-plugin/XDebugCommThread.cpp +++ b/codelitephp/php-plugin/XDebugCommThread.cpp @@ -13,7 +13,7 @@ XDebugComThread::~XDebugComThread() { Stop(); } void XDebugComThread::Stop() { - if(IsAlive()) { + if (IsAlive()) { Delete(NULL, wxTHREAD_WAIT_BLOCK); } else { @@ -40,7 +40,7 @@ void* XDebugComThread::Entry() // Wait for new connection (up to m_waitForConnTimeout seconds, which defaults to 5 seconds ) do { - if((m_waitForConnTimeout > 0) && (retry > m_waitForConnTimeout)) { + if ((m_waitForConnTimeout > 0) && (retry > m_waitForConnTimeout)) { // Don't wait any longer for XDebug m_xdebugMgr->CallAfter(&XDebugManager::XDebugNotConnecting); return NULL; @@ -49,7 +49,7 @@ void* XDebugComThread::Entry() ++retry; clDEBUG() << "CodeLite >>> Waiting for connection.." << clEndl; - } while(!TestDestroy() && !client); + } while (!TestDestroy() && !client); clDEBUG() << "CodeLite >>> Successfully accepted connection from XDebug!" << endl; m_xdebugMgr->CallAfter(&XDebugManager::SetConnected, true); @@ -60,7 +60,7 @@ void* XDebugComThread::Entry() //---------------------------------------------------------------- std::string initXML; - if(DoReadReply(initXML, client)) { + if (DoReadReply(initXML, client)) { m_xdebugMgr->CallAfter(&XDebugManager::OnSocketInput, initXML); } else { @@ -70,14 +70,14 @@ void* XDebugComThread::Entry() } // The main loop: request-reply mode - while(!TestDestroy()) { + while (!TestDestroy()) { wxString command; - if(m_queue.ReceiveTimeout(20, command) == wxMSGQUEUE_NO_ERROR) { + if (m_queue.ReceiveTimeout(20, command) == wxMSGQUEUE_NO_ERROR) { DoSendCommand(command, client); // Wait for the reply std::string reply; - if(!DoReadReply(reply, client)) { + if (!DoReadReply(reply, client)) { // AN error occurred - close session break; } @@ -98,18 +98,18 @@ void* XDebugComThread::Entry() bool XDebugComThread::DoReadReply(std::string& reply, clSocketBase::Ptr_t client) { - if(!client) { + if (!client) { return false; } try { // Read the data length wxString length; - while(true) { + while (true) { char c = 0; size_t count = 0; client->Read(&c, 1, count); - if(c == 0) { + if (c == 0) { break; } length << c; @@ -139,7 +139,7 @@ bool XDebugComThread::DoReadReply(std::string& reply, clSocketBase::Ptr_t client void XDebugComThread::DoSendCommand(const wxString& command, clSocketBase::Ptr_t client) { // got message, process it - if(!client) { + if (!client) { return; } clDEBUG() << "CodeLite >>> " << command << endl; diff --git a/codelitephp/php-plugin/XDebugCommThread.h b/codelitephp/php-plugin/XDebugCommThread.h index 4a35676e0b..acff6586bd 100644 --- a/codelitephp/php-plugin/XDebugCommThread.h +++ b/codelitephp/php-plugin/XDebugCommThread.h @@ -26,13 +26,14 @@ #ifndef XDEBUG_COMM_THREAD_H #define XDEBUG_COMM_THREAD_H -#include -#include -#include -#include #include "SocketAPI/clSocketBase.h" #include "SocketAPI/clSocketServer.h" +#include +#include +#include +#include + #if defined(__WXMSW__) #include #endif @@ -46,7 +47,7 @@ class XDebugComThread : public wxThread clSocketServer m_server; wxString m_host; int m_waitForConnTimeout; - + protected: void DoSendCommand(const wxString& command, clSocketBase::Ptr_t client); bool DoReadReply(std::string& reply, clSocketBase::Ptr_t client); diff --git a/codelitephp/php-plugin/XDebugCommandHandler.h b/codelitephp/php-plugin/XDebugCommandHandler.h index ed072bebb0..39a9543c11 100644 --- a/codelitephp/php-plugin/XDebugCommandHandler.h +++ b/codelitephp/php-plugin/XDebugCommandHandler.h @@ -26,8 +26,8 @@ #ifndef XDEBUGCOMMANDHANDLER_H #define XDEBUGCOMMANDHANDLER_H -#include #include +#include /// Base class for XDebug command handlers class XDebugManager; @@ -40,7 +40,7 @@ class XDebugCommandHandler using Map_t = std::map; protected: - XDebugManager *m_mgr; + XDebugManager* m_mgr; int m_transactionId; public: @@ -48,12 +48,8 @@ class XDebugCommandHandler virtual ~XDebugCommandHandler() = default; virtual void Process(const wxXmlNode* response) = 0; - void SetTransactionId(int transactionId) { - this->m_transactionId = transactionId; - } - int GetTransactionId() const { - return m_transactionId; - } + void SetTransactionId(int transactionId) { this->m_transactionId = transactionId; } + int GetTransactionId() const { return m_transactionId; } }; #endif // XDEBUGCOMMANDHANDLER_H diff --git a/codelitephp/php-plugin/XDebugEvalCmdHandler.cpp b/codelitephp/php-plugin/XDebugEvalCmdHandler.cpp index c789e967e4..e6b81e7ac1 100644 --- a/codelitephp/php-plugin/XDebugEvalCmdHandler.cpp +++ b/codelitephp/php-plugin/XDebugEvalCmdHandler.cpp @@ -7,7 +7,10 @@ #include -XDebugEvalCmdHandler::XDebugEvalCmdHandler(const wxString& expression, int evalReason, XDebugManager* mgr, int transactionId) +XDebugEvalCmdHandler::XDebugEvalCmdHandler(const wxString& expression, + int evalReason, + XDebugManager* mgr, + int transactionId) : XDebugCommandHandler(mgr, transactionId) , m_expression(expression) , m_evalReason(evalReason) @@ -18,28 +21,28 @@ void XDebugEvalCmdHandler::Process(const wxXmlNode* response) { // Search for the 'property' element wxXmlNode* xmlProp = XmlUtils::FindFirstByTagName(response, "property"); - if ( xmlProp ) { - XVariable var( xmlProp, m_evalReason == kEvalForEvalPane ); + if (xmlProp) { + XVariable var(xmlProp, m_evalReason == kEvalForEvalPane); // Send an event XDebugEvent event(wxEVT_XDEBUG_EVAL_EXPRESSION); - event.SetString( GetExpression() ); - event.SetEvaluated( var.value ); + event.SetString(GetExpression()); + event.SetEvaluated(var.value); event.SetEvalSucceeded(true); event.SetEvalReason(m_evalReason); - EventNotifier::Get()->AddPendingEvent( event ); + EventNotifier::Get()->AddPendingEvent(event); } else { wxXmlNode* errorNode = XmlUtils::FindFirstByTagName(response, "error"); - if ( errorNode ) { - wxXmlNode *message = XmlUtils::FindFirstByTagName(errorNode, "message"); - if ( message ) { + if (errorNode) { + wxXmlNode* message = XmlUtils::FindFirstByTagName(errorNode, "message"); + if (message) { XDebugEvent event(wxEVT_XDEBUG_EVAL_EXPRESSION); - event.SetString( GetExpression() ); + event.SetString(GetExpression()); event.SetEvalSucceeded(false); - event.SetErrorString( message->GetNodeContent() ); + event.SetErrorString(message->GetNodeContent()); event.SetEvalReason(m_evalReason); - EventNotifier::Get()->AddPendingEvent( event ); + EventNotifier::Get()->AddPendingEvent(event); } } } diff --git a/codelitephp/php-plugin/XDebugEvalCmdHandler.h b/codelitephp/php-plugin/XDebugEvalCmdHandler.h index 5b706f3f6b..5c5b99c630 100644 --- a/codelitephp/php-plugin/XDebugEvalCmdHandler.h +++ b/codelitephp/php-plugin/XDebugEvalCmdHandler.h @@ -27,6 +27,7 @@ #define XDEBUGEVALCMDHANDLER_H #include "XDebugCommandHandler.h" // Base class: XDebugCommandHandler + #include class XDebugManager; @@ -34,23 +35,21 @@ class XDebugEvalCmdHandler : public XDebugCommandHandler { public: enum { - kEvalForTooltip = 1, + kEvalForTooltip = 1, kEvalForEvalPane = 2, }; + protected: wxString m_expression; - int m_evalReason; - + int m_evalReason; + public: - XDebugEvalCmdHandler(const wxString &expression, int evalReason, XDebugManager* mgr, int transactionId); + XDebugEvalCmdHandler(const wxString& expression, int evalReason, XDebugManager* mgr, int transactionId); virtual ~XDebugEvalCmdHandler() = default; - void SetExpression(const wxString& expression) { - this->m_expression = expression; - } - const wxString& GetExpression() const { - return m_expression; - } + void SetExpression(const wxString& expression) { this->m_expression = expression; } + const wxString& GetExpression() const { return m_expression; } + public: virtual void Process(const wxXmlNode* response); }; diff --git a/codelitephp/php-plugin/XDebugManager.cpp b/codelitephp/php-plugin/XDebugManager.cpp index 9b58257dcd..62b38b4783 100644 --- a/codelitephp/php-plugin/XDebugManager.cpp +++ b/codelitephp/php-plugin/XDebugManager.cpp @@ -32,7 +32,7 @@ #include "xdebugevent.h" #define CHECK_XDEBUG_SESSION_ACTIVE(event) \ - if(!IsConnected()) { \ + if (!IsConnected()) { \ event.Skip(); \ return; \ } @@ -88,7 +88,7 @@ XDebugManager::~XDebugManager() void XDebugManager::OnDebugStartOrContinue(clDebugEvent& e) { - if(!PHPWorkspace::Get()->IsOpen()) { + if (!PHPWorkspace::Get()->IsOpen()) { // Call skip so CodeLite will continue to handle this event // by passing it to other debuggers e.Skip(); @@ -98,7 +98,7 @@ void XDebugManager::OnDebugStartOrContinue(clDebugEvent& e) // This event is ours to handler, don't call e.Skip() // a PHP debug session requested to start - if(!m_readerThread) { + if (!m_readerThread) { // No reader thread is up, start on // starting the debugger e.SetFeatures(0); // No special features by the PHP debugger @@ -115,10 +115,10 @@ void XDebugManager::DoStartDebugger(bool ideInitiate) CHECK_COND_RET(PHPWorkspace::Get()->GetActiveProject()); // Test which file we want to debug - PHPDebugStartDlg debugDlg(EventNotifier::Get()->TopFrame(), PHPWorkspace::Get()->GetActiveProject(), - m_plugin->GetManager()); - if(ideInitiate) { - if(debugDlg.ShowModal() != wxID_OK) { + PHPDebugStartDlg debugDlg( + EventNotifier::Get()->TopFrame(), PHPWorkspace::Get()->GetActiveProject(), m_plugin->GetManager()); + if (ideInitiate) { + if (debugDlg.ShowModal() != wxID_OK) { return; } } @@ -132,29 +132,29 @@ void XDebugManager::DoStartDebugger(bool ideInitiate) PHPConfigurationData conf; conf.Load(); - if(!conf.HasFlag(PHPConfigurationData::kDontPromptForMissingFileMapping) && - GetFileMapping(PHPWorkspace::Get()->GetActiveProject()).empty()) { + if (!conf.HasFlag(PHPConfigurationData::kDontPromptForMissingFileMapping) && + GetFileMapping(PHPWorkspace::Get()->GetActiveProject()).empty()) { // Issue a warning wxString message; message << _("This project has no file mapping defined. This may result in breakpoints not applied\n") << _("To fix this, set file mapping from Project Settings -> Debug"); - wxRichMessageDialog dlg(EventNotifier::Get()->TopFrame(), message, "CodeLite", - wxICON_WARNING | wxOK | wxOK_DEFAULT | wxCANCEL); + wxRichMessageDialog dlg( + EventNotifier::Get()->TopFrame(), message, "CodeLite", wxICON_WARNING | wxOK | wxOK_DEFAULT | wxCANCEL); dlg.ShowCheckBox(_("Remember my answer and don't show this message again")); dlg.SetOKCancelLabels(_("OK, Continue to Debug"), _("Stop the debugger")); int dlgResult = dlg.ShowModal(); conf.EnableFlag(PHPConfigurationData::kDontPromptForMissingFileMapping, dlg.IsCheckBoxChecked()).Save(); - if(dlgResult == wxID_CANCEL) { + if (dlgResult == wxID_CANCEL) { // Stop the debugger DoStopDebugger(); return; } } - if(ideInitiate) { + if (ideInitiate) { // Now we can run the project - if(!PHPWorkspace::Get()->RunProject(true, debugDlg.GetPath(), "", conf.GetXdebugIdeKey())) { + if (!PHPWorkspace::Get()->RunProject(true, debugDlg.GetPath(), "", conf.GetXdebugIdeKey())) { DoStopDebugger(); return; } @@ -173,7 +173,7 @@ void XDebugManager::OnSocketInput(const std::string& reply) { ProcessDebuggerMes void XDebugManager::OnDebugIsRunning(clDebugEvent& e) { - if(PHPWorkspace::Get()->IsOpen()) { + if (PHPWorkspace::Get()->IsOpen()) { e.SetAnswer((m_readerThread != nullptr)); } else { // Not ours to handle @@ -183,7 +183,7 @@ void XDebugManager::OnDebugIsRunning(clDebugEvent& e) void XDebugManager::OnStopDebugger(clDebugEvent& e) { - if(m_readerThread) { + if (m_readerThread) { // abort wxDELETE(m_readerThread); @@ -218,14 +218,14 @@ void XDebugManager::DoStopDebugger() bool XDebugManager::ProcessDebuggerMessage(const wxString& buffer) { - if(buffer.IsEmpty()) + if (buffer.IsEmpty()) return false; clDEBUG() << "XDebug <<< " << buffer << endl; wxXmlDocument doc; wxStringInputStream sis(buffer); - if(!doc.Load(sis)) { + if (!doc.Load(sis)) { // failed to parse XML clDEBUG() << "CodeLite >>> invalid XML!" << endl; return false; @@ -233,7 +233,7 @@ bool XDebugManager::ProcessDebuggerMessage(const wxString& buffer) wxXmlNode* root = doc.GetRoot(); - if(root->GetName() == "init") { + if (root->GetName() == "init") { // Parse the content and notify CodeLite to open the main file xInitStruct initData = ParseInitXML(root); @@ -247,7 +247,7 @@ bool XDebugManager::ProcessDebuggerMessage(const wxString& buffer) // Issue a "Continue" command DoContinue(); - } else if(root->GetName() == "response") { + } else if (root->GetName() == "response") { // Handle response DoHandleResponse(root); } @@ -257,13 +257,13 @@ bool XDebugManager::ProcessDebuggerMessage(const wxString& buffer) void XDebugManager::DoApplyBreakpoints() { clDEBUG() << "CodeLite >>> Applying breakpoints" << endl; - if(!m_readerThread) { + if (!m_readerThread) { clDEBUG() << "CodeLite (PHP): No XDebug reader thread?" << endl; return; } PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetActiveProject(); - if(!pProject) { + if (!pProject) { clDEBUG() << "CodeLite (PHP): No active project!" << endl; return; } @@ -272,14 +272,14 @@ void XDebugManager::DoApplyBreakpoints() // bool bRunAsWebserver = (pProject->GetSettings().GetRunAs() == PHPProjectSettingsData::kRunAsWebsite); XDebugBreakpoint::List_t& breakpoints = m_breakpointsMgr.GetBreakpoints(); - if(breakpoints.empty()) { + if (breakpoints.empty()) { clDEBUG() << "CodeLite (PHP): No breakpoints to apply" << endl; return; } - for(auto& bp : breakpoints) { + for (auto& bp : breakpoints) { // apply only breakpoints without xdebug-id attached to them - if(bp.IsApplied()) { + if (bp.IsApplied()) { clDEBUG() << "CodeLite (PHP): Breakpoint already applied" << endl; continue; } @@ -287,8 +287,8 @@ void XDebugManager::DoApplyBreakpoints() wxStringMap_t sftpMapping; SSHWorkspaceSettings sftpSettings; sftpSettings.Load(); - if(!sftpSettings.GetRemoteFolder().IsEmpty() && sftpSettings.IsRemoteUploadEnabled()) { - sftpMapping.insert({ PHPWorkspace::Get()->GetFilename().GetPath(), sftpSettings.GetRemoteFolder() }); + if (!sftpSettings.GetRemoteFolder().IsEmpty() && sftpSettings.IsRemoteUploadEnabled()) { + sftpMapping.insert({PHPWorkspace::Get()->GetFilename().GetPath(), sftpSettings.GetRemoteFolder()}); } wxString command; @@ -315,7 +315,7 @@ void XDebugManager::DoHandleResponse(wxXmlNode* xml) long nTxId(0); txId.ToCLong(&nTxId); XDebugCommandHandler::Ptr_t handler = PopHandler(nTxId); - if(handler) { + if (handler) { handler->Process(xml); } else { @@ -325,7 +325,7 @@ void XDebugManager::DoHandleResponse(wxXmlNode* xml) doc.SetRoot(xml); wxStringOutputStream sos; - if(doc.Save(sos)) { + if (doc.Save(sos)) { clDEBUG() << sos.GetString() << endl; } doc.DetachRoot(); @@ -348,7 +348,7 @@ xInitStruct XDebugManager::ParseInitXML(wxXmlNode* init) void XDebugManager::AddHandler(XDebugCommandHandler::Ptr_t handler) { - if(m_handlers.count(handler->GetTransactionId())) { + if (m_handlers.count(handler->GetTransactionId())) { m_handlers.erase(handler->GetTransactionId()); } m_handlers.insert(std::make_pair(handler->GetTransactionId(), handler)); @@ -386,21 +386,21 @@ void XDebugManager::SendStopCommand() void XDebugManager::OnToggleBreakpoint(clDebugEvent& e) { - if(!PHPWorkspace::Get()->IsOpen()) { + if (!PHPWorkspace::Get()->IsOpen()) { e.Skip(); return; } // User toggled a breakpoint IEditor* editor = m_plugin->GetManager()->GetActiveEditor(); - if(editor && editor->GetFileName().GetFullPath() == e.GetFileName()) { + if (editor && editor->GetFileName().GetFullPath() == e.GetFileName()) { // Correct editor // add marker - if(m_breakpointsMgr.HasBreakpoint(e.GetFileName(), e.GetInt())) { + if (m_breakpointsMgr.HasBreakpoint(e.GetFileName(), e.GetInt())) { XDebugBreakpoint bp; m_breakpointsMgr.GetBreakpoint(e.GetFileName(), e.GetInt(), bp); - if(bp.IsApplied() && m_readerThread) { + if (bp.IsApplied() && m_readerThread) { // Remove it from XDebug as well DoDeleteBreakpoint(bp.GetBreakpointId()); } @@ -440,7 +440,7 @@ void XDebugManager::OnGotFocusFromXDebug(XDebugEvent& e) // Make sure CodeLite is "Raised" wxFrame* frame = EventNotifier::Get()->TopFrame(); - if(frame->IsIconized() || !frame->IsShown()) { + if (frame->IsIconized() || !frame->IsShown()) { frame->Raise(); } @@ -449,14 +449,14 @@ void XDebugManager::OnGotFocusFromXDebug(XDebugEvent& e) // Mark the debugger line / file IEditor* editor = m_plugin->GetManager()->FindEditor(e.GetFileName()); - if(!editor && wxFileName::Exists(e.GetFileName())) { + if (!editor && wxFileName::Exists(e.GetFileName())) { // Try to open the editor - if(m_plugin->GetManager()->OpenFile(e.GetFileName(), "", e.GetLineNumber())) { + if (m_plugin->GetManager()->OpenFile(e.GetFileName(), "", e.GetLineNumber())) { editor = m_plugin->GetManager()->GetActiveEditor(); } } - if(editor) { + if (editor) { m_plugin->GetManager()->SelectPage(editor->GetCtrl()); CallAfter(&XDebugManager::SetDebuggerMarker, editor->GetCtrl(), e.GetLineNumber()); } @@ -512,7 +512,7 @@ void XDebugManager::OnXDebugStopped(XDebugEvent& e) void XDebugManager::DoRefreshDebuggerViews(int requestedStack) { - if(!m_readerThread) { + if (!m_readerThread) { return; } @@ -543,7 +543,7 @@ void XDebugManager::DoRefreshDebuggerViews(int requestedStack) static XDebugManager* s_xdebugManager = NULL; XDebugManager& XDebugManager::Get() { - if(!s_xdebugManager) { + if (!s_xdebugManager) { s_xdebugManager = new XDebugManager(); } return *s_xdebugManager; @@ -582,7 +582,7 @@ void XDebugManager::OnStackTraceItemActivated(PHPEvent& e) int line = e.GetLineNumber(); int depth = e.GetInt(); - if(!m_plugin->GetManager()->OpenFile(filename, "", line - 1)) { + if (!m_plugin->GetManager()->OpenFile(filename, "", line - 1)) { ::wxMessageBox(_("Could not open file: ") + filename, "CodeLite", wxICON_WARNING | wxOK | wxCENTER); } DoRefreshDebuggerViews(depth); @@ -598,7 +598,7 @@ wxStringMap_t XDebugManager::GetFileMapping(PHPProject::Ptr_t pProject) const // Add the SFTP mappings SSHWorkspaceSettings sftpSettings; sftpSettings.Load(); - if(!sftpSettings.GetRemoteFolder().IsEmpty() && sftpSettings.IsRemoteUploadEnabled()) { + if (!sftpSettings.GetRemoteFolder().IsEmpty() && sftpSettings.IsRemoteUploadEnabled()) { mappings.insert(std::make_pair(PHPWorkspace::Get()->GetFilename().GetPath(), sftpSettings.GetRemoteFolder())); } return mappings; @@ -626,12 +626,12 @@ void XDebugManager::OnDeleteBreakpoint(PHPEvent& e) int line = e.GetLineNumber(); int bpid = e.GetInt(); - if(bpid != wxNOT_FOUND) { + if (bpid != wxNOT_FOUND) { // breakpoint was applied DoDeleteBreakpoint(bpid); } IEditor* editor = m_plugin->GetManager()->FindEditor(filename); - if(editor) { + if (editor) { editor->GetCtrl()->MarkerDelete(line - 1, smt_breakpoint); } m_breakpointsMgr.DeleteBreakpoint(filename, line); @@ -642,7 +642,7 @@ bool XDebugManager::IsDebugSessionRunning() const { return PHPWorkspace::Get()-> void XDebugManager::OnBreakpointItemActivated(PHPEvent& e) { e.Skip(); - if(!m_plugin->GetManager()->OpenFile(e.GetFileName(), "", e.GetLineNumber() - 1)) { + if (!m_plugin->GetManager()->OpenFile(e.GetFileName(), "", e.GetLineNumber() - 1)) { ::wxMessageBox(_("Could not open file: ") + e.GetFileName(), "CodeLite", wxICON_WARNING | wxOK | wxCENTER); } } @@ -703,7 +703,7 @@ void XDebugManager::OnTooltip(clDebugEvent& e) CHECK_XDEBUG_SESSION_ACTIVE(e); wxString expression = e.GetString(); - if(expression.IsEmpty()) + if (expression.IsEmpty()) return; expression.Prepend("print_r(").Append(", true)"); @@ -726,10 +726,12 @@ void XDebugManager::OnCommThreadTerminated() void XDebugManager::XDebugNotConnecting() { - wxRichMessageDialog dlg(EventNotifier::Get()->TopFrame(), _("XDebug did not connect in a timely manner"), - "CodeLite", wxICON_WARNING | wxOK | wxCANCEL_DEFAULT | wxCANCEL); + wxRichMessageDialog dlg(EventNotifier::Get()->TopFrame(), + _("XDebug did not connect in a timely manner"), + "CodeLite", + wxICON_WARNING | wxOK | wxCANCEL_DEFAULT | wxCANCEL); dlg.SetOKCancelLabels(_("Run XDebug Test"), _("OK")); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { m_plugin->CallAfter(&PhpPlugin::RunXDebugDiagnostics); } DoStopDebugger(); @@ -737,11 +739,11 @@ void XDebugManager::XDebugNotConnecting() void XDebugManager::OnShowTooltip(XDebugEvent& e) { - if(e.GetEvalReason() == XDebugEvalCmdHandler::kEvalForTooltip) { + if (e.GetEvalReason() == XDebugEvalCmdHandler::kEvalForTooltip) { wxString tip, title; title << e.GetString(); - if(!e.IsEvalSucceeded()) { + if (!e.IsEvalSucceeded()) { tip << _("Error evaluating expression "); } else { wxString evaluated = e.GetEvaluated(); @@ -799,7 +801,7 @@ void XDebugManager::CenterEditor(wxStyledTextCtrl* ctrl, int lineNo) void XDebugManager::StartListener() { - if(m_readerThread) { + if (m_readerThread) { // Stop the current session DoStopDebugger(); } diff --git a/codelitephp/php-plugin/XDebugManager.h b/codelitephp/php-plugin/XDebugManager.h index 9ce5ccdcd3..01331f9085 100644 --- a/codelitephp/php-plugin/XDebugManager.h +++ b/codelitephp/php-plugin/XDebugManager.h @@ -69,9 +69,9 @@ class XDebugManager : public wxEvtHandler int GetPort() const; wxString GetHost() const; void CenterEditor(wxStyledTextCtrl* ctrl, int lineNo); - + void StartListener(); - + void SetConnected(bool connected); bool IsConnected() const { return m_connected; } void DoSocketWrite(const wxString& command); diff --git a/codelitephp/php-plugin/XDebugPropertyGetHandler.cpp b/codelitephp/php-plugin/XDebugPropertyGetHandler.cpp index 19eb4ddf1e..226758beee 100644 --- a/codelitephp/php-plugin/XDebugPropertyGetHandler.cpp +++ b/codelitephp/php-plugin/XDebugPropertyGetHandler.cpp @@ -1,11 +1,13 @@ #include "XDebugPropertyGetHandler.h" -#include "macros.h" + #include "XVariable.h" -#include -#include "xdebugevent.h" #include "event_notifier.h" +#include "macros.h" +#include "xdebugevent.h" + +#include -XDebugPropertyGetHandler::XDebugPropertyGetHandler(XDebugManager* mgr, int transactionId, const wxString &property) +XDebugPropertyGetHandler::XDebugPropertyGetHandler(XDebugManager* mgr, int transactionId, const wxString& property) : XDebugCommandHandler(mgr, transactionId) , m_property(property) { @@ -14,20 +16,20 @@ XDebugPropertyGetHandler::XDebugPropertyGetHandler(XDebugManager* mgr, int trans void XDebugPropertyGetHandler::Process(const wxXmlNode* response) { CHECK_PTR_RET(response); - + // got the reply from XDebug parse and display the locals XVariable::List_t variables; wxXmlNode* child = response->GetChildren(); - if ( child ) { - if ( child->GetName() == "property" ) { + if (child) { + if (child->GetName() == "property") { XVariable var(child); - variables.push_back( var ); + variables.push_back(var); } child = child->GetNext(); } - + XDebugEvent event(wxEVT_XDEBUG_PROPERTY_GET); - event.SetVariables( variables ); - event.SetEvaluated( m_property ); - EventNotifier::Get()->AddPendingEvent( event ); + event.SetVariables(variables); + event.SetEvaluated(m_property); + EventNotifier::Get()->AddPendingEvent(event); } diff --git a/codelitephp/php-plugin/XDebugPropertyGetHandler.h b/codelitephp/php-plugin/XDebugPropertyGetHandler.h index 4117422157..ffb2cee80a 100644 --- a/codelitephp/php-plugin/XDebugPropertyGetHandler.h +++ b/codelitephp/php-plugin/XDebugPropertyGetHandler.h @@ -26,15 +26,16 @@ #ifndef XDEBUGPROPERTYGETHANDLER_H #define XDEBUGPROPERTYGETHANDLER_H -#include #include "XDebugCommandHandler.h" // Base class: XDebugCommandHandler +#include + class XDebugPropertyGetHandler : public XDebugCommandHandler { wxString m_property; - + public: - XDebugPropertyGetHandler(XDebugManager* mgr, int transactionId, const wxString &property); + XDebugPropertyGetHandler(XDebugManager* mgr, int transactionId, const wxString& property); virtual ~XDebugPropertyGetHandler() = default; public: diff --git a/codelitephp/php-plugin/XDebugRunCmdHandler.cpp b/codelitephp/php-plugin/XDebugRunCmdHandler.cpp index abd24ff0bf..634149cf82 100644 --- a/codelitephp/php-plugin/XDebugRunCmdHandler.cpp +++ b/codelitephp/php-plugin/XDebugRunCmdHandler.cpp @@ -22,22 +22,22 @@ void XDebugRunCmdHandler::Process(const wxXmlNode* response) { // a reply to the "Run" command has arrived wxString status = response->GetAttribute("status"); - if(status == "stopping") { + if (status == "stopping") { clDEBUG() << "CodeLite >>> xdebug entered status 'stopping'" << endl; m_mgr->SendStopCommand(); - } else if(status == "break") { + } else if (status == "break") { // Break point was hit clDEBUG() << "CodeLite >>> Breakpoint was hit" << endl; wxXmlNode* msg = XmlUtils::FindFirstByTagName(response, "xdebug:message"); - if(msg) { + if (msg) { wxString filename = msg->GetAttribute("filename"); int line_number = XmlUtils::ReadLong(msg, "lineno"); wxString localFile = ::MapRemoteFileToLocalFile(filename); clDEBUG() << "Mapping remote file:" << filename << "->" << localFile << endl; wxFileName fnFilename(localFile); - if(fnFilename.Exists()) { + if (fnFilename.Exists()) { // Notify about control XDebugEvent focusEvent(wxEVT_XDEBUG_IDE_GOT_CONTROL); focusEvent.SetFileName(fnFilename.GetFullPath()); diff --git a/codelitephp/php-plugin/XDebugStackGetCmdHandler.cpp b/codelitephp/php-plugin/XDebugStackGetCmdHandler.cpp index 6c14944fe3..fd02bf7bc4 100644 --- a/codelitephp/php-plugin/XDebugStackGetCmdHandler.cpp +++ b/codelitephp/php-plugin/XDebugStackGetCmdHandler.cpp @@ -19,25 +19,25 @@ XDebugStackGetCmdHandler::XDebugStackGetCmdHandler(XDebugManager* mgr, int trans void XDebugStackGetCmdHandler::Process(const wxXmlNode* response) { wxArrayString stackTrace; - wxXmlNode *child = response->GetChildren(); - while ( child ) { - if ( child->GetName() == "stack" ) { - wxString level = child->GetAttribute("level"); - wxString where = child->GetAttribute("where"); + wxXmlNode* child = response->GetChildren(); + while (child) { + if (child->GetName() == "stack") { + wxString level = child->GetAttribute("level"); + wxString where = child->GetAttribute("where"); wxString filename = child->GetAttribute("filename"); int line_number = XmlUtils::ReadLong(child, "lineno"); - + wxString localFile = ::MapRemoteFileToLocalFile(filename); // Use pipe to separate the attributes wxString stackEntry; stackEntry << level << "|" << where << "|" << localFile << "|" << line_number; - stackTrace.Add( stackEntry ); + stackTrace.Add(stackEntry); } child = child->GetNext(); } - + XDebugEvent eventStack(wxEVT_XDEBUG_STACK_TRACE); - eventStack.SetStrings( stackTrace ); + eventStack.SetStrings(stackTrace); eventStack.SetInt(m_requestedStack); - EventNotifier::Get()->AddPendingEvent( eventStack ); + EventNotifier::Get()->AddPendingEvent(eventStack); } diff --git a/codelitephp/php-plugin/XDebugStackGetCmdHandler.h b/codelitephp/php-plugin/XDebugStackGetCmdHandler.h index edf676bfcd..b75c79e885 100644 --- a/codelitephp/php-plugin/XDebugStackGetCmdHandler.h +++ b/codelitephp/php-plugin/XDebugStackGetCmdHandler.h @@ -30,6 +30,7 @@ class XDebugStackGetCmdHandler : public XDebugCommandHandler { int m_requestedStack; + public: XDebugStackGetCmdHandler(XDebugManager* mgr, int transactionId, int requestedStack = 0); virtual ~XDebugStackGetCmdHandler() = default; diff --git a/codelitephp/php-plugin/XDebugStopCmdHandler.cpp b/codelitephp/php-plugin/XDebugStopCmdHandler.cpp index 56142ba8ee..225f2f824e 100644 --- a/codelitephp/php-plugin/XDebugStopCmdHandler.cpp +++ b/codelitephp/php-plugin/XDebugStopCmdHandler.cpp @@ -17,14 +17,14 @@ void XDebugStopCmdHandler::Process(const wxXmlNode* response) { clDEBUG() << "CodeLite: Stop command completed." << endl; wxString status = response->GetAttribute("status"); - if(status == "stopping") { + if (status == "stopping") { clDEBUG() << "CodeLite: xdebug entered status 'stopping'" << endl; // Notify about control XDebugEvent focusEvent(wxEVT_XDEBUG_STOPPED); EventNotifier::Get()->AddPendingEvent(focusEvent); - } else if(status == "stopped") { + } else if (status == "stopped") { clDEBUG() << "CodeLite: xdebug entered status 'stopped'" << endl; m_mgr->SendStopCommand(); diff --git a/codelitephp/php-plugin/XDebugTester.cpp b/codelitephp/php-plugin/XDebugTester.cpp index e2bbf1de8e..4c51a7bad6 100644 --- a/codelitephp/php-plugin/XDebugTester.cpp +++ b/codelitephp/php-plugin/XDebugTester.cpp @@ -13,18 +13,18 @@ bool XDebugTester::RunTest() { // Get the path to the xdebug tester script wxFileName xdebugTesterScript(clStandardPaths::Get().GetUserDataDir(), "TestXDebugSettings.php"); - if(!xdebugTesterScript.Exists()) { + if (!xdebugTesterScript.Exists()) { clZipReader zipReader(wxFileName(clStandardPaths::Get().GetDataDir(), "PHP.zip")); zipReader.Extract(xdebugTesterScript.GetFullName(), xdebugTesterScript.GetPath()); } - if(xdebugTesterScript.Exists()) { + if (xdebugTesterScript.Exists()) { PHPConfigurationData globalConf; globalConf.Load(); PHPExecutor executor; wxString php_output; - if(executor.RunScript(xdebugTesterScript.GetFullPath(), php_output)) { + if (executor.RunScript(xdebugTesterScript.GetFullPath(), php_output)) { JSON root(php_output); JSONItem rootElement = root.toElement(); @@ -33,7 +33,7 @@ bool XDebugTester::RunTest() ////////////////////////////////////////////////// { wxString msg; - if(rootElement.namedObject("_remoteConnectBack").toString() != "1") { + if (rootElement.namedObject("_remoteConnectBack").toString() != "1") { msg << "Failed. This value should be set to 1"; } else { msg << "Passed"; @@ -44,14 +44,14 @@ bool XDebugTester::RunTest() } { wxString msg; - if(rootElement.namedObject("_ideKey").toString() != globalConf.GetXdebugIdeKey()) { + if (rootElement.namedObject("_ideKey").toString() != globalConf.GetXdebugIdeKey()) { msg << "Failed. This value should be set to \"" << globalConf.GetXdebugIdeKey() << "\""; } else { msg << "Passed"; } - m_results.insert(std::make_pair(wxString("xdebug.idekey"), - std::make_pair(rootElement.namedObject("_ideKey").toString(), msg))); + m_results.insert(std::make_pair( + wxString("xdebug.idekey"), std::make_pair(rootElement.namedObject("_ideKey").toString(), msg))); } m_results.insert(std::make_pair( wxString("xdebug.remote_port"), @@ -65,7 +65,7 @@ bool XDebugTester::RunTest() "is ignored if xdebug.remote_connect_back is enabled"))); { wxString msg; - if(rootElement.namedObject("_remoteEnable").toString() != "1") { + if (rootElement.namedObject("_remoteEnable").toString() != "1") { msg << "Failed. This value should be set to 1"; } else { msg << "Passed"; @@ -77,7 +77,7 @@ bool XDebugTester::RunTest() { // XDebug loaded wxString msg; - if(rootElement.namedObject("_xdebugLoaded").toString() != "1") { + if (rootElement.namedObject("_xdebugLoaded").toString() != "1") { msg << "Failed. XDebug is NOT loaded"; } else { msg << "Passed"; @@ -91,7 +91,7 @@ bool XDebugTester::RunTest() { // If Zend Debugger is loaded, mark it the message with RED wxString msg; - if(rootElement.namedObject("_zendDebuggerLoaded").toString() == "1") { + if (rootElement.namedObject("_zendDebuggerLoaded").toString() == "1") { msg << "Failed. Unload Zend Debugger extension" ""; m_results.insert( diff --git a/codelitephp/php-plugin/XDebugUnknownCommand.cpp b/codelitephp/php-plugin/XDebugUnknownCommand.cpp index fbcfe7677b..d5786e6c97 100644 --- a/codelitephp/php-plugin/XDebugUnknownCommand.cpp +++ b/codelitephp/php-plugin/XDebugUnknownCommand.cpp @@ -14,14 +14,14 @@ XDebugUnknownCommand::XDebugUnknownCommand(XDebugManager* mgr, int transactionId void XDebugUnknownCommand::Process(const wxXmlNode* response) { wxXmlDocument doc; - doc.SetRoot( const_cast(response) ); - + doc.SetRoot(const_cast(response)); + wxString asString; - wxStringOutputStream sos( &asString ); - doc.Save( sos ); + wxStringOutputStream sos(&asString); + doc.Save(sos); doc.DetachRoot(); - + XDebugEvent event(wxEVT_XDEBUG_UNKNOWN_RESPONSE); - event.SetEvaluated( asString ); - EventNotifier::Get()->AddPendingEvent( event ); + event.SetEvaluated(asString); + EventNotifier::Get()->AddPendingEvent(event); } diff --git a/codelitephp/php-plugin/XVariable.cpp b/codelitephp/php-plugin/XVariable.cpp index 21e74ea2f0..e3f10bca30 100644 --- a/codelitephp/php-plugin/XVariable.cpp +++ b/codelitephp/php-plugin/XVariable.cpp @@ -5,28 +5,28 @@ #include ///----------------------------------------------------- -/// XVariable +/// XVariable ///----------------------------------------------------- XVariable::XVariable(wxXmlNode* xmlProp, bool useDoubleQoutesOnStrings) : numchildren(0) { - FromXML( xmlProp, useDoubleQoutesOnStrings ); + FromXML(xmlProp, useDoubleQoutesOnStrings); } void XVariable::FromXML(wxXmlNode* xmlProp, bool useDoubleQoutesOnStrings) { - this->fullname = XmlUtils::ReadString(xmlProp, "fullname"); - this->name = XmlUtils::ReadString(xmlProp, "name"); - this->classname = XmlUtils::ReadString(xmlProp, "classname"); - this->type = XmlUtils::ReadString(xmlProp, "type"); + this->fullname = XmlUtils::ReadString(xmlProp, "fullname"); + this->name = XmlUtils::ReadString(xmlProp, "name"); + this->classname = XmlUtils::ReadString(xmlProp, "classname"); + this->type = XmlUtils::ReadString(xmlProp, "type"); this->numchildren = XmlUtils::ReadLong(xmlProp, "numchildren", 0); - + wxString encoding = XmlUtils::ReadString(xmlProp, "encoding"); this->value = xmlProp->GetNodeContent(); - + // Check if decode is needed - if ( encoding.IsEmpty() == false ) { + if (encoding.IsEmpty() == false) { wxMemoryBuffer memBuf = ::wxBase64Decode(this->value); this->value = wxString((char*)memBuf.GetData(), memBuf.GetDataLen()); } @@ -37,18 +37,18 @@ void XVariable::FromXML(wxXmlNode* xmlProp, bool useDoubleQoutesOnStrings) this->value.Replace("\t", "\\t"); this->value.Replace("\v", "\\v"); this->value.Replace("\b", "\\b"); - - if ( this->type == "string" && useDoubleQoutesOnStrings ) { + + if (this->type == "string" && useDoubleQoutesOnStrings) { // wrap the value in "" this->value.Prepend("\"").Append("\""); } - + wxXmlNode* child = xmlProp->GetChildren(); - while ( child ) { - if ( child->GetName() == "property" ) { + while (child) { + if (child->GetName() == "property") { XVariable c; - c.FromXML( child, useDoubleQoutesOnStrings ); - children.push_back( c ); + c.FromXML(child, useDoubleQoutesOnStrings); + children.push_back(c); } child = child->GetNext(); } @@ -57,11 +57,10 @@ void XVariable::FromXML(wxXmlNode* xmlProp, bool useDoubleQoutesOnStrings) wxString XVariable::ToString() const { wxString tostr; - tostr << "Name :" << this->name << "\n" - << "Fullname :" << this->fullname << "\n" - << "Class :" << this->classname << "\n" - << "Value :" << "\n" - << "[" << this->value << "]\n"; + tostr << "Name :" << this->name << "\n" + << "Fullname :" << this->fullname << "\n" + << "Class :" << this->classname << "\n" + << "Value :" << "\n" + << "[" << this->value << "]\n"; return tostr; } - diff --git a/codelitephp/php-plugin/XVariable.h b/codelitephp/php-plugin/XVariable.h index cb1e8355b7..6f14c4f9b1 100644 --- a/codelitephp/php-plugin/XVariable.h +++ b/codelitephp/php-plugin/XVariable.h @@ -26,9 +26,9 @@ #ifndef __XVARIABLE_H__ #define __XVARIABLE_H__ -#include -#include #include +#include +#include class wxXmlNode; struct XVariable : public wxClientData { @@ -39,51 +39,47 @@ struct XVariable : public wxClientData { wxString classname; wxString value; wxString type; - int numchildren; + int numchildren; XVariable::List_t children; /** * @brief construct XVariable object from XML */ void FromXML(wxXmlNode* xmlProp, bool useDoubleQoutesOnStrings); - + /** * @brief return a string repsresentation for this variable */ wxString ToString() const; - + /** * @brief default ctor */ - XVariable() : numchildren(0) {} + XVariable() + : numchildren(0) + { + } /** * @brief construct XVariable from XDebug XML response */ XVariable(wxXmlNode* xmlProp, bool useDoubleQoutesOnStrings = true); - + /** * @brief does this variable has children? * Note that this may return positive number while HasChildren return false * When this happens it means that CodeLite should query XDebug for the children */ - bool GetNumChildren() const { - return numchildren; - } - + bool GetNumChildren() const { return numchildren; } + /** * @brief contains the actual children of this variable */ - bool HasChildren() const { - return !children.empty(); - } - + bool HasChildren() const { return !children.empty(); } + /** * @brief return true if a fake node should be created for this XVariable */ - bool GetCreateFakeNode() const { - return GetNumChildren() && !HasChildren(); - } + bool GetCreateFakeNode() const { return GetNumChildren() && !HasChildren(); } }; - -#endif // +#endif // diff --git a/codelitephp/php-plugin/evalpane.cpp b/codelitephp/php-plugin/evalpane.cpp index 377921bd92..4dc16f7982 100644 --- a/codelitephp/php-plugin/evalpane.cpp +++ b/codelitephp/php-plugin/evalpane.cpp @@ -14,11 +14,15 @@ EvalPane::EvalPane(wxWindow* parent) EventNotifier::Get()->Bind(wxEVT_XDEBUG_UNKNOWN_RESPONSE, &EvalPane::OnDBGPCommandEvaluated, this); EventNotifier::Get()->Bind(wxEVT_EDITOR_CONFIG_CHANGED, &EvalPane::OnSettingsChanged, this); LexerConf::Ptr_t lex = EditorConfigST::Get()->GetLexer("text"); - if(lex) { lex->Apply(m_stcOutput); } + if (lex) { + lex->Apply(m_stcOutput); + } // Since XDebug replies with XML, use the XML lexer for the output LexerConf::Ptr_t xml_lex = EditorConfigST::Get()->GetLexer("xml"); - if(xml_lex) { xml_lex->Apply(m_stcOutputXDebug, true); } + if (xml_lex) { + xml_lex->Apply(m_stcOutputXDebug, true); + } m_stcOutput->SetEditable(false); } @@ -31,7 +35,9 @@ EvalPane::~EvalPane() void EvalPane::OnEnter(wxCommandEvent& event) { - if(!m_textCtrlExpression->IsEmpty()) { OnSend(event); } + if (!m_textCtrlExpression->IsEmpty()) { + OnSend(event); + } } void EvalPane::OnSend(wxCommandEvent& event) @@ -46,13 +52,13 @@ void EvalPane::OnSendUI(wxUpdateUIEvent& event) void EvalPane::OnExpressionEvaluate(XDebugEvent& e) { - if(e.GetEvalReason() == XDebugEvalCmdHandler::kEvalForEvalPane) { + if (e.GetEvalReason() == XDebugEvalCmdHandler::kEvalForEvalPane) { m_stcOutput->SetEditable(true); m_stcOutput->ClearAll(); wxString str; - if(!e.IsEvalSucceeded()) { + if (!e.IsEvalSucceeded()) { str << _("*** Error evaluating expression: ") << e.GetString() << "\n" << e.GetErrorString(); } else { str << e.GetString() << " = \n"; diff --git a/codelitephp/php-plugin/evalpane.h b/codelitephp/php-plugin/evalpane.h index bcc02ee38d..e9f371569b 100644 --- a/codelitephp/php-plugin/evalpane.h +++ b/codelitephp/php-plugin/evalpane.h @@ -33,15 +33,15 @@ class EvalPane : public EvalPaneBase public: EvalPane(wxWindow* parent); virtual ~EvalPane(); + protected: virtual void OnSendXDebugCommand(wxCommandEvent& event); virtual void OnSendXDebugCommandUI(wxUpdateUIEvent& event); virtual void OnEnter(wxCommandEvent& event); virtual void OnSend(wxCommandEvent& event); virtual void OnSendUI(wxUpdateUIEvent& event); - void OnExpressionEvaluate(XDebugEvent &e); - void OnDBGPCommandEvaluated(XDebugEvent &e); + void OnExpressionEvaluate(XDebugEvent& e); + void OnDBGPCommandEvaluated(XDebugEvent& e); void OnSettingsChanged(wxCommandEvent& event); - }; #endif // EVALPANE_H diff --git a/codelitephp/php-plugin/localsview.cpp b/codelitephp/php-plugin/localsview.cpp index 0015e79900..83f2efd92a 100644 --- a/codelitephp/php-plugin/localsview.cpp +++ b/codelitephp/php-plugin/localsview.cpp @@ -53,7 +53,7 @@ void LocalsView::OnLocalCollapsed(wxTreeEvent& event) CHECK_ITEM_RET(event.GetItem()); MyStringData* cd = dynamic_cast(m_tree->GetItemData(event.GetItem())); CHECK_PTR_RET(cd); - if(m_localsExpandedItemsFullname.count(cd->GetData())) { + if (m_localsExpandedItemsFullname.count(cd->GetData())) { m_localsExpandedItemsFullname.erase(cd->GetData()); } } @@ -90,7 +90,7 @@ void LocalsView::OnLocalsUpdated(XDebugEvent& e) AppendVariablesToTree(m_tree->GetRootItem(), vars); // Expand the items that were expanded before the view refresh - for(size_t i = 0; i < m_localsExpandedItems.GetCount(); ++i) { + for (size_t i = 0; i < m_localsExpandedItems.GetCount(); ++i) { // Ensure it is visible m_tree->EnsureVisible(m_localsExpandedItems.Item(i)); // Ensure its expanded @@ -108,13 +108,13 @@ void LocalsView::AppendVariablesToTree(const wxTreeItemId& parent, const XVariab m_tree->SetItemText(item, var.classname, 2); m_tree->SetItemText(item, var.value, 3); - if(var.GetCreateFakeNode()) { + if (var.GetCreateFakeNode()) { // create dummy node in the tree view so we can expand it later m_tree->AppendItem(item, ""); - } else if(var.HasChildren()) { + } else if (var.HasChildren()) { AppendVariablesToTree(item, var.children); - if(m_localsExpandedItemsFullname.count(var.fullname)) { + if (m_localsExpandedItemsFullname.count(var.fullname)) { // this item should be expanded m_localsExpandedItems.Add(item); } @@ -141,21 +141,21 @@ void LocalsView::OnLocalExpanding(wxTreeEvent& event) wxTreeItemId item = event.GetItem(); wxTreeItemIdValue cookie; wxTreeItemId child = m_tree->GetFirstChild(item, cookie); - if(child.IsOk() && (m_tree->GetItemText(child) == "")) { + if (child.IsOk() && (m_tree->GetItemText(child) == "")) { // a dummy node has been found // Delete this node and request from XDebug to expand it m_tree->SetItemText(child, wxString("Loading...")); wxString propertyName = DoGetItemClientData(event.GetItem()); XDebugManager::Get().SendGetProperty(propertyName); - m_waitingExpand.insert({ propertyName, item }); + m_waitingExpand.insert({propertyName, item}); } } wxString LocalsView::DoGetItemClientData(const wxTreeItemId& item) const { MyStringData* scd = dynamic_cast(m_tree->GetItemData(item)); - if(scd) { + if (scd) { return scd->GetData(); } return wxEmptyString; @@ -166,7 +166,7 @@ void LocalsView::OnPropertyGet(XDebugEvent& e) e.Skip(); // An item was evaluated using property_get std::unordered_map::iterator iter = m_waitingExpand.find(e.GetEvaluated()); - if(iter == m_waitingExpand.end()) { + if (iter == m_waitingExpand.end()) { return; } @@ -177,7 +177,7 @@ void LocalsView::OnPropertyGet(XDebugEvent& e) m_tree->DeleteChildren(item); XVariable::List_t vars = e.GetVariables(); - if(vars.empty()) + if (vars.empty()) return; // Since we got here from property_get, XDebug will reply with the specific property (e.g. $myclass->secondClass) diff --git a/codelitephp/php-plugin/my_tree_view.cpp b/codelitephp/php-plugin/my_tree_view.cpp index 04cdcaa94f..3bf12de778 100644 --- a/codelitephp/php-plugin/my_tree_view.cpp +++ b/codelitephp/php-plugin/my_tree_view.cpp @@ -1,6 +1,8 @@ -#include "clTreeCtrlModel.h" #include "my_tree_view.h" + +#include "clTreeCtrlModel.h" #include "tree_item_data.h" + #include MyTreeView::MyTreeView(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) @@ -9,9 +11,9 @@ MyTreeView::MyTreeView(wxWindow* parent, wxWindowID id, const wxPoint& pos, cons clSortFunc_t SortFunc = [&](clRowEntry* itemA, clRowEntry* itemB) { ItemData* a = dynamic_cast(itemA->GetClientObject()); ItemData* b = dynamic_cast(itemB->GetClientObject()); - if(a->IsFolder() && b->IsFile()) + if (a->IsFolder() && b->IsFile()) return true; - else if(b->IsFolder() && a->IsFile()) + else if (b->IsFolder() && a->IsFile()) return false; return (a->GetDisplayName().CmpNoCase(b->GetDisplayName()) < 0); }; diff --git a/codelitephp/php-plugin/my_tree_view.h b/codelitephp/php-plugin/my_tree_view.h index 1462a1c09b..56b711a879 100644 --- a/codelitephp/php-plugin/my_tree_view.h +++ b/codelitephp/php-plugin/my_tree_view.h @@ -32,8 +32,11 @@ class MyTreeView : public clThemedTreeCtrl { public: - MyTreeView(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0); + MyTreeView(wxWindow* parent, + wxWindowID id = wxID_ANY, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = 0); virtual ~MyTreeView() = default; }; diff --git a/codelitephp/php-plugin/new_php_workspace_dlg.cpp b/codelitephp/php-plugin/new_php_workspace_dlg.cpp index d34ce88325..27d71bfe4f 100644 --- a/codelitephp/php-plugin/new_php_workspace_dlg.cpp +++ b/codelitephp/php-plugin/new_php_workspace_dlg.cpp @@ -17,7 +17,7 @@ NewPHPWorkspaceDlg::~NewPHPWorkspaceDlg() {} wxString NewPHPWorkspaceDlg::GetWorkspacePath() const { - if(m_textCtrlPath->IsEmpty() || m_textCtrlName->IsEmpty()) { + if (m_textCtrlPath->IsEmpty() || m_textCtrlName->IsEmpty()) { return ""; } @@ -32,10 +32,7 @@ void NewPHPWorkspaceDlg::OnNameUpdated(wxCommandEvent& event) m_textCtrlPreview->ChangeValue(GetWorkspacePath()); } -void NewPHPWorkspaceDlg::OnOK(wxCommandEvent& event) -{ - EndModal(wxID_OK); -} +void NewPHPWorkspaceDlg::OnOK(wxCommandEvent& event) { EndModal(wxID_OK); } void NewPHPWorkspaceDlg::OnCheckMakeSeparateDir(wxCommandEvent& event) { @@ -50,7 +47,7 @@ void NewPHPWorkspaceDlg::OnOKUI(wxUpdateUIEvent& event) void NewPHPWorkspaceDlg::OnBrowse(wxCommandEvent& event) { wxString path = ::wxDirSelector(_("select a folder"), m_textCtrlPath->GetValue()); - if(!path.IsEmpty()) { + if (!path.IsEmpty()) { m_textCtrlPath->SetValue(path); // we want event here m_textCtrlPreview->ChangeValue(GetWorkspacePath()); } @@ -60,7 +57,7 @@ void NewPHPWorkspaceDlg::OnFolderSelected(wxCommandEvent& event) { wxUnusedVar(event); wxFileName fn(m_textCtrlPath->GetValue()); - + // Use the last folder path as the project name m_textCtrlName->ChangeValue(fn.GetName()); } diff --git a/codelitephp/php-plugin/php_editor_context_menu.cpp b/codelitephp/php-plugin/php_editor_context_menu.cpp index 7030dea719..8140439829 100644 --- a/codelitephp/php-plugin/php_editor_context_menu.cpp +++ b/codelitephp/php-plugin/php_editor_context_menu.cpp @@ -30,12 +30,22 @@ PHPEditorContextMenu::~PHPEditorContextMenu() EventNotifier::Get()->Unbind(wxEVT_CONTEXT_MENU_EDITOR, &PHPEditorContextMenu::OnContextMenu, this); EventNotifier::Get()->Unbind(wxEVT_CONTEXT_MENU_EDITOR_MARGIN, &PHPEditorContextMenu::OnMarginContextMenu, this); - wxTheApp->Disconnect(wxID_OPEN_PHP_FILE, wxID_FIND_REFERENCES, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(PHPEditorContextMenu::OnPopupClicked), NULL, this); - wxTheApp->Disconnect(wxID_ADD_DOXY_COMMENT, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(PHPEditorContextMenu::OnInsertDoxyComment), NULL, this); - wxTheApp->Disconnect(wxID_GENERATE_GETTERS_SETTERS, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(PHPEditorContextMenu::OnGenerateSettersGetters), NULL, this); + wxTheApp->Disconnect(wxID_OPEN_PHP_FILE, + wxID_FIND_REFERENCES, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(PHPEditorContextMenu::OnPopupClicked), + NULL, + this); + wxTheApp->Disconnect(wxID_ADD_DOXY_COMMENT, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(PHPEditorContextMenu::OnInsertDoxyComment), + NULL, + this); + wxTheApp->Disconnect(wxID_GENERATE_GETTERS_SETTERS, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(PHPEditorContextMenu::OnGenerateSettersGetters), + NULL, + this); wxTheApp->Unbind(wxEVT_MENU, &PHPEditorContextMenu::OnCommentLine, this, XRCID("comment_line")); wxTheApp->Unbind(wxEVT_MENU, &PHPEditorContextMenu::OnCommentSelection, this, XRCID("comment_selection")); } @@ -46,19 +56,29 @@ void PHPEditorContextMenu::ConnectEvents() EventNotifier::Get()->Bind(wxEVT_CONTEXT_MENU_EDITOR_MARGIN, &PHPEditorContextMenu::OnMarginContextMenu, this); // The below Connect catches *all* the menu events there is no need to // call it per menu entry - wxTheApp->Connect(wxID_OPEN_PHP_FILE, wxID_FIND_REFERENCES, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(PHPEditorContextMenu::OnPopupClicked), NULL, this); - wxTheApp->Connect(wxID_ADD_DOXY_COMMENT, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(PHPEditorContextMenu::OnInsertDoxyComment), NULL, this); - wxTheApp->Connect(wxID_GENERATE_GETTERS_SETTERS, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(PHPEditorContextMenu::OnGenerateSettersGetters), NULL, this); + wxTheApp->Connect(wxID_OPEN_PHP_FILE, + wxID_FIND_REFERENCES, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(PHPEditorContextMenu::OnPopupClicked), + NULL, + this); + wxTheApp->Connect(wxID_ADD_DOXY_COMMENT, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(PHPEditorContextMenu::OnInsertDoxyComment), + NULL, + this); + wxTheApp->Connect(wxID_GENERATE_GETTERS_SETTERS, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(PHPEditorContextMenu::OnGenerateSettersGetters), + NULL, + this); wxTheApp->Bind(wxEVT_MENU, &PHPEditorContextMenu::OnCommentLine, this, XRCID("comment_line")); wxTheApp->Bind(wxEVT_MENU, &PHPEditorContextMenu::OnCommentSelection, this, XRCID("comment_selection")); } PHPEditorContextMenu* PHPEditorContextMenu::Instance() { - if(ms_instance == 0) { + if (ms_instance == 0) { ms_instance = new PHPEditorContextMenu(); } return ms_instance; @@ -66,7 +86,7 @@ PHPEditorContextMenu* PHPEditorContextMenu::Instance() void PHPEditorContextMenu::Release() { - if(ms_instance) { + if (ms_instance) { delete ms_instance; } ms_instance = 0; @@ -81,7 +101,7 @@ void PHPEditorContextMenu::DoBuildMenu(wxMenu* menu, IEditor* editor) // if this is not a PHP section than the above menu items are all we can offer int styleAtPos = editor->GetStyleAtPos(editor->GetSelectionStart()); - if(!IsPHPSection(styleAtPos)) + if (!IsPHPSection(styleAtPos)) return; menu->PrependSeparator(); @@ -94,7 +114,7 @@ void PHPEditorContextMenu::DoBuildMenu(wxMenu* menu, IEditor* editor) menu->AppendSeparator(); menu->Append(wxID_ANY, _("Code Generation"), refactoringMenu); - if(IsIncludeOrRequireStatement(includeWhat)) { + if (IsIncludeOrRequireStatement(includeWhat)) { menu->PrependSeparator(); menu->Prepend(wxID_OPEN_PHP_FILE, wxString::Format(_("Open '%s'"), includeWhat.c_str())); } @@ -102,11 +122,11 @@ void PHPEditorContextMenu::DoBuildMenu(wxMenu* menu, IEditor* editor) bool PHPEditorContextMenu::IsPHPSection(int styleAtPos) const { - if((styleAtPos == wxSTC_HPHP_DEFAULT) || (styleAtPos == wxSTC_HPHP_HSTRING) || - (styleAtPos == wxSTC_HPHP_SIMPLESTRING) || (styleAtPos == wxSTC_HPHP_WORD) || - (styleAtPos == wxSTC_HPHP_NUMBER) || (styleAtPos == wxSTC_HPHP_VARIABLE) || (styleAtPos == wxSTC_HPHP_COMMENT) || - (styleAtPos == wxSTC_HPHP_COMMENTLINE) || (styleAtPos == wxSTC_HPHP_HSTRING_VARIABLE) || - (styleAtPos == wxSTC_HPHP_OPERATOR)) + if ((styleAtPos == wxSTC_HPHP_DEFAULT) || (styleAtPos == wxSTC_HPHP_HSTRING) || + (styleAtPos == wxSTC_HPHP_SIMPLESTRING) || (styleAtPos == wxSTC_HPHP_WORD) || + (styleAtPos == wxSTC_HPHP_NUMBER) || (styleAtPos == wxSTC_HPHP_VARIABLE) || + (styleAtPos == wxSTC_HPHP_COMMENT) || (styleAtPos == wxSTC_HPHP_COMMENTLINE) || + (styleAtPos == wxSTC_HPHP_HSTRING_VARIABLE) || (styleAtPos == wxSTC_HPHP_OPERATOR)) return true; return false; } @@ -119,11 +139,11 @@ bool PHPEditorContextMenu::IsIncludeOrRequireStatement(wxString& includeWhat) static wxRegEx reInclude(wxT("(include|require_once|require|include_once)[ \t\\(]*(.*?)[\\) \t]*;"), wxRE_ADVANCED); IEditor* editor = m_manager->GetActiveEditor(); - if(!editor) + if (!editor) return false; wxString line = editor->GetCtrl()->GetLine(editor->GetCurrentLine()); - if(reInclude.IsValid() && reInclude.Matches(line)) { + if (reInclude.IsValid() && reInclude.Matches(line)) { includeWhat = reInclude.GetMatch(line, 2); return true; } @@ -145,10 +165,10 @@ bool PHPEditorContextMenu::GetIncludeOrRequireFileName(wxString& fn) void PHPEditorContextMenu::DoOpenPHPFile() { wxString fn; - if(!GetIncludeOrRequireFileName(fn)) + if (!GetIncludeOrRequireFileName(fn)) return; // no editor... wxString outFile = PHPCodeCompletion::Instance()->ExpandRequire(m_manager->GetActiveEditor()->GetFileName(), fn); - if(!outFile.IsEmpty()) { + if (!outFile.IsEmpty()) { m_manager->OpenFile(outFile); } } @@ -159,7 +179,9 @@ void PHPEditorContextMenu::DoGotoDefinition() PHPCodeCompletion::Instance()->GotoDefinition(m_manager->GetActiveEditor()); } -bool PHPEditorContextMenu::IsTokenInBlackList(wxStyledTextCtrl* sci, const wxString& token, int token_pos, +bool PHPEditorContextMenu::IsTokenInBlackList(wxStyledTextCtrl* sci, + const wxString& token, + int token_pos, const wxArrayString& tokensBlackList) { for (const auto& tokenBlackList : tokensBlackList) { @@ -177,7 +199,7 @@ void PHPEditorContextMenu::OnContextMenu(clContextMenuEvent& e) IEditor* editor = m_manager->GetActiveEditor(); CHECK_PTR_RET(editor); - if(editor && IsPHPFile(editor)) { + if (editor && IsPHPFile(editor)) { DoBuildMenu(e.GetMenu(), editor); } } @@ -186,30 +208,30 @@ void PHPEditorContextMenu::OnMarginContextMenu(clContextMenuEvent& e) { e.Skip(); IEditor* editor = m_manager->GetActiveEditor(); - if(editor && IsPHPFile(editor)) { + if (editor && IsPHPFile(editor)) { wxMenu* menu = e.GetMenu(); // Remove non-PHP related entries from the menu - if(menu->FindItem(XRCID("insert_temp_breakpoint"))) { + if (menu->FindItem(XRCID("insert_temp_breakpoint"))) { menu->Remove(XRCID("insert_temp_breakpoint")); } - if(menu->FindItem(XRCID("insert_disabled_breakpoint"))) { + if (menu->FindItem(XRCID("insert_disabled_breakpoint"))) { menu->Remove(XRCID("insert_disabled_breakpoint")); } - if(menu->FindItem(XRCID("insert_cond_breakpoint"))) { + if (menu->FindItem(XRCID("insert_cond_breakpoint"))) { menu->Remove(XRCID("insert_cond_breakpoint")); } - if(menu->FindItem(XRCID("ignore_breakpoint"))) { + if (menu->FindItem(XRCID("ignore_breakpoint"))) { menu->Remove(XRCID("ignore_breakpoint")); } - if(menu->FindItem(XRCID("toggle_breakpoint_enabled_status"))) { + if (menu->FindItem(XRCID("toggle_breakpoint_enabled_status"))) { menu->Remove(XRCID("toggle_breakpoint_enabled_status")); } - if(menu->FindItem(XRCID("edit_breakpoint"))) { + if (menu->FindItem(XRCID("edit_breakpoint"))) { menu->Remove(XRCID("edit_breakpoint")); } } @@ -218,8 +240,8 @@ void PHPEditorContextMenu::OnMarginContextMenu(clContextMenuEvent& e) void PHPEditorContextMenu::OnPopupClicked(wxCommandEvent& event) { IEditor* editor = m_manager->GetActiveEditor(); - if(editor && IsPHPFile(editor)) { - switch(event.GetId()) { + if (editor && IsPHPFile(editor)) { + switch (event.GetId()) { case wxID_OPEN_PHP_FILE: DoOpenPHPFile(); break; @@ -241,7 +263,7 @@ void PHPEditorContextMenu::OnPopupClicked(wxCommandEvent& event) void PHPEditorContextMenu::OnInsertDoxyComment(wxCommandEvent& e) { IEditor* editor = m_manager->GetActiveEditor(); - if(editor) { + if (editor) { PHPLookupTable table; wxString unsavedBuffer = editor->GetEditorText(); PHPSourceFile source(unsavedBuffer, &table); @@ -251,14 +273,14 @@ void PHPEditorContextMenu::OnInsertDoxyComment(wxCommandEvent& e) PHPEntityBase::Ptr_t entry; int lineNumber = editor->GetCurrentLine(); const auto& matches = source.GetAllMatchesInOrder(); - for(const auto& match : matches) { - if(match->GetLine() == lineNumber && match->Is(kEntityTypeFunction)) { + for (const auto& match : matches) { + if (match->GetLine() == lineNumber && match->Is(kEntityTypeFunction)) { entry = match; break; } } - if(entry) { + if (entry) { wxStyledTextCtrl* ctrl = editor->GetCtrl(); ctrl->BeginUndoAction(); @@ -274,8 +296,8 @@ void PHPEditorContextMenu::OnInsertDoxyComment(wxCommandEvent& e) // Collect all whitespace from the beginning of the line until the first non whitespace // character we find wxString whitespace; - for(int i = lineStartPos; lineStartPos < lineEndPos; ++i) { - if(ctrl->GetCharAt(i) == ' ' || ctrl->GetCharAt(i) == '\t') { + for (int i = lineStartPos; lineStartPos < lineEndPos; ++i) { + if (ctrl->GetCharAt(i) == ' ' || ctrl->GetCharAt(i) == '\t') { whitespace << (wxChar)ctrl->GetCharAt(i); } else { break; @@ -297,11 +319,11 @@ void PHPEditorContextMenu::OnInsertDoxyComment(wxCommandEvent& e) // Try to place the caret after the @brief wxRegEx reBrief("[@\\]brief[ \t]*"); - if(reBrief.IsValid() && reBrief.Matches(doxyBlock)) { + if (reBrief.IsValid() && reBrief.Matches(doxyBlock)) { wxString match = reBrief.GetMatch(doxyBlock); // Get the index int where = doxyBlock.Find(match); - if(where != wxNOT_FOUND) { + if (where != wxNOT_FOUND) { where += match.length(); int caretPos = lineStartPos + where; editor->SetCaretAt(caretPos); @@ -318,7 +340,7 @@ void PHPEditorContextMenu::OnGenerateSettersGetters(wxCommandEvent& e) { // CHeck the current context IEditor* editor = m_manager->GetActiveEditor(); - if(editor) { + if (editor) { // determine the scope name at the current position // Parse until the current position @@ -329,7 +351,7 @@ void PHPEditorContextMenu::OnGenerateSettersGetters(wxCommandEvent& e) sourceFile.Parse(); const PHPEntityClass* scopeAtPoint = sourceFile.Class()->Cast(); - if(!scopeAtPoint) { + if (!scopeAtPoint) { // Could not determine the scope at the give location return; } @@ -340,17 +362,17 @@ void PHPEditorContextMenu::OnGenerateSettersGetters(wxCommandEvent& e) // generate the code to generate wxString textToAdd; PHPSettersGettersDialog dlg(EventNotifier::Get()->TopFrame(), editor, m_manager); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { for (const auto& member : dlg.GetMembers()) { textToAdd << member.GetSetter(dlg.GetScope(), dlg.GetFlags()) << "\n"; textToAdd << member.GetGetter(dlg.GetFlags()) << "\n"; } - if(!textToAdd.IsEmpty()) { + if (!textToAdd.IsEmpty()) { int line = PHPCodeCompletion::Instance()->GetLocationForSettersGetters( editor->GetTextRange(0, editor->GetLength()), className); - if(!textToAdd.IsEmpty() && line != wxNOT_FOUND) { + if (!textToAdd.IsEmpty() && line != wxNOT_FOUND) { editor->GetCtrl()->InsertText(editor->PosFromLine(line), textToAdd); } } @@ -362,7 +384,7 @@ void PHPEditorContextMenu::OnCommentLine(wxCommandEvent& event) { event.Skip(); IEditor* editor = m_manager->GetActiveEditor(); - if(editor && IsPHPFile(editor)) { + if (editor && IsPHPFile(editor)) { event.Skip(false); editor->ToggleLineComment("//", wxSTC_HPHP_COMMENTLINE); } @@ -372,7 +394,7 @@ void PHPEditorContextMenu::OnCommentSelection(wxCommandEvent& event) { event.Skip(); IEditor* editor = m_manager->GetActiveEditor(); - if(editor && IsPHPFile(editor)) { + if (editor && IsPHPFile(editor)) { event.Skip(false); editor->CommentBlockSelection("/*", "*/"); } diff --git a/codelitephp/php-plugin/php_editor_context_menu.h b/codelitephp/php-plugin/php_editor_context_menu.h index 11a097ecb7..3d2db35152 100644 --- a/codelitephp/php-plugin/php_editor_context_menu.h +++ b/codelitephp/php-plugin/php_editor_context_menu.h @@ -79,10 +79,10 @@ class PHPEditorContextMenu : public wxEvtHandler private: PHPEditorContextMenu(); virtual ~PHPEditorContextMenu(); - - void OnCommentSelection(wxCommandEvent &event); - void OnCommentLine(wxCommandEvent &event); - + + void OnCommentSelection(wxCommandEvent& event); + void OnCommentLine(wxCommandEvent& event); + void DoBuildMenu(wxMenu* menu, IEditor* editor); bool IsIncludeOrRequireStatement(wxString& includeWhat); bool GetIncludeOrRequireFileName(wxString& fn); @@ -94,14 +94,18 @@ class PHPEditorContextMenu : public wxEvtHandler #define GET_EDITOR_SCI_BOOL() \ IEditor* editor = m_manager->GetActiveEditor(); \ - if(!editor) return false; \ - wxStyledTextCtrl* sci = editor->GetCtrl(); \ - if(!sci) return false; + if (!editor) \ + return false; \ + wxStyledTextCtrl* sci = editor->GetCtrl(); \ + if (!sci) \ + return false; #define GET_EDITOR_SCI_VOID() \ IEditor* editor = m_manager->GetActiveEditor(); \ - if(!editor) return; \ - wxStyledTextCtrl* sci = editor->GetCtrl(); \ - if(!sci) return; + if (!editor) \ + return; \ + wxStyledTextCtrl* sci = editor->GetCtrl(); \ + if (!sci) \ + return; #endif // PHPEDITORCONTEXTMENU_H diff --git a/codelitephp/php-plugin/php_file_layout_tree.cpp b/codelitephp/php-plugin/php_file_layout_tree.cpp index 351b0dd351..c0908ef87a 100644 --- a/codelitephp/php-plugin/php_file_layout_tree.cpp +++ b/codelitephp/php-plugin/php_file_layout_tree.cpp @@ -15,16 +15,22 @@ #endif PHPFileLayoutTree::PHPFileLayoutTree(wxWindow* parent, IEditor* editor, IManager* manager) - : wxTreeCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxTR_DEFAULT_STYLE | wxTR_HIDE_ROOT | wxTR_NO_LINES | wxTR_SINGLE) + : wxTreeCtrl(parent, + wxID_ANY, + wxDefaultPosition, + wxDefaultSize, + wxTR_DEFAULT_STYLE | wxTR_HIDE_ROOT | wxTR_NO_LINES | wxTR_SINGLE) , m_editor(editor) , m_manager(manager) { } PHPFileLayoutTree::PHPFileLayoutTree(wxWindow* parent) - : wxTreeCtrl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, - wxTR_DEFAULT_STYLE | wxTR_HIDE_ROOT | wxTR_NO_LINES | wxTR_SINGLE) + : wxTreeCtrl(parent, + wxID_ANY, + wxDefaultPosition, + wxDefaultSize, + wxTR_DEFAULT_STYLE | wxTR_HIDE_ROOT | wxTR_NO_LINES | wxTR_SINGLE) , m_editor(NULL) , m_manager(NULL) { @@ -34,7 +40,8 @@ PHPFileLayoutTree::PHPFileLayoutTree(wxWindow* parent) void PHPFileLayoutTree::Construct() { // Sanity - if(!m_editor || !m_manager) return; + if (!m_editor || !m_manager) + return; wxString text = m_editor->GetTextRange(0, m_editor->GetLength()); PHPSourceFile source(text, NULL); @@ -61,10 +68,10 @@ void PHPFileLayoutTree::Construct() // Build the tree view BuildTree(root, source.Namespace()); - if(HasChildren(GetRootItem())) { + if (HasChildren(GetRootItem())) { wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild(GetRootItem(), cookie); - if(child.IsOk()) { + if (child.IsOk()) { SelectItem(child); ScrollTo(child); } @@ -74,44 +81,45 @@ void PHPFileLayoutTree::Construct() int PHPFileLayoutTree::GetImageId(PHPEntityBase::Ptr_t entry) { - if(entry->Is(kEntityTypeFunction)) { + if (entry->Is(kEntityTypeFunction)) { PHPEntityFunction* func = entry->Cast(); - if(func->HasFlag(kFunc_Private)) + if (func->HasFlag(kFunc_Private)) return 1; - else if(func->HasFlag(kFunc_Protected)) + else if (func->HasFlag(kFunc_Protected)) return 2; else // public return 3; - } else if(entry->Is(kEntityTypeVariable)) { + } else if (entry->Is(kEntityTypeVariable)) { PHPEntityVariable* var = entry->Cast(); - if(!var->IsMember() && !var->IsConst()) { + if (!var->IsMember() && !var->IsConst()) { // A global variable return 6; - } else if(var->IsMember()) { - if(var->HasFlag(kVar_Const)) return 9; // constant + } else if (var->IsMember()) { + if (var->HasFlag(kVar_Const)) + return 9; // constant // Member - if(var->HasFlag(kVar_Private)) + if (var->HasFlag(kVar_Private)) return 4; - else if(var->HasFlag(kVar_Protected)) + else if (var->HasFlag(kVar_Protected)) return 5; else return 6; - } else if(var->IsConst()) { + } else if (var->IsConst()) { // Constant return 9; } else { return 6; } - } else if(entry->Is(kEntityTypeNamespace)) { + } else if (entry->Is(kEntityTypeNamespace)) { // Namespace return 7; - } else if(entry->Is(kEntityTypeClass)) { + } else if (entry->Is(kEntityTypeClass)) { return 8; } return -1; // Unknown @@ -119,20 +127,21 @@ int PHPFileLayoutTree::GetImageId(PHPEntityBase::Ptr_t entry) wxTreeItemId PHPFileLayoutTree::RecurseSearch(const wxTreeItemId& item, const wxString& word) { - if(!item.IsOk()) return wxTreeItemId(); + if (!item.IsOk()) + return wxTreeItemId(); - if(item != GetRootItem()) { - if(FileUtils::FuzzyMatch(word, GetItemText(item))) { + if (item != GetRootItem()) { + if (FileUtils::FuzzyMatch(word, GetItemText(item))) { return item; } } - if(ItemHasChildren(item)) { + if (ItemHasChildren(item)) { wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild(item, cookie); - while(child.IsOk()) { + while (child.IsOk()) { wxTreeItemId selection = RecurseSearch(child, word); - if(selection.IsOk()) { + if (selection.IsOk()) { return selection; } child = GetNextChild(item, cookie); @@ -147,24 +156,25 @@ wxTreeItemId PHPFileLayoutTree::TryGetPrevItem(wxTreeItemId item) // find out the starting point wxTreeItemId prevItem = GetPrevSibling(item); - if(!prevItem.IsOk()) { + if (!prevItem.IsOk()) { prevItem = GetItemParent(item); - if(prevItem == GetRootItem()) { + if (prevItem == GetRootItem()) { return wxTreeItemId(); } } // from there we must be able to navigate until this item - while(prevItem.IsOk()) { + while (prevItem.IsOk()) { ScrollTo(prevItem); - if(!IsVisible(prevItem)) { + if (!IsVisible(prevItem)) { return wxTreeItemId(); } const wxTreeItemId nextItem = GetNextVisible(prevItem); - if(!nextItem.IsOk() || nextItem == item) return prevItem; + if (!nextItem.IsOk() || nextItem == item) + return prevItem; prevItem = nextItem; } @@ -177,7 +187,8 @@ void PHPFileLayoutTree::BuildTree(wxTreeItemId parentTreeItem, PHPEntityBase::Pt int imgID = GetImageId(entity); wxTreeItemId parent = AppendItem(parentTreeItem, entity->GetDisplayName(), imgID, imgID, new QItemData(entity)); // don't add the children of the function (i.e. function arguments) - if (entity->Is(kEntityTypeFunction)) return; + if (entity->Is(kEntityTypeFunction)) + return; for (const auto& child : entity->GetChildren()) { BuildTree(parent, child); diff --git a/codelitephp/php-plugin/php_file_layout_tree.h b/codelitephp/php-plugin/php_file_layout_tree.h index ee75c91c44..69e8ae709b 100644 --- a/codelitephp/php-plugin/php_file_layout_tree.h +++ b/codelitephp/php-plugin/php_file_layout_tree.h @@ -26,8 +26,8 @@ #ifndef PHPFILELAYOUTTREE_H #define PHPFILELAYOUTTREE_H -#include "precompiled_header.h" #include "PHP/PHPEntityBase.h" +#include "precompiled_header.h" class IEditor; class IManager; diff --git a/codelitephp/php-plugin/php_open_resource_dlg.cpp b/codelitephp/php-plugin/php_open_resource_dlg.cpp index f2b20a1779..de60570fe0 100644 --- a/codelitephp/php-plugin/php_open_resource_dlg.cpp +++ b/codelitephp/php-plugin/php_open_resource_dlg.cpp @@ -69,12 +69,12 @@ OpenResourceDlg::OpenResourceDlg(wxWindow* parent, IManager* manager) wxString lastStringTyped = clConfig::Get().Read("PHP/OpenResourceDialog/SearchString", wxString()); - if(m_mgr->GetActiveEditor() && !m_mgr->GetActiveEditor()->GetSelection().IsEmpty()) { + if (m_mgr->GetActiveEditor() && !m_mgr->GetActiveEditor()->GetSelection().IsEmpty()) { wxString sel = m_mgr->GetActiveEditor()->GetSelection(); m_textCtrlFilter->ChangeValue(sel); m_textCtrlFilter->SelectAll(); - } else if(!lastStringTyped.IsEmpty()) { + } else if (!lastStringTyped.IsEmpty()) { m_textCtrlFilter->ChangeValue(lastStringTyped); m_textCtrlFilter->SelectAll(); } @@ -101,7 +101,7 @@ void OpenResourceDlg::DoInitialize() OpenResourceDlg::~OpenResourceDlg() { - for(size_t i = 0; i < m_dvListCtrl->GetItemCount(); ++i) { + for (size_t i = 0; i < m_dvListCtrl->GetItemCount(); ++i) { ResourceItem* data = (ResourceItem*)m_dvListCtrl->GetItemData(m_dvListCtrl->RowToItem(i)); wxDELETE(data); } @@ -112,7 +112,7 @@ OpenResourceDlg::~OpenResourceDlg() void OpenResourceDlg::OnFilterEnter(wxCommandEvent& event) { wxDataViewItem sel = m_dvListCtrl->GetSelection(); - if(sel.IsOk()) { + if (sel.IsOk()) { SetSelectedItem(DoGetItemData(sel)); EndModal(wxID_OK); } @@ -124,11 +124,11 @@ void OpenResourceDlg::OnTimer(wxTimerEvent& event) { event.Skip(); wxString currentFilter = m_textCtrlFilter->GetValue(); - if(currentFilter != m_lastFilter) { + if (currentFilter != m_lastFilter) { m_lastFilter = currentFilter; m_dvListCtrl->DeleteAllItems(); - if(m_lastFilter.IsEmpty()) { + if (m_lastFilter.IsEmpty()) { m_timer->Start(50, true); return; } @@ -147,13 +147,13 @@ void OpenResourceDlg::OnTimer(wxTimerEvent& event) wxString lcFilter = m_lastFilter.Lower(); ResourceVector_t v1, v2, v3, v4, v5; for (const ResourceItem& a : allVec) { - if(a.displayName == m_lastFilter) { + if (a.displayName == m_lastFilter) { v1.push_back(a); // Exact match - } else if(a.displayName.Lower() == lcFilter) { + } else if (a.displayName.Lower() == lcFilter) { v2.push_back(a); // case insensitive exact match - } else if(a.displayName.StartsWith(m_lastFilter)) { + } else if (a.displayName.StartsWith(m_lastFilter)) { v3.push_back(a); // starts with - } else if(a.displayName.Lower().StartsWith(lcFilter)) { + } else if (a.displayName.Lower().StartsWith(lcFilter)) { v4.push_back(a); // case insensitive starts with } else { // other @@ -181,12 +181,12 @@ void OpenResourceDlg::DoPopulateListCtrl(const ResourceVector_t& items) cols.push_back(item.TypeAsString()); cols.push_back(item.filename.GetFullPath()); m_dvListCtrl->AppendItem(cols, (wxUIntPtr)(new ResourceItem(item))); - if(!selection.IsOk()) { + if (!selection.IsOk()) { selection = m_dvListCtrl->RowToItem(0); } } - if(selection.IsOk()) { + if (selection.IsOk()) { m_dvListCtrl->Select(selection); m_dvListCtrl->EnsureVisible(selection); } @@ -222,10 +222,10 @@ ResourceVector_t OpenResourceDlg::DoGetFiles(const wxString& filter) for (const auto& resourceItem : m_allFiles) { wxString filename = resourceItem.filename.GetFullPath().Lower(); - if(FileUtils::FuzzyMatch(filter, filename)) { + if (FileUtils::FuzzyMatch(filter, filename)) { resources.push_back(resourceItem); // Don't return too many matches... - if(resources.size() == 300) + if (resources.size() == 300) break; } } @@ -240,17 +240,17 @@ ResourceItem* OpenResourceDlg::DoGetItemData(const wxDataViewItem& item) void OpenResourceDlg::OnKeyDown(wxKeyEvent& event) { - if(event.GetKeyCode() == WXK_DOWN) { + if (event.GetKeyCode() == WXK_DOWN) { // Select next item DoSelectNext(); - } else if(event.GetKeyCode() == WXK_UP) { + } else if (event.GetKeyCode() == WXK_UP) { // Select next item DoSelectPrev(); - } else if(event.GetKeyCode() == WXK_ESCAPE) { + } else if (event.GetKeyCode() == WXK_ESCAPE) { EndModal(wxID_CANCEL); } else { @@ -261,10 +261,10 @@ void OpenResourceDlg::OnKeyDown(wxKeyEvent& event) void OpenResourceDlg::DoSelectNext() { wxDataViewItem selecteditem = m_dvListCtrl->GetSelection(); - if(selecteditem.IsOk()) { + if (selecteditem.IsOk()) { long row = m_dvListCtrl->ItemToRow(selecteditem); ++row; - if(m_dvListCtrl->GetItemCount() > (size_t)row) { + if (m_dvListCtrl->GetItemCount() > (size_t)row) { m_dvListCtrl->Select(m_dvListCtrl->RowToItem(row)); m_dvListCtrl->EnsureVisible(m_dvListCtrl->RowToItem(row)); } @@ -274,10 +274,10 @@ void OpenResourceDlg::DoSelectNext() void OpenResourceDlg::DoSelectPrev() { wxDataViewItem selecteditem = m_dvListCtrl->GetSelection(); - if(selecteditem.IsOk()) { + if (selecteditem.IsOk()) { long row = m_dvListCtrl->ItemToRow(selecteditem); --row; - if(row >= 0) { + if (row >= 0) { m_dvListCtrl->Select(m_dvListCtrl->RowToItem(row)); m_dvListCtrl->EnsureVisible(m_dvListCtrl->RowToItem(row)); } @@ -286,7 +286,7 @@ void OpenResourceDlg::DoSelectPrev() int OpenResourceDlg::DoGetImgIdx(const ResourceItem* item) { - switch(item->type) { + switch (item->type) { case ResourceItem::kRI_Namespace: return NAMESPACE_IMG_ID; case ResourceItem::kRI_Class: @@ -315,9 +315,9 @@ bool OpenResourceDlg::IsMatchesFilter(const wxString& filter, const wxString& ke { wxString lcKey = key.Lower(); wxArrayString filters = ::wxStringTokenize(filter, " ", wxTOKEN_STRTOK); - for(size_t i = 0; i < filters.GetCount(); ++i) { + for (size_t i = 0; i < filters.GetCount(); ++i) { wxString lcFilter = filters.Item(i).Lower(); - if(lcKey.Contains(lcFilter)) + if (lcKey.Contains(lcFilter)) continue; else return false; diff --git a/codelitephp/php-plugin/php_open_resource_dlg.h b/codelitephp/php-plugin/php_open_resource_dlg.h index 383b3ff36f..52f8b6dbc4 100644 --- a/codelitephp/php-plugin/php_open_resource_dlg.h +++ b/codelitephp/php-plugin/php_open_resource_dlg.h @@ -49,26 +49,26 @@ struct ResourceItem { void SetType(PHPEntityBase::Ptr_t match) { - if(match->Is(kEntityTypeClass)) { + if (match->Is(kEntityTypeClass)) { type = kRI_Class; - } else if(match->Is(kEntityTypeFunction)) { + } else if (match->Is(kEntityTypeFunction)) { type = kRI_Function; - } else if(match->Is(kEntityTypeVariable)) { - if(match->Cast()->IsConst()) { + } else if (match->Is(kEntityTypeVariable)) { + if (match->Cast()->IsConst()) { type = kRI_Constant; - } else if(match->Cast()->IsMember()) { + } else if (match->Cast()->IsMember()) { type = kRI_Member; } else { type = kRI_Variable; } - } else if(match->Is(kEntityTypeNamespace)) { + } else if (match->Is(kEntityTypeNamespace)) { type = kRI_Namespace; } } wxString TypeAsString() const { - switch(type) { + switch (type) { case ResourceItem::kRI_Namespace: return "Namespace"; case ResourceItem::kRI_Class: diff --git a/codelitephp/php-plugin/php_project_settings_dlg.cpp b/codelitephp/php-plugin/php_project_settings_dlg.cpp index 08131823a4..2ba6dc0e29 100644 --- a/codelitephp/php-plugin/php_project_settings_dlg.cpp +++ b/codelitephp/php-plugin/php_project_settings_dlg.cpp @@ -34,7 +34,7 @@ PHPProjectSettingsDlg::PHPProjectSettingsDlg(wxWindow* parent, const wxString& p excludeFolders.Replace(";", ","); m_pgPropExcludeFolders->SetValueFromString(excludeFolders); - if(!data.GetPhpIniFile().IsEmpty()) { + if (!data.GetPhpIniFile().IsEmpty()) { m_filePickerPhpIni->SetPath(data.GetPhpIniFile()); } @@ -51,7 +51,7 @@ PHPProjectSettingsDlg::PHPProjectSettingsDlg(wxWindow* parent, const wxString& p SetDirty(false); GetSizer()->Fit(this); ::clSetDialogBestSizeAndPosition(this); - + m_dvListCtrlFileMapping->Bind( wxEVT_COMMAND_MENU_SELECTED, &PHPProjectSettingsDlg::OnNewFileMapping, this, wxID_NEW); m_dvListCtrlFileMapping->Bind( @@ -73,7 +73,7 @@ PHPProjectSettingsDlg::~PHPProjectSettingsDlg() void PHPProjectSettingsDlg::OnOK(wxCommandEvent& event) { - if(IsDirty()) { + if (IsDirty()) { OnApply(event); } EndModal(wxID_OK); @@ -86,11 +86,11 @@ void PHPProjectSettingsDlg::OnApplyUI(wxUpdateUIEvent& event) { event.Enable(thi void PHPProjectSettingsDlg::OnAddCCPath(wxCommandEvent& event) { wxString path = wxDirSelector(); - if(path.IsEmpty() == false) { + if (path.IsEmpty() == false) { wxString currentValue = m_textCtrlCCIncludePath->GetValue(); currentValue.Trim().Trim(false); - if(currentValue.IsEmpty() == false) { + if (currentValue.IsEmpty() == false) { currentValue << wxT("\n") << path; } else { currentValue << path; @@ -102,9 +102,9 @@ void PHPProjectSettingsDlg::OnAddCCPath(wxCommandEvent& event) void PHPProjectSettingsDlg::OnAddIncludePath(wxCommandEvent& event) { wxString path = ::wxDirSelector(_("Select folder")); - if(!path.IsEmpty()) { + if (!path.IsEmpty()) { wxArrayString curIncPaths = wxStringTokenize(m_textCtrlPHPIncludePath->GetValue(), "\n", wxTOKEN_STRTOK); - if(curIncPaths.Index(path) == wxNOT_FOUND) { + if (curIncPaths.Index(path) == wxNOT_FOUND) { curIncPaths.Add(path); } @@ -133,8 +133,8 @@ void PHPProjectSettingsDlg::Save() PHPProjectSettingsData& data = pProject->GetSettings(); // General settings - data.SetRunAs(m_choicebook1->GetSelection() == 0 ? PHPProjectSettingsData::kRunAsCLI : - PHPProjectSettingsData::kRunAsWebsite); + data.SetRunAs(m_choicebook1->GetSelection() == 0 ? PHPProjectSettingsData::kRunAsCLI + : PHPProjectSettingsData::kRunAsWebsite); data.SetPhpExe(m_filePickerPHPExe->GetPath()); data.SetIndexFile(m_filePickerIndex->GetPath()); data.SetArgs(m_textCtrlProgramArgs->GetValue()); @@ -151,7 +151,7 @@ void PHPProjectSettingsDlg::Save() // Save the file mapping wxStringMap_t mapping; int itemCount = m_dvListCtrlFileMapping->GetItemCount(); - for(int i = 0; i < itemCount; ++i) { + for (int i = 0; i < itemCount; ++i) { wxVariant source, target; m_dvListCtrlFileMapping->GetValue(source, i, 0); m_dvListCtrlFileMapping->GetValue(target, i, 1); @@ -196,7 +196,7 @@ void PHPProjectSettingsDlg::OnDeleteFileMapping(wxCommandEvent& e) { wxDataViewItemArray items; m_dvListCtrlFileMapping->GetSelections(items); - for(size_t i = 0; i < items.GetCount(); ++i) { + for (size_t i = 0; i < items.GetCount(); ++i) { m_dvListCtrlFileMapping->DeleteItem(m_dvListCtrlFileMapping->ItemToRow(items.Item(i))); SetDirty(true); } @@ -206,7 +206,8 @@ void PHPProjectSettingsDlg::OnEditFileMapping(wxCommandEvent& e) { wxDataViewItemArray items; m_dvListCtrlFileMapping->GetSelections(items); - if(items.GetCount() != 1) return; + if (items.GetCount() != 1) + return; wxDataViewItem item = items.Item(0); EditItem(item); @@ -215,7 +216,7 @@ void PHPProjectSettingsDlg::OnEditFileMapping(wxCommandEvent& e) void PHPProjectSettingsDlg::OnNewFileMapping(wxCommandEvent& e) { FileMappingDlg dlg(this); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { wxVector cols; cols.push_back(dlg.GetSourceFolder()); cols.push_back(dlg.GetTargetFolder()); @@ -226,7 +227,7 @@ void PHPProjectSettingsDlg::OnNewFileMapping(wxCommandEvent& e) void PHPProjectSettingsDlg::EditItem(const wxDataViewItem& item) { - if(!item.IsOk()) { + if (!item.IsOk()) { return; } @@ -238,7 +239,7 @@ void PHPProjectSettingsDlg::EditItem(const wxDataViewItem& item) FileMappingDlg dlg(this); dlg.SetSourceFolder(source.GetString()); dlg.SetTargetFolder(target.GetString()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { m_dvListCtrlFileMapping->SetValue(dlg.GetSourceFolder(), row, 0); m_dvListCtrlFileMapping->SetValue(dlg.GetTargetFolder(), row, 1); SetDirty(true); diff --git a/codelitephp/php-plugin/php_project_settings_dlg.h b/codelitephp/php-plugin/php_project_settings_dlg.h index f110d9eebb..9a4f1171cd 100644 --- a/codelitephp/php-plugin/php_project_settings_dlg.h +++ b/codelitephp/php-plugin/php_project_settings_dlg.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// Copyright : (C) 2015 Eran Ifrah -// File name : php_project_settings_dlg.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// Copyright : (C) 2015 Eran Ifrah +// File name : php_project_settings_dlg.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #ifndef __php_project_settings_dlg__ #define __php_project_settings_dlg__ diff --git a/codelitephp/php-plugin/php_settings_dlg.cpp b/codelitephp/php-plugin/php_settings_dlg.cpp index 27e37e2d53..55a7850519 100644 --- a/codelitephp/php-plugin/php_settings_dlg.cpp +++ b/codelitephp/php-plugin/php_settings_dlg.cpp @@ -14,7 +14,7 @@ PHPSettingsDlg::PHPSettingsDlg(wxWindow* parent) : PHPSettingsBaseDlg(parent) { LexerConf::Ptr_t lexer = ColoursAndFontsManager::Get().GetLexer("Default"); - if(lexer) { + if (lexer) { lexer->Apply(m_stcIncludePaths); } @@ -36,10 +36,10 @@ PHPSettingsDlg::PHPSettingsDlg(wxWindow* parent) void PHPSettingsDlg::OnBrowseForIncludePath(wxCommandEvent& event) { wxString path = wxDirSelector(); - if(path.IsEmpty() == false) { + if (path.IsEmpty() == false) { wxString curpath = m_stcIncludePaths->GetText(); curpath.Trim().Trim(false); - if(curpath.IsEmpty() == false) { + if (curpath.IsEmpty() == false) { curpath << wxT("\n"); } curpath << path; @@ -58,14 +58,14 @@ void PHPSettingsDlg::OnOK(wxCommandEvent& event) data.SetXdebugHost(m_textCtrlHost->GetValue()); wxString xdebugPort = m_textCtrlXDebugPort->GetValue(); long port(0); - if(xdebugPort.ToLong((long*)&port)) { + if (xdebugPort.ToLong((long*)&port)) { data.SetXdebugPort(port); } data.Save(); // Send an event to trigger a retag, but only if we got a PHP workspace opened - if(PHPWorkspace::Get()->IsOpen()) { + if (PHPWorkspace::Get()->IsOpen()) { wxCommandEvent evtRetag(wxEVT_COMMAND_MENU_SELECTED, XRCID("retag_workspace")); EventNotifier::Get()->TopFrame()->GetEventHandler()->AddPendingEvent(evtRetag); } @@ -75,12 +75,12 @@ void PHPSettingsDlg::OnOK(wxCommandEvent& event) void PHPSettingsDlg::OnAddCCPath(wxCommandEvent& event) { wxString path = wxDirSelector(); - if(path.IsEmpty() == false) { + if (path.IsEmpty() == false) { wxString curpath = m_textCtrCClIncludePath->GetValue(); curpath.Trim().Trim(false); - if(!curpath.IsEmpty()) { + if (!curpath.IsEmpty()) { curpath << wxT("\n"); } curpath << path; @@ -88,7 +88,4 @@ void PHPSettingsDlg::OnAddCCPath(wxCommandEvent& event) } } -void PHPSettingsDlg::OnUpdateApplyUI(wxCommandEvent& event) -{ - event.Skip(); -} +void PHPSettingsDlg::OnUpdateApplyUI(wxCommandEvent& event) { event.Skip(); } diff --git a/codelitephp/php-plugin/php_settings_dlg.h b/codelitephp/php-plugin/php_settings_dlg.h index 9bd61aa292..6813cfbca5 100644 --- a/codelitephp/php-plugin/php_settings_dlg.h +++ b/codelitephp/php-plugin/php_settings_dlg.h @@ -23,23 +23,23 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// -#ifndef __php_settings_dlg__ -#define __php_settings_dlg__ - -#include "php_ui.h" - -class PHPSettingsDlg : public PHPSettingsBaseDlg -{ -protected: - // Handlers for PHPSettingsBaseDlg events. - void OnBrowseForIncludePath(wxCommandEvent& event); - void OnAddCCPath(wxCommandEvent& event); - void OnUpdateApplyUI(wxCommandEvent& event); - -public: +#ifndef __php_settings_dlg__ +#define __php_settings_dlg__ + +#include "php_ui.h" + +class PHPSettingsDlg : public PHPSettingsBaseDlg +{ +protected: + // Handlers for PHPSettingsBaseDlg events. + void OnBrowseForIncludePath(wxCommandEvent& event); + void OnAddCCPath(wxCommandEvent& event); + void OnUpdateApplyUI(wxCommandEvent& event); + +public: PHPSettingsDlg(wxWindow* parent); - virtual ~PHPSettingsDlg() = default; - void OnOK(wxCommandEvent& event); -}; - -#endif // __php_settings_dlg__ + virtual ~PHPSettingsDlg() = default; + void OnOK(wxCommandEvent& event); +}; + +#endif // __php_settings_dlg__ diff --git a/codelitephp/php-plugin/php_view_model.h b/codelitephp/php-plugin/php_view_model.h index ff9acd1320..dbdd898a2a 100644 --- a/codelitephp/php-plugin/php_view_model.h +++ b/codelitephp/php-plugin/php_view_model.h @@ -2,114 +2,92 @@ #define PHPVIEWMODEL_H #include "phpworkspaceviewmodel.h" // Base class: PHPWorkspaceViewModel -#include + #include +#include class ItemData : public wxClientData { public: - enum kKIND { - Kind_Unknown = -1, - Kind_Workspace, - Kind_Project, - Kind_Folder, - Kind_File - }; + enum kKIND { Kind_Unknown = -1, Kind_Workspace, Kind_Project, Kind_Folder, Kind_File }; protected: - kKIND kind; - bool active; // make sense only if kind == Kind_Project - wxString projectName;// make sense only if kind == Kind_Project - wxString file; // make sense only if kind == Kind_File - wxString folderPath; // make sense only if kind == Kind_Folder + kKIND kind; + bool active; // make sense only if kind == Kind_Project + wxString projectName; // make sense only if kind == Kind_Project + wxString file; // make sense only if kind == Kind_File + wxString folderPath; // make sense only if kind == Kind_Folder public: ItemData(kKIND k) : kind(k) , active(false) - {} + { + } virtual ~ItemData() = default; - void SetProjectName(const wxString& projectName) { - this->projectName = projectName; - } - const wxString& GetProjectName() const { - return projectName; - } - void SetActive(bool active) { - this->active = active; - } - void SetFile(const wxString& file) { - this->file = file; - } - void SetFolderPath(const wxString& folderPath) { + void SetProjectName(const wxString& projectName) { this->projectName = projectName; } + const wxString& GetProjectName() const { return projectName; } + void SetActive(bool active) { this->active = active; } + void SetFile(const wxString& file) { this->file = file; } + void SetFolderPath(const wxString& folderPath) + { this->folderPath = folderPath; - if ( this->folderPath.EndsWith("/") ) { + if (this->folderPath.EndsWith("/")) { this->folderPath.RemoveLast(); } } - void SetKind(kKIND kind) { - this->kind = kind; - } - bool IsActive() const { - return active; - } - const wxString& GetFile() const { - return file; - } - const wxString& GetFolderPath() const { - return folderPath; - } + void SetKind(kKIND kind) { this->kind = kind; } + bool IsActive() const { return active; } + const wxString& GetFile() const { return file; } + const wxString& GetFolderPath() const { return folderPath; } - wxString GetFolderName() const { - return folderPath.AfterLast('/'); - } + wxString GetFolderName() const { return folderPath.AfterLast('/'); } - kKIND GetKind() const { - return kind; - } + kKIND GetKind() const { return kind; } - bool IsProject() const { - return kind == Kind_Project; - } + bool IsProject() const { return kind == Kind_Project; } - bool IsFolder() const { - return kind == Kind_Folder; - } + bool IsFolder() const { return kind == Kind_Folder; } - bool IsFile() const { - return kind == Kind_File; - } + bool IsFile() const { return kind == Kind_File; } - bool IsWorkspace() const { - return kind == Kind_Workspace; - } + bool IsWorkspace() const { return kind == Kind_Workspace; } }; // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- /** - * @class PHPViewModel + * @class PHPViewModel * @brief inherits from the model generated by wxCrafter for one purpose: * keeps a map between the filename and the wxDataViewItem */ class PHPViewModel : public PHPWorkspaceViewModel { - std::map m_all_items; // Maps between the filename and the dataitemview + std::map m_all_items; // Maps between the filename and the dataitemview public: PHPViewModel(); virtual ~PHPViewModel(); virtual void DeleteItem(const wxDataViewItem& item); - virtual void UpdateItem(const wxDataViewItem& item, const wxVector& data, const wxString &old_filename, const wxString &new_filename); - + virtual void UpdateItem(const wxDataViewItem& item, + const wxVector& data, + const wxString& old_filename, + const wxString& new_filename); + wxDataViewItem FindByFilename(const wxString& filename) const; void Clear(); - + protected: - virtual wxDataViewItem DoAppendItem(const wxDataViewItem& parent, const wxVector& data, bool isContainer, wxClientData *clientData = NULL); - virtual wxDataViewItem DoInsertItem(const wxDataViewItem& insertBeforeMe, const wxVector& data, bool isContainer, wxClientData *clientData); + virtual wxDataViewItem DoAppendItem(const wxDataViewItem& parent, + const wxVector& data, + bool isContainer, + wxClientData* clientData = NULL); + virtual wxDataViewItem DoInsertItem(const wxDataViewItem& insertBeforeMe, + const wxVector& data, + bool isContainer, + wxClientData* clientData); }; #endif // PHPVIEWMODEL_H diff --git a/codelitephp/php-plugin/php_workspace_view.cpp b/codelitephp/php-plugin/php_workspace_view.cpp index f831ee9c24..843cb1fa7c 100644 --- a/codelitephp/php-plugin/php_workspace_view.cpp +++ b/codelitephp/php-plugin/php_workspace_view.cpp @@ -38,13 +38,13 @@ #include #define CHECK_ID_FOLDER(id) \ - if(!id->IsFolder()) \ + if (!id->IsFolder()) \ return #define CHECK_ID_PROJECT(id) \ - if(!id->IsProject()) \ + if (!id->IsProject()) \ return #define CHECK_ID_FILE(id) \ - if(!id->IsFile()) \ + if (!id->IsFile()) \ return BEGIN_EVENT_TABLE(PHPWorkspaceView, PHPWorkspaceViewBase) @@ -81,12 +81,12 @@ PHPWorkspaceView::PHPWorkspaceView(wxWindow* parent, IManager* mgr) , m_scanInProgress(true) { // Initialise images map - EventNotifier::Get()->Connect(wxEVT_CMD_EXECUTE_ACTIVE_PROJECT, - clExecuteEventHandler(PHPWorkspaceView::OnRunActiveProject), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_CMD_EXECUTE_ACTIVE_PROJECT, clExecuteEventHandler(PHPWorkspaceView::OnRunActiveProject), NULL, this); EventNotifier::Get()->Bind(wxEVT_CMD_STOP_EXECUTED_PROGRAM, &PHPWorkspaceView::OnStopExecutedProgram, this); EventNotifier::Get()->Bind(wxEVT_CMD_IS_PROGRAM_RUNNING, &PHPWorkspaceView::OnIsProgramRunning, this); - EventNotifier::Get()->Connect(wxEVT_ACTIVE_EDITOR_CHANGED, wxCommandEventHandler(PHPWorkspaceView::OnEditorChanged), - NULL, this); + EventNotifier::Get()->Connect( + wxEVT_ACTIVE_EDITOR_CHANGED, wxCommandEventHandler(PHPWorkspaceView::OnEditorChanged), NULL, this); EventNotifier::Get()->Connect(wxEVT_PHP_FILE_RENAMED, PHPEventHandler(PHPWorkspaceView::OnFileRenamed), NULL, this); EventNotifier::Get()->Bind(wxPHP_PARSE_ENDED, &PHPWorkspaceView::OnPhpParserDone, this); EventNotifier::Get()->Bind(wxPHP_PARSE_PROGRESS, &PHPWorkspaceView::OnPhpParserProgress, this); @@ -115,20 +115,31 @@ PHPWorkspaceView::PHPWorkspaceView(wxWindow* parent, IManager* mgr) // Build the toolbar auto images = m_toolbar->GetBitmapsCreateIfNeeded(); - m_toolbar->AddTool(XRCID("ID_PHP_PROJECT_SETTINGS"), _("Open active project settings"), images->Add("cog"), - _("Open active project settings"), wxITEM_NORMAL); + m_toolbar->AddTool(XRCID("ID_PHP_PROJECT_SETTINGS"), + _("Open active project settings"), + images->Add("cog"), + _("Open active project settings"), + wxITEM_NORMAL); #if USE_SFTP - m_toolbar->AddTool(XRCID("ID_PHP_PROJECT_REMOTE_SAVE"), _("Setup automatic upload"), images->Add("file_open"), - _("Setup automatic upload"), wxITEM_DROPDOWN); + m_toolbar->AddTool(XRCID("ID_PHP_PROJECT_REMOTE_SAVE"), + _("Setup automatic upload"), + images->Add("file_open"), + _("Setup automatic upload"), + wxITEM_DROPDOWN); #endif m_toolbar->AddSeparator(); - m_toolbar->AddTool(XRCID("ID_TOOL_COLLAPSE"), _("Collapse All"), images->Add("fold"), _("Collapse All"), + m_toolbar->AddTool( + XRCID("ID_TOOL_COLLAPSE"), _("Collapse All"), images->Add("fold"), _("Collapse All"), wxITEM_NORMAL); + m_toolbar->AddTool(XRCID("ID_TOOL_SYNC_WORKSPACE"), + _("Sync workspace with file system"), + images->Add("debugger_restart"), + _("Sync workspace with file system..."), wxITEM_NORMAL); - m_toolbar->AddTool(XRCID("ID_TOOL_SYNC_WORKSPACE"), _("Sync workspace with file system"), - images->Add("debugger_restart"), _("Sync workspace with file system..."), wxITEM_NORMAL); m_toolbar->AddSeparator(); - m_toolbar->AddTool(XRCID("ID_TOOL_START_DEBUGGER_LISTENER"), _("Wait for Debugger Connection"), - images->Add("debugger_start"), _("Wait for Debugger Connection")); + m_toolbar->AddTool(XRCID("ID_TOOL_START_DEBUGGER_LISTENER"), + _("Wait for Debugger Connection"), + images->Add("debugger_start"), + _("Wait for Debugger Connection")); m_toolbar->Realize(); // Bind events @@ -136,7 +147,9 @@ PHPWorkspaceView::PHPWorkspaceView(wxWindow* parent, IManager* mgr) Bind(wxEVT_UPDATE_UI, &PHPWorkspaceView::OnActiveProjectSettingsUI, this, XRCID("ID_PHP_PROJECT_SETTINGS")); #if USE_SFTP - Bind(wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, &PHPWorkspaceView::OnSetupRemoteUpload, this, + Bind(wxEVT_COMMAND_AUITOOLBAR_TOOL_DROPDOWN, + &PHPWorkspaceView::OnSetupRemoteUpload, + this, XRCID("ID_PHP_PROJECT_REMOTE_SAVE")); Bind(wxEVT_UPDATE_UI, &PHPWorkspaceView::OnSetupRemoteUploadUI, this, XRCID("ID_PHP_PROJECT_REMOTE_SAVE")); Bind(wxEVT_TOOL, &PHPWorkspaceView::OnSetupRemoteUpload, this, XRCID("ID_PHP_PROJECT_REMOTE_SAVE")); @@ -157,14 +170,14 @@ PHPWorkspaceView::PHPWorkspaceView(wxWindow* parent, IManager* mgr) PHPWorkspaceView::~PHPWorkspaceView() { - EventNotifier::Get()->Disconnect(wxEVT_CMD_EXECUTE_ACTIVE_PROJECT, - clExecuteEventHandler(PHPWorkspaceView::OnRunActiveProject), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_CMD_EXECUTE_ACTIVE_PROJECT, clExecuteEventHandler(PHPWorkspaceView::OnRunActiveProject), NULL, this); EventNotifier::Get()->Unbind(wxEVT_CMD_STOP_EXECUTED_PROGRAM, &PHPWorkspaceView::OnStopExecutedProgram, this); EventNotifier::Get()->Unbind(wxEVT_CMD_IS_PROGRAM_RUNNING, &PHPWorkspaceView::OnIsProgramRunning, this); - EventNotifier::Get()->Disconnect(wxEVT_ACTIVE_EDITOR_CHANGED, - wxCommandEventHandler(PHPWorkspaceView::OnEditorChanged), NULL, this); - EventNotifier::Get()->Disconnect(wxEVT_PHP_FILE_RENAMED, PHPEventHandler(PHPWorkspaceView::OnFileRenamed), NULL, - this); + EventNotifier::Get()->Disconnect( + wxEVT_ACTIVE_EDITOR_CHANGED, wxCommandEventHandler(PHPWorkspaceView::OnEditorChanged), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_PHP_FILE_RENAMED, PHPEventHandler(PHPWorkspaceView::OnFileRenamed), NULL, this); EventNotifier::Get()->Unbind(wxPHP_PARSE_ENDED, &PHPWorkspaceView::OnPhpParserDone, this); EventNotifier::Get()->Unbind(wxPHP_PARSE_PROGRESS, &PHPWorkspaceView::OnPhpParserProgress, this); EventNotifier::Get()->Unbind(wxEVT_PHP_WORKSPACE_LOADED, &PHPWorkspaceView::OnWorkspaceLoaded, this); @@ -175,8 +188,8 @@ PHPWorkspaceView::~PHPWorkspaceView() Unbind(wxEVT_PHP_WORKSPACE_FILES_SYNC_START, &PHPWorkspaceView::OnWorkspaceSyncStart, this); Unbind(wxEVT_PHP_WORKSPACE_FILES_SYNC_END, &PHPWorkspaceView::OnWorkspaceSyncEnd, this); Unbind(wxEVT_MENU, &PHPWorkspaceView::OnStartDebuggerListener, this, XRCID("ID_TOOL_START_DEBUGGER_LISTENER")); - Unbind(wxEVT_UPDATE_UI, &PHPWorkspaceView::OnStartDebuggerListenerUI, this, - XRCID("ID_TOOL_START_DEBUGGER_LISTENER")); + Unbind( + wxEVT_UPDATE_UI, &PHPWorkspaceView::OnStartDebuggerListenerUI, this, XRCID("ID_TOOL_START_DEBUGGER_LISTENER")); EventNotifier::Get()->Unbind(wxEVT_FILE_SAVEAS, &PHPWorkspaceView::OnFileSaveAs, this); Unbind(wxEVT_PHP_PROJECT_FILES_SYNC_END, &PHPWorkspaceView::OnProjectSyncCompleted, this); @@ -190,7 +203,7 @@ PHPWorkspaceView::~PHPWorkspaceView() void PHPWorkspaceView::OnFolderDropped(clCommandEvent& event) { const wxArrayString& folders = event.GetStrings(); - if(folders.GetCount() != 1) { + if (folders.GetCount() != 1) { ::wxMessageBox(_("Can only import one folder at a time"), "CodeLite", wxOK | wxICON_ERROR | wxCENTER); return; } @@ -200,8 +213,8 @@ void PHPWorkspaceView::OnFolderDropped(clCommandEvent& event) wxString workspaceFile; wxDir::GetAllFiles(folders.Item(0), &workspaceFiles, "*.workspace", wxDIR_FILES); // Check the workspace type - for(size_t i = 0; i < workspaceFiles.size(); ++i) { - if(FileExtManager::GetType(workspaceFiles.Item(i)) == FileExtManager::TypeWorkspacePHP) { + for (size_t i = 0; i < workspaceFiles.size(); ++i) { + if (FileExtManager::GetType(workspaceFiles.Item(i)) == FileExtManager::TypeWorkspacePHP) { workspaceFile = workspaceFiles.Item(i); break; } @@ -212,16 +225,16 @@ void PHPWorkspaceView::OnFolderDropped(clCommandEvent& event) projectFileName.SetName(projectFileName.GetDirs().Last()); projectFileName.SetExt("phprj"); - if(!PHPWorkspace::Get()->IsOpen()) { + if (!PHPWorkspace::Get()->IsOpen()) { workspaceFileName = wxFileName(folders.Item(0), ""); workspaceFileName.SetName(workspaceFileName.GetDirs().Last()); workspaceFileName.SetExt("workspace"); - if(!workspaceFile.IsEmpty()) { + if (!workspaceFile.IsEmpty()) { workspaceFileName = wxFileName(workspaceFile); } - if(!workspaceFileName.IsDirWritable()) { + if (!workspaceFileName.IsDirWritable()) { wxString message; message << _("Failed to create workspace '") << workspaceFileName.GetFullPath() << "'\n" << _("Permission denied."); @@ -229,7 +242,7 @@ void PHPWorkspaceView::OnFolderDropped(clCommandEvent& event) return; } // Create an empty workspace - if(!PHPWorkspace::Get()->Open(workspaceFileName.GetFullPath(), this, true)) { + if (!PHPWorkspace::Get()->Open(workspaceFileName.GetFullPath(), this, true)) { wxString message; message << _("Failed to open workspace '") << workspaceFileName.GetFullPath() << "'\n" << _("File exists"); ::wxMessageBox(message, "CodeLite", wxOK | wxICON_ERROR | wxCENTER); @@ -244,25 +257,26 @@ void PHPWorkspaceView::OnFolderDropped(clCommandEvent& event) m_mgr->GetWorkspaceView()->SelectPage(PHPStrings::PHP_WORKSPACE_VIEW_LABEL); // If we loaded an already existing workspace, we are done here - if(!workspaceFile.IsEmpty()) + if (!workspaceFile.IsEmpty()) return; } else { - if(!workspaceFile.IsEmpty()) { + if (!workspaceFile.IsEmpty()) { // its the same workspace - do nothing - if(PHPWorkspace::Get()->GetFilename().GetFullPath() == workspaceFile) + if (PHPWorkspace::Get()->GetFilename().GetFullPath() == workspaceFile) return; // Different workspaces, prompt the user to close its workspace before continuing ::wxMessageBox( _("The folder already contains a workspace file\nPlease close the current workspace before continuing"), - "CodeLite", wxOK | wxICON_WARNING | wxCENTER); + "CodeLite", + wxOK | wxICON_WARNING | wxCENTER); return; } workspaceFileName = PHPWorkspace::Get()->GetFilename(); } // Make sure that this folder is not part of any of the existing projects - if(!PHPWorkspace::Get()->CanCreateProjectAtPath(projectFileName, true)) { + if (!PHPWorkspace::Get()->CanCreateProjectAtPath(projectFileName, true)) { return; } @@ -283,13 +297,13 @@ void PHPWorkspaceView::OnMenu(wxTreeEvent& event) { wxBitmap bmpFiF = m_mgr->GetStdIcons()->LoadBitmap("find"); wxTreeItemId item = event.GetItem(); - if(item.IsOk()) { + if (item.IsOk()) { // Ensure that the item is selected m_treeCtrlView->SelectItem(event.GetItem()); ItemData* data = DoGetItemData(item); - if(data) { + if (data) { wxMenuItem* menuItem = NULL; - switch(data->GetKind()) { + switch (data->GetKind()) { case ItemData::Kind_File: { wxMenu menu; menu.Append(XRCID("php_open_file"), _("Open")); @@ -359,8 +373,8 @@ void PHPWorkspaceView::OnMenu(wxTreeEvent& event) menu.Append(XRCID("php_open_shell"), _("Open Shell")); menu.AppendSeparator(); - menuItem = new wxMenuItem(NULL, XRCID("php_sync_project_with_filesystem"), - _("Sync project with file system...")); + menuItem = new wxMenuItem( + NULL, XRCID("php_sync_project_with_filesystem"), _("Sync project with file system...")); menuItem->SetBitmap(clGetManager()->GetStdIcons()->LoadBitmap("debugger_restart")); menu.Append(menuItem); menu.AppendSeparator(); @@ -387,8 +401,8 @@ void PHPWorkspaceView::OnMenu(wxTreeEvent& event) menu.AppendSeparator(); menu.Append(XRCID("php_remove_file"), _("Delete")); menu.AppendSeparator(); - menuItem = new wxMenuItem(NULL, XRCID("php_sync_folder_with_filesystem"), - _("Sync folder with file system...")); + menuItem = new wxMenuItem( + NULL, XRCID("php_sync_folder_with_filesystem"), _("Sync folder with file system...")); menuItem->SetBitmap(clGetManager()->GetStdIcons()->LoadBitmap("debugger_restart")); menu.Append(menuItem); menu.AppendSeparator(); @@ -424,7 +438,7 @@ void PHPWorkspaceView::LoadWorkspaceView() wxWindowUpdateLocker locker(m_treeCtrlView); m_treeCtrlView->DeleteAllItems(); - if(m_scanInProgress) { + if (m_scanInProgress) { m_treeCtrlView->AddRoot("Scanning for workspace files..."); m_treeCtrlView->Enable(false); return; @@ -437,9 +451,10 @@ void PHPWorkspaceView::LoadWorkspaceView() data->SetFile(PHPWorkspace::Get()->GetFilename().GetFullPath()); data->SetFolderPath(PHPWorkspace::Get()->GetDir()); - wxTreeItemId root = - m_treeCtrlView->AddRoot(workspaceName, bl->GetMimeImageId(PHPWorkspace::Get()->GetFilename().GetFullName()), - bl->GetMimeImageId(PHPWorkspace::Get()->GetFilename().GetFullName()), data); + wxTreeItemId root = m_treeCtrlView->AddRoot(workspaceName, + bl->GetMimeImageId(PHPWorkspace::Get()->GetFilename().GetFullName()), + bl->GetMimeImageId(PHPWorkspace::Get()->GetFilename().GetFullName()), + data); const PHPProject::Map_t& projects = PHPWorkspace::Get()->GetProjects(); wxBusyCursor bc; @@ -461,23 +476,23 @@ void PHPWorkspaceView::LoadWorkspaceView() bl->GetMimeImageId(FileExtManager::TypeProject), bl->GetMimeImageId(FileExtManager::TypeProjectExpanded), data); - if(data->IsActive()) { + if (data->IsActive()) { m_treeCtrlView->SetItemBold(projectItemId, true); } // The project is also a folder for the project folder m_foldersItems.insert(std::make_pair(project->GetFilename().GetPath(), projectItemId)); DoBuildProjectNode(projectItemId, project); - if(data->IsActive()) { + if (data->IsActive()) { activeProjectId = projectItemId; } } - if(m_treeCtrlView->ItemHasChildren(root)) { + if (m_treeCtrlView->ItemHasChildren(root)) { m_treeCtrlView->Expand(root); } - if(activeProjectId.IsOk() && m_treeCtrlView->ItemHasChildren(activeProjectId)) { + if (activeProjectId.IsOk() && m_treeCtrlView->ItemHasChildren(activeProjectId)) { m_treeCtrlView->Expand(activeProjectId); } wxCommandEvent dummy; @@ -517,12 +532,14 @@ void PHPWorkspaceView::OnDeleteProject(wxCommandEvent& e) { // Prompt user wxTreeItemId selection = m_treeCtrlView->GetFocusedItem(); - if(selection.IsOk()) { + if (selection.IsOk()) { ItemData* itemData = DoGetItemData(selection); - if(itemData && itemData->IsProject()) { - if(wxMessageBox(wxString() << _("Are you sure you want to remove project '") << itemData->GetProjectName() - << "'?", - wxT("CodeLite"), wxYES_NO | wxCANCEL | wxCANCEL_DEFAULT, wxTheApp->GetTopWindow()) == wxYES) { + if (itemData && itemData->IsProject()) { + if (wxMessageBox( + wxString() << _("Are you sure you want to remove project '") << itemData->GetProjectName() << "'?", + wxT("CodeLite"), + wxYES_NO | wxCANCEL | wxCANCEL_DEFAULT, + wxTheApp->GetTopWindow()) == wxYES) { PHPWorkspace::Get()->DeleteProject(itemData->GetProjectName()); m_treeCtrlView->Delete(selection); @@ -539,11 +556,11 @@ void PHPWorkspaceView::OnNewFolder(wxCommandEvent& e) wxUnusedVar(e); wxString name = wxGetTextFromUser(_("New Folder Name:"), _("New Folder")); - if(name.IsEmpty()) + if (name.IsEmpty()) return; wxString project = DoGetSelectedProject(); - if(project.IsEmpty()) + if (project.IsEmpty()) return; wxTreeItemId parent = m_treeCtrlView->GetFocusedItem(); @@ -569,7 +586,7 @@ void PHPWorkspaceView::OnNewFolder(wxCommandEvent& e) newfolder.AppendDir(name); // Create the folder on the file system - if(wxFileName::Mkdir(newfolder.GetPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL)) { + if (wxFileName::Mkdir(newfolder.GetPath(), wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL)) { // Add folder to the tree view ItemData* itemData = new ItemData(ItemData::Kind_Folder); itemData->SetFolderName(name); @@ -581,7 +598,7 @@ void PHPWorkspaceView::OnNewFolder(wxCommandEvent& e) wxTreeItemId newFolderItem = m_treeCtrlView->AppendItem(parent, name, imgId, imgIdExpanded, itemData); proj->FolderAdded(newfolder.GetPath()); // Expand the node - if(!m_treeCtrlView->IsExpanded(parent)) { + if (!m_treeCtrlView->IsExpanded(parent)) { m_treeCtrlView->Expand(parent); } @@ -593,7 +610,7 @@ void PHPWorkspaceView::OnNewFolder(wxCommandEvent& e) void PHPWorkspaceView::OnSetProjectActive(wxCommandEvent& e) { wxString project = DoGetSelectedProject(); - if(project.IsEmpty()) + if (project.IsEmpty()) return; DoSetProjectActive(project); @@ -602,23 +619,23 @@ void PHPWorkspaceView::OnSetProjectActive(wxCommandEvent& e) wxString PHPWorkspaceView::DoGetSelectedProject() { wxTreeItemId item = m_treeCtrlView->GetFocusedItem(); - if(!item.IsOk()) { + if (!item.IsOk()) { return wxEmptyString; } ItemData* id = DoGetItemData(item); - if(!id) + if (!id) return wxEmptyString; return id->GetProjectName(); } ItemData* PHPWorkspaceView::DoGetItemData(const wxTreeItemId& item) { - if(item.IsOk() == false) + if (item.IsOk() == false) return NULL; wxTreeItemData* data = m_treeCtrlView->GetItemData(item); - if(!data) { + if (!data) { return NULL; } return dynamic_cast(data); @@ -626,11 +643,11 @@ ItemData* PHPWorkspaceView::DoGetItemData(const wxTreeItemId& item) const ItemData* PHPWorkspaceView::DoGetItemData(const wxTreeItemId& item) const { - if(item.IsOk() == false) + if (item.IsOk() == false) return NULL; wxTreeItemData* data = m_treeCtrlView->GetItemData(item); - if(!data) { + if (!data) { return NULL; } return dynamic_cast(data); @@ -640,13 +657,13 @@ void PHPWorkspaceView::OnNewFile(wxCommandEvent& e) { wxTreeItemId folderId = DoGetSingleSelection(); ItemData* data = DoGetItemData(folderId); - if(data->IsFolder() || data->IsProject()) { + if (data->IsFolder() || data->IsProject()) { wxString filename = ::clGetTextFromUser(_("New File"), _("Set the file name:"), "Untitled.php", wxStrlen("Untitled")); - if(filename.IsEmpty()) + if (filename.IsEmpty()) return; wxFileName fn; - if(data->IsFolder()) { + if (data->IsFolder()) { fn = wxFileName(data->GetFolderPath(), filename); } else { PHPProject::Ptr_t proj = PHPWorkspace::Get()->GetProject(data->GetProjectName()); @@ -655,8 +672,8 @@ void PHPWorkspaceView::OnNewFile(wxCommandEvent& e) fn = wxFileName(proj->GetFilename().GetPath(), filename); } wxTreeItemId fileItem = DoCreateFile(folderId, fn.GetFullPath()); - if(fileItem.IsOk()) { - if(!m_treeCtrlView->IsExpanded(folderId)) { + if (fileItem.IsOk()) { + if (!m_treeCtrlView->IsExpanded(folderId)) { m_treeCtrlView->Expand(folderId); } CallAfter(&PHPWorkspaceView::DoOpenFile, fileItem); @@ -667,7 +684,7 @@ void PHPWorkspaceView::OnNewFile(wxCommandEvent& e) bool PHPWorkspaceView::IsFolderItem(const wxTreeItemId& item) { ItemData* data = DoGetItemData(item); - if(!data) + if (!data) return false; return data->IsFolder(); @@ -676,24 +693,24 @@ bool PHPWorkspaceView::IsFolderItem(const wxTreeItemId& item) void PHPWorkspaceView::OnDeleteFolder(wxCommandEvent& e) { wxTreeItemId folderItem = DoGetSingleSelection(); - if(!IsFolderItem(folderItem)) + if (!IsFolderItem(folderItem)) return; ItemData* data = DoGetItemData(folderItem); wxString folder = data->GetFolderPath(); wxString project = DoGetSelectedProject(); - if(folder.IsEmpty() || project.IsEmpty()) + if (folder.IsEmpty() || project.IsEmpty()) return; wxString msg = wxString() << _("Are you sure you want to delete folder '") << folder << _("' and its content?"); - if(wxMessageBox(msg, wxT("CodeLite"), wxYES_NO | wxCANCEL | wxICON_WARNING | wxCENTER) != wxYES) + if (wxMessageBox(msg, wxT("CodeLite"), wxYES_NO | wxCANCEL | wxICON_WARNING | wxCENTER) != wxYES) return; // Delete the folder from the file system PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(project); CHECK_PTR_RET(pProject); - if(wxFileName::Rmdir(folder, wxPATH_RMDIR_RECURSIVE)) { + if (wxFileName::Rmdir(folder, wxPATH_RMDIR_RECURSIVE)) { pProject->FolderDeleted(folder, true); pProject->Save(); // Update the UI @@ -713,7 +730,7 @@ void PHPWorkspaceView::OnRetagWorkspace(wxCommandEvent& e) int PHPWorkspaceView::DoGetItemImgIdx(const wxString& filename) { int idx = m_mgr->GetStdIcons()->GetMimeImageId(filename); - if(idx == wxNOT_FOUND) { + if (idx == wxNOT_FOUND) { idx = m_mgr->GetStdIcons()->GetMimeImageId(FileExtManager::TypeText); } return idx; @@ -724,13 +741,13 @@ void PHPWorkspaceView::OnOpenFile(wxCommandEvent& e) e.Skip(); wxArrayTreeItemIds items; DoGetSelectedItems(items); - if(items.IsEmpty()) + if (items.IsEmpty()) return; - for(size_t i = 0; i < items.GetCount(); ++i) { + for (size_t i = 0; i < items.GetCount(); ++i) { const wxTreeItemId& item = items.Item(i); ItemData* itemData = DoGetItemData(item); - if(itemData->IsFile()) { + if (itemData->IsFile()) { DoOpenFile(item); } } @@ -739,9 +756,9 @@ void PHPWorkspaceView::OnOpenFile(wxCommandEvent& e) void PHPWorkspaceView::DoOpenFile(const wxTreeItemId& item) { ItemData* data = DoGetItemData(item); - if(data && data->IsFile()) { + if (data && data->IsFile()) { m_mgr->OpenFile(data->GetFile()); - if(m_mgr->GetActiveEditor() && m_mgr->GetActiveEditor()->GetFileName().GetFullPath() == data->GetFile()) { + if (m_mgr->GetActiveEditor() && m_mgr->GetActiveEditor()->GetFileName().GetFullPath() == data->GetFile()) { m_mgr->GetActiveEditor()->GetCtrl()->CallAfter(&wxStyledTextCtrl::SetFocus); } } @@ -753,7 +770,7 @@ void PHPWorkspaceView::OnRenameFile(wxCommandEvent& e) { wxArrayTreeItemIds items; DoGetSelectedItems(items); - if(items.IsEmpty()) + if (items.IsEmpty()) return; wxTreeItemId item = items.Item(0); @@ -766,9 +783,9 @@ void PHPWorkspaceView::OnRenameFile(wxCommandEvent& e) wxFileName oldFileName = data->GetFile(); wxString new_name = ::clGetTextFromUser(_("New file name:"), _("Rename file"), oldFileName.GetFullName()); - if(new_name.IsEmpty()) + if (new_name.IsEmpty()) return; - if(new_name == oldFileName.GetFullName()) + if (new_name == oldFileName.GetFullName()) return; // Get the project that owns this file @@ -778,7 +795,7 @@ void PHPWorkspaceView::OnRenameFile(wxCommandEvent& e) // Check to see if we got a file with the old path opened bool reopenFile = false; IEditor* editor = m_mgr->FindEditor(oldFileName.GetFullPath()); - if(editor) { + if (editor) { m_mgr->ClosePage(editor->GetFileName().GetFullName()); reopenFile = true; editor = NULL; @@ -787,7 +804,7 @@ void PHPWorkspaceView::OnRenameFile(wxCommandEvent& e) wxFileName newFileName = oldFileName; newFileName.SetFullName(new_name); // Rename the file on the file system - if(::wxRenameFile(oldFileName.GetFullPath(), newFileName.GetFullPath())) { + if (::wxRenameFile(oldFileName.GetFullPath(), newFileName.GetFullPath())) { pProject->FileRenamed(oldFileName.GetFullPath(), newFileName.GetFullPath(), true); pProject->Save(); m_treeCtrlView->SetItemText(item, new_name); @@ -797,7 +814,7 @@ void PHPWorkspaceView::OnRenameFile(wxCommandEvent& e) // Open the file if it was opened earlier // old_file_name now contains the new full path to the new file - if(reopenFile) { + if (reopenFile) { m_mgr->OpenFile(newFileName.GetFullPath()); } } @@ -809,33 +826,39 @@ void PHPWorkspaceView::DoDeleteSelectedFileItem() { wxArrayTreeItemIds items; DoGetSelectedItems(items); - if(items.IsEmpty()) + if (items.IsEmpty()) return; wxString msg; msg = wxString::Format(_("This operation will delete the selected items.\nContinue?"), (int)items.GetCount()); - wxStandardID res = ::PromptForYesNoDialogWithCheckbox(msg, "PHPDeleteFiles", _("Yes"), _("No"), + wxStandardID res = ::PromptForYesNoDialogWithCheckbox(msg, + "PHPDeleteFiles", + _("Yes"), + _("No"), _("Remember my answer and don't ask me again"), wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT); - if(res != wxID_YES) + if (res != wxID_YES) return; wxArrayString removedFiles, removedFolders; - for(size_t i = 0; i < items.GetCount(); ++i) { + for (size_t i = 0; i < items.GetCount(); ++i) { ItemData* itemData = static_cast(m_treeCtrlView->GetItemData(items.Item(i))); - if(!itemData || (!itemData->IsFile() && !itemData->IsFolder())) + if (!itemData || (!itemData->IsFile() && !itemData->IsFolder())) continue; // Folder or file - if(itemData->IsFolder()) { + if (itemData->IsFolder()) { // Prompt for folder message msg = wxString::Format( _("'%s' is a folder.\nThis operation will delete the folder and its content.\nContinue?"), itemData->GetFolderPath()); - res = ::PromptForYesNoDialogWithCheckbox(msg, "PHPDeleteFolder", _("Yes"), _("No"), + res = ::PromptForYesNoDialogWithCheckbox(msg, + "PHPDeleteFolder", + _("Yes"), + _("No"), _("Remember my answer and don't ask me again"), wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT); - if(res != wxID_YES) + if (res != wxID_YES) continue; // Don't delete the folder removedFolders.Add(itemData->GetFolderPath()); wxFileName::Rmdir(itemData->GetFolderPath(), wxPATH_RMDIR_RECURSIVE); @@ -870,7 +893,7 @@ void PHPWorkspaceView::OnRunProject(wxCommandEvent& e) // Test which file we want to debug PHPDebugStartDlg debugDlg(EventNotifier::Get()->TopFrame(), PHPWorkspace::Get()->GetActiveProject(), m_mgr); debugDlg.SetLabel("Run Project"); - if(debugDlg.ShowModal() != wxID_OK) { + if (debugDlg.ShowModal() != wxID_OK) { return; } @@ -879,13 +902,15 @@ void PHPWorkspaceView::OnRunProject(wxCommandEvent& e) void PHPWorkspaceView::OnActiveProjectSettings(wxCommandEvent& event) { - if(!PHPWorkspace::Get()->GetActiveProject()) { - ::wxMessageBox(_("No active project is set !?\nPlease set an active project and try again"), "CodeLite", - wxICON_ERROR | wxOK | wxCENTER, FRAME); + if (!PHPWorkspace::Get()->GetActiveProject()) { + ::wxMessageBox(_("No active project is set !?\nPlease set an active project and try again"), + "CodeLite", + wxICON_ERROR | wxOK | wxCENTER, + FRAME); return; } PHPProjectSettingsDlg settingsDlg(FRAME, PHPWorkspace::Get()->GetActiveProjectName()); - if(settingsDlg.ShowModal() == wxID_OK && settingsDlg.IsResyncNeeded()) { + if (settingsDlg.ShowModal() == wxID_OK && settingsDlg.IsResyncNeeded()) { // Re-sync the project with the file system PHPWorkspace::Get()->SyncWithFileSystemAsync(this); } @@ -900,7 +925,7 @@ void PHPWorkspaceView::OnProjectSettings(wxCommandEvent& event) { wxString selectedProject = DoGetSelectedProject(); PHPProjectSettingsDlg settingsDlg(FRAME, selectedProject); - if(settingsDlg.ShowModal() == wxID_OK && settingsDlg.IsResyncNeeded()) { + if (settingsDlg.ShowModal() == wxID_OK && settingsDlg.IsResyncNeeded()) { // Re-sync the project with the file system PHPWorkspace::Get()->SyncWithFileSystemAsync(this); } @@ -908,12 +933,12 @@ void PHPWorkspaceView::OnProjectSettings(wxCommandEvent& event) void PHPWorkspaceView::OnRunActiveProject(clExecuteEvent& e) { - if(PHPWorkspace::Get()->IsOpen()) { + if (PHPWorkspace::Get()->IsOpen()) { CHECK_COND_RET(PHPWorkspace::Get()->GetActiveProject()); // Test which file we want to debug PHPDebugStartDlg dlg(EventNotifier::Get()->TopFrame(), PHPWorkspace::Get()->GetActiveProject(), m_mgr); dlg.SetLabel("Run Project"); - if(dlg.ShowModal() != wxID_OK) { + if (dlg.ShowModal() != wxID_OK) { return; } PHPWorkspace::Get()->RunProject(false, dlg.GetPath()); @@ -926,7 +951,7 @@ void PHPWorkspaceView::OnRunActiveProject(clExecuteEvent& e) void PHPWorkspaceView::OnIsProgramRunning(clExecuteEvent& e) { - if(PHPWorkspace::Get()->IsOpen()) { + if (PHPWorkspace::Get()->IsOpen()) { e.SetAnswer(PHPWorkspace::Get()->IsProjectRunning()); } else { @@ -937,7 +962,7 @@ void PHPWorkspaceView::OnIsProgramRunning(clExecuteEvent& e) void PHPWorkspaceView::OnStopExecutedProgram(clExecuteEvent& e) { - if(PHPWorkspace::Get()->IsOpen() && PHPWorkspace::Get()->IsProjectRunning()) { + if (PHPWorkspace::Get()->IsOpen() && PHPWorkspace::Get()->IsProjectRunning()) { PHPWorkspace::Get()->StopExecutedProgram(); } else { @@ -949,7 +974,7 @@ void PHPWorkspaceView::OnStopExecutedProgram(clExecuteEvent& e) void PHPWorkspaceView::OnEditorChanged(wxCommandEvent& e) { e.Skip(); - if(PHPWorkspace::Get()->IsOpen()) { + if (PHPWorkspace::Get()->IsOpen()) { DoExpandToActiveEditor(); } } @@ -961,7 +986,7 @@ void PHPWorkspaceView::OnMakeIndexPHP(wxCommandEvent& e) e.Skip(); wxArrayTreeItemIds items; DoGetSelectedItems(items); - if(items.GetCount() != 1) + if (items.GetCount() != 1) return; ItemData* itemData = DoGetItemData(items.Item(0)); @@ -969,7 +994,7 @@ void PHPWorkspaceView::OnMakeIndexPHP(wxCommandEvent& e) CHECK_ID_FILE(itemData); wxString projectName = itemData->GetProjectName(); - if(projectName.IsEmpty()) + if (projectName.IsEmpty()) return; PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(projectName); CHECK_PTR_RET(pProject); @@ -984,18 +1009,18 @@ void PHPWorkspaceView::OnNewClass(wxCommandEvent& e) wxArrayTreeItemIds items; DoGetSelectedItems(items); - if(items.GetCount() != 1) + if (items.GetCount() != 1) return; wxTreeItemId folderId = items.Item(0); ItemData* data = DoGetItemData(folderId); - if(!data->IsFolder() && !data->IsProject()) { + if (!data->IsFolder() && !data->IsProject()) { return; } PHPProject::Ptr_t pProject; - if(data->IsFolder()) { + if (data->IsFolder()) { pProject = PHPWorkspace::Get()->GetProject(data->GetProjectName()); } else { pProject = PHPWorkspace::Get()->GetProject(data->GetProjectName()); @@ -1003,7 +1028,7 @@ void PHPWorkspaceView::OnNewClass(wxCommandEvent& e) CHECK_PTR_RET(pProject); NewPHPClass dlg(wxTheApp->GetTopWindow(), data->GetFolderPath()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { PHPClassDetails pcd = dlg.GetDetails(); wxWindowUpdateLocker locker(m_treeCtrlView); @@ -1019,15 +1044,15 @@ void PHPWorkspaceView::OnNewClass(wxCommandEvent& e) // which formatter tool to use (PHP/JS/C++ etc) event.SetFileName(pcd.GetFilepath().GetFullPath()); EventNotifier::Get()->ProcessEvent(event); - if(!event.GetFormattedString().IsEmpty()) { + if (!event.GetFormattedString().IsEmpty()) { fileContent = event.GetFormattedString(); } wxTreeItemId fileItem = DoCreateFile(folderId, pcd.GetFilepath().GetFullPath(), fileContent); // Set the focus the new class - if(fileItem.IsOk()) { - if(!m_treeCtrlView->IsExpanded(folderId)) { + if (fileItem.IsOk()) { + if (!m_treeCtrlView->IsExpanded(folderId)) { m_treeCtrlView->Expand(folderId); } CallAfter(&PHPWorkspaceView::DoOpenFile, fileItem); @@ -1041,7 +1066,7 @@ void PHPWorkspaceView::OnNewClass(wxCommandEvent& e) void PHPWorkspaceView::OnRenameWorkspace(wxCommandEvent& e) { wxString new_name = ::wxGetTextFromUser(_("New workspace name:"), _("Rename workspace")); - if(!new_name.IsEmpty()) { + if (!new_name.IsEmpty()) { PHPWorkspace::Get()->Rename(new_name); } } @@ -1053,7 +1078,7 @@ void PHPWorkspaceView::OnSetupRemoteUploadMenu(wxCommandEvent& event) settings.Load(); wxMenu menu; - if(!settings.IsRemoteUploadSet()) { + if (!settings.IsRemoteUploadSet()) { // We never setup remote upload for this workspace menu.AppendCheckItem(ID_TOGGLE_AUTOMATIC_UPLOAD, _("Enable automatic upload")); menu.Enable(ID_TOGGLE_AUTOMATIC_UPLOAD, false); @@ -1062,8 +1087,11 @@ void PHPWorkspaceView::OnSetupRemoteUploadMenu(wxCommandEvent& event) } else { menu.AppendCheckItem(ID_TOGGLE_AUTOMATIC_UPLOAD, _("Enable automatic upload")); menu.Check(ID_TOGGLE_AUTOMATIC_UPLOAD, settings.IsRemoteUploadEnabled()); - menu.Connect(ID_TOGGLE_AUTOMATIC_UPLOAD, wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(PHPWorkspaceView::OnToggleAutoUpload), NULL, this); + menu.Connect(ID_TOGGLE_AUTOMATIC_UPLOAD, + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(PHPWorkspaceView::OnToggleAutoUpload), + NULL, + this); } m_toolbar->ShowMenuForButton(event.GetId(), &menu); } @@ -1089,11 +1117,12 @@ void PHPWorkspaceView::DoOpenSSHAccountManager() settings.Load(); SFTPBrowserDlg dlg(EventNotifier::Get()->TopFrame(), - _("Select the remote folder corresponding to the current workspace file"), "", + _("Select the remote folder corresponding to the current workspace file"), + "", clSFTP::SFTP_BROWSE_FOLDERS); // Browse for folders only dlg.Initialize(settings.GetAccount(), settings.GetRemoteFolder()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { settings.SetAccount(dlg.GetAccount()); settings.SetRemoteFolder(dlg.GetPath()); settings.Save(); @@ -1112,13 +1141,13 @@ void PHPWorkspaceView::ReloadWorkspace(bool saveBeforeReload) void PHPWorkspaceView::ReportParseThreadProgress(size_t curIndex, size_t total) { - if(!m_gaugeParseProgress->IsShown()) { + if (!m_gaugeParseProgress->IsShown()) { m_gaugeParseProgress->SetValue(0); m_gaugeParseProgress->Show(); GetSizer()->Layout(); } - if(total) { + if (total) { int percent = (curIndex * 100) / total; m_gaugeParseProgress->SetValue(percent); } @@ -1127,7 +1156,7 @@ void PHPWorkspaceView::ReportParseThreadProgress(size_t curIndex, size_t total) void PHPWorkspaceView::ReportParseThreadDone() { m_gaugeParseProgress->SetValue(0); - if(m_gaugeParseProgress->IsShown()) { + if (m_gaugeParseProgress->IsShown()) { m_gaugeParseProgress->Hide(); GetSizer()->Layout(); } @@ -1138,7 +1167,7 @@ wxTreeItemId PHPWorkspaceView::DoGetSingleSelection() { return m_treeCtrlView->G void PHPWorkspaceView::OnItemActivated(wxTreeEvent& event) { ItemData* itemData = DoGetItemData(event.GetItem()); - if(itemData && itemData->IsFile()) { + if (itemData && itemData->IsFile()) { DoOpenFile(event.GetItem()); } else { @@ -1166,14 +1195,14 @@ void PHPWorkspaceView::OnSyncWorkspaceWithFileSystem(wxCommandEvent& e) void PHPWorkspaceView::DoBuildProjectNode(const wxTreeItemId& projectItem, PHPProject::Ptr_t project) { const wxArrayString& files = project->GetFiles(NULL); - for(size_t i = 0; i < files.GetCount(); ++i) { + for (size_t i = 0; i < files.GetCount(); ++i) { const wxString& filename = files.Item(i); wxFileName file(filename); wxTreeItemId folder = DoAddFolder(project->GetName(), file.GetPath()); - if(folder.IsOk()) { + if (folder.IsOk()) { // Don't add our folder marker files which are fake items we added // so the workspace will also include empty folders - if(file.GetFullName() != FOLDER_MARKER) { + if (file.GetFullName() != FOLDER_MARKER) { // Add the file ItemData* itemData = new ItemData(ItemData::Kind_File); itemData->SetFile(filename); @@ -1192,16 +1221,16 @@ void PHPWorkspaceView::DoGetSelectedItems(wxArrayTreeItemIds& items) { m_treeCtr wxTreeItemId PHPWorkspaceView::DoAddFolder(const wxString& project, const wxString& path) { // Check the cache - if(m_foldersItems.count(path)) { + if (m_foldersItems.count(path)) { return m_foldersItems.find(path)->second; } wxTreeItemId projectItem = DoGetProject(project); - if(!projectItem.IsOk()) + if (!projectItem.IsOk()) return wxTreeItemId(); PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(project); - if(!pProject) + if (!pProject) return wxTreeItemId(); int imgId = m_mgr->GetStdIcons()->GetMimeImageId(FileExtManager::TypeFolder); @@ -1210,16 +1239,16 @@ wxTreeItemId PHPWorkspaceView::DoAddFolder(const wxString& project, const wxStri wxTreeItemId parent = projectItem; wxFileName fnFolder(path, "dummy.txt"); fnFolder.MakeRelativeTo(pProject->GetFilename().GetPath()); - if(fnFolder.GetDirCount() == 0) { + if (fnFolder.GetDirCount() == 0) { // the folder is the same as the project, return the project item return projectItem; } const wxArrayString& parts = fnFolder.GetDirs(); wxFileName curdir = pProject->GetFilename(); - for(size_t i = 0; i < parts.GetCount(); ++i) { + for (size_t i = 0; i < parts.GetCount(); ++i) { curdir.AppendDir(parts.Item(i)); - if(m_foldersItems.count(curdir.GetPath()) == 0) { + if (m_foldersItems.count(curdir.GetPath()) == 0) { ItemData* itemData = new ItemData(ItemData::Kind_Folder); itemData->SetFolderPath(curdir.GetPath()); itemData->SetProjectName(project); @@ -1238,8 +1267,8 @@ wxTreeItemId PHPWorkspaceView::DoGetProject(const wxString& project) wxTreeItemId root = m_treeCtrlView->GetRootItem(); wxTreeItemIdValue cookie; wxTreeItemId item = m_treeCtrlView->GetFirstChild(root, cookie); - while(item.IsOk()) { - if(m_treeCtrlView->GetItemText(item) == project) { + while (item.IsOk()) { + if (m_treeCtrlView->GetItemText(item) == project) { return item; } item = m_treeCtrlView->GetNextChild(root, cookie); @@ -1254,27 +1283,29 @@ void PHPWorkspaceView::OnWorkspaceRenamed(PHPEvent& e) m_treeCtrlView->SetItemText(m_treeCtrlView->GetRootItem(), newName.GetName()); } -wxTreeItemId PHPWorkspaceView::DoCreateFile(const wxTreeItemId& parent, const wxString& fullpath, - const wxString& content) +wxTreeItemId +PHPWorkspaceView::DoCreateFile(const wxTreeItemId& parent, const wxString& fullpath, const wxString& content) { PHPProject::Ptr_t proj = DoGetProjectForItem(parent); - if(!proj) + if (!proj) return wxTreeItemId(); wxFileName file(fullpath); // Write the file content - if(FileUtils::WriteFileContent(file, content)) { + if (FileUtils::WriteFileContent(file, content)) { // Update the UI // Add the file ItemData* itemData = new ItemData(ItemData::Kind_File); itemData->SetFile(file.GetFullPath()); PHPProject::Ptr_t pProj = PHPWorkspace::Get()->GetProjectForFile(file); - if(pProj) { + if (pProj) { itemData->SetProjectName(pProj->GetName()); } - wxTreeItemId fileItem = - m_treeCtrlView->AppendItem(parent, file.GetFullName(), DoGetItemImgIdx(file.GetFullName()), - DoGetItemImgIdx(file.GetFullName()), itemData); + wxTreeItemId fileItem = m_treeCtrlView->AppendItem(parent, + file.GetFullName(), + DoGetItemImgIdx(file.GetFullName()), + DoGetItemImgIdx(file.GetFullName()), + itemData); // Cache the result m_filesItems.insert(std::make_pair(file.GetFullPath(), fileItem)); @@ -1286,12 +1317,12 @@ wxTreeItemId PHPWorkspaceView::DoCreateFile(const wxTreeItemId& parent, const wx PHPProject::Ptr_t PHPWorkspaceView::DoGetProjectForItem(const wxTreeItemId& item) { - if(m_treeCtrlView->GetRootItem() == item) + if (m_treeCtrlView->GetRootItem() == item) return PHPProject::Ptr_t(NULL); wxTreeItemId cur = item; - while(cur.IsOk()) { - if(m_treeCtrlView->GetItemParent(cur) == m_treeCtrlView->GetRootItem()) { + while (cur.IsOk()) { + if (m_treeCtrlView->GetItemParent(cur) == m_treeCtrlView->GetRootItem()) { // we found the project level ItemData* itemData = DoGetItemData(cur); return PHPWorkspace::Get()->GetProject(itemData->GetProjectName()); @@ -1310,13 +1341,13 @@ void PHPWorkspaceView::OnOpenInExplorer(wxCommandEvent& e) ItemData* itemData = DoGetItemData(item); CHECK_PTR_RET(itemData); - if(itemData->IsProject()) { + if (itemData->IsProject()) { file = itemData->GetFile(); - } else if(itemData->IsFolder()) { + } else if (itemData->IsFolder()) { file = wxFileName(itemData->GetFolderPath(), ""); - } else if(itemData->IsFile()) { + } else if (itemData->IsFile()) { file = itemData->GetFile(); - } else if(itemData->IsWorkspace()) { + } else if (itemData->IsWorkspace()) { file = PHPWorkspace::Get()->GetFilename(); } else { return; @@ -1333,13 +1364,13 @@ void PHPWorkspaceView::OnOpenShell(wxCommandEvent& e) ItemData* itemData = DoGetItemData(item); CHECK_PTR_RET(itemData); - if(itemData->IsProject()) { + if (itemData->IsProject()) { file = itemData->GetFile(); - } else if(itemData->IsFolder()) { + } else if (itemData->IsFolder()) { file = wxFileName(itemData->GetFolderPath(), ""); - } else if(itemData->IsFile()) { + } else if (itemData->IsFile()) { file = itemData->GetFile(); - } else if(itemData->IsWorkspace()) { + } else if (itemData->IsWorkspace()) { file = PHPWorkspace::Get()->GetFilename(); } else { return; @@ -1352,17 +1383,17 @@ void PHPWorkspaceView::DoGetSelectedFolders(wxArrayString& paths) wxArrayTreeItemIds items; DoGetSelectedItems(items); - for(size_t i = 0; i < items.GetCount(); ++i) { + for (size_t i = 0; i < items.GetCount(); ++i) { wxTreeItemId item = items.Item(i); ItemData* itemData = DoGetItemData(item); - if(itemData->IsFolder()) { + if (itemData->IsFolder()) { paths.Add(itemData->GetFolderPath()); - } else if(itemData->IsProject()) { + } else if (itemData->IsProject()) { wxString projectPath = wxFileName(itemData->GetFile()).GetPath(); paths.Add(projectPath); - } else if(itemData->IsWorkspace()) { + } else if (itemData->IsWorkspace()) { // If the workspace is included, use the project paths and nothing more paths.Clear(); for (const auto& [_, project] : PHPWorkspace::Get()->GetProjects()) { @@ -1386,10 +1417,10 @@ void PHPWorkspaceView::OnOpenWithDefaultApp(wxCommandEvent& e) { wxArrayTreeItemIds items; DoGetSelectedItems(items); - for(size_t i = 0; i < items.GetCount(); ++i) { + for (size_t i = 0; i < items.GetCount(); ++i) { wxTreeItemId item = items.Item(i); ItemData* itemData = DoGetItemData(item); - if(itemData->IsFile()) { + if (itemData->IsFile()) { ::wxLaunchDefaultApplication(itemData->GetFile()); } } @@ -1402,13 +1433,13 @@ void PHPWorkspaceView::DoGetSelectedFiles(wxArrayString& files) { wxArrayTreeItemIds items; DoGetSelectedItems(items); - if(items.IsEmpty()) + if (items.IsEmpty()) return; - for(size_t i = 0; i < items.GetCount(); ++i) { + for (size_t i = 0; i < items.GetCount(); ++i) { const wxTreeItemId& item = items.Item(i); ItemData* itemData = DoGetItemData(item); - if(itemData->IsFile()) { + if (itemData->IsFile()) { files.Add(itemData->GetFile()); } } @@ -1430,13 +1461,18 @@ void PHPWorkspaceView::OnAddExistingProject(wxCommandEvent& e) { // Prompt user for project path const wxString ALL("CodeLite PHP Projects (*.phprj)|*.phprj"); - wxFileDialog dlg(this, _("Open Project"), wxEmptyString, wxEmptyString, ALL, wxFD_OPEN | wxFD_FILE_MUST_EXIST, + wxFileDialog dlg(this, + _("Open Project"), + wxEmptyString, + wxEmptyString, + ALL, + wxFD_OPEN | wxFD_FILE_MUST_EXIST, wxDefaultPosition); - if(dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty()) { + if (dlg.ShowModal() == wxID_OK && !dlg.GetPath().IsEmpty()) { wxString projectToAdd = dlg.GetPath(); wxString errmsg; - if(!PHPWorkspace::Get()->AddProject(projectToAdd, errmsg)) { - if(!errmsg.IsEmpty()) { + if (!PHPWorkspace::Get()->AddProject(projectToAdd, errmsg)) { + if (!errmsg.IsEmpty()) { ::wxMessageBox(errmsg, "CodeLite", wxICON_WARNING | wxOK | wxCENTER); } return; @@ -1460,7 +1496,7 @@ void PHPWorkspaceView::OnRenameFolder(wxCommandEvent& e) { wxArrayTreeItemIds items; DoGetSelectedItems(items); - if(items.IsEmpty()) + if (items.IsEmpty()) return; wxTreeItemId item = items.Item(0); @@ -1472,16 +1508,16 @@ void PHPWorkspaceView::OnRenameFolder(wxCommandEvent& e) // Get the project that owns this file wxString project = DoGetSelectedProject(); - if(project.IsEmpty()) + if (project.IsEmpty()) return; PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(project); CHECK_PTR_RET(pProject); wxString new_name = ::clGetTextFromUser(_("Rename folder"), _("Folder name:"), data->GetFolderName()); - if(new_name.IsEmpty()) + if (new_name.IsEmpty()) return; - if(new_name == data->GetFolderName()) + if (new_name == data->GetFolderName()) return; wxFileName oldFolderPath(data->GetFolderPath(), ""); @@ -1491,7 +1527,7 @@ void PHPWorkspaceView::OnRenameFolder(wxCommandEvent& e) newFolderPath.AppendDir(new_name); // Rename the file on the file system - if(::wxRename(oldFolderPath.GetPath(), newFolderPath.GetPath()) == 0) { + if (::wxRename(oldFolderPath.GetPath(), newFolderPath.GetPath()) == 0) { pProject->SynchWithFileSystem(); pProject->Save(); ReloadWorkspace(true); @@ -1527,7 +1563,7 @@ void PHPWorkspaceView::OnFileSaveAs(clFileSystemEvent& event) { event.Skip(); // File "Save as" - if(PHPWorkspace::Get()->IsOpen()) { + if (PHPWorkspace::Get()->IsOpen()) { PHPWorkspace::Get()->SyncWithFileSystemAsync(this); } } @@ -1537,7 +1573,7 @@ void PHPWorkspaceView::OnStartDebuggerListener(wxCommandEvent& e) { XDebugManage void PHPWorkspaceView::OnSyncProjectWithFileSystem(wxCommandEvent& e) { wxString project = DoGetSelectedProject(); - if(project.IsEmpty()) + if (project.IsEmpty()) return; PHPProject::Ptr_t pProject = PHPWorkspace::Get()->GetProject(project); @@ -1550,7 +1586,7 @@ void PHPWorkspaceView::OnSyncProjectWithFileSystem(wxCommandEvent& e) void PHPWorkspaceView::OnProjectSyncCompleted(clCommandEvent& event) { wxString projectName = event.GetString(); - if(m_pendingSync.count(projectName) == 0) + if (m_pendingSync.count(projectName) == 0) return; m_pendingSync.erase(projectName); @@ -1570,13 +1606,13 @@ void PHPWorkspaceView::OnProjectSyncCompleted(clCommandEvent& event) // Clear these items from the cache for (const wxString& s : files) { - if(m_filesItems.count(s)) { + if (m_filesItems.count(s)) { m_filesItems.erase(s); } } for (const wxString& s : folders) { - if(m_foldersItems.count(s)) { + if (m_foldersItems.count(s)) { m_foldersItems.erase(s); } } @@ -1600,10 +1636,10 @@ void PHPWorkspaceView::DoGetFilesAndFolders(const wxString& projectName, wxArray void PHPWorkspaceView::DoGetFilesAndFolders(const wxTreeItemId& item, wxArrayString& folders, wxArrayString& files) { - if(m_treeCtrlView->ItemHasChildren(item)) { + if (m_treeCtrlView->ItemHasChildren(item)) { wxTreeItemIdValue cookie; wxTreeItemId child = m_treeCtrlView->GetFirstChild(item, cookie); - while(child.IsOk()) { + while (child.IsOk()) { DoGetFilesAndFolders(child, folders, files); child = m_treeCtrlView->GetNextChild(item, cookie); } @@ -1612,9 +1648,9 @@ void PHPWorkspaceView::DoGetFilesAndFolders(const wxTreeItemId& item, wxArrayStr ItemData* id = DoGetItemData(item); CHECK_PTR_RET(id); - if(id->IsFile()) { + if (id->IsFile()) { files.Add(id->GetFile()); - } else if(id->IsFolder()) { + } else if (id->IsFolder()) { folders.Add(id->GetFolderPath()); } } @@ -1624,12 +1660,12 @@ void PHPWorkspaceView::DoExpandToActiveEditor() IEditor* editor = m_mgr->GetActiveEditor(); CHECK_PTR_RET(editor); - if(m_filesItems.count(editor->GetFileName().GetFullPath())) { + if (m_filesItems.count(editor->GetFileName().GetFullPath())) { const wxTreeItemId& item = m_filesItems.find(editor->GetFileName().GetFullPath())->second; CHECK_ITEM_RET(item); wxArrayTreeItemIds items; - if(m_treeCtrlView->GetSelections(items)) { + if (m_treeCtrlView->GetSelections(items)) { m_treeCtrlView->UnselectAll(); } m_treeCtrlView->SelectItem(item); @@ -1642,7 +1678,7 @@ void PHPWorkspaceView::OnSyncFolderWithFileSystem(wxCommandEvent& e) wxArrayTreeItemIds items; DoGetSelectedItems(items); - if(items.GetCount() > 1) + if (items.GetCount() > 1) return; wxTreeItemId item = items.Item(0); @@ -1663,9 +1699,9 @@ void PHPWorkspaceView::OnDragBegin(wxTreeEvent& event) m_draggedFiles.clear(); wxArrayTreeItemIds items; DoGetSelectedItems(items); - for(size_t i = 0; i < items.GetCount(); ++i) { + for (size_t i = 0; i < items.GetCount(); ++i) { ItemData* data = DoGetItemData(items.Item(i)); - if(!data || !data->IsFile()) { + if (!data || !data->IsFile()) { return; } m_draggedFiles.Add(data->GetFile()); @@ -1674,38 +1710,42 @@ void PHPWorkspaceView::OnDragBegin(wxTreeEvent& event) void PHPWorkspaceView::OnDragEnd(wxTreeEvent& event) { - if(m_draggedFiles.IsEmpty()) { + if (m_draggedFiles.IsEmpty()) { return; } wxTreeItemId item = event.GetItem(); CHECK_ITEM_RET(item); ItemData* data = DoGetItemData(item); - if(data) { + if (data) { bool syncNeeded = false; wxString targetFolder; - if(data->IsFolder()) { + if (data->IsFolder()) { targetFolder = data->GetFolderPath(); - } else if(data->IsProject()) { + } else if (data->IsProject()) { targetFolder = wxFileName(data->GetFile()).GetPath(); } - if(!targetFolder.IsEmpty()) { + if (!targetFolder.IsEmpty()) { // Move the files from their current folder to the new folder for (const wxString& srcfile : m_draggedFiles) { wxFileName newFile = srcfile; newFile.SetPath(targetFolder); - if(newFile.FileExists()) { + if (newFile.FileExists()) { wxStandardID answer = ::PromptForYesNoDialogWithCheckbox( - _("A file with this name already exists in the target folder\nOverwrite it?"), "dndphpview", - _("Yes"), _("No"), _("Do this for all files"), - wxCANCEL_DEFAULT | wxCENTRE | wxYES_NO | wxCANCEL | wxICON_WARNING, false); - if(answer != wxID_YES) { + _("A file with this name already exists in the target folder\nOverwrite it?"), + "dndphpview", + _("Yes"), + _("No"), + _("Do this for all files"), + wxCANCEL_DEFAULT | wxCENTRE | wxYES_NO | wxCANCEL | wxICON_WARNING, + false); + if (answer != wxID_YES) { continue; } } - if(::wxCopyFile(srcfile, newFile.GetFullPath(), true)) { - if(clRemoveFile(srcfile)) { + if (::wxCopyFile(srcfile, newFile.GetFullPath(), true)) { + if (clRemoveFile(srcfile)) { syncNeeded = true; clFileSystemEvent rmEvent(wxEVT_FILE_DELETED); rmEvent.GetPaths().Add(srcfile); @@ -1715,7 +1755,7 @@ void PHPWorkspaceView::OnDragEnd(wxTreeEvent& event) } } - if(syncNeeded) { + if (syncNeeded) { PHPWorkspace::Get()->SyncWithFileSystemAsync(this); } } @@ -1727,36 +1767,36 @@ void PHPWorkspaceView::OnFolderChanged(clFileSystemEvent& event) { event.Skip(); auto workspace = PHPWorkspace::Get(); - if(!workspace->IsOpen()) { + if (!workspace->IsOpen()) { return; } // folder-create event sends the path in the event.GetPath() // while folder-deleted sends the paths (plural) in event.GetPaths() (we can delete multiple items) wxArrayString paths; - if(!event.GetPath().empty()) { + if (!event.GetPath().empty()) { paths.Add(event.GetPath()); } - for(const auto& p : event.GetPaths()) { - if(paths.Index(p) == wxNOT_FOUND) { + for (const auto& p : event.GetPaths()) { + if (paths.Index(p) == wxNOT_FOUND) { paths.Add(p); } } // Anything was modified? - if(paths.IsEmpty()) { + if (paths.IsEmpty()) { return; } // User created a folder (does not matter really how..) // if the newly created folder is part of our source tree, // trigger a sync - for(const auto& path : paths) { + for (const auto& path : paths) { // find the project associated with this path wxFileName dummy(path, ""); auto project = workspace->GetProjectForFile(dummy); - if(project) { + if (project) { // issue a sync project->SyncWithFileSystemAsync(this); m_pendingSync.insert(project->GetName()); @@ -1766,7 +1806,7 @@ void PHPWorkspaceView::OnFolderChanged(clFileSystemEvent& event) void PHPWorkspaceView::OnActiveProjectChanged(clProjectSettingsEvent& e) { - if(!PHPWorkspace::Get()->IsOpen()) { + if (!PHPWorkspace::Get()->IsOpen()) { e.Skip(); return; } @@ -1775,9 +1815,9 @@ void PHPWorkspaceView::OnActiveProjectChanged(clProjectSettingsEvent& e) wxString projectName = e.GetProjectName(); wxTreeItemIdValue cookie; wxTreeItemId child = m_treeCtrlView->GetFirstChild(m_treeCtrlView->GetRootItem(), cookie); - while(child.IsOk()) { + while (child.IsOk()) { ItemData* id = DoGetItemData(child); - if(id && id->IsProject()) { + if (id && id->IsProject()) { id->SetActive(id->GetProjectName() == projectName); m_treeCtrlView->SetItemBold(child, id->IsActive()); } diff --git a/codelitephp/php-plugin/quick_outline_dlg.cpp b/codelitephp/php-plugin/quick_outline_dlg.cpp index b5bb83bda8..31b3c1a28b 100644 --- a/codelitephp/php-plugin/quick_outline_dlg.cpp +++ b/codelitephp/php-plugin/quick_outline_dlg.cpp @@ -16,8 +16,8 @@ PHPQuickOutlineDlg::PHPQuickOutlineDlg(wxWindow* parent, IEditor* editor, IManag m_treeCtrlLayout->SetEditor(m_editor); m_treeCtrlLayout->Construct(); - m_treeCtrlLayout->Connect(wxEVT_COMMAND_TREE_ITEM_ACTIVATED, - wxTreeEventHandler(PHPQuickOutlineDlg::OnItemActivated), NULL, this); + m_treeCtrlLayout->Connect( + wxEVT_COMMAND_TREE_ITEM_ACTIVATED, wxTreeEventHandler(PHPQuickOutlineDlg::OnItemActivated), NULL, this); m_treeCtrlLayout->SetFocus(); m_treeCtrlLayout->Bind(wxEVT_KEY_DOWN, &PHPQuickOutlineDlg::OnKeyDown, this); SetName("PHPQuickOutlineDlg"); @@ -32,7 +32,7 @@ PHPQuickOutlineDlg::~PHPQuickOutlineDlg() void PHPQuickOutlineDlg::OnKeyDown(wxKeyEvent& event) { event.Skip(); - if(event.GetKeyCode() == WXK_ESCAPE) { + if (event.GetKeyCode() == WXK_ESCAPE) { event.Skip(false); Close(); } @@ -42,10 +42,11 @@ void PHPQuickOutlineDlg::OnItemActivated(wxTreeEvent& event) { DoItemSelected(ev void PHPQuickOutlineDlg::DoItemSelected(const wxTreeItemId& item) { - if(item.IsOk()) { + if (item.IsOk()) { QItemData* data = dynamic_cast(m_treeCtrlLayout->GetItemData(item)); - if(data && data->m_entry) { - DoSelectMatch(data->m_entry->GetFilename().GetFullPath(), data->m_entry->GetLine() - 1, + if (data && data->m_entry) { + DoSelectMatch(data->m_entry->GetFilename().GetFullPath(), + data->m_entry->GetLine() - 1, data->m_entry->GetShortName()); Close(); } @@ -54,9 +55,9 @@ void PHPQuickOutlineDlg::DoItemSelected(const wxTreeItemId& item) void PHPQuickOutlineDlg::DoSelectMatch(const wxString& filename, int line, const wxString& what) { - if(m_mgr->OpenFile(filename, wxT(""), line)) { + if (m_mgr->OpenFile(filename, wxT(""), line)) { IEditor* editor = m_mgr->GetActiveEditor(); - if(editor) { + if (editor) { m_mgr->FindAndSelect(what, what, editor->PosFromLine(line)); editor->SetActive(); } diff --git a/codelitephp/php-plugin/quick_outline_dlg.h b/codelitephp/php-plugin/quick_outline_dlg.h index 5245e7ab39..3f32541d08 100644 --- a/codelitephp/php-plugin/quick_outline_dlg.h +++ b/codelitephp/php-plugin/quick_outline_dlg.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// Copyright : (C) 2015 Eran Ifrah -// File name : quick_outline_dlg.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// Copyright : (C) 2015 Eran Ifrah +// File name : quick_outline_dlg.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #ifndef __quick_outline_dlg__ #define __quick_outline_dlg__ diff --git a/codelitephp/php-plugin/ssh_workspace_settings.cpp b/codelitephp/php-plugin/ssh_workspace_settings.cpp index 9191920415..6d2f7c89aa 100644 --- a/codelitephp/php-plugin/ssh_workspace_settings.cpp +++ b/codelitephp/php-plugin/ssh_workspace_settings.cpp @@ -1,4 +1,5 @@ #include "ssh_workspace_settings.h" + #include "php_workspace.h" SSHWorkspaceSettings::SSHWorkspaceSettings() @@ -25,22 +26,19 @@ JSONItem SSHWorkspaceSettings::ToJSON() const void SSHWorkspaceSettings::Load() { - wxFileName fn(PHPWorkspace::Get()->GetPrivateFolder(), "php-sftp.conf" ); + wxFileName fn(PHPWorkspace::Get()->GetPrivateFolder(), "php-sftp.conf"); clConfig conf(fn.GetFullPath()); conf.ReadItem(*this); } void SSHWorkspaceSettings::Save() { - wxFileName fn(PHPWorkspace::Get()->GetPrivateFolder(), "php-sftp.conf" ); + wxFileName fn(PHPWorkspace::Get()->GetPrivateFolder(), "php-sftp.conf"); clConfig conf(fn.GetFullPath()); conf.WriteItem(*this); } -bool SSHWorkspaceSettings::IsRemoteUploadSet() const -{ - return !m_remoteFolder.IsEmpty() && !m_account.IsEmpty(); -} +bool SSHWorkspaceSettings::IsRemoteUploadSet() const { return !m_remoteFolder.IsEmpty() && !m_account.IsEmpty(); } void SSHWorkspaceSettings::Reset() { diff --git a/codelitephp/php-plugin/ssh_workspace_settings.h b/codelitephp/php-plugin/ssh_workspace_settings.h index 81e1b2a2fe..572c240195 100644 --- a/codelitephp/php-plugin/ssh_workspace_settings.h +++ b/codelitephp/php-plugin/ssh_workspace_settings.h @@ -32,7 +32,7 @@ class SSHWorkspaceSettings : public clConfigItem { wxString m_account; wxString m_remoteFolder; - bool m_remoteUploadEnabled; + bool m_remoteUploadEnabled; public: SSHWorkspaceSettings(); @@ -45,27 +45,15 @@ class SSHWorkspaceSettings : public clConfigItem void Load(); void Save(); - void EnableRemoteUpload(bool b) { - m_remoteUploadEnabled = b; - } + void EnableRemoteUpload(bool b) { m_remoteUploadEnabled = b; } bool IsRemoteUploadSet() const; - bool IsRemoteUploadEnabled() const { - return m_remoteUploadEnabled; - } - void SetAccount(const wxString& account) { - this->m_account = account; - } - void SetRemoteFolder(const wxString& remoteFolder) { - this->m_remoteFolder = remoteFolder; - } - const wxString& GetAccount() const { - return m_account; - } - const wxString& GetRemoteFolder() const { - return m_remoteFolder; - } + bool IsRemoteUploadEnabled() const { return m_remoteUploadEnabled; } + void SetAccount(const wxString& account) { this->m_account = account; } + void SetRemoteFolder(const wxString& remoteFolder) { this->m_remoteFolder = remoteFolder; } + const wxString& GetAccount() const { return m_account; } + const wxString& GetRemoteFolder() const { return m_remoteFolder; } void Reset(); }; -#endif // SSHWORKSPACESETTINGS_H +#endif // SSHWORKSPACESETTINGS_H diff --git a/codelitephp/php-plugin/tree_item_data.h b/codelitephp/php-plugin/tree_item_data.h index 902866b352..befbacf18b 100644 --- a/codelitephp/php-plugin/tree_item_data.h +++ b/codelitephp/php-plugin/tree_item_data.h @@ -1,34 +1,34 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// Copyright : (C) 2015 Eran Ifrah -// File name : tree_item_data.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// Copyright : (C) 2015 Eran Ifrah +// File name : tree_item_data.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + #ifndef PHPVIEWMODEL_H #define PHPVIEWMODEL_H #include -#include #include +#include class ItemData : public wxTreeItemData { @@ -60,7 +60,7 @@ class ItemData : public wxTreeItemData void SetFolderPath(const wxString& folderPath) { this->folderPath = folderPath; - if(this->folderPath.EndsWith("/")) { + if (this->folderPath.EndsWith("/")) { this->folderPath.RemoveLast(); } } @@ -81,12 +81,12 @@ class ItemData : public wxTreeItemData wxString GetDisplayName() const { - switch(kind) { + switch (kind) { case Kind_File: { wxFileName fn(GetFile()); return fn.GetFullName(); } - case Kind_Folder: + case Kind_Folder: return GetFolderName(); case Kind_Project: return GetProjectName(); diff --git a/codelitephp/php-plugin/xdebugbreakpointsmgr.cpp b/codelitephp/php-plugin/xdebugbreakpointsmgr.cpp index 153fb09507..5f91a019e1 100644 --- a/codelitephp/php-plugin/xdebugbreakpointsmgr.cpp +++ b/codelitephp/php-plugin/xdebugbreakpointsmgr.cpp @@ -20,8 +20,8 @@ XDebugBreakpointsMgr::XDebugBreakpointsMgr() EventNotifier::Get()->Bind(wxEVT_XDEBUG_SESSION_STARTING, &XDebugBreakpointsMgr::OnXDebugSessionStarting, this); EventNotifier::Get()->Bind(wxEVT_PHP_WORKSPACE_LOADED, &XDebugBreakpointsMgr::OnWorkspaceOpened, this); EventNotifier::Get()->Bind(wxEVT_PHP_WORKSPACE_CLOSED, &XDebugBreakpointsMgr::OnWorkspaceClosed, this); - EventNotifier::Get()->Connect(wxEVT_ACTIVE_EDITOR_CHANGED, - wxCommandEventHandler(XDebugBreakpointsMgr::OnEditorChanged), NULL, this); + EventNotifier::Get()->Connect( + wxEVT_ACTIVE_EDITOR_CHANGED, wxCommandEventHandler(XDebugBreakpointsMgr::OnEditorChanged), NULL, this); } XDebugBreakpointsMgr::~XDebugBreakpointsMgr() @@ -30,14 +30,14 @@ XDebugBreakpointsMgr::~XDebugBreakpointsMgr() EventNotifier::Get()->Unbind(wxEVT_XDEBUG_SESSION_STARTING, &XDebugBreakpointsMgr::OnXDebugSessionStarting, this); EventNotifier::Get()->Unbind(wxEVT_PHP_WORKSPACE_LOADED, &XDebugBreakpointsMgr::OnWorkspaceOpened, this); EventNotifier::Get()->Unbind(wxEVT_PHP_WORKSPACE_CLOSED, &XDebugBreakpointsMgr::OnWorkspaceClosed, this); - EventNotifier::Get()->Disconnect(wxEVT_ACTIVE_EDITOR_CHANGED, - wxCommandEventHandler(XDebugBreakpointsMgr::OnEditorChanged), NULL, this); + EventNotifier::Get()->Disconnect( + wxEVT_ACTIVE_EDITOR_CHANGED, wxCommandEventHandler(XDebugBreakpointsMgr::OnEditorChanged), NULL, this); } bool XDebugBreakpointsMgr::HasBreakpoint(const wxString& filename, int line) const { - if(std::find_if(m_breakpoints.begin(), m_breakpoints.end(), XDebugBreakpoint::Equal(filename, line)) == - m_breakpoints.end()) { + if (std::find_if(m_breakpoints.begin(), m_breakpoints.end(), XDebugBreakpoint::Equal(filename, line)) == + m_breakpoints.end()) { return false; } return true; @@ -45,8 +45,8 @@ bool XDebugBreakpointsMgr::HasBreakpoint(const wxString& filename, int line) con void XDebugBreakpointsMgr::AddBreakpoint(const wxString& filename, int line) { - if(std::find_if(m_breakpoints.begin(), m_breakpoints.end(), XDebugBreakpoint::Equal(filename, line)) == - m_breakpoints.end()) { + if (std::find_if(m_breakpoints.begin(), m_breakpoints.end(), XDebugBreakpoint::Equal(filename, line)) == + m_breakpoints.end()) { // new breakpoint m_breakpoints.push_back(XDebugBreakpoint(filename, line)); Notify(); @@ -58,7 +58,7 @@ void XDebugBreakpointsMgr::DeleteBreakpoint(const wxString& filename, int line) { XDebugBreakpoint::List_t::iterator iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(), XDebugBreakpoint::Equal(filename, line)); - if(iter != m_breakpoints.end()) { + if (iter != m_breakpoints.end()) { m_breakpoints.erase(iter); Notify(); Save(); @@ -70,7 +70,7 @@ void XDebugBreakpointsMgr::OnXDebugSessionEnded(XDebugEvent& e) e.Skip(); // clear any xdebug ID associated with the breakpoints - for(auto& bp : m_breakpoints) { + for (auto& bp : m_breakpoints) { bp.SetBreakpointId(wxNOT_FOUND); } } @@ -79,7 +79,7 @@ bool XDebugBreakpointsMgr::GetBreakpoint(const wxString& filename, int line, XDe { XDebugBreakpoint::List_t::const_iterator iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(), XDebugBreakpoint::Equal(filename, line)); - if(iter != m_breakpoints.end()) { + if (iter != m_breakpoints.end()) { bp = *iter; return true; } @@ -90,7 +90,7 @@ bool XDebugBreakpointsMgr::GetBreakpoint(const wxString& filename, int line, XDe { XDebugBreakpoint::List_t::iterator iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(), XDebugBreakpoint::Equal(filename, line)); - if(iter != m_breakpoints.end()) { + if (iter != m_breakpoints.end()) { bp = *iter; return true; } @@ -101,7 +101,7 @@ void XDebugBreakpointsMgr::OnXDebugSessionStarting(XDebugEvent& e) { e.Skip(); // clear any xdebug ID associated with the breakpoints - for(auto& bp : m_breakpoints) { + for (auto& bp : m_breakpoints) { bp.SetBreakpointId(wxNOT_FOUND); } } @@ -111,7 +111,7 @@ void XDebugBreakpointsMgr::OnWorkspaceClosed(PHPEvent& e) e.Skip(); // Save the breakpoints to the file system - if(!m_workspacePath.IsEmpty()) { + if (!m_workspacePath.IsEmpty()) { PHPUserWorkspace userWorkspace(m_workspacePath); userWorkspace.Load().SetBreakpoints(m_breakpoints).Save(); m_workspacePath.Clear(); @@ -133,12 +133,12 @@ void XDebugBreakpointsMgr::OnEditorChanged(wxCommandEvent& e) // Apply breakpoints for this editor IEditor* editor = ::clGetManager()->GetActiveEditor(); - if(editor) { + if (editor) { XDebugBreakpoint::List_t bps; - if(GetBreakpointsForFile(editor->GetFileName().GetFullPath(), bps)) { + if (GetBreakpointsForFile(editor->GetFileName().GetFullPath(), bps)) { for (const auto& bp : bps) { int markerMask = editor->GetCtrl()->MarkerGet(bp.GetLine() - 1); - if(!(markerMask & mmt_breakpoint)) { + if (!(markerMask & mmt_breakpoint)) { // No marker on this line yet // add one editor->GetCtrl()->MarkerAdd(bp.GetLine() - 1, smt_breakpoint); @@ -174,7 +174,7 @@ void XDebugBreakpointsMgr::DeleteAllBreakpoints() void XDebugBreakpointsMgr::Save() { - if(!m_workspacePath.IsEmpty()) { + if (!m_workspacePath.IsEmpty()) { // Save the breakpoints to the file system PHPUserWorkspace userWorkspace(m_workspacePath); userWorkspace.Load().SetBreakpoints(m_breakpoints).Save(); diff --git a/codelitephp/php-plugin/xdebugevent.h b/codelitephp/php-plugin/xdebugevent.h index 14e358f09a..b9009a4476 100644 --- a/codelitephp/php-plugin/xdebugevent.h +++ b/codelitephp/php-plugin/xdebugevent.h @@ -26,8 +26,8 @@ #ifndef XDEBUGEVENT_H #define XDEBUGEVENT_H -#include "php_event.h" #include "XVariable.h" +#include "php_event.h" class XDebugEvent : public PHPEvent { diff --git a/cppchecker/cppchecker.cpp b/cppchecker/cppchecker.cpp index cbabcf4af2..2a60dae316 100644 --- a/cppchecker/cppchecker.cpp +++ b/cppchecker/cppchecker.cpp @@ -63,10 +63,7 @@ #include // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new CppCheckPlugin(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new CppCheckPlugin(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -101,7 +98,7 @@ CppCheckPlugin::CppCheckPlugin(IManager* manager) EventNotifier::Get()->Bind(wxEVT_STOP_BUILD, &CppCheckPlugin::OnStopRun, this); EventNotifier::Get()->Bind(wxEVT_WORKSPACE_CLOSED, &CppCheckPlugin::OnWorkspaceClosed, this); - clKeyboardManager::Get()->AddAccelerator(_("CppCheck"), { { "run_cppcheck", _("Run cppcheck...") } }); + clKeyboardManager::Get()->AddAccelerator(_("CppCheck"), {{"run_cppcheck", _("Run cppcheck...")}}); } void CppCheckPlugin::CreateToolBar(clToolBarGeneric* toolbar) { wxUnusedVar(toolbar); } @@ -172,7 +169,8 @@ void CppCheckPlugin::DoRun() size_t flags = IProcessCreateDefault | IProcessWrapInShell; m_cppcheckProcess = ::CreateAsyncProcess(this, command, flags); if (!m_cppcheckProcess) { - wxMessageBox(_("Failed to launch cppcheck process.\nMake sure its installed and in your PATH"), _("Warning"), + wxMessageBox(_("Failed to launch cppcheck process.\nMake sure its installed and in your PATH"), + _("Warning"), wxOK | wxCENTER | wxICON_WARNING); return; } @@ -184,7 +182,8 @@ wxString CppCheckPlugin::DoGetCommand() // Linux / Mac way: spawn the process and execute the command const auto cppcheck = ThePlatform->Which("cppcheck"); if (!cppcheck) { - ::wxMessageBox(_("Could not locate \"cppcheck\". Please install it and try again"), "CodeLite", + ::wxMessageBox(_("Could not locate \"cppcheck\". Please install it and try again"), + "CodeLite", wxICON_WARNING | wxOK | wxOK_DEFAULT | wxCENTRE); return wxEmptyString; } @@ -229,8 +228,8 @@ wxString CppCheckPlugin::DoGetCommand() } cmd.Trim(); if (cmd.empty()) { - ::wxMessageBox(_("Cannot run cppcheck. Empty command"), "CodeLite", - wxICON_WARNING | wxOK | wxOK_DEFAULT | wxCENTRE); + ::wxMessageBox( + _("Cannot run cppcheck. Empty command"), "CodeLite", wxICON_WARNING | wxOK | wxOK_DEFAULT | wxCENTRE); return wxEmptyString; } return cmd; @@ -245,7 +244,7 @@ void CppCheckPlugin::OnCppCheckReadData(clProcessEvent& e) void CppCheckPlugin::OnSettings(wxCommandEvent& event) { wxUnusedVar(event); - CppCheckSettingsDialog dlg{ EventNotifier::Get()->TopFrame() }; + CppCheckSettingsDialog dlg{EventNotifier::Get()->TopFrame()}; dlg.ShowModal(); } diff --git a/cscope/CScopeSettingsDlg.cpp b/cscope/CScopeSettingsDlg.cpp index 23025231a4..335db3ddd8 100644 --- a/cscope/CScopeSettingsDlg.cpp +++ b/cscope/CScopeSettingsDlg.cpp @@ -1,7 +1,8 @@ #include "CScopeSettingsDlg.h" -#include "windowattrmanager.h" + #include "csscopeconfdata.h" #include "editor_config.h" +#include "windowattrmanager.h" CScopeSettingsDlg::CScopeSettingsDlg(wxWindow* parent) : CScopeSettingsDlgBase(parent) diff --git a/cscope/CScopeSettingsDlg.h b/cscope/CScopeSettingsDlg.h index 061646809e..2e2b6daf0a 100644 --- a/cscope/CScopeSettingsDlg.h +++ b/cscope/CScopeSettingsDlg.h @@ -32,7 +32,7 @@ class CScopeSettingsDlg : public CScopeSettingsDlgBase public: CScopeSettingsDlg(wxWindow* parent); virtual ~CScopeSettingsDlg() = default; - + wxString GetPath() const { return m_filePickerCScopeExe->GetPath(); } }; #endif // CSCOPESETTINGSDLG_H diff --git a/cscope/cscope.cpp b/cscope/cscope.cpp index bf1073f20f..b8bdd6257c 100644 --- a/cscope/cscope.cpp +++ b/cscope/cscope.cpp @@ -54,10 +54,7 @@ static const wxString CSCOPE_NAME = _("CScope"); // Define the plugin entry point -CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) -{ - return new Cscope(manager); -} +CL_PLUGIN_API IPlugin* CreatePlugin(IManager* manager) { return new Cscope(manager); } CL_PLUGIN_API PluginInfo* GetPluginInfo() { @@ -93,12 +90,12 @@ Cscope::Cscope(IManager* manager) // Register keyboard shortcuts for CScope clKeyboardManager::Get()->AddAccelerator( _("CScope"), - { { "cscope_find_user_symbol", _("Find"), "Ctrl-)" }, - { "cscope_find_symbol", _("Find selected text"), "Ctrl-0" }, - { "cscope_find_global_definition", _("Find this global definition"), "Ctrl-1" }, - { "cscope_functions_calling_this_function", _("Find functions called by this function"), "Ctrl-2" }, - { "cscope_functions_called_by_this_function", _("Find functions calling this function"), "Ctrl-3" }, - { "cscope_create_db", _("Create CScope database"), "Ctrl-4" } }); + {{"cscope_find_user_symbol", _("Find"), "Ctrl-)"}, + {"cscope_find_symbol", _("Find selected text"), "Ctrl-0"}, + {"cscope_find_global_definition", _("Find this global definition"), "Ctrl-1"}, + {"cscope_functions_calling_this_function", _("Find functions called by this function"), "Ctrl-2"}, + {"cscope_functions_called_by_this_function", _("Find functions calling this function"), "Ctrl-3"}, + {"cscope_create_db", _("Create CScope database"), "Ctrl-4"}}); EventNotifier::Get()->Bind(wxEVT_CONTEXT_MENU_EDITOR, &Cscope::OnEditorContentMenu, this); } @@ -113,46 +110,95 @@ void Cscope::CreateToolBar(clToolBarGeneric* toolbar) // use the large icons set toolbar->AddSpacer(); - toolbar->AddTool(XRCID("cscope_find_symbol"), _("Find this C symbol"), images->Add("find", size), - _("Find this C symbol")); - toolbar->AddTool(XRCID("cscope_functions_calling_this_function"), _("Find functions calling this function"), - images->Add("step_in", size), _("Find functions calling this function")); - toolbar->AddTool(XRCID("cscope_functions_called_by_this_function"), _("Find functions called by this function"), - images->Add("step_out", size), _("Find functions called by this function")); + toolbar->AddTool( + XRCID("cscope_find_symbol"), _("Find this C symbol"), images->Add("find", size), _("Find this C symbol")); + toolbar->AddTool(XRCID("cscope_functions_calling_this_function"), + _("Find functions calling this function"), + images->Add("step_in", size), + _("Find functions calling this function")); + toolbar->AddTool(XRCID("cscope_functions_called_by_this_function"), + _("Find functions called by this function"), + images->Add("step_out", size), + _("Find functions called by this function")); // Command events - m_topWindow->Connect(XRCID("cscope_find_global_definition"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindGlobalDefinition), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_create_db"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnCreateDB), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_settings"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnDoSettings), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_functions_calling_this_function"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindFunctionsCallingThisFunction), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_find_symbol"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindSymbol), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_find_user_symbol"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindUserInsertedSymbol), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_functions_called_by_this_function"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindFunctionsCalledByThisFunction), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_files_including_this_filename"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindFilesIncludingThisFname), NULL, (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_find_global_definition"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindGlobalDefinition), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_create_db"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnCreateDB), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_settings"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnDoSettings), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_functions_calling_this_function"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindFunctionsCallingThisFunction), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_find_symbol"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindSymbol), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_find_user_symbol"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindUserInsertedSymbol), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_functions_called_by_this_function"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindFunctionsCalledByThisFunction), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_files_including_this_filename"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindFilesIncludingThisFname), + NULL, + (wxEvtHandler*)this); // UI events - m_topWindow->Connect(XRCID("cscope_functions_called_by_this_function"), wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(Cscope::OnCscopeUI), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_files_including_this_filename"), wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(Cscope::OnCscopeUI), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_create_db"), wxEVT_UPDATE_UI, wxUpdateUIEventHandler(Cscope::OnWorkspaceOpenUI), - NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_functions_calling_this_function"), wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(Cscope::OnCscopeUI), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_find_global_definition"), wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(Cscope::OnCscopeUI), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_find_symbol"), wxEVT_UPDATE_UI, wxUpdateUIEventHandler(Cscope::OnCscopeUI), NULL, + m_topWindow->Connect(XRCID("cscope_functions_called_by_this_function"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnCscopeUI), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_files_including_this_filename"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnCscopeUI), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_create_db"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnWorkspaceOpenUI), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_functions_calling_this_function"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnCscopeUI), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_find_global_definition"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnCscopeUI), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_find_symbol"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnCscopeUI), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_find_user_symbol"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnWorkspaceOpenUI), + NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_find_user_symbol"), wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(Cscope::OnWorkspaceOpenUI), NULL, (wxEvtHandler*)this); } void Cscope::CreatePluginMenu(wxMenu* pluginsMenu) @@ -164,33 +210,45 @@ void Cscope::CreatePluginMenu(wxMenu* pluginsMenu) menu->AppendSeparator(); - item = new wxMenuItem(menu, XRCID("cscope_find_symbol"), _("Find selected text"), _("Find this C symbol"), - wxITEM_NORMAL); + item = new wxMenuItem( + menu, XRCID("cscope_find_symbol"), _("Find selected text"), _("Find this C symbol"), wxITEM_NORMAL); menu->Append(item); - item = new wxMenuItem(menu, XRCID("cscope_find_global_definition"), _("Find this global definition"), - _("Find this C global definition"), wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("cscope_find_global_definition"), + _("Find this global definition"), + _("Find this C global definition"), + wxITEM_NORMAL); menu->Append(item); - item = new wxMenuItem(menu, XRCID("cscope_functions_called_by_this_function"), - _("Find functions called by this function"), _("Find functions called by this function"), + item = new wxMenuItem(menu, + XRCID("cscope_functions_called_by_this_function"), + _("Find functions called by this function"), + _("Find functions called by this function"), wxITEM_NORMAL); menu->Append(item); - item = - new wxMenuItem(menu, XRCID("cscope_functions_calling_this_function"), _("Find functions calling this function"), - _("Find functions calling this function"), wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("cscope_functions_calling_this_function"), + _("Find functions calling this function"), + _("Find functions calling this function"), + wxITEM_NORMAL); menu->Append(item); - item = - new wxMenuItem(menu, XRCID("cscope_files_including_this_filename"), _("Find files #&including this filename"), - _("Find files #including this filename"), wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("cscope_files_including_this_filename"), + _("Find files #&including this filename"), + _("Find files #including this filename"), + wxITEM_NORMAL); menu->Append(item); menu->AppendSeparator(); - item = new wxMenuItem(menu, XRCID("cscope_create_db"), _("Create CScope database"), - _("Create/Recreate the cscope database"), wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("cscope_create_db"), + _("Create CScope database"), + _("Create/Recreate the cscope database"), + wxITEM_NORMAL); menu->Append(item); menu->AppendSeparator(); @@ -204,36 +262,70 @@ void Cscope::CreatePluginMenu(wxMenu* pluginsMenu) void Cscope::UnPlug() { m_tabHelper.reset(); - m_topWindow->Disconnect(XRCID("cscope_functions_called_by_this_function"), wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(Cscope::OnCscopeUI), NULL, (wxEvtHandler*)this); - m_topWindow->Disconnect(XRCID("cscope_files_including_this_filename"), wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(Cscope::OnCscopeUI), NULL, (wxEvtHandler*)this); - m_topWindow->Disconnect(XRCID("cscope_create_db"), wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(Cscope::OnWorkspaceOpenUI), NULL, (wxEvtHandler*)this); - m_topWindow->Disconnect(XRCID("cscope_functions_calling_this_function"), wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(Cscope::OnCscopeUI), NULL, (wxEvtHandler*)this); - m_topWindow->Disconnect(XRCID("cscope_find_global_definition"), wxEVT_UPDATE_UI, - wxUpdateUIEventHandler(Cscope::OnCscopeUI), NULL, (wxEvtHandler*)this); - m_topWindow->Disconnect(XRCID("cscope_find_symbol"), wxEVT_UPDATE_UI, wxUpdateUIEventHandler(Cscope::OnCscopeUI), - NULL, (wxEvtHandler*)this); - - m_topWindow->Disconnect(XRCID("cscope_find_symbol"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindSymbol), NULL, (wxEvtHandler*)this); - m_topWindow->Disconnect(XRCID("cscope_find_global_definition"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindGlobalDefinition), NULL, (wxEvtHandler*)this); - m_topWindow->Disconnect(XRCID("cscope_functions_called_by_this_function"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindFunctionsCalledByThisFunction), NULL, + m_topWindow->Disconnect(XRCID("cscope_functions_called_by_this_function"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnCscopeUI), + NULL, (wxEvtHandler*)this); - m_topWindow->Disconnect(XRCID("cscope_files_including_this_filename"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindFilesIncludingThisFname), NULL, (wxEvtHandler*)this); - m_topWindow->Disconnect(XRCID("cscope_functions_calling_this_function"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindFunctionsCallingThisFunction), NULL, + m_topWindow->Disconnect(XRCID("cscope_files_including_this_filename"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnCscopeUI), + NULL, + (wxEvtHandler*)this); + m_topWindow->Disconnect(XRCID("cscope_create_db"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnWorkspaceOpenUI), + NULL, + (wxEvtHandler*)this); + m_topWindow->Disconnect(XRCID("cscope_functions_calling_this_function"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnCscopeUI), + NULL, + (wxEvtHandler*)this); + m_topWindow->Disconnect(XRCID("cscope_find_global_definition"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnCscopeUI), + NULL, + (wxEvtHandler*)this); + m_topWindow->Disconnect(XRCID("cscope_find_symbol"), + wxEVT_UPDATE_UI, + wxUpdateUIEventHandler(Cscope::OnCscopeUI), + NULL, + (wxEvtHandler*)this); + + m_topWindow->Disconnect(XRCID("cscope_find_symbol"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindSymbol), + NULL, + (wxEvtHandler*)this); + m_topWindow->Disconnect(XRCID("cscope_find_global_definition"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindGlobalDefinition), + NULL, + (wxEvtHandler*)this); + m_topWindow->Disconnect(XRCID("cscope_functions_called_by_this_function"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindFunctionsCalledByThisFunction), + NULL, + (wxEvtHandler*)this); + m_topWindow->Disconnect(XRCID("cscope_files_including_this_filename"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindFilesIncludingThisFname), + NULL, + (wxEvtHandler*)this); + m_topWindow->Disconnect(XRCID("cscope_functions_calling_this_function"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindFunctionsCallingThisFunction), + NULL, + (wxEvtHandler*)this); + m_topWindow->Disconnect(XRCID("cscope_create_db"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnCreateDB), + NULL, (wxEvtHandler*)this); - m_topWindow->Disconnect(XRCID("cscope_create_db"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnCreateDB), NULL, (wxEvtHandler*)this); // before this plugin is un-plugged we must remove the tab we added - if(!m_mgr->BookDeletePage(PaneId::BOTTOM_BAR, m_cscopeWin)) { + if (!m_mgr->BookDeletePage(PaneId::BOTTOM_BAR, m_cscopeWin)) { m_cscopeWin->Destroy(); } m_cscopeWin = nullptr; @@ -254,39 +346,66 @@ wxMenu* Cscope::CreateEditorPopMenu() item = new wxMenuItem(menu, XRCID("cscope_find_symbol"), _("&Find this C symbol"), wxEmptyString, wxITEM_NORMAL); menu->Append(item); - item = new wxMenuItem(menu, XRCID("cscope_find_global_definition"), _("Find this &global definition"), - wxEmptyString, wxITEM_NORMAL); + item = new wxMenuItem( + menu, XRCID("cscope_find_global_definition"), _("Find this &global definition"), wxEmptyString, wxITEM_NORMAL); menu->Append(item); - item = new wxMenuItem(menu, XRCID("cscope_functions_called_by_this_function"), - _("Find functions &called by this function"), wxEmptyString, wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("cscope_functions_called_by_this_function"), + _("Find functions &called by this function"), + wxEmptyString, + wxITEM_NORMAL); menu->Append(item); - item = new wxMenuItem(menu, XRCID("cscope_functions_calling_this_function"), - _("Fi&nd functions calling this function"), wxEmptyString, wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("cscope_functions_calling_this_function"), + _("Fi&nd functions calling this function"), + wxEmptyString, + wxITEM_NORMAL); menu->Append(item); - item = new wxMenuItem(menu, XRCID("cscope_files_including_this_filename"), - _("Find files #&including this filename"), wxEmptyString, wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("cscope_files_including_this_filename"), + _("Find files #&including this filename"), + wxEmptyString, + wxITEM_NORMAL); menu->Append(item); menu->AppendSeparator(); - item = new wxMenuItem(menu, XRCID("cscope_create_db"), _("Create CScope &database"), - _("Create/Recreate the cscope database"), wxITEM_NORMAL); + item = new wxMenuItem(menu, + XRCID("cscope_create_db"), + _("Create CScope &database"), + _("Create/Recreate the cscope database"), + wxITEM_NORMAL); menu->Append(item); // connect the events - m_topWindow->Connect(XRCID("cscope_find_symbol"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindSymbol), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_find_global_definition"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindGlobalDefinition), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_functions_called_by_this_function"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindFunctionsCalledByThisFunction), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_functions_calling_this_function"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnFindFunctionsCallingThisFunction), NULL, (wxEvtHandler*)this); - m_topWindow->Connect(XRCID("cscope_create_db"), wxEVT_COMMAND_MENU_SELECTED, - wxCommandEventHandler(Cscope::OnCreateDB), NULL, (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_find_symbol"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindSymbol), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_find_global_definition"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindGlobalDefinition), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_functions_called_by_this_function"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindFunctionsCalledByThisFunction), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_functions_calling_this_function"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnFindFunctionsCallingThisFunction), + NULL, + (wxEvtHandler*)this); + m_topWindow->Connect(XRCID("cscope_create_db"), + wxEVT_COMMAND_MENU_SELECTED, + wxCommandEventHandler(Cscope::OnCreateDB), + NULL, + (wxEvtHandler*)this); return menu; } @@ -300,15 +419,15 @@ wxString Cscope::DoCreateListFile(bool force) wxString privateFolder = GetWorkingDirectory(); wxFileName list_file(privateFolder, "cscope_file.list"); bool createFileList = force || settings.GetRebuildOption() || !list_file.FileExists(); - if(createFileList) { + if (createFileList) { std::vector files; - if(clFileSystemWorkspace::Get().IsOpen()) { + if (clFileSystemWorkspace::Get().IsOpen()) { const std::vector& all_files = clFileSystemWorkspace::Get().GetFiles(); - if(!all_files.empty()) { + if (!all_files.empty()) { files.reserve(all_files.size()); - for(wxFileName fn : all_files) { + for (wxFileName fn : all_files) { wxString ext = fn.GetExt(); - if(ext == "exe" || ext == "" || ext == "xpm" || ext == "png") { + if (ext == "exe" || ext == "" || ext == "xpm" || ext == "png") { continue; } fn.MakeRelativeTo(privateFolder); @@ -321,12 +440,12 @@ wxString Cscope::DoCreateListFile(bool force) wxString err_msg; m_cscopeWin->SetMessage(_("Creating file list..."), 5); - if(settings.GetScanScope() == SCOPE_ENTIRE_WORKSPACE) { + if (settings.GetScanScope() == SCOPE_ENTIRE_WORKSPACE) { m_mgr->GetWorkspace()->GetWorkspaceFiles(tmpfiles); } else { // SCOPE_ACTIVE_PROJECT ProjectPtr proj = m_mgr->GetWorkspace()->GetActiveProject(); - if(proj) { + if (proj) { proj->GetFilesAsStringArray(tmpfiles); } } @@ -334,12 +453,12 @@ wxString Cscope::DoCreateListFile(bool force) // Also remove any .exe files (one of which managed to crash cscope), // and files without an ext, which may be binaries and are unlikely to be .c or .h files in disguise; and // .xpm and .png too - if(!tmpfiles.empty()) { + if (!tmpfiles.empty()) { files.reserve(tmpfiles.size()); - for(const wxString& filepath : tmpfiles) { + for (const wxString& filepath : tmpfiles) { wxFileName fn(filepath); wxString ext = fn.GetExt(); - if(ext == "exe" || ext == "" || ext == "xpm" || ext == "png") { + if (ext == "exe" || ext == "" || ext == "xpm" || ext == "png") { continue; } fn.MakeRelativeTo(privateFolder); @@ -363,7 +482,7 @@ void Cscope::DoCscopeCommand(const wxString& command, const wxString& findWhat, { // We haven't yet found a valid cscope exe, so look for one wxString where; - if(!ExeLocator::Locate(GetCscopeExeName(), where)) { + if (!ExeLocator::Locate(GetCscopeExeName(), where)) { wxString msg; msg << _("I can't find 'cscope' anywhere. Please check if it's installed.") << '\n' << _("Or tell me where it can be found, from the menu: 'Plugins | CScope | Settings'"); @@ -375,9 +494,9 @@ void Cscope::DoCscopeCommand(const wxString& command, const wxString& findWhat, // make sure that the Output pane is visible wxAuiManager* aui = m_mgr->GetDockingManager(); - if(aui) { + if (aui) { wxAuiPaneInfo& info = aui->GetPane("Output View"); - if(info.IsOk() && !info.IsShown()) { + if (info.IsOk() && !info.IsShown()) { info.Show(); aui->Update(); } @@ -399,7 +518,7 @@ void Cscope::DoCscopeCommand(const wxString& command, const wxString& findWhat, void Cscope::OnFindSymbol(wxCommandEvent& e) { wxString word = GetSearchPattern(); - if(!word.IsEmpty()) { + if (!word.IsEmpty()) { DoFindSymbol(word); } } @@ -407,7 +526,7 @@ void Cscope::OnFindSymbol(wxCommandEvent& e) void Cscope::OnFindGlobalDefinition(wxCommandEvent& e) { wxString word = GetSearchPattern(); - if(word.IsEmpty()) { + if (word.IsEmpty()) { return; } m_cscopeWin->Clear(); @@ -424,7 +543,7 @@ void Cscope::OnFindGlobalDefinition(wxCommandEvent& e) void Cscope::OnFindFunctionsCalledByThisFunction(wxCommandEvent& e) { wxString word = GetSearchPattern(); - if(word.IsEmpty()) { + if (word.IsEmpty()) { return; } @@ -436,7 +555,7 @@ void Cscope::OnFindFunctionsCalledByThisFunction(wxCommandEvent& e) CScopeConfData settings; m_mgr->GetConfigTool()->ReadObject("CscopeSettings", &settings); - if(!settings.GetRebuildOption()) { + if (!settings.GetRebuildOption()) { rebuildOption = " -d"; } @@ -451,7 +570,7 @@ void Cscope::OnFindFunctionsCalledByThisFunction(wxCommandEvent& e) void Cscope::OnFindFunctionsCallingThisFunction(wxCommandEvent& e) { wxString word = GetSearchPattern(); - if(word.IsEmpty()) { + if (word.IsEmpty()) { return; } @@ -463,7 +582,7 @@ void Cscope::OnFindFunctionsCallingThisFunction(wxCommandEvent& e) CScopeConfData settings; m_mgr->GetConfigTool()->ReadObject("CscopeSettings", &settings); - if(!settings.GetRebuildOption()) { + if (!settings.GetRebuildOption()) { rebuildOption = " -d"; } @@ -478,13 +597,13 @@ void Cscope::OnFindFunctionsCallingThisFunction(wxCommandEvent& e) void Cscope::OnFindFilesIncludingThisFname(wxCommandEvent& e) { wxString word = m_mgr->GetActiveEditor()->GetSelection(); - if(word.IsEmpty()) { + if (word.IsEmpty()) { // If there's no selection, try for the caret word // That'll either be (rubbish, or) a filename // or it'll be the 'h' of filename.h // Cscope can cope with just a filename word = m_mgr->GetActiveEditor()->GetWordAtCaret(); - if(word == "h") { + if (word == "h") { long pos = m_mgr->GetActiveEditor()->GetCurrentPosition(); long start = m_mgr->GetActiveEditor()->WordStartPos(pos - 2, true); wxString name = m_mgr->GetActiveEditor()->GetTextRange(start, pos - 2); @@ -492,7 +611,7 @@ void Cscope::OnFindFilesIncludingThisFname(wxCommandEvent& e) // but would also return #include foobar.h which isn't what's been requested word = name + ".h"; } - if(word.IsEmpty()) { + if (word.IsEmpty()) { return; } } @@ -505,7 +624,7 @@ void Cscope::OnFindFilesIncludingThisFname(wxCommandEvent& e) CScopeConfData settings; m_mgr->GetConfigTool()->ReadObject("CscopeSettings", &settings); - if(!settings.GetRebuildOption()) { + if (!settings.GetRebuildOption()) { rebuildOption = " -d"; } @@ -520,7 +639,7 @@ void Cscope::OnFindFilesIncludingThisFname(wxCommandEvent& e) void Cscope::OnCreateDB(wxCommandEvent& e) { // sanity - if(!m_mgr->IsWorkspaceOpen() && !clFileSystemWorkspace::Get().IsOpen()) { + if (!m_mgr->IsWorkspaceOpen() && !clFileSystemWorkspace::Get().IsOpen()) { return; } @@ -535,7 +654,7 @@ void Cscope::OnCreateDB(wxCommandEvent& e) command << GetCscopeExeName(); m_mgr->GetConfigTool()->ReadObject("CscopeSettings", &settings); - if(settings.GetBuildRevertedIndexOption()) { + if (settings.GetBuildRevertedIndexOption()) { command << " -q"; endMsg << _("Recreated inverted CScope DB"); } else { @@ -560,7 +679,7 @@ void Cscope::OnDoSettings(wxCommandEvent& e) wxString filepath = settings.GetCscopeExe(); CScopeSettingsDlg dlg(EventNotifier::Get()->TopFrame()); - if(dlg.ShowModal() == wxID_OK) { + if (dlg.ShowModal() == wxID_OK) { settings.SetCscopeExe(dlg.GetPath()); m_mgr->GetConfigTool()->WriteObject("CscopeSettings", &settings); } @@ -582,10 +701,10 @@ void Cscope::OnCScopeThreadEnded(wxCommandEvent& e) void Cscope::OnCScopeThreadUpdateStatus(wxCommandEvent& e) { CScopeStatusMessage* msg = (CScopeStatusMessage*)e.GetClientData(); - if(msg) { + if (msg) { m_cscopeWin->SetMessage(msg->GetMessage(), msg->GetPercentage()); - if(msg->GetFindWhat().IsEmpty() == false) { + if (msg->GetFindWhat().IsEmpty() == false) { m_cscopeWin->SetFindWhat(msg->GetFindWhat()); } delete msg; @@ -609,7 +728,7 @@ void Cscope::OnWorkspaceOpenUI(wxUpdateUIEvent& e) void Cscope::OnFindUserInsertedSymbol(wxCommandEvent& WXUNUSED(e)) { wxString word = GetSearchPattern(); - if(word.IsEmpty()) { + if (word.IsEmpty()) { return; } @@ -619,18 +738,18 @@ void Cscope::OnFindUserInsertedSymbol(wxCommandEvent& WXUNUSED(e)) wxString Cscope::GetSearchPattern() const { wxString pattern; - if(m_mgr->IsShutdownInProgress()) { + if (m_mgr->IsShutdownInProgress()) { return pattern; } IEditor* editor = m_mgr->GetActiveEditor(); - if(editor) { + if (editor) { pattern = editor->GetWordAtCaret(); } - if(pattern.IsEmpty()) { - pattern = wxGetTextFromUser(_("Enter the symbol to search for:"), _("cscope: find symbol"), "", - m_mgr->GetTheApp()->GetTopWindow()); + if (pattern.IsEmpty()) { + pattern = wxGetTextFromUser( + _("Enter the symbol to search for:"), _("cscope: find symbol"), "", m_mgr->GetTheApp()->GetTopWindow()); } return pattern; @@ -646,7 +765,7 @@ void Cscope::DoFindSymbol(const wxString& word) CScopeConfData settings; m_mgr->GetConfigTool()->ReadObject("CscopeSettings", &settings); - if(!settings.GetRebuildOption()) { + if (!settings.GetRebuildOption()) { rebuildOption = " -d"; } @@ -663,18 +782,18 @@ void Cscope::OnEditorContentMenu(clContextMenuEvent& event) event.Skip(); IEditor* editor = m_mgr->GetActiveEditor(); CHECK_PTR_RET(editor); - if(FileExtManager::IsCxxFile(editor->GetFileName())) { + if (FileExtManager::IsCxxFile(editor->GetFileName())) { event.GetMenu()->Append(wxID_ANY, _("CScope"), CreateEditorPopMenu()); } } wxString Cscope::GetWorkingDirectory() const { - if(!IsWorkspaceOpen()) { + if (!IsWorkspaceOpen()) { return wxEmptyString; } - if(clFileSystemWorkspace::Get().IsOpen()) { + if (clFileSystemWorkspace::Get().IsOpen()) { wxFileName fn = clFileSystemWorkspace::Get().GetFileName(); fn.AppendDir(".codelite"); return fn.GetPath(); diff --git a/cscope/cscope.h b/cscope/cscope.h index d575b045a6..d26e82f54d 100644 --- a/cscope/cscope.h +++ b/cscope/cscope.h @@ -63,7 +63,7 @@ class Cscope : public IPlugin wxString GetSearchPattern() const; wxString GetWorkingDirectory() const; bool IsWorkspaceOpen() const; - + // Event handlers //------------------------------------------ void OnFindSymbol(wxCommandEvent& e); diff --git a/cscope/cscopedbbuilderthread.cpp b/cscope/cscopedbbuilderthread.cpp index 8fc48ad5b4..61223c5061 100644 --- a/cscope/cscopedbbuilderthread.cpp +++ b/cscope/cscopedbbuilderthread.cpp @@ -69,7 +69,7 @@ void CscopeDbBuilderThread::ProcessRequest(ThreadRequest* request) CScopeResultTable_t* CscopeDbBuilderThread::ParseResults(const wxArrayString& output) { CScopeResultTable_t* results = new CScopeResultTable_t(); - for(size_t i = 0; i < output.GetCount(); i++) { + for (size_t i = 0; i < output.GetCount(); i++) { // parse each line wxString line = output.Item(i); CscopeEntryData data; @@ -77,7 +77,9 @@ CScopeResultTable_t* CscopeDbBuilderThread::ParseResults(const wxArrayString& ou // first is the file name line = line.Trim().Trim(false); // skip errors - if(line.StartsWith(wxT("cscope:"))) { continue; } + if (line.StartsWith(wxT("cscope:"))) { + continue; + } wxString file = line.BeforeFirst(wxT(' ')); data.SetFile(file); @@ -104,7 +106,7 @@ CScopeResultTable_t* CscopeDbBuilderThread::ParseResults(const wxArrayString& ou // insert the result CScopeResultTable_t::const_iterator iter = results->find(data.GetFile()); std::vector* vec(NULL); - if(iter != results->end()) { + if (iter != results->end()) { // this file already exist, append the result vec = iter->second; } else { @@ -117,7 +119,9 @@ CScopeResultTable_t* CscopeDbBuilderThread::ParseResults(const wxArrayString& ou return results; } -void CscopeDbBuilderThread::SendStatusEvent(const wxString& msg, int percent, const wxString& findWhat, +void CscopeDbBuilderThread::SendStatusEvent(const wxString& msg, + int percent, + const wxString& findWhat, wxEvtHandler* owner) { wxCommandEvent e(wxEVT_CSCOPE_THREAD_UPDATE_STATUS); diff --git a/cscope/cscopeentrydata.cpp b/cscope/cscopeentrydata.cpp index a15aba0f9c..7c00164fb4 100644 --- a/cscope/cscopeentrydata.cpp +++ b/cscope/cscopeentrydata.cpp @@ -1,30 +1,31 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : cscopeentrydata.cpp -// +// copyright : (C) 2008 by Eran Ifrah +// file name : cscopeentrydata.cpp +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - #include "cscopeentrydata.h" +#include "cscopeentrydata.h" + CscopeEntryData::CscopeEntryData() -: m_line(wxNOT_FOUND) -, m_kind(KindSingleEntry) + : m_line(wxNOT_FOUND) + , m_kind(KindSingleEntry) { } diff --git a/cscope/cscopeentrydata.h b/cscope/cscopeentrydata.h index 549716d335..a96ec57387 100644 --- a/cscope/cscopeentrydata.h +++ b/cscope/cscopeentrydata.h @@ -1,74 +1,57 @@ ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // -// copyright : (C) 2008 by Eran Ifrah -// file name : cscopeentrydata.h -// +// copyright : (C) 2008 by Eran Ifrah +// file name : cscopeentrydata.h +// // ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// - #ifndef __cscopeentrydata__ +#ifndef __cscopeentrydata__ #define __cscopeentrydata__ #include -enum { - KindFileNode = 0, - KindSingleEntry -}; +enum { KindFileNode = 0, KindSingleEntry }; class CscopeEntryData { - wxString m_file; - int m_line; - wxString m_pattern; - wxString m_scope; - int m_kind; + wxString m_file; + int m_line; + wxString m_pattern; + wxString m_scope; + int m_kind; public: - CscopeEntryData(); - ~CscopeEntryData() = default; - - -//Setters - void SetFile(const wxString& file) { - this->m_file = file.c_str(); - } - void SetKind(int kind) { this->m_kind = kind; } - void SetLine(int line) { this->m_line = line; } - void SetPattern(const wxString& pattern) { - this->m_pattern = pattern.c_str(); - } - void SetScope(const wxString& scope) { - this->m_scope = scope.c_str(); - } -//Getters - const wxString& GetFile() const { - return m_file; - } - int GetKind() const { return m_kind; } - int GetLine() const { return m_line; } - const wxString& GetPattern() const { - return m_pattern; - } - const wxString& GetScope() const { - return m_scope; - } + CscopeEntryData(); + ~CscopeEntryData() = default; + // Setters + void SetFile(const wxString& file) { this->m_file = file.c_str(); } + void SetKind(int kind) { this->m_kind = kind; } + void SetLine(int line) { this->m_line = line; } + void SetPattern(const wxString& pattern) { this->m_pattern = pattern.c_str(); } + void SetScope(const wxString& scope) { this->m_scope = scope.c_str(); } + // Getters + const wxString& GetFile() const { return m_file; } + int GetKind() const { return m_kind; } + int GetLine() const { return m_line; } + const wxString& GetPattern() const { return m_pattern; } + const wxString& GetScope() const { return m_scope; } }; #endif // __cscopeentrydata__ diff --git a/cscope/cscopestatusmessage.cpp b/cscope/cscopestatusmessage.cpp index 47be2d3710..27416f9f78 100644 --- a/cscope/cscopestatusmessage.cpp +++ b/cscope/cscopestatusmessage.cpp @@ -25,32 +25,14 @@ #include "cscopestatusmessage.h" -void CScopeStatusMessage::SetMessage(const wxString& message) -{ - this->m_message = message.c_str(); -} +void CScopeStatusMessage::SetMessage(const wxString& message) { this->m_message = message.c_str(); } -void CScopeStatusMessage::SetPercentage(int percentage) -{ - this->m_percentage = percentage; -} +void CScopeStatusMessage::SetPercentage(int percentage) { this->m_percentage = percentage; } -const wxString& CScopeStatusMessage::GetMessage() const -{ - return m_message; -} +const wxString& CScopeStatusMessage::GetMessage() const { return m_message; } -int CScopeStatusMessage::GetPercentage() const -{ - return m_percentage; -} +int CScopeStatusMessage::GetPercentage() const { return m_percentage; } -const wxString& CScopeStatusMessage::GetFindWhat() const -{ - return m_findWhat; -} +const wxString& CScopeStatusMessage::GetFindWhat() const { return m_findWhat; } -void CScopeStatusMessage::SetFindWhat(const wxString& findWhat) -{ - m_findWhat = findWhat.c_str(); -} +void CScopeStatusMessage::SetFindWhat(const wxString& findWhat) { m_findWhat = findWhat.c_str(); } diff --git a/cscope/cscopestatusmessage.h b/cscope/cscopestatusmessage.h index 0fc98dd668..2fd40f7c68 100644 --- a/cscope/cscopestatusmessage.h +++ b/cscope/cscopestatusmessage.h @@ -29,22 +29,22 @@ #include class CScopeStatusMessage { - wxString m_message; - int m_percentage; - wxString m_findWhat; + wxString m_message; + int m_percentage; + wxString m_findWhat; public: - CScopeStatusMessage() = default; - virtual ~CScopeStatusMessage() = default; + CScopeStatusMessage() = default; + virtual ~CScopeStatusMessage() = default; - // Setters - void SetMessage (const wxString& message ) ; - void SetPercentage (int percentage); - void SetFindWhat (const wxString& findWhat); + // Setters + void SetMessage(const wxString& message); + void SetPercentage(int percentage); + void SetFindWhat(const wxString& findWhat); - // Getters - const wxString& GetMessage () const ; - const wxString& GetFindWhat () const ; - int GetPercentage() const; + // Getters + const wxString& GetMessage() const; + const wxString& GetFindWhat() const; + int GetPercentage() const; }; #endif // __cscopestatusmessage__ diff --git a/cscope/cscopetab.cpp b/cscope/cscopetab.cpp index 8e6f8f469c..5940c06964 100644 --- a/cscope/cscopetab.cpp +++ b/cscope/cscopetab.cpp @@ -54,9 +54,9 @@ CscopeTab::CscopeTab(wxWindow* parent, IManager* mgr) CScopeConfData data; m_mgr->GetConfigTool()->ReadObject(wxT("CscopeSettings"), &data); - const wxString SearchScope[] = { wxTRANSLATE("Entire Workspace"), wxTRANSLATE("Active Project") }; - m_stringManager.AddStrings(sizeof(SearchScope) / sizeof(wxString), SearchScope, data.GetScanScope(), - m_choiceSearchScope); + const wxString SearchScope[] = {wxTRANSLATE("Entire Workspace"), wxTRANSLATE("Active Project")}; + m_stringManager.AddStrings( + sizeof(SearchScope) / sizeof(wxString), SearchScope, data.GetScanScope(), m_choiceSearchScope); wxFont defFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); m_font = wxFont(defFont.GetPointSize(), wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); @@ -71,8 +71,8 @@ CscopeTab::CscopeTab(wxWindow* parent, IManager* mgr) CscopeTab::~CscopeTab() { - EventNotifier::Get()->Disconnect(wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(CscopeTab::OnThemeChanged), NULL, - this); + EventNotifier::Get()->Disconnect( + wxEVT_CL_THEME_CHANGED, wxCommandEventHandler(CscopeTab::OnThemeChanged), NULL, this); } void CscopeTab::Clear() @@ -106,7 +106,7 @@ void CscopeTab::BuildTable(CScopeResultTable_t* table) wxString display_string; display_string << _("Line: ") << entry.GetLine() << wxT(", ") << entry.GetScope() << wxT(", ") << entry.GetPattern(); - if(insertedItems.count(display_string) == 0) { + if (insertedItems.count(display_string) == 0) { insertedItems.insert(display_string); int lineno = m_stc->GetLineCount() - 1; // STC line number *before* we add the result AddMatch(entry.GetLine(), entry.GetPattern()); @@ -119,7 +119,7 @@ void CscopeTab::BuildTable(CScopeResultTable_t* table) void CscopeTab::FreeTable() { - if(m_table) { + if (m_table) { for (auto& [_, vec] : *m_table) { // delete the vector delete vec; @@ -131,7 +131,9 @@ void CscopeTab::FreeTable() void CscopeTab::SetMessage(const wxString& msg, int percent) { - if(m_mgr->GetStatusBar()) { m_mgr->GetStatusBar()->SetMessage(msg, 3); } + if (m_mgr->GetStatusBar()) { + m_mgr->GetStatusBar()->SetMessage(msg, 3); + } m_gauge->SetValue(percent); } @@ -204,20 +206,22 @@ void CscopeTab::AddFile(const wxString& filename) void CscopeTab::OnHotspotClicked(wxStyledTextEvent& e) { - if(!IsWorkspaceOpen()) { return; } - + if (!IsWorkspaceOpen()) { + return; + } + int clickedLine; int style = m_styler->HitTest(e, clickedLine); - if(style == clFindResultsStyler::LEX_FIF_FILE || style == clFindResultsStyler::LEX_FIF_HEADER) { + if (style == clFindResultsStyler::LEX_FIF_FILE || style == clFindResultsStyler::LEX_FIF_HEADER) { // Toggle m_stc->ToggleFold(clickedLine); } else { // Open the match std::map::const_iterator iter = m_matchesInStc.find(clickedLine); - if(iter != m_matchesInStc.end()) { + if (iter != m_matchesInStc.end()) { wxString wsp_path = GetWorkingDirectory(); wxFileName fn(iter->second.GetFile()); - if(!fn.MakeAbsolute(wsp_path)) { + if (!fn.MakeAbsolute(wsp_path)) { clLogMessage(wxT("CScope: failed to convert file to absolute path")); return; } @@ -234,14 +238,18 @@ void CscopeTab::OnHotspotClicked(wxStyledTextEvent& e) void CscopeTab::CenterEditorLine(int lineno) { IEditor* editor = m_mgr->GetActiveEditor(); - if(editor) { editor->CenterLine(lineno); } + if (editor) { + editor->CenterLine(lineno); + } } wxString CscopeTab::GetWorkingDirectory() const { - if(!IsWorkspaceOpen()) { return wxEmptyString; } + if (!IsWorkspaceOpen()) { + return wxEmptyString; + } - if(clFileSystemWorkspace::Get().IsOpen()) { + if (clFileSystemWorkspace::Get().IsOpen()) { wxFileName fn = clFileSystemWorkspace::Get().GetFileName(); fn.AppendDir(".codelite"); return fn.GetPath(); diff --git a/cscope/cscopetab.h b/cscope/cscopetab.h index 340fbfb5cf..267b67f47a 100644 --- a/cscope/cscopetab.h +++ b/cscope/cscopetab.h @@ -30,12 +30,12 @@ Subclass of CscopeTabBase, which is generated by wxFormBuilder. */ -#include "globals.h" #include "CscopeTabBase.h" -#include "cscopeentrydata.h" -#include "cscopedbbuilderthread.h" #include "bitmap_loader.h" #include "clFindResultsStyler.h" +#include "cscopedbbuilderthread.h" +#include "cscopeentrydata.h" +#include "globals.h" class IManager; class CscopeTabClientData : public wxClientData diff --git a/cscope/cscoptviewresultsmodel.cpp b/cscope/cscoptviewresultsmodel.cpp index 08434da503..026b39aae7 100644 --- a/cscope/cscoptviewresultsmodel.cpp +++ b/cscope/cscoptviewresultsmodel.cpp @@ -4,6 +4,7 @@ ////////////////////////////////////////////////////////////////////// #include "cscoptviewresultsmodel.h" + #include #include @@ -14,10 +15,10 @@ // ------------------------------------------------- // Help method // ------------------------------------------------- -wxVariant CScoptViewResultsModel::CreateIconTextVariant(const wxString &text, const wxBitmap& bmp) +wxVariant CScoptViewResultsModel::CreateIconTextVariant(const wxString& text, const wxBitmap& bmp) { wxIcon icn; - icn.CopyFromBitmap( bmp); + icn.CopyFromBitmap(bmp); wxDataViewIconText ict(text, icn); wxVariant v; v << ict; @@ -43,7 +44,7 @@ CScoptViewResultsModel::~CScoptViewResultsModel() unsigned int CScoptViewResultsModel::GetChildren(const wxDataViewItem& item, wxDataViewItemArray& children) const { - if(item.GetID() == NULL) { + if (item.GetID() == NULL) { // Root for (auto* item : m_data) { children.Add(wxDataViewItem(item)); @@ -53,22 +54,19 @@ unsigned int CScoptViewResultsModel::GetChildren(const wxDataViewItem& item, wxD children.Clear(); CScoptViewResultsModel_Item* node = reinterpret_cast(item.m_pItem); - if ( node ) { - for(size_t i=0; iGetChildren().size(); ++i) { - children.Add( wxDataViewItem( node->GetChildren().at(i) ) ); + if (node) { + for (size_t i = 0; i < node->GetChildren().size(); ++i) { + children.Add(wxDataViewItem(node->GetChildren().at(i))); } } return children.GetCount(); } -unsigned int CScoptViewResultsModel::GetColumnCount() const -{ - return m_colCount; -} +unsigned int CScoptViewResultsModel::GetColumnCount() const { return m_colCount; } wxString CScoptViewResultsModel::GetColumnType(unsigned int col) const { - if ( !m_data.empty() && m_data.at(0)->GetData().size() > col ) { + if (!m_data.empty() && m_data.at(0)->GetData().size() > col) { return m_data.at(0)->GetData().at(col).GetType(); } return "string"; @@ -76,12 +74,12 @@ wxString CScoptViewResultsModel::GetColumnType(unsigned int col) const wxDataViewItem CScoptViewResultsModel::GetParent(const wxDataViewItem& item) const { - if ( IsEmpty() ) { + if (IsEmpty()) { return wxDataViewItem(NULL); } - + CScoptViewResultsModel_Item* node = reinterpret_cast(item.m_pItem); - if ( node ) { + if (node) { return wxDataViewItem(node->GetParent()); } return wxDataViewItem(NULL); @@ -90,7 +88,7 @@ wxDataViewItem CScoptViewResultsModel::GetParent(const wxDataViewItem& item) con bool CScoptViewResultsModel::IsContainer(const wxDataViewItem& item) const { CScoptViewResultsModel_Item* node = reinterpret_cast(item.m_pItem); - if ( node ) { + if (node) { return node->IsContainer(); } return false; @@ -99,78 +97,86 @@ bool CScoptViewResultsModel::IsContainer(const wxDataViewItem& item) const void CScoptViewResultsModel::GetValue(wxVariant& variant, const wxDataViewItem& item, unsigned int col) const { CScoptViewResultsModel_Item* node = reinterpret_cast(item.m_pItem); - if ( node && node->GetData().size() > col ) { + if (node && node->GetData().size() > col) { variant = node->GetData().at(col); } } -wxDataViewItem CScoptViewResultsModel::DoAppendItem(const wxDataViewItem& parent, const wxVector& data, bool isContainer, wxClientData *clientData) +wxDataViewItem CScoptViewResultsModel::DoAppendItem(const wxDataViewItem& parent, + const wxVector& data, + bool isContainer, + wxClientData* clientData) { CScoptViewResultsModel_Item* parentNode = reinterpret_cast(parent.m_pItem); DoChangeItemType(parent, true); - + CScoptViewResultsModel_Item* child = new CScoptViewResultsModel_Item(); child->SetIsContainer(isContainer); - child->SetClientObject( clientData ); - child->SetData( data ); - if ( parentNode ) { - parentNode->AddChild( child ); + child->SetClientObject(clientData); + child->SetData(data); + if (parentNode) { + parentNode->AddChild(child); } else { - m_data.push_back( child ); + m_data.push_back(child); } return wxDataViewItem(child); } -wxDataViewItem CScoptViewResultsModel::DoInsertItem(const wxDataViewItem& insertBeforeMe, const wxVector& data, bool isContainer, wxClientData *clientData) +wxDataViewItem CScoptViewResultsModel::DoInsertItem(const wxDataViewItem& insertBeforeMe, + const wxVector& data, + bool isContainer, + wxClientData* clientData) { CScoptViewResultsModel_Item* child = new CScoptViewResultsModel_Item(); child->SetIsContainer(isContainer); - child->SetClientObject( clientData ); - child->SetData( data ); + child->SetClientObject(clientData); + child->SetData(data); // find the location where to insert the new item CScoptViewResultsModel_Item* node = reinterpret_cast(insertBeforeMe.m_pItem); - if ( !node ) + if (!node) return wxDataViewItem(); wxVector::iterator where = std::find(m_data.begin(), m_data.end(), node); - if ( where != m_data.end() ) { + if (where != m_data.end()) { // top level item - m_data.insert( where, child ); + m_data.insert(where, child); } else { - if ( !node->GetParent() ) + if (!node->GetParent()) return wxDataViewItem(); child->SetParent(node->GetParent()); where = std::find(node->GetParent()->GetChildren().begin(), node->GetParent()->GetChildren().end(), node); - if ( where == node->GetParent()->GetChildren().end() ) { - node->GetParent()->GetChildren().push_back( child ); + if (where == node->GetParent()->GetChildren().end()) { + node->GetParent()->GetChildren().push_back(child); } else { node->GetParent()->GetChildren().insert(where, child); - } } return wxDataViewItem(child); } -wxDataViewItem CScoptViewResultsModel::AppendItem(const wxDataViewItem &parent, const wxVector& data, wxClientData *clientData) +wxDataViewItem CScoptViewResultsModel::AppendItem(const wxDataViewItem& parent, + const wxVector& data, + wxClientData* clientData) { wxDataViewItem ch = DoAppendItem(parent, data, false, clientData); ItemAdded(parent, ch); return ch; } -wxDataViewItemArray CScoptViewResultsModel::AppendItems(const wxDataViewItem &parent, const wxVector >& data) +wxDataViewItemArray CScoptViewResultsModel::AppendItems(const wxDataViewItem& parent, + const wxVector>& data) { wxDataViewItemArray items; - for(size_t i=0; i(item.m_pItem); - if ( node && node->GetData().size() > col ) { + if (node && node->GetData().size() > col) { node->GetData().at(col) = variant; } return true; @@ -188,36 +194,36 @@ bool CScoptViewResultsModel::SetValue(const wxVariant& variant, const wxDataView void CScoptViewResultsModel::DeleteItem(const wxDataViewItem& item) { CScoptViewResultsModel_Item* node = reinterpret_cast(item.m_pItem); - if ( node ) { - + if (node) { + CScoptViewResultsModel_Item* parent = node->GetParent(); wxDataViewItem parentItem(parent); ItemDeleted(parentItem, item); - + // this will also remove it from its model parent children list - if ( parent == NULL ) { + if (parent == NULL) { // root item, remove it from the roots array wxVector::iterator where = std::find(m_data.begin(), m_data.end(), node); - if ( where != m_data.end() ) { + if (where != m_data.end()) { m_data.erase(where); } } - + // If there are no more children, change the item back to 'normal' - if ( parent && parent->GetChildren().empty() ) + if (parent && parent->GetChildren().empty()) DoChangeItemType(parentItem, false); - + wxDELETE(node); } - - if ( IsEmpty() ) + + if (IsEmpty()) Cleared(); } void CScoptViewResultsModel::DeleteItems(const wxDataViewItem& parent, const wxDataViewItemArray& items) { // sanity - for(size_t i=0; i(items.Item(i).m_pItem); wxUnusedVar(node); wxASSERT(node && node->GetParent() == parent.m_pItem); @@ -235,24 +241,21 @@ void CScoptViewResultsModel::Clear() Cleared(); } -bool CScoptViewResultsModel::IsEmpty() const -{ - return m_data.empty(); -} +bool CScoptViewResultsModel::IsEmpty() const { return m_data.empty(); } wxClientData* CScoptViewResultsModel::GetClientObject(const wxDataViewItem& item) const { CScoptViewResultsModel_Item* node = reinterpret_cast(item.GetID()); - if ( node ) { + if (node) { return node->GetClientObject(); } return NULL; } -void CScoptViewResultsModel::SetClientObject(const wxDataViewItem& item, wxClientData *data) +void CScoptViewResultsModel::SetClientObject(const wxDataViewItem& item, wxClientData* data) { CScoptViewResultsModel_Item* node = reinterpret_cast(item.GetID()); - if ( node ) { + if (node) { node->SetClientObject(data); } } @@ -260,16 +263,18 @@ void CScoptViewResultsModel::SetClientObject(const wxDataViewItem& item, wxClien void CScoptViewResultsModel::UpdateItem(const wxDataViewItem& item, const wxVector& data) { CScoptViewResultsModel_Item* node = reinterpret_cast(item.GetID()); - if ( node ) { - node->SetData( data ); - ItemChanged( item ); + if (node) { + node->SetData(data); + ItemChanged(item); } } -wxDataViewItem CScoptViewResultsModel::InsertItem(const wxDataViewItem& insertBeforeMe, const wxVector& data, wxClientData *clientData) +wxDataViewItem CScoptViewResultsModel::InsertItem(const wxDataViewItem& insertBeforeMe, + const wxVector& data, + wxClientData* clientData) { wxDataViewItem ch = DoInsertItem(insertBeforeMe, data, false, clientData); - if ( ch.IsOk() ) { + if (ch.IsOk()) { CScoptViewResultsModel_Item* node = reinterpret_cast(ch.GetID()); ItemAdded(wxDataViewItem(node->GetParent()), ch); } @@ -278,11 +283,11 @@ wxDataViewItem CScoptViewResultsModel::InsertItem(const wxDataViewItem& insertBe wxVector CScoptViewResultsModel::GetItemColumnsData(const wxDataViewItem& item) const { - if ( !item.IsOk() ) + if (!item.IsOk()) return wxVector(); CScoptViewResultsModel_Item* node = reinterpret_cast(item.GetID()); - if ( !node ) { + if (!node) { return wxVector(); } return node->GetData(); @@ -290,11 +295,11 @@ wxVector CScoptViewResultsModel::GetItemColumnsData(const wxDataViewI bool CScoptViewResultsModel::HasChildren(const wxDataViewItem& item) const { - if ( !item.IsOk() ) + if (!item.IsOk()) return false; CScoptViewResultsModel_Item* node = reinterpret_cast(item.GetID()); - if ( !node ) { + if (!node) { return false; } return !node->GetChildren().empty(); @@ -303,16 +308,16 @@ bool CScoptViewResultsModel::HasChildren(const wxDataViewItem& item) const void CScoptViewResultsModel::DoChangeItemType(const wxDataViewItem& item, bool changeToContainer) { CScoptViewResultsModel_Item* node = reinterpret_cast(item.GetID()); - if ( !node ) + if (!node) return; - - if ( ( changeToContainer && !node->IsContainer()) || // change an item from non-container to container type - ( !changeToContainer && node->IsContainer()) ) { // change an item from container to non-container type + + if ((changeToContainer && !node->IsContainer()) || // change an item from non-container to container type + (!changeToContainer && node->IsContainer())) { // change an item from container to non-container type #if defined(__WXGTK__) || defined(__WXMAC__) // change the item to container type: // 1st we need to delete it ItemDeleted(wxDataViewItem(node->GetParent()), item); - + // update the node type node->SetIsContainer(changeToContainer); ItemAdded(wxDataViewItem(node->GetParent()), item); diff --git a/cscope/cscoptviewresultsmodel.h b/cscope/cscoptviewresultsmodel.h index 6b0ced48df..2c49e13b3a 100644 --- a/cscope/cscoptviewresultsmodel.h +++ b/cscope/cscoptviewresultsmodel.h @@ -1,28 +1,28 @@ -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -// -// Copyright : (C) 2015 Eran Ifrah -// File name : cscoptviewresultsmodel.h -// -// ------------------------------------------------------------------------- -// A -// _____ _ _ _ _ -// / __ \ | | | | (_) | -// | / \/ ___ __| | ___| | _| |_ ___ -// | | / _ \ / _ |/ _ \ | | | __/ _ ) -// | \__/\ (_) | (_| | __/ |___| | || __/ -// \____/\___/ \__,_|\___\_____/_|\__\___| -// -// F i l e -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +// +// Copyright : (C) 2015 Eran Ifrah +// File name : cscoptviewresultsmodel.h +// +// ------------------------------------------------------------------------- +// A +// _____ _ _ _ _ +// / __ \ | | | | (_) | +// | / \/ ___ __| | ___| | _| |_ ___ +// | | / _ \ / _ |/ _ \ | | | __/ _ ) +// | \__/\ (_) | (_| | __/ |___| | || __/ +// \____/\___/ \__,_|\___\_____/_|\__\___| +// +// F i l e +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////// // This file was auto-generated by codelite's wxCrafter Plugin // Do not modify this file by hand! @@ -31,41 +31,43 @@ #ifndef __CScoptViewResultsModel_GUARD__H__ #define __CScoptViewResultsModel_GUARD__H__ -#include -#include #include #include +#include +#include /** * @brief each item in the wxDataViewCtrl is represented in the model by this class. - * m_data - contains the data (columns values) as passed when adding an item to the wxDataViewCtrl model class - * m_clientData - is the user client data (owned by the model) + * m_data - contains the data (columns values) as passed when adding an item to the wxDataViewCtrl model class + * m_clientData - is the user client data (owned by the model) * To convert between a wxDataViewItem to a CScoptViewResultsModel_Item class, simply use: * @code * CScoptViewResultsModel_Item* itemData = reinterpret_cast( item.GetID() ); * if ( itemData ) { * // you can now traverese the tree or have a direct access to the model internal data - * // note that you must not delete itemData as it is owned by the model and + * // note that you must not delete itemData as it is owned by the model and * } * @endcode */ class CScoptViewResultsModel_Item { protected: - wxVector m_data; - CScoptViewResultsModel_Item* m_parent; + wxVector m_data; + CScoptViewResultsModel_Item* m_parent; wxVector m_children; - bool m_isContainer; - wxClientData* m_clientData; + bool m_isContainer; + wxClientData* m_clientData; public: CScoptViewResultsModel_Item() : m_parent(NULL) , m_isContainer(false) , m_clientData(NULL) - {} - virtual ~CScoptViewResultsModel_Item() { - if ( m_clientData ) { + { + } + virtual ~CScoptViewResultsModel_Item() + { + if (m_clientData) { delete m_clientData; m_clientData = NULL; } @@ -75,33 +77,30 @@ class CScoptViewResultsModel_Item // since the deletion of a child may alter its parent m_children array // we use a temporary vector for the loop wxVector tmpChildren = m_children; - while ( !tmpChildren.empty() ) { + while (!tmpChildren.empty()) { delete (*tmpChildren.begin()); tmpChildren.erase(tmpChildren.begin()); } m_children.clear(); // Remove us from the parent - if ( m_parent ) { + if (m_parent) { m_parent->RemoveChild(this); } } - void SetIsContainer(bool b) { - m_isContainer = b; - } + void SetIsContainer(bool b) { m_isContainer = b; } - bool IsContainer() const { - return m_isContainer; - } + bool IsContainer() const { return m_isContainer; } /** * @brief remove a child from this node and free its memory * @param child */ - void DeleteChild(CScoptViewResultsModel_Item* child) { + void DeleteChild(CScoptViewResultsModel_Item* child) + { wxVector::iterator iter = std::find(m_children.begin(), m_children.end(), child); - if ( iter != m_children.end() ) { + if (iter != m_children.end()) { delete *iter; m_children.erase(iter); } @@ -111,9 +110,10 @@ class CScoptViewResultsModel_Item * @brief remove child from this node without freeing its memory * @param child */ - void RemoveChild(CScoptViewResultsModel_Item* child) { + void RemoveChild(CScoptViewResultsModel_Item* child) + { wxVector::iterator iter = std::find(m_children.begin(), m_children.end(), child); - if ( iter != m_children.end() ) { + if (iter != m_children.end()) { m_children.erase(iter); } } @@ -121,51 +121,33 @@ class CScoptViewResultsModel_Item /** * @brief add child to this node */ - void AddChild(CScoptViewResultsModel_Item* child) { + void AddChild(CScoptViewResultsModel_Item* child) + { m_children.push_back(child); child->m_parent = this; } - bool IsRoot() const { - return m_parent == NULL; - } + bool IsRoot() const { return m_parent == NULL; } // Setters / Getters - void SetChildren(const wxVector& children) { - this->m_children = children; - } - void SetData(const wxVector& data) { - this->m_data = data; - } - void SetParent(CScoptViewResultsModel_Item* parent) { - this->m_parent = parent; - } - const wxVector& GetChildren() const { - return m_children; - } - wxVector& GetChildren() { - return m_children; - } - const wxVector& GetData() const { - return m_data; - } - wxVector& GetData() { - return m_data; - } - CScoptViewResultsModel_Item* GetParent() { - return m_parent; - } - - void SetClientObject(wxClientData *data) { - if ( m_clientData ) { + void SetChildren(const wxVector& children) { this->m_children = children; } + void SetData(const wxVector& data) { this->m_data = data; } + void SetParent(CScoptViewResultsModel_Item* parent) { this->m_parent = parent; } + const wxVector& GetChildren() const { return m_children; } + wxVector& GetChildren() { return m_children; } + const wxVector& GetData() const { return m_data; } + wxVector& GetData() { return m_data; } + CScoptViewResultsModel_Item* GetParent() { return m_parent; } + + void SetClientObject(wxClientData* data) + { + if (m_clientData) { delete m_clientData; } m_clientData = data; } - wxClientData* GetClientObject() const { - return m_clientData; - } + wxClientData* GetClientObject() const { return m_clientData; } }; ////////////////////////////////////////////// @@ -181,57 +163,53 @@ class CScoptViewResultsModel : public wxDataViewModel public: CScoptViewResultsModel(); virtual ~CScoptViewResultsModel(); - + /** * @brief a helper method creating a wxVariant containing both bitmap and text * this is useful when mostly when populating a column of type 'icontext' */ - static wxVariant CreateIconTextVariant(const wxString &text, const wxBitmap& bmp); - - void SetColCount(unsigned int colCount) { - this->m_colCount = colCount; - } - void SetData(const wxVector data) { - this->m_data = data; - } - unsigned int GetColCount() const { - return m_colCount; - } - const wxVector& GetData() const { - return m_data; - } - wxVector& GetData() { - return m_data; - } + static wxVariant CreateIconTextVariant(const wxString& text, const wxBitmap& bmp); - virtual bool HasContainerColumns (const wxDataViewItem& item) const { - return false; - } + void SetColCount(unsigned int colCount) { this->m_colCount = colCount; } + void SetData(const wxVector data) { this->m_data = data; } + unsigned int GetColCount() const { return m_colCount; } + const wxVector& GetData() const { return m_data; } + wxVector& GetData() { return m_data; } + + virtual bool HasContainerColumns(const wxDataViewItem& item) const { return false; } public: // Make the functions below 'virtual' so the user may override them virtual unsigned int GetColumnCount() const; virtual wxString GetColumnType(unsigned int col) const; virtual void GetValue(wxVariant& variant, const wxDataViewItem& item, unsigned int col) const; - virtual bool SetValue(const wxVariant &variant, const wxDataViewItem &item, unsigned int col); + virtual bool SetValue(const wxVariant& variant, const wxDataViewItem& item, unsigned int col); protected: // Helpers - virtual wxDataViewItem DoAppendItem(const wxDataViewItem& parent, const wxVector& data, bool isContainer, wxClientData *clientData = NULL); - virtual wxDataViewItem DoInsertItem(const wxDataViewItem& insertBeforeMe, const wxVector& data, bool isContainer, wxClientData *clientData); + virtual wxDataViewItem DoAppendItem(const wxDataViewItem& parent, + const wxVector& data, + bool isContainer, + wxClientData* clientData = NULL); + virtual wxDataViewItem DoInsertItem(const wxDataViewItem& insertBeforeMe, + const wxVector& data, + bool isContainer, + wxClientData* clientData); virtual void DoChangeItemType(const wxDataViewItem& item, bool changeToContainer); - + public: /** * @brief Append a line to the model - * clientData will be owned by the model once added (i.e. the clientData must be allocated on the heap and it will be freed by the model) + * clientData will be owned by the model once added (i.e. the clientData must be allocated on the heap and it will + * be freed by the model) */ - virtual wxDataViewItem AppendItem(const wxDataViewItem& parent, const wxVector& data, wxClientData *clientData = NULL); + virtual wxDataViewItem + AppendItem(const wxDataViewItem& parent, const wxVector& data, wxClientData* clientData = NULL); /** * @brief Append a lines to the model */ - virtual wxDataViewItemArray AppendItems(const wxDataViewItem& parent, const wxVector >& data); + virtual wxDataViewItemArray AppendItems(const wxDataViewItem& parent, const wxVector>& data); /** * @brief delete an item and all its children @@ -253,7 +231,8 @@ class CScoptViewResultsModel : public wxDataViewModel /** * @brief insert an item into the model before 'insertBeforeMe' item. Return the newly inserted item on success */ - virtual wxDataViewItem InsertItem (const wxDataViewItem& insertBeforeMe, const wxVector& data, wxClientData *clientData = NULL); + virtual wxDataViewItem + InsertItem(const wxDataViewItem& insertBeforeMe, const wxVector& data, wxClientData* clientData = NULL); /** * @brief clear the control and delete all its content @@ -270,7 +249,7 @@ class CScoptViewResultsModel : public wxDataViewModel /** * @brief set the client data for an item. The item data will be freed by the model */ - void SetClientObject(const wxDataViewItem& item, wxClientData *data); + void SetClientObject(const wxDataViewItem& item, wxClientData* data); /** * @brief returns the item columns data (as passed to AppendItem(..) / InsertItem(...)) @@ -278,8 +257,8 @@ class CScoptViewResultsModel : public wxDataViewModel wxVector GetItemColumnsData(const wxDataViewItem& item) const; /** - * @brief return true if this node is a container (i.e. has children) - */ + * @brief return true if this node is a container (i.e. has children) + */ virtual bool IsContainer(const wxDataViewItem& item) const; /** diff --git a/cscope/csscopeconfdata.cpp b/cscope/csscopeconfdata.cpp index 43bcca5447..ccff0c580c 100644 --- a/cscope/csscopeconfdata.cpp +++ b/cscope/csscopeconfdata.cpp @@ -24,30 +24,32 @@ ////////////////////////////////////////////////////////////////////////////// #include "csscopeconfdata.h" -#include + #include "cl_standard_paths.h" +#include + CScopeConfData::CScopeConfData() - : m_cscopeFilepath( wxT( "" ) ) - , m_scanScope( SCOPE_ENTIRE_WORKSPACE ) - , m_rebuildDb( false ) - , m_buildRevertedIndex( false ) + : m_cscopeFilepath(wxT("")) + , m_scanScope(SCOPE_ENTIRE_WORKSPACE) + , m_rebuildDb(false) + , m_buildRevertedIndex(false) { m_cscopeFilepath = clStandardPaths::Get().GetBinaryFullPath("cscope"); } -void CScopeConfData::DeSerialize( Archive& arch ) +void CScopeConfData::DeSerialize(Archive& arch) { - arch.Read( wxT( "m_cscopeFilepath" ), m_cscopeFilepath ); - arch.Read( wxT( "m_scanScope" ), m_scanScope ); - arch.Read( wxT( "m_rebuildDb" ), m_rebuildDb ); - arch.Read( wxT( "m_buildRevertedIndex" ), m_buildRevertedIndex ); + arch.Read(wxT("m_cscopeFilepath"), m_cscopeFilepath); + arch.Read(wxT("m_scanScope"), m_scanScope); + arch.Read(wxT("m_rebuildDb"), m_rebuildDb); + arch.Read(wxT("m_buildRevertedIndex"), m_buildRevertedIndex); } -void CScopeConfData::Serialize( Archive& arch ) +void CScopeConfData::Serialize(Archive& arch) { - arch.Write( wxT( "m_cscopeFilepath" ), m_cscopeFilepath ); - arch.Write( wxT( "m_scanScope" ), m_scanScope ); - arch.Write( wxT( "m_rebuildDb" ), m_rebuildDb ); - arch.Write( wxT( "m_buildRevertedIndex" ), m_buildRevertedIndex ); + arch.Write(wxT("m_cscopeFilepath"), m_cscopeFilepath); + arch.Write(wxT("m_scanScope"), m_scanScope); + arch.Write(wxT("m_rebuildDb"), m_rebuildDb); + arch.Write(wxT("m_buildRevertedIndex"), m_buildRevertedIndex); } diff --git a/cscope/csscopeconfdata.h b/cscope/csscopeconfdata.h index 37e84313b9..5fae1a21c6 100644 --- a/cscope/csscopeconfdata.h +++ b/cscope/csscopeconfdata.h @@ -27,49 +27,34 @@ #define __csscopeconfdata__ #include "serialized_object.h" + #include #define SCOPE_ENTIRE_WORKSPACE wxT("Entire Workspace") -#define SCOPE_ACTIVE_PROJECT wxT("Active Project") +#define SCOPE_ACTIVE_PROJECT wxT("Active Project") class CScopeConfData : public SerializedObject { - wxString m_cscopeFilepath; - wxString m_scanScope; - bool m_rebuildDb; - bool m_buildRevertedIndex; + wxString m_cscopeFilepath; + wxString m_scanScope; + bool m_rebuildDb; + bool m_buildRevertedIndex; public: - CScopeConfData(); + CScopeConfData(); virtual ~CScopeConfData() = default; public: - virtual void DeSerialize(Archive &arch); - virtual void Serialize(Archive &arch); + virtual void DeSerialize(Archive& arch); + virtual void Serialize(Archive& arch); - void SetCscopeExe(const wxString& filepath) { - this->m_cscopeFilepath = filepath; - } - const wxString& GetCscopeExe() const { - return m_cscopeFilepath; - } - void SetScanScope(const wxString& scanScope) { - this->m_scanScope = scanScope; - } - const wxString& GetScanScope() const { - return m_scanScope; - } - void SetRebuildDbOption(const bool rebuild) { - this->m_rebuildDb = rebuild; - } - bool GetRebuildOption() const { - return m_rebuildDb; - } - void SetBuildRevertedIndexOption(const bool revertedIndex) { - this->m_buildRevertedIndex = revertedIndex; - } - bool GetBuildRevertedIndexOption() const { - return m_buildRevertedIndex; - } + void SetCscopeExe(const wxString& filepath) { this->m_cscopeFilepath = filepath; } + const wxString& GetCscopeExe() const { return m_cscopeFilepath; } + void SetScanScope(const wxString& scanScope) { this->m_scanScope = scanScope; } + const wxString& GetScanScope() const { return m_scanScope; } + void SetRebuildDbOption(const bool rebuild) { this->m_rebuildDb = rebuild; } + bool GetRebuildOption() const { return m_rebuildDb; } + void SetBuildRevertedIndexOption(const bool revertedIndex) { this->m_buildRevertedIndex = revertedIndex; } + bool GetBuildRevertedIndexOption() const { return m_buildRevertedIndex; } }; #endif // __csscopeconfdata__ diff --git a/ctagsd/lib/Channel.cpp b/ctagsd/lib/Channel.cpp index a099ab9304..078ffdd215 100644 --- a/ctagsd/lib/Channel.cpp +++ b/ctagsd/lib/Channel.cpp @@ -18,7 +18,7 @@ eReadSome ChannelSocket::read_some() client->SelectRead(); char buffer[1024 * 4]; size_t bytes_read = 0; - switch(client->Read(buffer, sizeof(buffer), bytes_read)) { + switch (client->Read(buffer, sizeof(buffer), bytes_read)) { case clSocketBase::kSuccess: m_buffer.append(buffer, bytes_read); return eReadSome::kSuccess; @@ -55,16 +55,16 @@ bool ChannelSocket::write_reply(const wxString& message) std::unique_ptr ChannelSocket::read_message() { - while(true) { + while (true) { auto msg = LSP::Message::GetJSONPayload(m_buffer); - if(msg) { + if (msg) { return msg; } // attempt to read some more data from stdin bool cont = true; - while(cont) { - switch(read_some()) { + while (cont) { + switch (read_some()) { case eReadSome::kError: return nullptr; case eReadSome::kSuccess: @@ -87,7 +87,7 @@ void ChannelSocket::open() clSYSTEM() << "Accepting connection on:" << connection_string << endl; client = server.WaitForNewConnection(); - if(!client) { + if (!client) { clERROR() << "failed to accept new connection. Error code:" << server.GetLastError() << endl; exit(1); } diff --git a/ctagsd/lib/LSPUtils.cpp b/ctagsd/lib/LSPUtils.cpp index cdb9114b2b..0be9579daf 100644 --- a/ctagsd/lib/LSPUtils.cpp +++ b/ctagsd/lib/LSPUtils.cpp @@ -18,7 +18,7 @@ void LSPUtils::encode_semantic_tokens(const std::vector& tokens_ve std::array info; bool changed_line = prev_token_ptr->line() != current_token_ptr->line(); - if(changed_line) { + if (changed_line) { info[0] = current_token_ptr->line() - prev_token_ptr->line(); // keep the delta } else { // we are the same line, set it to 0 @@ -26,7 +26,7 @@ void LSPUtils::encode_semantic_tokens(const std::vector& tokens_ve } // represent each column relative the previous token start column - if(changed_line) { + if (changed_line) { info[1] = current_token_ptr->column(); } else { info[1] = current_token_ptr->column() - @@ -51,27 +51,27 @@ void LSPUtils::encode_semantic_tokens(const std::vector& tokens_ve LSP::eSymbolKind LSPUtils::get_symbol_kind(const TagEntry* tag) { LSP::eSymbolKind kind = LSP::eSymbolKind::kSK_Variable; - if(tag->IsMethod()) { + if (tag->IsMethod()) { kind = LSP::eSymbolKind::kSK_Method; - } else if(tag->IsConstructor()) { + } else if (tag->IsConstructor()) { kind = LSP::eSymbolKind::kSK_Class; - } else if(tag->IsClass()) { + } else if (tag->IsClass()) { kind = LSP::eSymbolKind::kSK_Class; - } else if(tag->IsStruct()) { + } else if (tag->IsStruct()) { kind = LSP::eSymbolKind::kSK_Struct; - } else if(tag->IsLocalVariable()) { + } else if (tag->IsLocalVariable()) { kind = LSP::eSymbolKind::kSK_Variable; - } else if(tag->IsTypedef()) { + } else if (tag->IsTypedef()) { kind = LSP::eSymbolKind::kSK_TypeParameter; - } else if(tag->IsMacro()) { + } else if (tag->IsMacro()) { kind = LSP::eSymbolKind::kSK_TypeParameter; - } else if(tag->GetKind() == "namespace") { + } else if (tag->GetKind() == "namespace") { kind = LSP::eSymbolKind::kSK_Module; - } else if(tag->GetKind() == "union") { + } else if (tag->GetKind() == "union") { kind = LSP::eSymbolKind::kSK_Struct; - } else if(tag->GetKind() == "enum") { + } else if (tag->GetKind() == "enum") { kind = LSP::eSymbolKind::kSK_Enum; - } else if(tag->GetKind() == "enumerator") { + } else if (tag->GetKind() == "enumerator") { kind = LSP::eSymbolKind::kSK_EnumMember; } return kind; @@ -80,29 +80,29 @@ LSP::eSymbolKind LSPUtils::get_symbol_kind(const TagEntry* tag) LSP::CompletionItem::eCompletionItemKind LSPUtils::get_completion_kind(const TagEntry* tag) { LSP::CompletionItem::eCompletionItemKind kind = LSP::CompletionItem::kKindVariable; - if(tag->IsMethod()) { + if (tag->IsMethod()) { kind = LSP::CompletionItem::kKindFunction; - } else if(tag->IsConstructor()) { + } else if (tag->IsConstructor()) { kind = LSP::CompletionItem::kKindClass; - } else if(tag->IsClass()) { + } else if (tag->IsClass()) { kind = LSP::CompletionItem::kKindClass; - } else if(tag->IsStruct()) { + } else if (tag->IsStruct()) { kind = LSP::CompletionItem::kKindStruct; - } else if(tag->IsLocalVariable()) { + } else if (tag->IsLocalVariable()) { kind = LSP::CompletionItem::kKindVariable; - } else if(tag->IsTypedef()) { + } else if (tag->IsTypedef()) { kind = LSP::CompletionItem::kKindTypeParameter; - } else if(tag->IsMacro()) { + } else if (tag->IsMacro()) { kind = LSP::CompletionItem::kKindTypeParameter; - } else if(tag->GetKind() == "namespace") { + } else if (tag->GetKind() == "namespace") { kind = LSP::CompletionItem::kKindModule; - } else if(tag->GetKind() == "union") { + } else if (tag->GetKind() == "union") { kind = LSP::CompletionItem::kKindStruct; - } else if(tag->GetKind() == "enum") { + } else if (tag->GetKind() == "enum") { kind = LSP::CompletionItem::kKindEnum; - } else if(tag->GetKind() == "enumerator") { + } else if (tag->GetKind() == "enumerator") { kind = LSP::CompletionItem::kKindEnumMember; - } else if(tag->GetKind() == "file") { + } else if (tag->GetKind() == "file") { kind = LSP::CompletionItem::kKindTypeParameter; } return kind; @@ -115,7 +115,7 @@ std::vector LSPUtils::to_symbol_information_array(const result.reserve(tags.size()); wxStringSet_t parent_seen; - for(auto tag : tags) { + for (auto tag : tags) { LSP::SymbolInformation symbol_information; to_symbol_information(tag.get(), symbol_information, for_tree_view ? &parent_seen : nullptr); result.push_back(symbol_information); @@ -123,17 +123,18 @@ std::vector LSPUtils::to_symbol_information_array(const return result; } -void LSPUtils::to_symbol_information(const TagEntry* tag, LSP::SymbolInformation& symbol_information, +void LSPUtils::to_symbol_information(const TagEntry* tag, + LSP::SymbolInformation& symbol_information, std::unordered_set* parents_seen) { - if(parents_seen && tag->IsContainer()) { + if (parents_seen && tag->IsContainer()) { parents_seen->insert(tag->GetName()); } LSP::Location loc; LSP::Range range; - range.SetStart({ tag->GetLine() - 1, 0 }); - range.SetEnd({ tag->GetLine() - 1, 0 }); + range.SetStart({tag->GetLine() - 1, 0}); + range.SetEnd({tag->GetLine() - 1, 0}); loc.SetRange(range); loc.SetPath(FileUtils::FilePathToURI(tag->GetFile())); @@ -142,15 +143,15 @@ void LSPUtils::to_symbol_information(const TagEntry* tag, LSP::SymbolInformation wxString display_name = tag->GetDisplayName(); wxString display_name_full = tag->GetFullDisplayName(); - if(tag->IsMethod() && tag->GetName().StartsWith("__anon")) { + if (tag->IsMethod() && tag->GetName().StartsWith("__anon")) { // Lambda display_name = display_name_full = "[lambda]" + tag->GetSignature(); - } else if(tag->IsNamespace() && tag->GetName().StartsWith("__anon")) { + } else if (tag->IsNamespace() && tag->GetName().StartsWith("__anon")) { display_name = display_name_full = "(anonymous namespace)"; } - if(parents_seen) { - if(parents_seen->count(tag->GetParent())) { + if (parents_seen) { + if (parents_seen->count(tag->GetParent())) { symbol_information.SetContainerName(tag->GetParent()); symbol_information.SetName(display_name); } else { diff --git a/ctagsd/lib/ParseThread.cpp b/ctagsd/lib/ParseThread.cpp index f8cd7d2ca1..965ba9dff3 100644 --- a/ctagsd/lib/ParseThread.cpp +++ b/ctagsd/lib/ParseThread.cpp @@ -12,28 +12,30 @@ void ParseThread::start(const wxString& settings_folder, const wxString& indexer [=](std::mutex& m, std::condition_variable& cv, std::vector& Q) { FileLogger::RegisterThread(wxThread::GetCurrentId(), "Parser"); clDEBUG() << "ctagsd parser thread started..." << endl; - while(true) { + while (true) { ParseThreadTaskFunc task_callback = nullptr; { - std::unique_lock lk{ m }; + std::unique_lock lk{m}; cv.wait(lk, [&] { return !Q.empty(); }); task_callback = std::move(Q.front()); Q.erase(Q.begin()); } // parse the file - if(task_callback() == eParseThreadCallbackRC::RC_EXIT) { + if (task_callback() == eParseThreadCallbackRC::RC_EXIT) { break; } } }, - ref(m_mutex), ref(m_cv), ref(m_queue)); + ref(m_mutex), + ref(m_cv), + ref(m_queue)); } void ParseThread::stop() { clDEBUG() << "Shutting down change thread" << endl; - if(!m_change_thread) { + if (!m_change_thread) { return; } @@ -48,7 +50,7 @@ void ParseThread::stop() void ParseThread::queue_parse_request(ParseThreadTaskFunc&& task) { - std::unique_lock lk{ m_mutex }; + std::unique_lock lk{m_mutex}; // add new entry m_queue.emplace_back(std::move(task)); m_cv.notify_one(); diff --git a/ctagsd/lib/Scanner.cpp b/ctagsd/lib/Scanner.cpp index 582b0a0d4e..0f29194d74 100644 --- a/ctagsd/lib/Scanner.cpp +++ b/ctagsd/lib/Scanner.cpp @@ -5,18 +5,23 @@ #include "Cxx/CxxTokenizer.h" #include "fileutils.h" -void Scanner::scan(const wxFileName& current_file, const wxArrayString& search_path, wxStringSet_t* includes_set, +void Scanner::scan(const wxFileName& current_file, + const wxArrayString& search_path, + wxStringSet_t* includes_set, wxStringSet_t* using_ns_set) { wxString content; - if(!FileUtils::ReadFileContent(current_file, content)) { + if (!FileUtils::ReadFileContent(current_file, content)) { return; } scan_buffer(current_file, content, search_path, includes_set, using_ns_set); } -void Scanner::scan_buffer(const wxFileName& current_file, const wxString& content, const wxArrayString& search_path, - wxStringSet_t* includes_set, wxStringSet_t* using_ns_set) +void Scanner::scan_buffer(const wxFileName& current_file, + const wxString& content, + const wxArrayString& search_path, + wxStringSet_t* includes_set, + wxStringSet_t* using_ns_set) { CxxTokenizer tokenizer; @@ -24,16 +29,16 @@ void Scanner::scan_buffer(const wxFileName& current_file, const wxString& conten wxStringSet_t seen_includes; tokenizer.Reset(content); CxxLexerToken token; - while(tokenizer.NextToken(token)) { - switch(token.GetType()) { + while (tokenizer.NextToken(token)) { + switch (token.GetType()) { case T_PP_INCLUDE_FILENAME: { std::set fixed_path; wxString include_line = fix_include_line(token.GetWXString()); - if(!include_line.empty() // valid include line - && seen_includes.count(include_line) == 0 && - IsFileExists(cur_file_dir, include_line, search_path, fixed_path)) { + if (!include_line.empty() // valid include line + && seen_includes.count(include_line) == 0 && + IsFileExists(cur_file_dir, include_line, search_path, fixed_path)) { seen_includes.insert(include_line); - for (const auto& path: fixed_path) { + for (const auto& path : fixed_path) { includes_set->insert(path); } } @@ -64,13 +69,15 @@ static wxString fix_separators_to_platform(const wxString& str) return s; } -bool Scanner::IsFileExists(const wxString& current_dir, const wxString& name, const wxArrayString& search_path, +bool Scanner::IsFileExists(const wxString& current_dir, + const wxString& name, + const wxArrayString& search_path, std::set& fixed_path) { - if(m_missing_includes.count(name)) + if (m_missing_includes.count(name)) return false; - if(m_matches.count(name)) { + if (m_matches.count(name)) { fixed_path = m_matches[name]; return true; } @@ -79,26 +86,26 @@ bool Scanner::IsFileExists(const wxString& current_dir, const wxString& name, co wxString fullpath = current_dir + DIR_SEP + name; fullpath = fix_separators_to_platform(fullpath); - if(wxStat(fullpath, &buf) == 0) { + if (wxStat(fullpath, &buf) == 0) { wxFileName fn(fullpath); fn.MakeAbsolute(); fixed_path.insert(fn.GetFullPath()); } // try the search paths - for(const wxString& path : search_path) { + for (const wxString& path : search_path) { fullpath = path + DIR_SEP + name; fullpath = fix_separators_to_platform(fullpath); - if(wxStat(fullpath, &buf) == 0) { + if (wxStat(fullpath, &buf) == 0) { fixed_path.insert(fullpath); } } if (!fixed_path.empty()) { - m_matches.insert({ name, fixed_path }); + m_matches.insert({name, fixed_path}); return true; } - + m_missing_includes.insert(name); return false; } @@ -109,21 +116,21 @@ void Scanner::ParseUsingNamespace(CxxTokenizer& tokenizer, wxStringSet_t* using_ CxxLexerToken token; tokenizer.NextToken(token); - if(token.GetType() != T_NAMESPACE) + if (token.GetType() != T_NAMESPACE) return; // Read everything until we find the ';' wxString usingNamespace; - while(tokenizer.NextToken(token)) { - if(token.GetType() == ';') { + while (tokenizer.NextToken(token)) { + if (token.GetType() == ';') { break; } usingNamespace << token.GetText(); } - if(!usingNamespace.empty() && using_ns_set->count(usingNamespace) == 0) { - if(!usingNamespace.StartsWith("std::_") && !usingNamespace.Contains("GLIBCXX") && usingNamespace != "__pstl" && - usingNamespace != "__detail") { + if (!usingNamespace.empty() && using_ns_set->count(usingNamespace) == 0) { + if (!usingNamespace.StartsWith("std::_") && !usingNamespace.Contains("GLIBCXX") && usingNamespace != "__pstl" && + usingNamespace != "__detail") { using_ns_set->insert(usingNamespace); } } @@ -132,7 +139,7 @@ void Scanner::ParseUsingNamespace(CxxTokenizer& tokenizer, wxStringSet_t* using_ wxString Scanner::fix_include_line(const wxString& include_line) { // skip STL debug folders - if(include_line.StartsWith(" S{ m_search_path.begin(), m_search_path.end() }; + std::set S{m_search_path.begin(), m_search_path.end()}; if (compile_flags_txt.FileExists()) { // we are using the compile_flags.txt file method CompileFlagsTxt cft(compile_flags_txt); @@ -159,7 +159,7 @@ void CTagsdSettings::build_search_path(const wxFileName& filepath) // Common compiler paths - should be placed at top of the include path! if (const auto command = ThePlatform->Which(basename)) { - GCCMetadata md{ basename }; + GCCMetadata md{basename}; md.Load(*command, wxEmptyString, false); m_search_path.insert(m_search_path.end(), md.GetSearchPaths().begin(), md.GetSearchPaths().end()); diff --git a/ctagsd/lib/SimpleTokenizer.cpp b/ctagsd/lib/SimpleTokenizer.cpp index 29a2f6ff4c..8b25741393 100644 --- a/ctagsd/lib/SimpleTokenizer.cpp +++ b/ctagsd/lib/SimpleTokenizer.cpp @@ -7,45 +7,45 @@ SimpleTokenizer::SimpleTokenizer(const wxString& str) { } -#define __PEEK_LOOKAHEAD_N(__N, c) \ - if((m_pos + __N) < m_str.length()) { \ - c = m_str[m_pos + __N]; \ - } else { \ - c = 0; \ +#define __PEEK_LOOKAHEAD_N(__N, c) \ + if ((m_pos + __N) < m_str.length()) { \ + c = m_str[m_pos + __N]; \ + } else { \ + c = 0; \ } #define PEEK_LOOKAHEAD_1(c) __PEEK_LOOKAHEAD_N(1, c) #define PEEK_LOOKAHEAD_2(c) __PEEK_LOOKAHEAD_N(2, c) -#define PEEK_LOOKAHEAD_FIRST_NON_WHITESPACE(c) \ - { \ - \ - for(size_t __cur = m_pos; __cur < m_str.length(); ++__cur) { \ - if(m_str[__cur] != ' ' && m_str[__cur] != '\t' && m_str[__cur] != '\n' && m_str[__cur] != '\r') { \ - c = m_str[__cur]; \ - break; \ - } \ - } \ +#define PEEK_LOOKAHEAD_FIRST_NON_WHITESPACE(c) \ + { \ + \ + for (size_t __cur = m_pos; __cur < m_str.length(); ++__cur) { \ + if (m_str[__cur] != ' ' && m_str[__cur] != '\t' && m_str[__cur] != '\n' && m_str[__cur] != '\r') { \ + c = m_str[__cur]; \ + break; \ + } \ + } \ } -#define PEEK_LOOKAHEAD_FIRST_2_NON_WHITESPACE(c1, c2) \ - { \ - size_t __count_found = 0; \ - for(size_t __cur = m_pos; __cur < m_str.length(); ++__cur) { \ - if(m_str[__cur] != ' ' && m_str[__cur] != '\t' && m_str[__cur] != '\n' && m_str[__cur] != '\r') { \ - if(__count_found == 0) { \ - c1 = m_str[__cur]; \ - __count_found = 1; \ - } else { \ - c2 = m_str[__cur]; \ - break; \ - } \ - } \ - } \ +#define PEEK_LOOKAHEAD_FIRST_2_NON_WHITESPACE(c1, c2) \ + { \ + size_t __count_found = 0; \ + for (size_t __cur = m_pos; __cur < m_str.length(); ++__cur) { \ + if (m_str[__cur] != ' ' && m_str[__cur] != '\t' && m_str[__cur] != '\n' && m_str[__cur] != '\r') { \ + if (__count_found == 0) { \ + c1 = m_str[__cur]; \ + __count_found = 1; \ + } else { \ + c2 = m_str[__cur]; \ + break; \ + } \ + } \ + } \ } #define RETURN_TOKEN_IF_POSSIBLE() \ - if(m_token.ok()) { \ - if(!m_token.is_valid_identifier(m_str)) { \ + if (m_token.ok()) { \ + if (!m_token.is_valid_identifier(m_str)) { \ m_token.clear(); \ } else { \ *token = m_token; \ @@ -61,7 +61,7 @@ SimpleTokenizer::SimpleTokenizer(const wxString& str) } #define RETURN_COMMENT_TOKEN_IF_POSSIBLE() \ - if(m_token.ok()) { \ + if (m_token.ok()) { \ *token = m_token; \ m_token.clear(); \ ++m_pos; \ @@ -76,10 +76,10 @@ SimpleTokenizer::SimpleTokenizer(const wxString& str) m_line_start_pos = m_pos #define CHECK_TOKENIZER_MODE(expected_mode) \ - if(m_mode == TOKNZR_MODE_NONE) { \ + if (m_mode == TOKNZR_MODE_NONE) { \ m_mode = expected_mode; \ } \ - if(m_mode != expected_mode) { \ + if (m_mode != expected_mode) { \ return false; \ } @@ -88,11 +88,11 @@ bool SimpleTokenizer::next(SimpleTokenizer::Token* token) CHECK_TOKENIZER_MODE(TOKNZR_MODE_NORMAL); eSimpleTokenizerState escape_return_state = TOKNZR_STATE_DQUOTE_STRING; - for(; m_pos < m_str.length(); ++m_pos) { + for (; m_pos < m_str.length(); ++m_pos) { wxChar ch = m_str[m_pos]; - switch(m_state) { + switch (m_state) { case TOKNZR_STATE_PREPROCESSOR: - switch(ch) { + switch (ch) { case '\n': INCREMENT_LINE(); m_state = TOKNZR_STATE_NORMAL; @@ -103,16 +103,16 @@ bool SimpleTokenizer::next(SimpleTokenizer::Token* token) } break; case TOKNZR_STATE_NORMAL: - switch(ch) { + switch (ch) { case '#': m_state = TOKNZR_STATE_PREPROCESSOR; RETURN_TOKEN_IF_POSSIBLE(); break; case '/': - if(LOOKAHEAD_1('*')) { + if (LOOKAHEAD_1('*')) { ++m_pos; m_state = TOKNZR_STATE_MULTILINE_COMMENT; - } else if(LOOKAHEAD_1('/')) { + } else if (LOOKAHEAD_1('/')) { ++m_pos; m_state = TOKNZR_STATE_LINE_COMMENT; } @@ -185,7 +185,7 @@ bool SimpleTokenizer::next(SimpleTokenizer::Token* token) case '7': case '8': case '9': - if(m_token.ok()) { + if (m_token.ok()) { m_token.inc_length(); } else { // start a new token @@ -207,7 +207,7 @@ bool SimpleTokenizer::next(SimpleTokenizer::Token* token) } break; case TOKNZR_STATE_DQUOTE_STRING: - switch(ch) { + switch (ch) { case '"': m_state = TOKNZR_STATE_NORMAL; break; @@ -218,7 +218,7 @@ bool SimpleTokenizer::next(SimpleTokenizer::Token* token) } break; case TOKNZR_STATE_SINGLE_STRING: - switch(ch) { + switch (ch) { case '\'': m_state = TOKNZR_STATE_NORMAL; break; @@ -232,9 +232,9 @@ bool SimpleTokenizer::next(SimpleTokenizer::Token* token) m_state = escape_return_state; break; case TOKNZR_STATE_MULTILINE_COMMENT: - switch(ch) { + switch (ch) { case '*': - if(LOOKAHEAD_1('/')) { + if (LOOKAHEAD_1('/')) { ++m_pos; m_state = TOKNZR_STATE_NORMAL; } @@ -248,7 +248,7 @@ bool SimpleTokenizer::next(SimpleTokenizer::Token* token) } break; case TOKNZR_STATE_LINE_COMMENT: - switch(ch) { + switch (ch) { case '\n': INCREMENT_LINE(); m_state = TOKNZR_STATE_NORMAL; @@ -269,11 +269,11 @@ bool SimpleTokenizer::next_comment(Token* token) { CHECK_TOKENIZER_MODE(TOKNZR_MODE_COMMENTS); eSimpleTokenizerState escape_return_state = TOKNZR_STATE_DQUOTE_STRING; - for(; m_pos < m_str.length(); ++m_pos) { + for (; m_pos < m_str.length(); ++m_pos) { wxChar ch = m_str[m_pos]; - switch(m_state) { + switch (m_state) { case TOKNZR_STATE_PREPROCESSOR: - switch(ch) { + switch (ch) { case '\n': INCREMENT_LINE(); m_state = TOKNZR_STATE_NORMAL; @@ -284,21 +284,21 @@ bool SimpleTokenizer::next_comment(Token* token) } break; case TOKNZR_STATE_NORMAL: - switch(ch) { + switch (ch) { case '#': m_state = TOKNZR_STATE_PREPROCESSOR; break; case '/': - if(LOOKAHEAD_1('*')) { + if (LOOKAHEAD_1('*')) { // check for Javadoc or Qt style - if(LOOKAHEAD_2('*') || LOOKAHEAD_2('!')) { + if (LOOKAHEAD_2('*') || LOOKAHEAD_2('!')) { ++m_pos; } ++m_pos; m_state = TOKNZR_STATE_MULTILINE_COMMENT; m_token = Token(m_pos + 1, m_line, m_pos - m_line_start_pos, 0); - } else if(LOOKAHEAD_1('/')) { - if(LOOKAHEAD_2('/') || LOOKAHEAD_2('!')) { + } else if (LOOKAHEAD_1('/')) { + if (LOOKAHEAD_2('/') || LOOKAHEAD_2('!')) { ++m_pos; } ++m_pos; @@ -321,7 +321,7 @@ bool SimpleTokenizer::next_comment(Token* token) } break; case TOKNZR_STATE_DQUOTE_STRING: - switch(ch) { + switch (ch) { case '"': m_state = TOKNZR_STATE_NORMAL; break; @@ -332,7 +332,7 @@ bool SimpleTokenizer::next_comment(Token* token) } break; case TOKNZR_STATE_SINGLE_STRING: - switch(ch) { + switch (ch) { case '\'': m_state = TOKNZR_STATE_NORMAL; break; @@ -346,14 +346,14 @@ bool SimpleTokenizer::next_comment(Token* token) m_state = escape_return_state; break; case TOKNZR_STATE_MULTILINE_COMMENT: - switch(ch) { + switch (ch) { case '*': - if(LOOKAHEAD_1('*') && LOOKAHEAD_2('/')) { + if (LOOKAHEAD_1('*') && LOOKAHEAD_2('/')) { m_pos += 2; m_state = TOKNZR_STATE_NORMAL; m_token.set_line(m_line); RETURN_COMMENT_TOKEN_IF_POSSIBLE(); - } else if(LOOKAHEAD_1('/')) { + } else if (LOOKAHEAD_1('/')) { m_pos += 1; m_state = TOKNZR_STATE_NORMAL; m_token.set_line(m_line); @@ -371,7 +371,7 @@ bool SimpleTokenizer::next_comment(Token* token) } break; case TOKNZR_STATE_LINE_COMMENT: - switch(ch) { + switch (ch) { case '\n': m_token.set_line(m_line); INCREMENT_LINE(); @@ -398,16 +398,16 @@ void SimpleTokenizer::strip_comment(wxString& comment) { wxArrayString lines = ::wxStringTokenize(comment, "\n", wxTOKEN_STRTOK); comment.clear(); - for(auto& line : lines) { + for (auto& line : lines) { line.erase(0, line.find_first_not_of(LEFT_TRIM)); line.erase(line.find_last_not_of(RIGHT_TRIM) + 1); - if(line.empty()) { + if (line.empty()) { continue; } comment << line << "\n"; } - if(!comment.empty()) { + if (!comment.empty()) { comment.RemoveLast(); } } diff --git a/ctagsd/main.cpp b/ctagsd/main.cpp index b7be24cc5b..a5b73ea4cf 100644 --- a/ctagsd/main.cpp +++ b/ctagsd/main.cpp @@ -14,20 +14,20 @@ namespace { std::unordered_map function_table = { - { "initialize", &ProtocolHandler::on_initialize }, - { "initialized", &ProtocolHandler::on_initialized }, - { "textDocument/didOpen", &ProtocolHandler::on_did_open }, - { "textDocument/didChange", &ProtocolHandler::on_did_change }, - { "textDocument/completion", &ProtocolHandler::on_completion }, - { "textDocument/didClose", &ProtocolHandler::on_did_close }, - { "textDocument/didSave", &ProtocolHandler::on_did_save }, - { "textDocument/semanticTokens/full", &ProtocolHandler::on_semantic_tokens }, - { "textDocument/signatureHelp", &ProtocolHandler::on_document_signature_help }, - { "textDocument/definition", &ProtocolHandler::on_definition }, - { "textDocument/declaration", &ProtocolHandler::on_declaration }, - { "textDocument/hover", &ProtocolHandler::on_hover }, - { "textDocument/documentSymbol", &ProtocolHandler::on_document_symbol }, - { "workspace/symbol", &ProtocolHandler::on_workspace_symbol }, + {"initialize", &ProtocolHandler::on_initialize}, + {"initialized", &ProtocolHandler::on_initialized}, + {"textDocument/didOpen", &ProtocolHandler::on_did_open}, + {"textDocument/didChange", &ProtocolHandler::on_did_change}, + {"textDocument/completion", &ProtocolHandler::on_completion}, + {"textDocument/didClose", &ProtocolHandler::on_did_close}, + {"textDocument/didSave", &ProtocolHandler::on_did_save}, + {"textDocument/semanticTokens/full", &ProtocolHandler::on_semantic_tokens}, + {"textDocument/signatureHelp", &ProtocolHandler::on_document_signature_help}, + {"textDocument/definition", &ProtocolHandler::on_definition}, + {"textDocument/declaration", &ProtocolHandler::on_declaration}, + {"textDocument/hover", &ProtocolHandler::on_hover}, + {"textDocument/documentSymbol", &ProtocolHandler::on_document_symbol}, + {"workspace/symbol", &ProtocolHandler::on_workspace_symbol}, }; } @@ -48,7 +48,7 @@ int main(int argc, char** argv) parser.AddLongOption("log-level", "Log level, one of: ERR, WARN, DBG, TRACE"); parser.Parse(); - if(parser.Found("v")) { + if (parser.Found("v")) { wxPrintf("ctagsd v-%s\n", CTAGSD_VERSION); exit(0); } @@ -76,14 +76,14 @@ int main(int argc, char** argv) clSYSTEM() << "Started main loop" << endl; wxString message; - while(true) { + while (true) { auto msg = channel->read_message(); - if(!msg) { + if (!msg) { break; } auto json = msg->toElement(); wxString method = json["method"].toString(); - if(function_table.count(method) == 0) { + if (function_table.count(method) == 0) { LOG_IF_TRACE { clDEBUG1() << "Received unsupported method:" << method << endl; } protocol_handler.on_unsupported_message(std::move(msg), channel); } else {