From c65a5d04b1f31d0119f4322396dadabadc2d6b5f Mon Sep 17 00:00:00 2001 From: mlangkabel Date: Tue, 12 Jun 2018 21:16:51 +0200 Subject: [PATCH] logic: cleaned up code for SourceGroupSettings and Wizzard * Flattened sourcegroupsettings class hierarchy by moving cross compilation options to own base class * QtProjectWizzardContentFlags constructor required correct settings object to reduce the need for type casting * QtProjectWizzardContentPath constructors required correct settings objects * moved SourcePaths from SourceGroupSettingsJava to SourceGroupSettingsJavaEmpty because they are not required for Gradle and Maven projects * removed classpath from maven and gradle source group settings * reuse code of SourceGroup for "show source files" in wizard --- src/lib/CMakeLists.txt | 4 +- .../settings/SourceGroupSettingsCEmpty.cpp | 22 +- src/lib/settings/SourceGroupSettingsCEmpty.h | 12 +- .../settings/SourceGroupSettingsCppEmpty.cpp | 22 +- .../settings/SourceGroupSettingsCppEmpty.h | 12 +- src/lib/settings/SourceGroupSettingsJava.cpp | 13 +- src/lib/settings/SourceGroupSettingsJava.h | 5 - .../settings/SourceGroupSettingsJavaEmpty.cpp | 37 ++ .../settings/SourceGroupSettingsJavaEmpty.h | 12 + .../SourceGroupSettingsJavaGradle.cpp | 5 + .../settings/SourceGroupSettingsJavaGradle.h | 3 + .../settings/SourceGroupSettingsJavaMaven.cpp | 5 + .../settings/SourceGroupSettingsJavaMaven.h | 3 + ...ettingsWithCxxCrossCompilationOptions.cpp} | 92 ++-- ...pSettingsWithCxxCrossCompilationOptions.h} | 36 +- src/lib_cxx/project/SourceGroupCxxEmpty.cpp | 70 ++- src/lib_cxx/project/SourceGroupCxxEmpty.h | 6 +- .../project/SourceGroupFactoryModuleCxx.cpp | 9 +- .../project_wizzard/QtProjectWizzard.cpp | 169 ++++--- ...tWizzardContentCrossCompilationOptions.cpp | 38 +- ...ectWizzardContentCrossCompilationOptions.h | 6 +- .../QtProjectWizzardContentExtensions.cpp | 3 +- .../QtProjectWizzardContentExtensions.h | 5 +- .../QtProjectWizzardContentFlags.cpp | 14 +- .../QtProjectWizzardContentFlags.h | 6 +- .../QtProjectWizzardContentPath.cpp | 456 ++++++++---------- .../QtProjectWizzardContentPath.h | 123 +++-- .../QtProjectWizzardContentPaths.cpp | 55 +-- src/lib_java/project/SourceGroupJavaEmpty.cpp | 2 +- .../project/SourceGroupJavaGradle.cpp | 6 +- src/lib_java/project/SourceGroupJavaMaven.cpp | 2 +- .../project/SourceGroupJavaSonargraph.cpp | 5 +- src/lib_java/utility/utilityJava.cpp | 6 +- src/lib_java/utility/utilityJava.h | 3 +- 34 files changed, 697 insertions(+), 570 deletions(-) rename src/lib/settings/{SourceGroupSettingsCxxEmpty.cpp => SourceGroupSettingsWithCxxCrossCompilationOptions.cpp} (54%) rename src/lib/settings/{SourceGroupSettingsCxxEmpty.h => SourceGroupSettingsWithCxxCrossCompilationOptions.h} (50%) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index f7fdd0c5..97ab22e6 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -324,8 +324,6 @@ add_files( settings/SourceGroupSettingsCxxCdb.h settings/SourceGroupSettingsCxxCodeblocks.cpp settings/SourceGroupSettingsCxxCodeblocks.h - settings/SourceGroupSettingsCxxEmpty.cpp - settings/SourceGroupSettingsCxxEmpty.h settings/SourceGroupSettingsCxxSonargraph.cpp settings/SourceGroupSettingsCxxSonargraph.h settings/SourceGroupSettingsJava.cpp @@ -344,6 +342,8 @@ add_files( settings/SourceGroupSettingsWithCppStandard.h settings/SourceGroupSettingsWithCStandard.cpp settings/SourceGroupSettingsWithCStandard.h + settings/SourceGroupSettingsWithCxxCrossCompilationOptions.cpp + settings/SourceGroupSettingsWithCxxCrossCompilationOptions.h settings/SourceGroupSettingsWithExcludeFilters.cpp settings/SourceGroupSettingsWithExcludeFilters.h settings/SourceGroupSettingsWithIndexedHeaderPaths.cpp diff --git a/src/lib/settings/SourceGroupSettingsCEmpty.cpp b/src/lib/settings/SourceGroupSettingsCEmpty.cpp index ecf53b0f..b0b4ce76 100644 --- a/src/lib/settings/SourceGroupSettingsCEmpty.cpp +++ b/src/lib/settings/SourceGroupSettingsCEmpty.cpp @@ -1,26 +1,34 @@ #include "settings/SourceGroupSettingsCEmpty.h" SourceGroupSettingsCEmpty::SourceGroupSettingsCEmpty(const std::string& id, const ProjectSettings* projectSettings) - : SourceGroupSettingsCxxEmpty(id, SOURCE_GROUP_C_EMPTY, projectSettings) + : SourceGroupSettingsCxx(id, SOURCE_GROUP_C_EMPTY, projectSettings) { } void SourceGroupSettingsCEmpty::load(std::shared_ptr config) { - SourceGroupSettingsCxxEmpty::load(config); + SourceGroupSettingsCxx::load(config); const std::string key = s_keyPrefix + getId(); SourceGroupSettingsWithCStandard::load(config, key); + SourceGroupSettingsWithCxxCrossCompilationOptions::load(config, key); + SourceGroupSettingsWithSourceExtensions::load(config, key); + SourceGroupSettingsWithSourcePaths::load(config, key); + SourceGroupSettingsWithExcludeFilters::load(config, key); } void SourceGroupSettingsCEmpty::save(std::shared_ptr config) { - SourceGroupSettingsCxxEmpty::save(config); + SourceGroupSettingsCxx::save(config); const std::string key = s_keyPrefix + getId(); SourceGroupSettingsWithCStandard::save(config, key); + SourceGroupSettingsWithCxxCrossCompilationOptions::save(config, key); + SourceGroupSettingsWithSourceExtensions::save(config, key); + SourceGroupSettingsWithSourcePaths::save(config, key); + SourceGroupSettingsWithExcludeFilters::save(config, key); } bool SourceGroupSettingsCEmpty::equals(std::shared_ptr other) const @@ -29,8 +37,12 @@ bool SourceGroupSettingsCEmpty::equals(std::shared_ptr othe return ( otherCxxEmpty && - SourceGroupSettingsCxxEmpty::equals(other) && - SourceGroupSettingsWithCStandard::equals(otherCxxEmpty) + SourceGroupSettingsCxx::equals(other) && + SourceGroupSettingsWithCStandard::equals(otherCxxEmpty) && + SourceGroupSettingsWithCxxCrossCompilationOptions::equals(otherCxxEmpty) && + SourceGroupSettingsWithSourceExtensions::equals(otherCxxEmpty) && + SourceGroupSettingsWithSourcePaths::equals(otherCxxEmpty) && + SourceGroupSettingsWithExcludeFilters::equals(otherCxxEmpty) ); } diff --git a/src/lib/settings/SourceGroupSettingsCEmpty.h b/src/lib/settings/SourceGroupSettingsCEmpty.h index f0e38a05..2500e686 100644 --- a/src/lib/settings/SourceGroupSettingsCEmpty.h +++ b/src/lib/settings/SourceGroupSettingsCEmpty.h @@ -1,12 +1,20 @@ #ifndef SOURCE_GROUP_SETTINGS_C_EMPTY_H #define SOURCE_GROUP_SETTINGS_C_EMPTY_H -#include "settings/SourceGroupSettingsCxxEmpty.h" +#include "settings/SourceGroupSettingsCxx.h" #include "settings/SourceGroupSettingsWithCStandard.h" +#include "settings/SourceGroupSettingsWithCxxCrossCompilationOptions.h" +#include "settings/SourceGroupSettingsWithExcludeFilters.h" +#include "settings/SourceGroupSettingsWithSourceExtensions.h" +#include "settings/SourceGroupSettingsWithSourcePaths.h" class SourceGroupSettingsCEmpty - : public SourceGroupSettingsCxxEmpty + : public SourceGroupSettingsCxx , public SourceGroupSettingsWithCStandard + , public SourceGroupSettingsWithCxxCrossCompilationOptions + , public SourceGroupSettingsWithExcludeFilters + , public SourceGroupSettingsWithSourceExtensions + , public SourceGroupSettingsWithSourcePaths { public: SourceGroupSettingsCEmpty(const std::string& id, const ProjectSettings* projectSettings); diff --git a/src/lib/settings/SourceGroupSettingsCppEmpty.cpp b/src/lib/settings/SourceGroupSettingsCppEmpty.cpp index c6e86fc5..e354f7a6 100644 --- a/src/lib/settings/SourceGroupSettingsCppEmpty.cpp +++ b/src/lib/settings/SourceGroupSettingsCppEmpty.cpp @@ -1,26 +1,34 @@ #include "settings/SourceGroupSettingsCppEmpty.h" SourceGroupSettingsCppEmpty::SourceGroupSettingsCppEmpty(const std::string& id, const ProjectSettings* projectSettings) - : SourceGroupSettingsCxxEmpty(id, SOURCE_GROUP_CPP_EMPTY, projectSettings) + : SourceGroupSettingsCxx(id, SOURCE_GROUP_CPP_EMPTY, projectSettings) { } void SourceGroupSettingsCppEmpty::load(std::shared_ptr config) { - SourceGroupSettingsCxxEmpty::load(config); + SourceGroupSettingsCxx::load(config); const std::string key = s_keyPrefix + getId(); SourceGroupSettingsWithCppStandard::load(config, key); + SourceGroupSettingsWithCxxCrossCompilationOptions::load(config, key); + SourceGroupSettingsWithSourceExtensions::load(config, key); + SourceGroupSettingsWithSourcePaths::load(config, key); + SourceGroupSettingsWithExcludeFilters::load(config, key); } void SourceGroupSettingsCppEmpty::save(std::shared_ptr config) { - SourceGroupSettingsCxxEmpty::save(config); + SourceGroupSettingsCxx::save(config); const std::string key = s_keyPrefix + getId(); SourceGroupSettingsWithCppStandard::save(config, key); + SourceGroupSettingsWithCxxCrossCompilationOptions::save(config, key); + SourceGroupSettingsWithSourceExtensions::save(config, key); + SourceGroupSettingsWithSourcePaths::save(config, key); + SourceGroupSettingsWithExcludeFilters::save(config, key); } bool SourceGroupSettingsCppEmpty::equals(std::shared_ptr other) const @@ -29,8 +37,12 @@ bool SourceGroupSettingsCppEmpty::equals(std::shared_ptr ot return ( otherCxxEmpty && - SourceGroupSettingsCxxEmpty::equals(other) && - SourceGroupSettingsWithCppStandard::equals(otherCxxEmpty) + SourceGroupSettingsCxx::equals(other) && + SourceGroupSettingsWithCppStandard::equals(otherCxxEmpty) && + SourceGroupSettingsWithCxxCrossCompilationOptions::equals(otherCxxEmpty) && + SourceGroupSettingsWithSourceExtensions::equals(otherCxxEmpty) && + SourceGroupSettingsWithSourcePaths::equals(otherCxxEmpty) && + SourceGroupSettingsWithExcludeFilters::equals(otherCxxEmpty) ); } diff --git a/src/lib/settings/SourceGroupSettingsCppEmpty.h b/src/lib/settings/SourceGroupSettingsCppEmpty.h index 34a339f1..5a4155d0 100644 --- a/src/lib/settings/SourceGroupSettingsCppEmpty.h +++ b/src/lib/settings/SourceGroupSettingsCppEmpty.h @@ -1,12 +1,20 @@ #ifndef SOURCE_GROUP_SETTINGS_CPP_EMPTY_H #define SOURCE_GROUP_SETTINGS_CPP_EMPTY_H -#include "settings/SourceGroupSettingsCxxEmpty.h" +#include "settings/SourceGroupSettingsCxx.h" #include "settings/SourceGroupSettingsWithCppStandard.h" +#include "settings/SourceGroupSettingsWithCxxCrossCompilationOptions.h" +#include "settings/SourceGroupSettingsWithExcludeFilters.h" +#include "settings/SourceGroupSettingsWithSourceExtensions.h" +#include "settings/SourceGroupSettingsWithSourcePaths.h" class SourceGroupSettingsCppEmpty - : public SourceGroupSettingsCxxEmpty + : public SourceGroupSettingsCxx , public SourceGroupSettingsWithCppStandard + , public SourceGroupSettingsWithCxxCrossCompilationOptions + , public SourceGroupSettingsWithExcludeFilters + , public SourceGroupSettingsWithSourceExtensions + , public SourceGroupSettingsWithSourcePaths { public: SourceGroupSettingsCppEmpty(const std::string& id, const ProjectSettings* projectSettings); diff --git a/src/lib/settings/SourceGroupSettingsJava.cpp b/src/lib/settings/SourceGroupSettingsJava.cpp index ac35b942..6b440704 100644 --- a/src/lib/settings/SourceGroupSettingsJava.cpp +++ b/src/lib/settings/SourceGroupSettingsJava.cpp @@ -12,10 +12,8 @@ void SourceGroupSettingsJava::load(std::shared_ptr config) const std::string key = s_keyPrefix + getId(); SourceGroupSettingsWithSourceExtensions::load(config, key); - SourceGroupSettingsWithSourcePaths::load(config, key); SourceGroupSettingsWithExcludeFilters::load(config, key); SourceGroupSettingsWithJavaStandard::load(config, key); - SourceGroupSettingsWithClasspath::load(config, key); } void SourceGroupSettingsJava::save(std::shared_ptr config) @@ -25,10 +23,8 @@ void SourceGroupSettingsJava::save(std::shared_ptr config) const std::string key = s_keyPrefix + getId(); SourceGroupSettingsWithSourceExtensions::save(config, key); - SourceGroupSettingsWithSourcePaths::save(config, key); SourceGroupSettingsWithExcludeFilters::save(config, key); SourceGroupSettingsWithJavaStandard::save(config, key); - SourceGroupSettingsWithClasspath::save(config, key); } bool SourceGroupSettingsJava::equals(std::shared_ptr other) const @@ -39,18 +35,11 @@ bool SourceGroupSettingsJava::equals(std::shared_ptr other) otherJava && SourceGroupSettings::equals(other) && SourceGroupSettingsWithSourceExtensions::equals(otherJava) && - SourceGroupSettingsWithSourcePaths::equals(otherJava) && SourceGroupSettingsWithExcludeFilters::equals(otherJava) && - SourceGroupSettingsWithJavaStandard::equals(otherJava) && - SourceGroupSettingsWithClasspath::equals(otherJava) + SourceGroupSettingsWithJavaStandard::equals(otherJava) ); } -const ProjectSettings* SourceGroupSettingsJava::getProjectSettings() const -{ - return m_projectSettings; -} - std::vector SourceGroupSettingsJava::getDefaultSourceExtensions() const { return { L".java" }; diff --git a/src/lib/settings/SourceGroupSettingsJava.h b/src/lib/settings/SourceGroupSettingsJava.h index 94d6c672..ce9ad3d4 100644 --- a/src/lib/settings/SourceGroupSettingsJava.h +++ b/src/lib/settings/SourceGroupSettingsJava.h @@ -5,19 +5,15 @@ #include #include "settings/SourceGroupSettings.h" -#include "settings/SourceGroupSettingsWithClasspath.h" #include "settings/SourceGroupSettingsWithExcludeFilters.h" #include "settings/SourceGroupSettingsWithJavaStandard.h" #include "settings/SourceGroupSettingsWithSourceExtensions.h" -#include "settings/SourceGroupSettingsWithSourcePaths.h" class SourceGroupSettingsJava : public SourceGroupSettings , public SourceGroupSettingsWithSourceExtensions - , public SourceGroupSettingsWithSourcePaths , public SourceGroupSettingsWithExcludeFilters , public SourceGroupSettingsWithJavaStandard - , public SourceGroupSettingsWithClasspath { public: SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings); @@ -28,7 +24,6 @@ public: bool equals(std::shared_ptr other) const override; private: - const ProjectSettings* getProjectSettings() const override; std::vector getDefaultSourceExtensions() const override; }; diff --git a/src/lib/settings/SourceGroupSettingsJavaEmpty.cpp b/src/lib/settings/SourceGroupSettingsJavaEmpty.cpp index 0a3d2706..7d9abe0f 100644 --- a/src/lib/settings/SourceGroupSettingsJavaEmpty.cpp +++ b/src/lib/settings/SourceGroupSettingsJavaEmpty.cpp @@ -4,3 +4,40 @@ SourceGroupSettingsJavaEmpty::SourceGroupSettingsJavaEmpty(const std::string& id : SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_EMPTY, projectSettings) { } + +void SourceGroupSettingsJavaEmpty::load(std::shared_ptr config) +{ + SourceGroupSettings::load(config); + + const std::string key = s_keyPrefix + getId(); + + SourceGroupSettingsWithSourcePaths::load(config, key); + SourceGroupSettingsWithClasspath::load(config, key); +} + +void SourceGroupSettingsJavaEmpty::save(std::shared_ptr config) +{ + SourceGroupSettings::save(config); + + const std::string key = s_keyPrefix + getId(); + + SourceGroupSettingsWithSourcePaths::save(config, key); + SourceGroupSettingsWithClasspath::save(config, key); +} + +bool SourceGroupSettingsJavaEmpty::equals(std::shared_ptr other) const +{ + std::shared_ptr otherJava = std::dynamic_pointer_cast(other); + + return ( + otherJava && + SourceGroupSettingsJava::equals(other) && + SourceGroupSettingsWithSourcePaths::equals(otherJava) && + SourceGroupSettingsWithClasspath::equals(otherJava) + ); +} + +const ProjectSettings* SourceGroupSettingsJavaEmpty::getProjectSettings() const +{ + return m_projectSettings; +} diff --git a/src/lib/settings/SourceGroupSettingsJavaEmpty.h b/src/lib/settings/SourceGroupSettingsJavaEmpty.h index 5e8cf13f..4e50deec 100644 --- a/src/lib/settings/SourceGroupSettingsJavaEmpty.h +++ b/src/lib/settings/SourceGroupSettingsJavaEmpty.h @@ -2,12 +2,24 @@ #define SOURCE_GROUP_SETTINGS_JAVA_EMPTY_H #include "settings/SourceGroupSettingsJava.h" +#include "settings/SourceGroupSettingsWithClasspath.h" +#include "settings/SourceGroupSettingsWithSourcePaths.h" class SourceGroupSettingsJavaEmpty : public SourceGroupSettingsJava + , public SourceGroupSettingsWithSourcePaths + , public SourceGroupSettingsWithClasspath { public: SourceGroupSettingsJavaEmpty(const std::string& id, const ProjectSettings* projectSettings); + + void load(std::shared_ptr config) override; + void save(std::shared_ptr config) override; + + bool equals(std::shared_ptr other) const override; + +private: + const ProjectSettings* getProjectSettings() const override; }; #endif // SOURCE_GROUP_SETTINGS_JAVA_EMPTY_H diff --git a/src/lib/settings/SourceGroupSettingsJavaGradle.cpp b/src/lib/settings/SourceGroupSettingsJavaGradle.cpp index 89721e08..469f5780 100644 --- a/src/lib/settings/SourceGroupSettingsJavaGradle.cpp +++ b/src/lib/settings/SourceGroupSettingsJavaGradle.cpp @@ -85,3 +85,8 @@ void SourceGroupSettingsJavaGradle::setShouldIndexGradleTests(bool value) { m_shouldIndexGradleTests = value; } + +const ProjectSettings* SourceGroupSettingsJavaGradle::getProjectSettings() const +{ + return m_projectSettings; +} diff --git a/src/lib/settings/SourceGroupSettingsJavaGradle.h b/src/lib/settings/SourceGroupSettingsJavaGradle.h index ae0d1909..341f0227 100644 --- a/src/lib/settings/SourceGroupSettingsJavaGradle.h +++ b/src/lib/settings/SourceGroupSettingsJavaGradle.h @@ -2,6 +2,7 @@ #define SOURCE_GROUP_SETTINGS_JAVA_GRADLE_H #include "settings/SourceGroupSettingsJava.h" +#include "utility/file/FilePath.h" class SourceGroupSettingsJavaGradle : public SourceGroupSettingsJava @@ -26,6 +27,8 @@ public: void setShouldIndexGradleTests(bool value); private: + const ProjectSettings* getProjectSettings() const override; + FilePath m_gradleProjectFilePath; FilePath m_gradleDependenciesDirectory; bool m_shouldIndexGradleTests; diff --git a/src/lib/settings/SourceGroupSettingsJavaMaven.cpp b/src/lib/settings/SourceGroupSettingsJavaMaven.cpp index 22640ebb..a2878999 100644 --- a/src/lib/settings/SourceGroupSettingsJavaMaven.cpp +++ b/src/lib/settings/SourceGroupSettingsJavaMaven.cpp @@ -85,3 +85,8 @@ void SourceGroupSettingsJavaMaven::setShouldIndexMavenTests(bool value) { m_shouldIndexMavenTests = value; } + +const ProjectSettings* SourceGroupSettingsJavaMaven::getProjectSettings() const +{ + return m_projectSettings; +} diff --git a/src/lib/settings/SourceGroupSettingsJavaMaven.h b/src/lib/settings/SourceGroupSettingsJavaMaven.h index 6329a0ac..2a22c760 100644 --- a/src/lib/settings/SourceGroupSettingsJavaMaven.h +++ b/src/lib/settings/SourceGroupSettingsJavaMaven.h @@ -2,6 +2,7 @@ #define SOURCE_GROUP_SETTINGS_JAVA_MAVEN_H #include "settings/SourceGroupSettingsJava.h" +#include "utility/file/FilePath.h" class SourceGroupSettingsJavaMaven : public SourceGroupSettingsJava @@ -26,6 +27,8 @@ public: void setShouldIndexMavenTests(bool value); private: + const ProjectSettings* getProjectSettings() const override; + FilePath m_mavenProjectFilePath; FilePath m_mavenDependenciesDirectory; bool m_shouldIndexMavenTests; diff --git a/src/lib/settings/SourceGroupSettingsCxxEmpty.cpp b/src/lib/settings/SourceGroupSettingsWithCxxCrossCompilationOptions.cpp similarity index 54% rename from src/lib/settings/SourceGroupSettingsCxxEmpty.cpp rename to src/lib/settings/SourceGroupSettingsWithCxxCrossCompilationOptions.cpp index 0ed091a5..42c704ba 100644 --- a/src/lib/settings/SourceGroupSettingsCxxEmpty.cpp +++ b/src/lib/settings/SourceGroupSettingsWithCxxCrossCompilationOptions.cpp @@ -1,12 +1,11 @@ -#include "settings/SourceGroupSettingsCxxEmpty.h" +#include "settings/SourceGroupSettingsWithCxxCrossCompilationOptions.h" -#include "utility/ConfigManager.h" -#include "utility/utility.h" -#include "utility/utilityApp.h" +#include "settings/ProjectSettings.h" -std::vector SourceGroupSettingsCxxEmpty::getAvailableArchTypes() + +std::vector SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableArchTypes() { - return { + return{ L"aarch64", L"aarch64_be", L"arm", @@ -58,9 +57,9 @@ std::vector SourceGroupSettingsCxxEmpty::getAvailableArchTypes() }; } -std::vector SourceGroupSettingsCxxEmpty::getAvailableVendorTypes() +std::vector SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableVendorTypes() { - return { + return{ L"unknown", L"apple", L"pc", @@ -79,9 +78,9 @@ std::vector SourceGroupSettingsCxxEmpty::getAvailableVendorTypes() }; } -std::vector SourceGroupSettingsCxxEmpty::getAvailableOsTypes() +std::vector SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableOsTypes() { - return { + return{ L"unknown", L"cloudabi", L"darwin", @@ -116,9 +115,9 @@ std::vector SourceGroupSettingsCxxEmpty::getAvailableOsTypes() }; } -std::vector SourceGroupSettingsCxxEmpty::getAvailableEnvironmentTypes() +std::vector SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableEnvironmentTypes() { - return { + return{ L"unknown", L"gnu", L"gnuabi64", @@ -141,9 +140,8 @@ std::vector SourceGroupSettingsCxxEmpty::getAvailableEnvironmentTy }; } -SourceGroupSettingsCxxEmpty::SourceGroupSettingsCxxEmpty(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings) - : SourceGroupSettingsCxx(id, type, projectSettings) - , m_targetOptionsEnabled(false) +SourceGroupSettingsWithCxxCrossCompilationOptions::SourceGroupSettingsWithCxxCrossCompilationOptions() + : m_targetOptionsEnabled(false) , m_targetArch(L"") , m_targetVendor(L"") , m_targetSys(L"") @@ -151,16 +149,16 @@ SourceGroupSettingsCxxEmpty::SourceGroupSettingsCxxEmpty(const std::string& id, { } -void SourceGroupSettingsCxxEmpty::load(std::shared_ptr config) +bool SourceGroupSettingsWithCxxCrossCompilationOptions::equals(std::shared_ptr other) const { - SourceGroupSettingsCxx::load(config); - - const std::string key = s_keyPrefix + getId(); - - SourceGroupSettingsWithSourceExtensions::load(config, key); - SourceGroupSettingsWithSourcePaths::load(config, key); - SourceGroupSettingsWithExcludeFilters::load(config, key); + return ( + other && + getTargetFlag() == other->getTargetFlag() + ); +} +void SourceGroupSettingsWithCxxCrossCompilationOptions::load(std::shared_ptr config, const std::string& key) +{ setTargetOptionsEnabled(config->getValueOrDefault(key + "/cross_compilation/target_options_enabled", false)); setTargetArch(config->getValueOrDefault(key + "/cross_compilation/target/arch", L"")); setTargetVendor(config->getValueOrDefault(key + "/cross_compilation/target/vendor", L"")); @@ -168,16 +166,8 @@ void SourceGroupSettingsCxxEmpty::load(std::shared_ptr conf setTargetAbi(config->getValueOrDefault(key + "/cross_compilation/target/abi", L"")); } -void SourceGroupSettingsCxxEmpty::save(std::shared_ptr config) +void SourceGroupSettingsWithCxxCrossCompilationOptions::save(std::shared_ptr config, const std::string& key) { - SourceGroupSettingsCxx::save(config); - - const std::string key = s_keyPrefix + getId(); - - SourceGroupSettingsWithSourceExtensions::save(config, key); - SourceGroupSettingsWithSourcePaths::save(config, key); - SourceGroupSettingsWithExcludeFilters::save(config, key); - config->setValue(key + "/cross_compilation/target_options_enabled", getTargetOptionsEnabled()); config->setValue(key + "/cross_compilation/target/arch", getTargetArch()); config->setValue(key + "/cross_compilation/target/vendor", getTargetVendor()); @@ -185,71 +175,57 @@ void SourceGroupSettingsCxxEmpty::save(std::shared_ptr config) config->setValue(key + "/cross_compilation/target/abi", getTargetAbi()); } -bool SourceGroupSettingsCxxEmpty::equals(std::shared_ptr other) const -{ - std::shared_ptr otherCxxEmpty = std::dynamic_pointer_cast(other); - - return ( - otherCxxEmpty && - SourceGroupSettingsCxx::equals(other) && - SourceGroupSettingsWithSourceExtensions::equals(otherCxxEmpty) && - SourceGroupSettingsWithSourcePaths::equals(otherCxxEmpty) && - SourceGroupSettingsWithExcludeFilters::equals(otherCxxEmpty) && - getTargetFlag() == otherCxxEmpty->getTargetFlag() - ); -} - -bool SourceGroupSettingsCxxEmpty::getTargetOptionsEnabled() const +bool SourceGroupSettingsWithCxxCrossCompilationOptions::getTargetOptionsEnabled() const { return m_targetOptionsEnabled; } -void SourceGroupSettingsCxxEmpty::setTargetOptionsEnabled(bool targetOptionsEnabled) +void SourceGroupSettingsWithCxxCrossCompilationOptions::setTargetOptionsEnabled(bool targetOptionsEnabled) { m_targetOptionsEnabled = targetOptionsEnabled; } -std::wstring SourceGroupSettingsCxxEmpty::getTargetArch() const +std::wstring SourceGroupSettingsWithCxxCrossCompilationOptions::getTargetArch() const { return m_targetArch; } -void SourceGroupSettingsCxxEmpty::setTargetArch(const std::wstring& arch) +void SourceGroupSettingsWithCxxCrossCompilationOptions::setTargetArch(const std::wstring& arch) { m_targetArch = arch; } -std::wstring SourceGroupSettingsCxxEmpty::getTargetVendor() const +std::wstring SourceGroupSettingsWithCxxCrossCompilationOptions::getTargetVendor() const { return m_targetVendor; } -void SourceGroupSettingsCxxEmpty::setTargetVendor(const std::wstring& vendor) +void SourceGroupSettingsWithCxxCrossCompilationOptions::setTargetVendor(const std::wstring& vendor) { m_targetVendor = vendor; } -std::wstring SourceGroupSettingsCxxEmpty::getTargetSys() const +std::wstring SourceGroupSettingsWithCxxCrossCompilationOptions::getTargetSys() const { return m_targetSys; } -void SourceGroupSettingsCxxEmpty::setTargetSys(const std::wstring& sys) +void SourceGroupSettingsWithCxxCrossCompilationOptions::setTargetSys(const std::wstring& sys) { m_targetSys = sys; } -std::wstring SourceGroupSettingsCxxEmpty::getTargetAbi() const +std::wstring SourceGroupSettingsWithCxxCrossCompilationOptions::getTargetAbi() const { return m_targetAbi; } -void SourceGroupSettingsCxxEmpty::setTargetAbi(const std::wstring& abi) +void SourceGroupSettingsWithCxxCrossCompilationOptions::setTargetAbi(const std::wstring& abi) { m_targetAbi = abi; } -std::wstring SourceGroupSettingsCxxEmpty::getTargetFlag() const +std::wstring SourceGroupSettingsWithCxxCrossCompilationOptions::getTargetFlag() const { std::wstring targetFlag = L""; if (m_targetOptionsEnabled && !m_targetArch.empty()) @@ -261,4 +237,4 @@ std::wstring SourceGroupSettingsCxxEmpty::getTargetFlag() const targetFlag += L"-" + (m_targetAbi.empty() ? L"unknown" : m_targetAbi); } return targetFlag; -} \ No newline at end of file +} diff --git a/src/lib/settings/SourceGroupSettingsCxxEmpty.h b/src/lib/settings/SourceGroupSettingsWithCxxCrossCompilationOptions.h similarity index 50% rename from src/lib/settings/SourceGroupSettingsCxxEmpty.h rename to src/lib/settings/SourceGroupSettingsWithCxxCrossCompilationOptions.h index 07580380..fad5f6f1 100644 --- a/src/lib/settings/SourceGroupSettingsCxxEmpty.h +++ b/src/lib/settings/SourceGroupSettingsWithCxxCrossCompilationOptions.h @@ -1,16 +1,14 @@ -#ifndef SOURCE_GROUP_SETTINGS_CXX_EMPTY_H -#define SOURCE_GROUP_SETTINGS_CXX_EMPTY_H +#ifndef SOURCE_GROUP_SETTINGS_WITH_CXX_CROSS_COMPILATION_OPTIONS_H +#define SOURCE_GROUP_SETTINGS_WITH_CXX_CROSS_COMPILATION_OPTIONS_H -#include "settings/SourceGroupSettingsCxx.h" -#include "settings/SourceGroupSettingsWithExcludeFilters.h" -#include "settings/SourceGroupSettingsWithSourceExtensions.h" -#include "settings/SourceGroupSettingsWithSourcePaths.h" +#include +#include +#include -class SourceGroupSettingsCxxEmpty - : public SourceGroupSettingsCxx - , public SourceGroupSettingsWithExcludeFilters - , public SourceGroupSettingsWithSourceExtensions - , public SourceGroupSettingsWithSourcePaths +class ConfigManager; +class ProjectSettings; + +class SourceGroupSettingsWithCxxCrossCompilationOptions { public: static std::vector getAvailableArchTypes(); @@ -18,12 +16,10 @@ public: static std::vector getAvailableOsTypes(); static std::vector getAvailableEnvironmentTypes(); - SourceGroupSettingsCxxEmpty(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings); + SourceGroupSettingsWithCxxCrossCompilationOptions(); + virtual ~SourceGroupSettingsWithCxxCrossCompilationOptions() = default; - void load(std::shared_ptr config) override; - void save(std::shared_ptr config) override; - - bool equals(std::shared_ptr other) const override; + bool equals(std::shared_ptr other) const; bool getTargetOptionsEnabled() const; void setTargetOptionsEnabled(bool targetOptionsEnabled); @@ -42,7 +38,13 @@ public: std::wstring getTargetFlag() const; +protected: + void load(std::shared_ptr config, const std::string& key); + void save(std::shared_ptr config, const std::string& key); + private: + virtual const ProjectSettings* getProjectSettings() const = 0; + bool m_targetOptionsEnabled; std::wstring m_targetArch; std::wstring m_targetVendor; @@ -50,4 +52,4 @@ private: std::wstring m_targetAbi; }; -#endif // SOURCE_GROUP_SETTINGS_CXX_EMPTY_H +#endif // SOURCE_GROUP_SETTINGS_WITH_CXX_CROSS_COMPILATION_OPTIONS_H diff --git a/src/lib_cxx/project/SourceGroupCxxEmpty.cpp b/src/lib_cxx/project/SourceGroupCxxEmpty.cpp index e5101283..04b03024 100644 --- a/src/lib_cxx/project/SourceGroupCxxEmpty.cpp +++ b/src/lib_cxx/project/SourceGroupCxxEmpty.cpp @@ -2,13 +2,14 @@ #include "data/indexer/IndexerCommandCxxEmpty.h" #include "settings/ApplicationSettings.h" -#include "settings/SourceGroupSettingsCxxEmpty.h" +#include "settings/SourceGroupSettingsCEmpty.h" +#include "settings/SourceGroupSettingsCppEmpty.h" #include "settings/SourceGroupSettingsWithCppStandard.h" #include "settings/SourceGroupSettingsWithCStandard.h" #include "utility/file/FileManager.h" #include "utility/utility.h" -SourceGroupCxxEmpty::SourceGroupCxxEmpty(std::shared_ptr settings) +SourceGroupCxxEmpty::SourceGroupCxxEmpty(std::shared_ptr settings) : m_settings(settings) { } @@ -18,8 +19,21 @@ std::set SourceGroupCxxEmpty::filterToContainedFilePaths(const std::se std::set containedFilePaths; const std::set allSourceFilePaths = getAllSourceFilePaths(); - const std::vector indexedPaths = m_settings->getSourcePathsExpandedAndAbsolute(); - const std::vector excludeFilters = m_settings->getExcludeFiltersExpandedAndAbsolute(); + + std::vector indexedPaths; + std::vector excludeFilters; + if (std::shared_ptr settings = + std::dynamic_pointer_cast(m_settings)) + { + indexedPaths = settings->getSourcePathsExpandedAndAbsolute(); + excludeFilters = settings->getExcludeFiltersExpandedAndAbsolute(); + } + else if (std::shared_ptr settings = + std::dynamic_pointer_cast(m_settings)) + { + indexedPaths = settings->getSourcePathsExpandedAndAbsolute(); + excludeFilters = settings->getExcludeFiltersExpandedAndAbsolute(); + } for (const FilePath& filePath : filePaths) { @@ -56,11 +70,25 @@ std::set SourceGroupCxxEmpty::filterToContainedFilePaths(const std::se std::set SourceGroupCxxEmpty::getAllSourceFilePaths() const { FileManager fileManager; - fileManager.update( - m_settings->getSourcePathsExpandedAndAbsolute(), - m_settings->getExcludeFiltersExpandedAndAbsolute(), - m_settings->getSourceExtensions() - ); + if (std::shared_ptr settings = + std::dynamic_pointer_cast(m_settings)) + { + fileManager.update( + settings->getSourcePathsExpandedAndAbsolute(), + settings->getExcludeFiltersExpandedAndAbsolute(), + settings->getSourceExtensions() + ); + } + else if (std::shared_ptr settings = + std::dynamic_pointer_cast(m_settings)) + { + fileManager.update( + settings->getSourcePathsExpandedAndAbsolute(), + settings->getExcludeFiltersExpandedAndAbsolute(), + settings->getSourceExtensions() + ); + } + return fileManager.getAllSourceFilePaths(); } @@ -70,8 +98,26 @@ std::vector> SourceGroupCxxEmpty::getIndexerComm std::vector systemHeaderSearchPaths; + std::set indexedPaths; + std::set excludeFilters; + std::wstring targetFlag; + if (std::shared_ptr settings = + std::dynamic_pointer_cast(m_settings)) + { + indexedPaths = utility::toSet(settings->getSourcePathsExpandedAndAbsolute()); + excludeFilters = utility::toSet(settings->getExcludeFiltersExpandedAndAbsolute()); + targetFlag = settings->getTargetFlag(); + } + else if (std::shared_ptr settings = + std::dynamic_pointer_cast(m_settings)) + { + indexedPaths = utility::toSet(settings->getSourcePathsExpandedAndAbsolute()); + excludeFilters = utility::toSet(settings->getExcludeFiltersExpandedAndAbsolute()); + targetFlag = settings->getTargetFlag(); + } + // Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files. - for (const FilePath& sourcePath: m_settings->getSourcePathsExpandedAndAbsolute()) + for (const FilePath& sourcePath: indexedPaths) { if (sourcePath.isDirectory()) { @@ -88,7 +134,6 @@ std::vector> SourceGroupCxxEmpty::getIndexerComm std::vector compilerFlags; { - const std::wstring targetFlag = m_settings->getTargetFlag(); if (!targetFlag.empty()) { compilerFlags.push_back(targetFlag); @@ -97,9 +142,6 @@ std::vector> SourceGroupCxxEmpty::getIndexerComm utility::append(compilerFlags, m_settings->getCompilerFlags()); - const std::set indexedPaths = utility::toSet(m_settings->getSourcePathsExpandedAndAbsolute()); - const std::set excludeFilters = utility::toSet(m_settings->getExcludeFiltersExpandedAndAbsolute()); - std::string languageStandard = SourceGroupSettingsWithCppStandard::getDefaultCppStandardStatic(); if (std::shared_ptr cSettings = std::dynamic_pointer_cast(m_settings)) diff --git a/src/lib_cxx/project/SourceGroupCxxEmpty.h b/src/lib_cxx/project/SourceGroupCxxEmpty.h index a5c0b106..8065b646 100644 --- a/src/lib_cxx/project/SourceGroupCxxEmpty.h +++ b/src/lib_cxx/project/SourceGroupCxxEmpty.h @@ -6,12 +6,12 @@ #include "project/SourceGroup.h" -class SourceGroupSettingsCxxEmpty; +class SourceGroupSettingsCxx; class SourceGroupCxxEmpty: public SourceGroup { public: - SourceGroupCxxEmpty(std::shared_ptr settings); + SourceGroupCxxEmpty(std::shared_ptr settings); std::set filterToContainedFilePaths(const std::set& filePaths) const override; std::set getAllSourceFilePaths() const override; @@ -21,7 +21,7 @@ private: std::shared_ptr getSourceGroupSettings() override; std::shared_ptr getSourceGroupSettings() const override; - std::shared_ptr m_settings; + std::shared_ptr m_settings; }; #endif // SOURCE_GROUP_CXX_EMPTY_H diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleCxx.cpp b/src/lib_cxx/project/SourceGroupFactoryModuleCxx.cpp index ef5108a7..d3233c7d 100644 --- a/src/lib_cxx/project/SourceGroupFactoryModuleCxx.cpp +++ b/src/lib_cxx/project/SourceGroupFactoryModuleCxx.cpp @@ -6,7 +6,8 @@ #include "project/SourceGroupCxxSonargraph.h" #include "settings/SourceGroupSettingsCxxCdb.h" #include "settings/SourceGroupSettingsCxxCodeblocks.h" -#include "settings/SourceGroupSettingsCxxEmpty.h" +#include "settings/SourceGroupSettingsCEmpty.h" +#include "settings/SourceGroupSettingsCppEmpty.h" #include "settings/SourceGroupSettingsCxxSonargraph.h" SourceGroupFactoryModuleCxx::~SourceGroupFactoryModuleCxx() @@ -40,7 +41,11 @@ std::shared_ptr SourceGroupFactoryModuleCxx::createSourceGroup(std: { sourceGroup = std::shared_ptr(new SourceGroupCxxCodeblocks(cxxSettings)); } - else if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(settings)) + else if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(settings)) + { + sourceGroup = std::shared_ptr(new SourceGroupCxxEmpty(cxxSettings)); + } + else if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(settings)) { sourceGroup = std::shared_ptr(new SourceGroupCxxEmpty(cxxSettings)); } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index 0823a201..860b4906 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -441,15 +441,15 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index) { if (std::shared_ptr settingsJavaGradle = std::dynamic_pointer_cast(group)) { - summary->addContent(new QtProjectWizzardContentPathSourceGradle(group, this)); + summary->addContent(new QtProjectWizzardContentPathSourceGradle(settingsJavaGradle, this)); summary->addSpace(); - summary->addContent(new QtProjectWizzardContentPathDependenciesGradle(group, this)); + summary->addContent(new QtProjectWizzardContentPathDependenciesGradle(settingsJavaGradle, this)); } else if (std::shared_ptr settingsJavaMaven = std::dynamic_pointer_cast(group)) { - summary->addContent(new QtProjectWizzardContentPathSourceMaven(group, this)); + summary->addContent(new QtProjectWizzardContentPathSourceMaven(settingsJavaMaven, this)); summary->addSpace(); - summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(group, this)); + summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(settingsJavaMaven, this)); } summary->addSpace(); @@ -462,44 +462,44 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index) { summary->addContent(new QtProjectWizzardContentJavaStandard(settingsJavaSonargraph, this)); summary->addSpace(); - summary->addContent(new QtProjectWizzardContentSonargraphProjectPath(group, this)); + summary->addContent(new QtProjectWizzardContentSonargraphProjectPath( + settingsJavaSonargraph, std::shared_ptr(), settingsJavaSonargraph, this + )); summary->addSpace(); summary->addContent(new QtProjectWizzardContentPathsClassJava(group, this)); - summary->addSpace(); - } else if (std::shared_ptr settingsCxx = std::dynamic_pointer_cast(group)) { bool indicateSearchPathsAsAdditional = false; - if (std::shared_ptr settingsCxxEmpty = std::dynamic_pointer_cast(group)) + if (std::shared_ptr settingsCEmpty = std::dynamic_pointer_cast(group)) { - if (std::shared_ptr settingsCEmpty = std::dynamic_pointer_cast(group)) - { - summary->addContent(new QtProjectWizzardContentCStandard(settingsCEmpty, this)); - } - else if (std::shared_ptr settingsCppEmpty = std::dynamic_pointer_cast(group)) - { - summary->addContent(new QtProjectWizzardContentCppStandard(settingsCppEmpty, this)); - } + summary->addContent(new QtProjectWizzardContentCStandard(settingsCEmpty, this)); summary->addSpace(); - summary->addContent(new QtProjectWizzardContentCrossCompilationOptions(group, this)); + summary->addContent(new QtProjectWizzardContentCrossCompilationOptions(settingsCEmpty, this)); summary->addSpace(); - summary->addContent(new QtProjectWizzardContentPathsSource(group, this)); summary->addContent(new QtProjectWizzardContentPathsExclude(group, this)); - summary->addContent(new QtProjectWizzardContentExtensions(settingsCxxEmpty, this)); + summary->addContent(new QtProjectWizzardContentExtensions(settingsCEmpty, this)); + } + else if (std::shared_ptr settingsCppEmpty = std::dynamic_pointer_cast(group)) + { + summary->addContent(new QtProjectWizzardContentCppStandard(settingsCppEmpty, this)); summary->addSpace(); + summary->addContent(new QtProjectWizzardContentCrossCompilationOptions(settingsCppEmpty, this)); + summary->addSpace(); + summary->addContent(new QtProjectWizzardContentPathsSource(group, this)); + summary->addContent(new QtProjectWizzardContentPathsExclude(group, this)); + summary->addContent(new QtProjectWizzardContentExtensions(settingsCppEmpty, this)); } else if (std::shared_ptr settingsCxxCdb = std::dynamic_pointer_cast(group)) { indicateSearchPathsAsAdditional = true; - summary->addContent(new QtProjectWizzardContentPathCDB(group, this)); + summary->addContent(new QtProjectWizzardContentPathCDB(settingsCxxCdb, this)); summary->addSpace(); summary->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Compilation Database", group, this)); summary->addContent(new QtProjectWizzardContentPathsExclude(group, this)); - summary->addSpace(); } else if (std::shared_ptr settingsCxxCodeblocks = std::dynamic_pointer_cast(group)) { @@ -513,7 +513,6 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index) summary->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Code::Blocks project", settingsCxxCodeblocks, this)); summary->addSpace(); summary->addContent(new QtProjectWizzardContentExtensions(settingsCxxCodeblocks, this)); - summary->addSpace(); } else if (std::shared_ptr settingsCxxSonargraph = std::dynamic_pointer_cast(group)) { @@ -521,12 +520,12 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index) summary->addContent(new QtProjectWizzardContentCppStandard(settingsCxxSonargraph, this)); summary->addSpace(); - summary->addContent(new QtProjectWizzardContentSonargraphProjectPath(group, this)); + summary->addContent(new QtProjectWizzardContentSonargraphProjectPath(settingsCxxSonargraph, settingsCxxSonargraph, settingsCxxSonargraph, this)); summary->addSpace(); summary->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Sonargraph project", group, this)); - summary->addSpace(); } + summary->addSpace(); summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(group, this, indicateSearchPathsAsAdditional)); summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(this)); @@ -539,7 +538,7 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index) summary->addSpace(); } - summary->addContent(new QtProjectWizzardContentFlags(group, this, indicateSearchPathsAsAdditional)); + summary->addContent(new QtProjectWizzardContentFlags(settingsCxx, this, indicateSearchPathsAsAdditional)); } setContent(summary); @@ -822,10 +821,11 @@ void QtProjectWizzard::emptySourceGroup() { contentGroup->addContent(new QtProjectWizzardContentJavaStandard(settingsJavaEmpty, this)); } - if (m_newSourceGroupSettings->getType() == SOURCE_GROUP_C_EMPTY || - m_newSourceGroupSettings->getType() == SOURCE_GROUP_CPP_EMPTY) + + if (std::shared_ptr settingsCrossCompile = + std::dynamic_pointer_cast(m_newSourceGroupSettings)) { - contentGroup->addContent(new QtProjectWizzardContentCrossCompilationOptions(m_newSourceGroupSettings, window)); + contentGroup->addContent(new QtProjectWizzardContentCrossCompilationOptions(settingsCrossCompile, window)); window->setPreferredSize(QSize(470, 460)); } else @@ -852,12 +852,15 @@ void QtProjectWizzard::emptySourceGroupCDBVS() QtProjectWizzardWindow* window = createWindowWithContentGroup( [this](QtProjectWizzardWindow* window, QtProjectWizzardContentGroup* contentGroup) { - contentGroup->addContent(new QtProjectWizzardContentVS(window)); - contentGroup->addContent(new QtProjectWizzardContentPathCDB(m_newSourceGroupSettings, window)); - contentGroup->addSpace(); - contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Compilation Database", m_newSourceGroupSettings, window)); - contentGroup->addSpace(); - contentGroup->addContent(new QtProjectWizzardContentPathsExclude(m_newSourceGroupSettings, window)); + if (std::shared_ptr settings = std::dynamic_pointer_cast(m_newSourceGroupSettings)) + { + contentGroup->addContent(new QtProjectWizzardContentVS(window)); + contentGroup->addContent(new QtProjectWizzardContentPathCDB(settings, window)); + contentGroup->addSpace(); + contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Compilation Database", m_newSourceGroupSettings, window)); + contentGroup->addSpace(); + contentGroup->addContent(new QtProjectWizzardContentPathsExclude(m_newSourceGroupSettings, window)); + } } ); @@ -870,11 +873,14 @@ void QtProjectWizzard::emptySourceGroupCDB() QtProjectWizzardWindow* window = createWindowWithContentGroup( [this](QtProjectWizzardWindow* window, QtProjectWizzardContentGroup* contentGroup) { - contentGroup->addContent(new QtProjectWizzardContentPathCDB(m_newSourceGroupSettings, window)); - contentGroup->addSpace(); - contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Compilation Database", m_newSourceGroupSettings, window)); - contentGroup->addSpace(); - contentGroup->addContent(new QtProjectWizzardContentPathsExclude(m_newSourceGroupSettings, window)); + if (std::shared_ptr settings = std::dynamic_pointer_cast(m_newSourceGroupSettings)) + { + contentGroup->addContent(new QtProjectWizzardContentPathCDB(settings, window)); + contentGroup->addSpace(); + contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Compilation Database", m_newSourceGroupSettings, window)); + contentGroup->addSpace(); + contentGroup->addContent(new QtProjectWizzardContentPathsExclude(m_newSourceGroupSettings, window)); + } } ); @@ -914,7 +920,7 @@ void QtProjectWizzard::emptySourceGroupCxxSonargraph() { contentGroup->addContent(new QtProjectWizzardContentCppStandard(settings, this)); contentGroup->addSpace(); - contentGroup->addContent(new QtProjectWizzardContentSonargraphProjectPath(m_newSourceGroupSettings, window)); + contentGroup->addContent(new QtProjectWizzardContentSonargraphProjectPath(settings, settings, settings, window)); contentGroup->addSpace(); contentGroup->addContent(new QtProjectWizzardContentIndexedHeaderPaths("Sonargraph project", m_newSourceGroupSettings, window)); } @@ -934,12 +940,14 @@ void QtProjectWizzard::emptySourceGroupJavaSonargraph() { contentGroup->addContent(new QtProjectWizzardContentJavaStandard(settings, this)); contentGroup->addSpace(); - contentGroup->addContent(new QtProjectWizzardContentSonargraphProjectPath(m_newSourceGroupSettings, window)); + contentGroup->addContent(new QtProjectWizzardContentSonargraphProjectPath( + settings, std::shared_ptr(), settings, window) + ); } } ); - connect(window, &QtProjectWizzardWindow::next, this, &QtProjectWizzard::createSourceGroup); + connect(window, &QtProjectWizzardWindow::next, this, &QtProjectWizzard::dependenciesJava); window->updateSubTitle("Sonargraph Project Path"); } @@ -953,12 +961,12 @@ void QtProjectWizzard::sourcePaths() contentGroup->addContent(new QtProjectWizzardContentPathsSource(settingsCxx, window)); contentGroup->addSpace(); contentGroup->addContent(new QtProjectWizzardContentPathsExclude(settingsCxx, window)); - if (std::shared_ptr settingsSourceExtension = - std::dynamic_pointer_cast(m_newSourceGroupSettings)) - { - contentGroup->addSpace(); - contentGroup->addContent(new QtProjectWizzardContentExtensions(settingsSourceExtension, window)); - } + } + if (std::shared_ptr settingsSourceExtension = + std::dynamic_pointer_cast(m_newSourceGroupSettings)) + { + contentGroup->addSpace(); + contentGroup->addContent(new QtProjectWizzardContentExtensions(settingsSourceExtension, window)); } } ); @@ -1044,21 +1052,29 @@ void QtProjectWizzard::dependenciesJava() void QtProjectWizzard::sourcePathsJavaMaven() { - std::dynamic_pointer_cast(m_newSourceGroupSettings)->setMavenDependenciesDirectory( - FilePath( - L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") + - L"/" + - utility::decodeFromUtf8(m_newSourceGroupSettings->getId()) + - L"/maven" - ) - ); + if (std::shared_ptr settingsJavaMaven = std::dynamic_pointer_cast(m_newSourceGroupSettings)) + { + settingsJavaMaven->setMavenDependenciesDirectory( + FilePath( + L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") + + L"/" + + utility::decodeFromUtf8(m_newSourceGroupSettings->getId()) + + L"/maven" + ) + ); + } QtProjectWizzardWindow* window = createWindowWithContentGroup( [this](QtProjectWizzardWindow* window, QtProjectWizzardContentGroup* contentGroup) { - contentGroup->addContent(new QtProjectWizzardContentPathSourceMaven(m_newSourceGroupSettings, window)); - contentGroup->addSpace(); - contentGroup->addContent(new QtProjectWizzardContentPathDependenciesMaven(m_newSourceGroupSettings, window)); + if (std::shared_ptr settingsJavaMaven = std::dynamic_pointer_cast(m_newSourceGroupSettings)) + { + contentGroup->addContent(new QtProjectWizzardContentJavaStandard(settingsJavaMaven, this)); + contentGroup->addSpace(); + contentGroup->addContent(new QtProjectWizzardContentPathSourceMaven(settingsJavaMaven, window)); + contentGroup->addSpace(); + contentGroup->addContent(new QtProjectWizzardContentPathDependenciesMaven(settingsJavaMaven, window)); + } } ); @@ -1068,21 +1084,29 @@ void QtProjectWizzard::sourcePathsJavaMaven() void QtProjectWizzard::sourcePathsJavaGradle() { - std::dynamic_pointer_cast(m_newSourceGroupSettings)->setGradleDependenciesDirectory( - FilePath( - L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") + - L"/" + - utility::decodeFromUtf8(m_newSourceGroupSettings->getId()) + - L"/gradle" - ) - ); + if (std::shared_ptr settingsJavaGradle = std::dynamic_pointer_cast(m_newSourceGroupSettings)) + { + settingsJavaGradle->setGradleDependenciesDirectory( + FilePath( + L"./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), L" ", L"_") + + L"/" + + utility::decodeFromUtf8(m_newSourceGroupSettings->getId()) + + L"/gradle" + ) + ); + } QtProjectWizzardWindow* window = createWindowWithContentGroup( [this](QtProjectWizzardWindow* window, QtProjectWizzardContentGroup* contentGroup) { - contentGroup->addContent(new QtProjectWizzardContentPathSourceGradle(m_newSourceGroupSettings, window)); - contentGroup->addSpace(); - contentGroup->addContent(new QtProjectWizzardContentPathDependenciesGradle(m_newSourceGroupSettings, window)); + if (std::shared_ptr settingsJavaGradle = std::dynamic_pointer_cast(m_newSourceGroupSettings)) + { + contentGroup->addContent(new QtProjectWizzardContentJavaStandard(settingsJavaGradle, this)); + contentGroup->addSpace(); + contentGroup->addContent(new QtProjectWizzardContentPathSourceGradle(settingsJavaGradle, window)); + contentGroup->addSpace(); + contentGroup->addContent(new QtProjectWizzardContentPathDependenciesGradle(settingsJavaGradle, window)); + } } ); @@ -1095,7 +1119,10 @@ void QtProjectWizzard::advancedSettingsCxx() QtProjectWizzardWindow* window = createWindowWithContentGroup( [this](QtProjectWizzardWindow* window, QtProjectWizzardContentGroup* contentGroup) { - contentGroup->addContent(new QtProjectWizzardContentFlags(m_newSourceGroupSettings, window)); + if (std::shared_ptr settings = std::dynamic_pointer_cast(m_newSourceGroupSettings)) + { + contentGroup->addContent(new QtProjectWizzardContentFlags(settings, window)); + } } ); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp index 8fe42127..b37f1e70 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp @@ -4,11 +4,11 @@ #include #include -#include "settings/SourceGroupSettingsCxxEmpty.h" +#include "settings/SourceGroupSettingsWithCxxCrossCompilationOptions.h" #include "utility/logging/logging.h" QtProjectWizzardContentCrossCompilationOptions::QtProjectWizzardContentCrossCompilationOptions( - std::shared_ptr sourceGroupSettings, + std::shared_ptr sourceGroupSettings, QtProjectWizzardWindow* window ) : QtProjectWizzardContent(window) @@ -61,7 +61,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou QLabel* label = new QLabel("Architecture:"); m_arch = new QComboBox(); - std::vector archTypes = SourceGroupSettingsCxxEmpty::getAvailableArchTypes(); + std::vector archTypes = SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableArchTypes(); std::sort(archTypes.begin(), archTypes.end()); for (size_t i = 0; i < archTypes.size(); i++) { @@ -77,7 +77,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou QLabel* label = new QLabel("Vendor:"); m_vendor = new QComboBox(); - std::vector vendorTypes = SourceGroupSettingsCxxEmpty::getAvailableVendorTypes(); + std::vector vendorTypes = SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableVendorTypes(); std::sort(vendorTypes.begin() + 1, vendorTypes.end()); for (size_t i = 0; i < vendorTypes.size(); i++) { @@ -92,7 +92,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou QLabel* label = new QLabel("OS:"); m_sys = new QComboBox(); - std::vector osTypes = SourceGroupSettingsCxxEmpty::getAvailableOsTypes(); + std::vector osTypes = SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableOsTypes(); std::sort(osTypes.begin() + 1, osTypes.end()); for (size_t i = 0; i < osTypes.size(); i++) { @@ -107,7 +107,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou QLabel* label = new QLabel("Environment:"); m_abi = new QComboBox(); - std::vector environmentTypes = SourceGroupSettingsCxxEmpty::getAvailableEnvironmentTypes(); + std::vector environmentTypes = SourceGroupSettingsWithCxxCrossCompilationOptions::getAvailableEnvironmentTypes(); std::sort(environmentTypes.begin() + 1, environmentTypes.end()); for (size_t i = 0; i < environmentTypes.size(); i++) { @@ -129,28 +129,22 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou void QtProjectWizzardContentCrossCompilationOptions::load() { - if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_sourceGroupSettings)) - { - m_useTargetOptions->setChecked(cxxSettings->getTargetOptionsEnabled()); - m_arch->setCurrentText(QString::fromStdWString(cxxSettings->getTargetArch())); - m_vendor->setCurrentText(QString::fromStdWString(cxxSettings->getTargetVendor())); - m_sys->setCurrentText(QString::fromStdWString(cxxSettings->getTargetSys())); - m_abi->setCurrentText(QString::fromStdWString(cxxSettings->getTargetAbi())); - } + m_useTargetOptions->setChecked(m_sourceGroupSettings->getTargetOptionsEnabled()); + m_arch->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getTargetArch())); + m_vendor->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getTargetVendor())); + m_sys->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getTargetSys())); + m_abi->setCurrentText(QString::fromStdWString(m_sourceGroupSettings->getTargetAbi())); updateTargetOptionsEnabled(); } void QtProjectWizzardContentCrossCompilationOptions::save() { - if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_sourceGroupSettings)) - { - cxxSettings->setTargetOptionsEnabled(m_useTargetOptions->isChecked()); - cxxSettings->setTargetArch(m_arch->currentText().toStdWString()); - cxxSettings->setTargetVendor(m_vendor->currentText().toStdWString()); - cxxSettings->setTargetSys(m_sys->currentText().toStdWString()); - cxxSettings->setTargetAbi(m_abi->currentText().toStdWString()); - } + m_sourceGroupSettings->setTargetOptionsEnabled(m_useTargetOptions->isChecked()); + m_sourceGroupSettings->setTargetArch(m_arch->currentText().toStdWString()); + m_sourceGroupSettings->setTargetVendor(m_vendor->currentText().toStdWString()); + m_sourceGroupSettings->setTargetSys(m_sys->currentText().toStdWString()); + m_sourceGroupSettings->setTargetAbi(m_abi->currentText().toStdWString()); } bool QtProjectWizzardContentCrossCompilationOptions::check() diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h index d5829841..5ea00ecf 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.h @@ -6,7 +6,7 @@ class QCheckBox; class QComboBox; class QLabel; -class SourceGroupSettings; +class SourceGroupSettingsWithCxxCrossCompilationOptions; class QtProjectWizzardContentCrossCompilationOptions : public QtProjectWizzardContent @@ -15,7 +15,7 @@ class QtProjectWizzardContentCrossCompilationOptions public: QtProjectWizzardContentCrossCompilationOptions( - std::shared_ptr sourceGroupSettings, + std::shared_ptr sourceGroupSettings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation @@ -29,7 +29,7 @@ private: void onUseTargetOptionsChanged(); void updateTargetOptionsEnabled(); - std::shared_ptr m_sourceGroupSettings; + std::shared_ptr m_sourceGroupSettings; QCheckBox* m_useTargetOptions; QComboBox* m_arch; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp index 6601c6c6..f2ae0b5e 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.cpp @@ -6,7 +6,8 @@ #include "qt/element/QtStringListBox.h" QtProjectWizzardContentExtensions::QtProjectWizzardContentExtensions( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, + QtProjectWizzardWindow* window ) : QtProjectWizzardContent(window) , m_settings(settings) diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h index 89b72936..2011be69 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentExtensions.h @@ -14,7 +14,10 @@ class QtProjectWizzardContentExtensions Q_OBJECT public: - QtProjectWizzardContentExtensions(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentExtensions( + std::shared_ptr settings, + QtProjectWizzardWindow* window + ); // QtProjectWizzardContent implementation virtual void populate(QGridLayout* layout, int& row) override; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp index e498d0b9..65f73750 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.cpp @@ -6,7 +6,7 @@ #include "qt/element/QtStringListBox.h" #include "settings/SourceGroupSettingsCxx.h" -QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(std::shared_ptr settings, QtProjectWizzardWindow* window, bool indicateAsAdditional) +QtProjectWizzardContentFlags::QtProjectWizzardContentFlags(std::shared_ptr settings, QtProjectWizzardWindow* window, bool indicateAsAdditional) : QtProjectWizzardContent(window) , m_settings(settings) , m_indicateAsAdditional(indicateAsAdditional) @@ -35,20 +35,12 @@ void QtProjectWizzardContentFlags::populate(QGridLayout* layout, int& row) void QtProjectWizzardContentFlags::load() { - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); - if (cxxSettings) - { - m_list->setStrings(cxxSettings->getCompilerFlags()); - } + m_list->setStrings(m_settings->getCompilerFlags()); } void QtProjectWizzardContentFlags::save() { - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); - if (cxxSettings) - { - cxxSettings->setCompilerFlags(m_list->getStrings()); - } + m_settings->setCompilerFlags(m_list->getStrings()); } bool QtProjectWizzardContentFlags::check() diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h index 92c46992..7e1c95df 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentFlags.h @@ -4,7 +4,7 @@ #include "qt/window/project_wizzard/QtProjectWizzardContent.h" class QtStringListBox; -class SourceGroupSettings; +class SourceGroupSettingsCxx; class QtProjectWizzardContentFlags : public QtProjectWizzardContent @@ -12,7 +12,7 @@ class QtProjectWizzardContentFlags Q_OBJECT public: - QtProjectWizzardContentFlags(std::shared_ptr settings, QtProjectWizzardWindow* window, bool indicateAsAdditional = false); + QtProjectWizzardContentFlags(std::shared_ptr settings, QtProjectWizzardWindow* window, bool indicateAsAdditional = false); // QtProjectWizzardContent implementation virtual void populate(QGridLayout* layout, int& row) override; @@ -22,7 +22,7 @@ public: virtual bool check() override; private: - std::shared_ptr m_settings; + std::shared_ptr m_settings; const bool m_indicateAsAdditional; QtStringListBox* m_list; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp index 9cc38ff2..1eebf02c 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp @@ -8,6 +8,11 @@ #include "data/indexer/IndexerCommandCxxCdb.h" #include "project/SourceGroupCxxCdb.h" +#include "project/SourceGroupCxxCodeblocks.h" +#include "project/SourceGroupCxxSonargraph.h" +#include "project/SourceGroupJavaSonargraph.h" +#include "project/SourceGroupJavaGradle.h" +#include "project/SourceGroupJavaMaven.h" #include "qt/element/QtLocationPicker.h" #include "qt/view/QtDialogView.h" #include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h" @@ -16,21 +21,20 @@ #include "settings/SourceGroupSettingsCxxSonargraph.h" #include "settings/SourceGroupSettingsJavaMaven.h" #include "settings/SourceGroupSettingsJavaGradle.h" +#include "settings/SourceGroupSettingsJavaSonargraph.h" #include "settings/SourceGroupSettingsWithSonargraphProjectPath.h" #include "settings/SourceGroupSettingsCxxCodeblocks.h" #include "utility/file/FileManager.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/sonargraph/SonargraphProject.h" -#include "utility/codeblocks/CodeblocksProject.h" #include "utility/ScopedFunctor.h" #include "utility/utility.h" #include "utility/utilityGradle.h" #include "utility/utilityMaven.h" #include "Application.h" -QtProjectWizzardContentPath::QtProjectWizzardContentPath(std::shared_ptr settings, QtProjectWizzardWindow* window) +QtProjectWizzardContentPath::QtProjectWizzardContentPath(QtProjectWizzardWindow* window) : QtProjectWizzardContent(window) - , m_settings(settings) , m_makePathRelativeToProjectFileLocation(true) { } @@ -50,7 +54,7 @@ void QtProjectWizzardContentPath::populate(QGridLayout* layout, int& row) if (m_makePathRelativeToProjectFileLocation) { - m_picker->setRelativeRootDirectory(m_settings->getProjectDirectoryPath()); + m_picker->setRelativeRootDirectory(getSourceGroupSettings()->getProjectDirectoryPath()); } layout->addWidget(m_picker, row, QtProjectWizzardWindow::BACK_COL); @@ -69,7 +73,7 @@ bool QtProjectWizzardContentPath::check() break; } - FilePath path = m_settings->makePathExpandedAndAbsolute(FilePath(m_picker->getText().toStdWString())); + FilePath path = getSourceGroupSettings()->makePathExpandedAndAbsolute(FilePath(m_picker->getText().toStdWString())); if (m_picker->pickDirectory()) { @@ -119,9 +123,10 @@ void QtProjectWizzardContentPath::setFileEndings(const std::set& f QtProjectWizzardContentPathCDB::QtProjectWizzardContentPathCDB( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) - : QtProjectWizzardContentPath(settings, window) + : QtProjectWizzardContentPath(window) + , m_settings(settings) { setTitleString("Compilation Database (compile_commands.json)"); setHelpString( @@ -164,39 +169,30 @@ void QtProjectWizzardContentPathCDB::populate(QGridLayout* layout, int& row) void QtProjectWizzardContentPathCDB::load() { + m_picker->setText(QString::fromStdWString(m_settings->getCompilationDatabasePath().wstr())); + m_filePaths.clear(); const FilePath projectPath = m_settings->getProjectDirectoryPath(); - - if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings)) + for (FilePath path : SourceGroupCxxCdb(m_settings).getAllSourceFilePaths()) { - m_picker->setText(QString::fromStdWString(cxxSettings->getCompilationDatabasePath().wstr())); - - for (FilePath path : SourceGroupCxxCdb(cxxSettings).getAllSourceFilePaths()) + if (projectPath.exists()) { - if (projectPath.exists()) - { - path.makeRelativeTo(projectPath); - } - - m_filePaths.push_back(path); + path.makeRelativeTo(projectPath); } - if (m_fileCountLabel) - { - m_fileCountLabel->setText("" + QString::number(m_filePaths.size()) + " source files were found in the compilation database."); - } + m_filePaths.push_back(path); + } + + if (m_fileCountLabel) + { + m_fileCountLabel->setText("" + QString::number(m_filePaths.size()) + " source files were found in the compilation database."); } } void QtProjectWizzardContentPathCDB::save() { - std::shared_ptr settings = - std::dynamic_pointer_cast(m_settings); - if (settings) - { - settings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdWString())); - } + m_settings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdWString())); } std::vector QtProjectWizzardContentPathCDB::getFilePaths() const @@ -220,29 +216,32 @@ void QtProjectWizzardContentPathCDB::pickedPath() { m_window->saveContent(); - if (std::shared_ptr cdbSettings = std::dynamic_pointer_cast(m_settings)) - { - const FilePath projectPath = m_settings->getProjectDirectoryPath(); + const FilePath projectPath = m_settings->getProjectDirectoryPath(); - std::set indexedHeaderPaths; - for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCDB(cdbSettings)) + std::set indexedHeaderPaths; + for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCDB(m_settings)) + { + if (projectPath.contains(path)) { - if (projectPath.contains(path)) - { - indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); - } + indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); } - cdbSettings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); } + m_settings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); m_window->loadContent(); } +std::shared_ptr QtProjectWizzardContentPathCDB::getSourceGroupSettings() +{ + return m_settings; +} + QtProjectWizzardContentCodeblocksProjectPath::QtProjectWizzardContentCodeblocksProjectPath( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) - : QtProjectWizzardContentPath(settings, window) + : QtProjectWizzardContentPath(window) + , m_settings(settings) { setTitleString("Code::Blocks Project (.cbp)"); setHelpString( @@ -284,40 +283,30 @@ void QtProjectWizzardContentCodeblocksProjectPath::populate(QGridLayout* layout, void QtProjectWizzardContentCodeblocksProjectPath::load() { + m_picker->setText(QString::fromStdWString(m_settings->getCodeblocksProjectPath().wstr())); + m_filePaths.clear(); - std::shared_ptr settings = - std::dynamic_pointer_cast(m_settings); - if (settings) + const FilePath projectPath = m_settings->getProjectDirectoryPath(); + for (FilePath path : SourceGroupCxxCodeblocks(m_settings).getAllSourceFilePaths()) { - m_picker->setText(QString::fromStdWString(settings->getCodeblocksProjectPath().wstr())); - - const FilePath codeblocksProjectPath = settings->getCodeblocksProjectPathExpandedAndAbsolute(); - if (!codeblocksProjectPath.empty() && codeblocksProjectPath.exists()) + if (projectPath.exists()) { - if (std::shared_ptr codeblocksProject = Codeblocks::Project::load( - codeblocksProjectPath - )) - { - m_filePaths = utility::toVector(codeblocksProject->getAllSourceFilePathsCanonical(settings)); - } + path.makeRelativeTo(projectPath); } - if (m_fileCountLabel) - { - m_fileCountLabel->setText("" + QString::number(m_filePaths.size()) + " source files were found in the Code::Blocks project."); - } + m_filePaths.push_back(path); + } + + if (m_fileCountLabel) + { + m_fileCountLabel->setText("" + QString::number(m_filePaths.size()) + " source files were found in the Code::Blocks project."); } } void QtProjectWizzardContentCodeblocksProjectPath::save() { - std::shared_ptr settings = - std::dynamic_pointer_cast(m_settings); - if (settings) - { - settings->setCodeblocksProjectPath(FilePath(m_picker->getText().toStdWString())); - } + m_settings->setCodeblocksProjectPath(FilePath(m_picker->getText().toStdWString())); } bool QtProjectWizzardContentCodeblocksProjectPath::check() @@ -346,29 +335,37 @@ void QtProjectWizzardContentCodeblocksProjectPath::pickedPath() { m_window->saveContent(); - if (std::shared_ptr codeblocksSettings = std::dynamic_pointer_cast(m_settings)) - { - const FilePath projectPath = m_settings->getProjectDirectoryPath(); + const FilePath projectPath = m_settings->getProjectDirectoryPath(); - std::set indexedHeaderPaths; - for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCodeblocksProject(codeblocksSettings)) + std::set indexedHeaderPaths; + for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromCodeblocksProject(m_settings)) + { + if (projectPath.contains(path)) { - if (projectPath.contains(path)) - { - indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); - } + indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); } - codeblocksSettings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); } + m_settings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); m_window->loadContent(); } +std::shared_ptr QtProjectWizzardContentCodeblocksProjectPath::getSourceGroupSettings() +{ + return m_settings; +} + QtProjectWizzardContentSonargraphProjectPath::QtProjectWizzardContentSonargraphProjectPath( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, + std::shared_ptr settingsCxxSonargraph, + std::shared_ptr settingsWithSonargraphProjectPath, + QtProjectWizzardWindow* window ) - : QtProjectWizzardContentPath(settings, window) + : QtProjectWizzardContentPath(window) + , m_settings(settings) + , m_settingsCxxSonargraph(settingsCxxSonargraph) + , m_settingsWithSonargraphProjectPath(settingsWithSonargraphProjectPath) { setTitleString("Sonargraph Project (system.sonargraph)"); setHelpString( @@ -410,65 +407,59 @@ void QtProjectWizzardContentSonargraphProjectPath::populate(QGridLayout* layout, void QtProjectWizzardContentSonargraphProjectPath::load() { + m_picker->setText(QString::fromStdWString(m_settingsWithSonargraphProjectPath->getSonargraphProjectPath().wstr())); + m_filePaths.clear(); - std::shared_ptr settings = - std::dynamic_pointer_cast(m_settings); - if (settings) + std::set allSourceFilePaths; + if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) { - m_picker->setText(QString::fromStdWString(settings->getSonargraphProjectPath().wstr())); - - const FilePath sonargraphProjectPath = settings->getSonargraphProjectPathExpandedAndAbsolute(); - if (!sonargraphProjectPath.empty() && sonargraphProjectPath.exists()) + allSourceFilePaths = SourceGroupCxxSonargraph(settings).getAllSourceFilePaths(); + } + else if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) + { + allSourceFilePaths = SourceGroupJavaSonargraph(settings).getAllSourceFilePaths(); + } + + const FilePath projectPath = m_settings->getProjectDirectoryPath(); + for (FilePath path : allSourceFilePaths) + { + if (projectPath.exists()) { - if (std::shared_ptr sonargraphProject = Sonargraph::Project::load( - sonargraphProjectPath, m_settings->getLanguage() - )) - { - m_filePaths = utility::toVector(sonargraphProject->getAllSourceFilePathsCanonical()); - } + path.makeRelativeTo(projectPath); } + m_filePaths.push_back(path); + } - if (m_fileCountLabel) - { - m_fileCountLabel->setText("" + QString::number(m_filePaths.size()) + " source files were found in the Sonargraph project."); - } + if (m_fileCountLabel) + { + m_fileCountLabel->setText("" + QString::number(m_filePaths.size()) + " source files were found in the Sonargraph project."); } } void QtProjectWizzardContentSonargraphProjectPath::save() { - std::shared_ptr settings = - std::dynamic_pointer_cast(m_settings); - if (settings) - { - settings->setSonargraphProjectPath(FilePath(m_picker->getText().toStdWString())); - } + m_settingsWithSonargraphProjectPath->setSonargraphProjectPath(FilePath(m_picker->getText().toStdWString())); } bool QtProjectWizzardContentSonargraphProjectPath::check() { - std::shared_ptr settings = - std::dynamic_pointer_cast(m_settings); - if (settings) + if (std::shared_ptr sonargraphProject = Sonargraph::Project::load( + m_settingsWithSonargraphProjectPath->getSonargraphProjectPathExpandedAndAbsolute(), m_settings->getLanguage() + )) { - if (std::shared_ptr sonargraphProject = Sonargraph::Project::load( - settings->getSonargraphProjectPathExpandedAndAbsolute(), m_settings->getLanguage() - )) + if (sonargraphProject->getLoadedModuleCount() == 0) { - if (sonargraphProject->getLoadedModuleCount() == 0) - { - QMessageBox msgBox; - msgBox.setText(QString::fromStdString( - "The Sonargraph project file doesn't seem to contain any supported " + - languageTypeToString(m_settings->getLanguage()) + " modules. Please " + - "consider choosing another project file or removing this sourcegroup." - )); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Ok); - return msgBox.exec() == QMessageBox::Ok; - } + QMessageBox msgBox; + msgBox.setText(QString::fromStdString( + "The Sonargraph project file doesn't seem to contain any supported " + + languageTypeToString(m_settings->getLanguage()) + " modules. Please " + + "consider choosing another project file or removing this sourcegroup." + )); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Ok); + return msgBox.exec() == QMessageBox::Ok; } } return true; @@ -495,30 +486,34 @@ void QtProjectWizzardContentSonargraphProjectPath::pickedPath() { m_window->saveContent(); - if (std::shared_ptr sonargraphSettings = std::dynamic_pointer_cast(m_settings)) + if (m_settingsCxxSonargraph) { const FilePath projectPath = m_settings->getProjectDirectoryPath(); std::set indexedHeaderPaths; - for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromSonargraphProject(sonargraphSettings)) + for (const FilePath& path : QtProjectWizzardContentIndexedHeaderPaths::getIndexedPathsDerivedFromSonargraphProject(m_settingsCxxSonargraph)) { - std::string asdasd = path.str(); if (projectPath.contains(path)) { indexedHeaderPaths.insert(path.getRelativeTo(projectPath)); } } - sonargraphSettings->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); + m_settingsCxxSonargraph->setIndexedHeaderPaths(utility::toVector(indexedHeaderPaths)); } - m_window->loadContent(); } +std::shared_ptr QtProjectWizzardContentSonargraphProjectPath::getSourceGroupSettings() +{ + return m_settings; +} + QtProjectWizzardContentPathSourceMaven::QtProjectWizzardContentPathSourceMaven( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) - : QtProjectWizzardContentPath(settings, window) + : QtProjectWizzardContentPath(window) + , m_settings(settings) { setTitleString("Maven Project File (pom.xml)"); setHelpString( @@ -550,88 +545,77 @@ void QtProjectWizzardContentPathSourceMaven::populate(QGridLayout* layout, int& void QtProjectWizzardContentPathSourceMaven::load() { - std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); - if (settings) - { - m_picker->setText(QString::fromStdWString(settings->getMavenProjectFilePath().wstr())); - m_shouldIndexTests->setChecked(settings->getShouldIndexMavenTests()); - } + m_picker->setText(QString::fromStdWString(m_settings->getMavenProjectFilePath().wstr())); + m_shouldIndexTests->setChecked(m_settings->getShouldIndexMavenTests()); } void QtProjectWizzardContentPathSourceMaven::save() { - std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); - if (settings) - { - settings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdWString())); - settings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked()); - } + m_settings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdWString())); + m_settings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked()); } std::vector QtProjectWizzardContentPathSourceMaven::getFilePaths() const { - std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); + { + const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); + const FilePath mavenProjectRoot = m_settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory(); - const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); - const FilePath mavenProjectRoot = settings->getMavenProjectFilePathExpandedAndAbsolute().getParentDirectory(); + if (!mavenProjectRoot.exists()) + { + LOG_INFO("Could not find any source file paths because Maven project path does not exist."); + return std::vector(); + } + + std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + + ScopedFunctor scopedFunctor([&dialogView]() { + dialogView->hideUnknownProgressDialog(); + }); + + std::dynamic_pointer_cast(dialogView)->setParentWindow(m_window); + dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nGenerating Source Files"); + const bool success = utility::mavenGenerateSources(mavenPath, mavenProjectRoot); + if (!success) + { + const std::wstring dialogMessage = + L"Sourcetrail was unable to locate Maven on this machine.\n" + "Please make sure to provide the correct Maven Path in the preferences."; + + MessageStatus(dialogMessage, true, false).dispatch(); + + Application::getInstance()->handleDialog(dialogMessage); + + return std::vector(); + } + } std::vector list; - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); - - ScopedFunctor scopedFunctor([&dialogView](){ - dialogView->hideUnknownProgressDialog(); - }); - - std::dynamic_pointer_cast(dialogView)->setParentWindow(m_window); - dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nGenerating Source Files"); - const bool success = utility::mavenGenerateSources(mavenPath, mavenProjectRoot); - if (!success) + const FilePath projectPath = m_settings->getProjectDirectoryPath(); + for (FilePath path : SourceGroupJavaMaven(m_settings).getAllSourceFilePaths()) { - const std::wstring dialogMessage = - L"Sourcetrail was unable to locate Maven on this machine.\n" - "Please make sure to provide the correct Maven Path in the preferences."; - - MessageStatus(dialogMessage, true, false).dispatch(); - - Application::getInstance()->handleDialog(dialogMessage); - } - else - { - dialogView->showUnknownProgressDialog(L"Preparing Project", L"Maven\nFetching Source Directories"); - const std::vector sourceDirectories = utility::mavenGetAllDirectoriesFromEffectivePom( - mavenPath, - mavenProjectRoot, - settings->getShouldIndexMavenTests() - ); - - FileManager fileManager; - fileManager.update( - sourceDirectories, - settings->getExcludeFiltersExpandedAndAbsolute(), - settings->getSourceExtensions() - ); - - const FilePath projectPath = m_settings->getProjectDirectoryPath(); - - for (FilePath path : fileManager.getAllSourceFilePaths()) + if (projectPath.exists()) { - if (projectPath.exists()) - { - path.makeRelativeTo(projectPath); - } - - list.push_back(path); + path.makeRelativeTo(projectPath); } + + list.push_back(path); } return list; } +std::shared_ptr QtProjectWizzardContentPathSourceMaven::getSourceGroupSettings() +{ + return m_settings; +} + QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDependenciesMaven( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) - : QtProjectWizzardContentPath(settings, window) + : QtProjectWizzardContentPath(window) + , m_settings(settings) { setTitleString("Intermediate Dependencies Directory"); setHelpString( @@ -643,27 +627,25 @@ QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDepende void QtProjectWizzardContentPathDependenciesMaven::load() { - std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); - if (settings) - { - m_picker->setText(QString::fromStdWString(settings->getMavenDependenciesDirectory().wstr())); - } + m_picker->setText(QString::fromStdWString(m_settings->getMavenDependenciesDirectory().wstr())); } void QtProjectWizzardContentPathDependenciesMaven::save() { - std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); - if (settings) - { - settings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdWString())); - } + m_settings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdWString())); +} + +std::shared_ptr QtProjectWizzardContentPathDependenciesMaven::getSourceGroupSettings() +{ + return m_settings; } QtProjectWizzardContentPathSourceGradle::QtProjectWizzardContentPathSourceGradle( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) - : QtProjectWizzardContentPath(settings, window) + : QtProjectWizzardContentPath(window) + , m_settings(settings) { setTitleString("Gradle Project File (build.gradle)"); setHelpString( @@ -695,74 +677,43 @@ void QtProjectWizzardContentPathSourceGradle::populate(QGridLayout* layout, int& void QtProjectWizzardContentPathSourceGradle::load() { - std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); - if (settings) - { - m_picker->setText(QString::fromStdWString(settings->getGradleProjectFilePath().wstr())); - m_shouldIndexTests->setChecked(settings->getShouldIndexGradleTests()); - } + m_picker->setText(QString::fromStdWString(m_settings->getGradleProjectFilePath().wstr())); + m_shouldIndexTests->setChecked(m_settings->getShouldIndexGradleTests()); } void QtProjectWizzardContentPathSourceGradle::save() { - std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); - if (settings) - { - settings->setGradleProjectFilePath(FilePath(m_picker->getText().toStdWString())); - settings->setShouldIndexGradleTests(m_shouldIndexTests->isChecked()); - } + m_settings->setGradleProjectFilePath(FilePath(m_picker->getText().toStdWString())); + m_settings->setShouldIndexGradleTests(m_shouldIndexTests->isChecked()); } std::vector QtProjectWizzardContentPathSourceGradle::getFilePaths() const { - std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); - - const FilePath gradleProjectRoot = settings->getGradleProjectFilePathExpandedAndAbsolute().getParentDirectory(); - std::vector list; - - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); - - ScopedFunctor scopedFunctor([&dialogView]() { - dialogView->hideUnknownProgressDialog(); - }); - - std::dynamic_pointer_cast(dialogView)->setParentWindow(m_window); + const FilePath projectPath = m_settings->getProjectDirectoryPath(); + for (FilePath path : SourceGroupJavaGradle(m_settings).getAllSourceFilePaths()) { - dialogView->showUnknownProgressDialog(L"Preparing Project", L"Gradle\nFetching Source Directories"); - const std::vector sourceDirectories = utility::gradleGetAllSourceDirectories( - gradleProjectRoot, - settings->getShouldIndexGradleTests() - ); - - FileManager fileManager; - fileManager.update( - sourceDirectories, - settings->getExcludeFiltersExpandedAndAbsolute(), - settings->getSourceExtensions() - ); - - const FilePath projectPath = settings->getProjectDirectoryPath(); - - for (FilePath path : fileManager.getAllSourceFilePaths()) + if (projectPath.exists()) { - if (projectPath.exists()) - { - path.makeRelativeTo(projectPath); - } - - list.push_back(path); + path.makeRelativeTo(projectPath); } + + list.push_back(path); } - return list; } +std::shared_ptr QtProjectWizzardContentPathSourceGradle::getSourceGroupSettings() +{ + return m_settings; +} + QtProjectWizzardContentPathDependenciesGradle::QtProjectWizzardContentPathDependenciesGradle( - std::shared_ptr settings, QtProjectWizzardWindow* window + std::shared_ptr settings, QtProjectWizzardWindow* window ) - : QtProjectWizzardContentPath(settings, window) + : QtProjectWizzardContentPath(window) + , m_settings(settings) { setTitleString("Intermediate Dependencies Directory"); setHelpString( @@ -774,18 +725,15 @@ QtProjectWizzardContentPathDependenciesGradle::QtProjectWizzardContentPathDepend void QtProjectWizzardContentPathDependenciesGradle::load() { - std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); - if (settings) - { - m_picker->setText(QString::fromStdWString(settings->getGradleDependenciesDirectory().wstr())); - } + m_picker->setText(QString::fromStdWString(m_settings->getGradleDependenciesDirectory().wstr())); } void QtProjectWizzardContentPathDependenciesGradle::save() { - std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); - if (settings) - { - settings->setGradleDependenciesDirectory(FilePath(m_picker->getText().toStdWString())); - } + m_settings->setGradleDependenciesDirectory(FilePath(m_picker->getText().toStdWString())); +} + +std::shared_ptr QtProjectWizzardContentPathDependenciesGradle::getSourceGroupSettings() +{ + return m_settings; } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h index b1b996e0..d5972209 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h @@ -11,6 +11,12 @@ class QPushButton; class QtLocationPicker; class SourceGroupSettings; +class SourceGroupSettingsCxxCdb; +class SourceGroupSettingsCxxCodeblocks; +class SourceGroupSettingsCxxSonargraph; +class SourceGroupSettingsJavaGradle; +class SourceGroupSettingsJavaMaven; +class SourceGroupSettingsWithSonargraphProjectPath; class QtProjectWizzardContentPath : public QtProjectWizzardContent @@ -18,7 +24,7 @@ class QtProjectWizzardContentPath Q_OBJECT public: - QtProjectWizzardContentPath(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPath(QtProjectWizzardWindow* window); // QtSettingsWindow implementation virtual void populate(QGridLayout* layout, int& row) override; @@ -31,13 +37,13 @@ protected: void setFileEndings(const std::set& fileEndings); - std::shared_ptr m_settings; - QtLocationPicker* m_picker; bool m_makePathRelativeToProjectFileLocation; private: + virtual std::shared_ptr getSourceGroupSettings() = 0; + QString m_titleString; QString m_helpString; std::set m_fileEndings; @@ -50,22 +56,25 @@ class QtProjectWizzardContentPathCDB Q_OBJECT public: - QtProjectWizzardContentPathCDB(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathCDB(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; + void populate(QGridLayout* layout, int& row) override; - virtual void load() override; - virtual void save() override; + void load() override; + void save() override; - virtual std::vector getFilePaths() const override; - virtual QString getFileNamesTitle() const override; - virtual QString getFileNamesDescription() const override; + std::vector getFilePaths() const override; + QString getFileNamesTitle() const override; + QString getFileNamesDescription() const override; private slots: void pickedPath(); private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; QLabel* m_fileCountLabel; std::vector m_filePaths; }; @@ -77,23 +86,28 @@ class QtProjectWizzardContentCodeblocksProjectPath Q_OBJECT public: - QtProjectWizzardContentCodeblocksProjectPath(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentCodeblocksProjectPath( + std::shared_ptr settings, + QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; + void populate(QGridLayout* layout, int& row) override; - virtual void load() override; - virtual void save() override; - virtual bool check() override; + void load() override; + void save() override; + bool check() override; - virtual std::vector getFilePaths() const override; - virtual QString getFileNamesTitle() const override; - virtual QString getFileNamesDescription() const override; + std::vector getFilePaths() const override; + QString getFileNamesTitle() const override; + QString getFileNamesDescription() const override; private slots: void pickedPath(); private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; QLabel* m_fileCountLabel; std::vector m_filePaths; }; @@ -105,23 +119,32 @@ class QtProjectWizzardContentSonargraphProjectPath Q_OBJECT public: - QtProjectWizzardContentSonargraphProjectPath(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentSonargraphProjectPath( + std::shared_ptr settings, + std::shared_ptr settingsCxxSonargraph, + std::shared_ptr settingsWithSonargraphProjectPath, + QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; + void populate(QGridLayout* layout, int& row) override; - virtual void load() override; - virtual void save() override; - virtual bool check() override; + void load() override; + void save() override; + bool check() override; - virtual std::vector getFilePaths() const override; - virtual QString getFileNamesTitle() const override; - virtual QString getFileNamesDescription() const override; + std::vector getFilePaths() const override; + QString getFileNamesTitle() const override; + QString getFileNamesDescription() const override; private slots: void pickedPath(); private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; + std::shared_ptr m_settingsCxxSonargraph; + std::shared_ptr m_settingsWithSonargraphProjectPath; QLabel* m_fileCountLabel; std::vector m_filePaths; }; @@ -132,17 +155,20 @@ class QtProjectWizzardContentPathSourceMaven { Q_OBJECT public: - QtProjectWizzardContentPathSourceMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathSourceMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; + void populate(QGridLayout* layout, int& row) override; - virtual void load() override; - virtual void save() override; + void load() override; + void save() override; - virtual std::vector getFilePaths() const override; + std::vector getFilePaths() const override; private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; QCheckBox* m_shouldIndexTests; }; @@ -152,11 +178,16 @@ class QtProjectWizzardContentPathDependenciesMaven { Q_OBJECT public: - QtProjectWizzardContentPathDependenciesMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathDependenciesMaven(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation - virtual void load() override; - virtual void save() override; + void load() override; + void save() override; + +private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; }; @@ -165,17 +196,20 @@ class QtProjectWizzardContentPathSourceGradle { Q_OBJECT public: - QtProjectWizzardContentPathSourceGradle(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathSourceGradle(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; + void populate(QGridLayout* layout, int& row) override; - virtual void load() override; - virtual void save() override; + void load() override; + void save() override; - virtual std::vector getFilePaths() const override; + std::vector getFilePaths() const override; private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; QCheckBox* m_shouldIndexTests; }; @@ -185,11 +219,16 @@ class QtProjectWizzardContentPathDependenciesGradle { Q_OBJECT public: - QtProjectWizzardContentPathDependenciesGradle(std::shared_ptr settings, QtProjectWizzardWindow* window); + QtProjectWizzardContentPathDependenciesGradle(std::shared_ptr settings, QtProjectWizzardWindow* window); // QtProjectWizzardContent implementation - virtual void load() override; - virtual void save() override; + void load() override; + void save() override; + +private: + std::shared_ptr getSourceGroupSettings() override; + + std::shared_ptr m_settings; }; #endif // QT_PROJECT_WIZZARD_CONTENT_PATH_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index d1d7062f..63ae9878 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -6,18 +6,19 @@ #include #include -#include "Application.h" #include "component/view/DialogView.h" #include "data/indexer/IndexerCommandCxxCdb.h" -#include "utility/IncludeDirective.h" -#include "utility/IncludeProcessing.h" +#include "project/SourceGroupCxxEmpty.h" +#include "project/SourceGroupJavaEmpty.h" #include "qt/view/QtDialogView.h" #include "qt/window/QtPathListDialog.h" #include "qt/window/QtSelectPathsDialog.h" #include "settings/ApplicationSettings.h" +#include "settings/SourceGroupSettingsCxx.h" #include "settings/SourceGroupSettingsCxxCdb.h" #include "settings/SourceGroupSettingsCxxCodeblocks.h" #include "settings/SourceGroupSettingsCxxSonargraph.h" +#include "settings/SourceGroupSettingsJavaEmpty.h" #include "settings/SourceGroupSettingsWithClasspath.h" #include "settings/SourceGroupSettingsWithIndexedHeaderPaths.h" #include "settings/SourceGroupSettingsWithExcludeFilters.h" @@ -27,11 +28,14 @@ #include "utility/file/FileManager.h" #include "utility/sonargraph/SonargraphProject.h" #include "utility/CompilationDatabase.h" +#include "utility/IncludeDirective.h" +#include "utility/IncludeProcessing.h" #include "utility/ScopedFunctor.h" #include "utility/utility.h" #include "utility/utilityFile.h" #include "utility/utilityPathDetection.h" #include "utility/utilityString.h" +#include "Application.h" QtProjectWizzardContentPaths::QtProjectWizzardContentPaths( std::shared_ptr settings, @@ -235,32 +239,29 @@ void QtProjectWizzardContentPathsSource::save() std::vector QtProjectWizzardContentPathsSource::getFilePaths() const { - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); - - ScopedFunctor scopedFunctor([&dialogView](){ - dialogView->hideUnknownProgressDialog(); - }); - - std::dynamic_pointer_cast(dialogView)->setParentWindow(m_window); - dialogView->showUnknownProgressDialog(L"Processing", L"Gathering Source Files"); - - std::shared_ptr extensionSettings = std::dynamic_pointer_cast(m_settings); - std::shared_ptr pathSettings = std::dynamic_pointer_cast(m_settings); - std::shared_ptr excludeFilterSettings = std::dynamic_pointer_cast(m_settings); - - if (extensionSettings && pathSettings && excludeFilterSettings) // FIXME: pass msettings as required type + std::set allSourceFilePaths; + if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) { - FileManager fileManager; - fileManager.update( - pathSettings->getSourcePathsExpandedAndAbsolute(), - excludeFilterSettings->getExcludeFiltersExpandedAndAbsolute(), - extensionSettings->getSourceExtensions() - ); - - const std::set filePaths = fileManager.getAllSourceFilePathsRelative(m_settings->getProjectDirectoryPath()); - return utility::toVector(filePaths); + allSourceFilePaths = SourceGroupCxxEmpty(settings).getAllSourceFilePaths(); } - return std::vector(); + else if (std::shared_ptr settings = std::dynamic_pointer_cast(m_settings)) + { + allSourceFilePaths = SourceGroupJavaEmpty(settings).getAllSourceFilePaths(); + } + + std::vector filePaths; + + const FilePath projectPath = m_settings->getProjectDirectoryPath(); + for (FilePath path : allSourceFilePaths) + { + if (projectPath.exists()) + { + path.makeRelativeTo(projectPath); + } + filePaths.push_back(path); + } + + return filePaths; } QString QtProjectWizzardContentPathsSource::getFileNamesTitle() const diff --git a/src/lib_java/project/SourceGroupJavaEmpty.cpp b/src/lib_java/project/SourceGroupJavaEmpty.cpp index cf2f8e2e..7915e996 100644 --- a/src/lib_java/project/SourceGroupJavaEmpty.cpp +++ b/src/lib_java/project/SourceGroupJavaEmpty.cpp @@ -24,7 +24,7 @@ std::vector SourceGroupJavaEmpty::getAllSourcePaths() const std::vector SourceGroupJavaEmpty::doGetClassPath() const { - return utility::getClassPath(getSourceGroupSettingsJava(), getAllSourceFilePaths()); + return utility::getClassPath(m_settings->getClasspathExpandedAndAbsolute(), m_settings->getUseJreSystemLibrary(), getAllSourceFilePaths()); } std::shared_ptr SourceGroupJavaEmpty::getSourceGroupSettingsJava() diff --git a/src/lib_java/project/SourceGroupJavaGradle.cpp b/src/lib_java/project/SourceGroupJavaGradle.cpp index af33383b..26a9eeb8 100644 --- a/src/lib_java/project/SourceGroupJavaGradle.cpp +++ b/src/lib_java/project/SourceGroupJavaGradle.cpp @@ -42,12 +42,16 @@ std::vector SourceGroupJavaGradle::getAllSourcePaths() const dialogView->hideUnknownProgressDialog(); } + else + { + LOG_INFO("Could not find any source paths because Gradle project path does not exist."); + } return sourcePaths; } std::vector SourceGroupJavaGradle::doGetClassPath() const { - std::vector classPath = utility::getClassPath(getSourceGroupSettingsJava(), getAllSourceFilePaths()); + std::vector classPath = utility::getClassPath({}, true, getAllSourceFilePaths()); if (m_settings->getGradleDependenciesDirectoryExpandedAndAbsolute().exists()) { diff --git a/src/lib_java/project/SourceGroupJavaMaven.cpp b/src/lib_java/project/SourceGroupJavaMaven.cpp index e1a2ddd2..a503bf62 100644 --- a/src/lib_java/project/SourceGroupJavaMaven.cpp +++ b/src/lib_java/project/SourceGroupJavaMaven.cpp @@ -50,7 +50,7 @@ std::vector SourceGroupJavaMaven::getAllSourcePaths() const std::vector SourceGroupJavaMaven::doGetClassPath() const { - std::vector classPath = utility::getClassPath(getSourceGroupSettingsJava(), getAllSourceFilePaths()); + std::vector classPath = utility::getClassPath({}, true, getAllSourceFilePaths()); if (m_settings && m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute().exists()) { diff --git a/src/lib_java/project/SourceGroupJavaSonargraph.cpp b/src/lib_java/project/SourceGroupJavaSonargraph.cpp index e36795a0..63f2fb7d 100644 --- a/src/lib_java/project/SourceGroupJavaSonargraph.cpp +++ b/src/lib_java/project/SourceGroupJavaSonargraph.cpp @@ -92,7 +92,10 @@ std::vector> SourceGroupJavaSonargraph::getIndex if (!indexerCommands.empty()) { - const std::vector classPath = utility::getClassPath(m_settings, getAllSourceFilePaths()); // TODO: remove this hack once sourcegroup and sourcegroupsettings are merged + // TODO: remove this hack once sourcegroup and sourcegroupsettings are merged + const std::vector classPath = utility::getClassPath( + m_settings->getClasspathExpandedAndAbsolute(), m_settings->getUseJreSystemLibrary(), getAllSourceFilePaths() + ); for (std::shared_ptr indexerCommand : indexerCommands) { if (std::shared_ptr javaIndexerCommand = std::dynamic_pointer_cast(indexerCommand)) diff --git a/src/lib_java/utility/utilityJava.cpp b/src/lib_java/utility/utilityJava.cpp index 7bd7a05d..4728e629 100644 --- a/src/lib_java/utility/utilityJava.cpp +++ b/src/lib_java/utility/utilityJava.cpp @@ -149,11 +149,11 @@ namespace utility return rootDirectories; } - std::vector getClassPath(std::shared_ptr settings, const std::set& sourceFilePaths) + std::vector getClassPath(const std::vector& classpathItems, bool useJreSystemLibrary, const std::set& sourceFilePaths) { std::vector classPath; - for (const FilePath& classpath : settings->getClasspathExpandedAndAbsolute()) + for (const FilePath& classpath : classpathItems) { if (classpath.exists()) { @@ -162,7 +162,7 @@ namespace utility } } - if (settings->getUseJreSystemLibrary()) + if (useJreSystemLibrary) { for (const FilePath& systemLibraryPath : ApplicationSettings::getInstance()->getJreSystemLibraryPathsExpanded()) { diff --git a/src/lib_java/utility/utilityJava.h b/src/lib_java/utility/utilityJava.h index 025a918a..ac8b7c79 100644 --- a/src/lib_java/utility/utilityJava.h +++ b/src/lib_java/utility/utilityJava.h @@ -15,7 +15,8 @@ namespace utility bool prepareJavaEnvironmentAndDisplayOccurringErrors(); std::set fetchRootDirectories(const std::set& sourceFilePaths); std::vector getClassPath( - std::shared_ptr settings, + const std::vector& classpathItems, + bool useJreSystemLibrary, const std::set& sourceFilePaths); }