logic: added Gradle project setup (issue #379)
* added implementation for Gradle project setup (icon is still missing) * refactored project loading/saving and SourceGroupSettings * removed long deprecated Cxx UseSourcePathsForHeaderSearch option fortune cookie message = There is true and sincere friendship between you and your friends.
This commit is contained in:
+2
-4
@@ -9,8 +9,7 @@
|
||||
#include "data/indexer/IndexerFactoryModuleCxxManual.h"
|
||||
#include "LicenseChecker.h"
|
||||
#include "project/SourceGroupFactory.h"
|
||||
#include "project/SourceGroupFactoryModuleC.h"
|
||||
#include "project/SourceGroupFactoryModuleCpp.h"
|
||||
#include "project/SourceGroupFactoryModuleCxx.h"
|
||||
#include "project/SourceGroupFactoryModuleJava.h"
|
||||
#include "qt/network/QtNetworkFactory.h"
|
||||
#include "qt/QtApplication.h"
|
||||
@@ -167,8 +166,7 @@ void prefillPaths()
|
||||
|
||||
void addLanguageModules()
|
||||
{
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleC>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleCpp>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleCxx>());
|
||||
SourceGroupFactory::getInstance()->addModule(std::make_shared<SourceGroupFactoryModuleJava>());
|
||||
|
||||
IndexerFactory::getInstance()->addModule(std::make_shared<IndexerFactoryModuleJava>());
|
||||
|
||||
@@ -296,8 +296,18 @@ add_files(
|
||||
settings/SourceGroupSettings.h
|
||||
settings/SourceGroupSettingsCxx.cpp
|
||||
settings/SourceGroupSettingsCxx.h
|
||||
settings/SourceGroupSettingsCxxCdb.cpp
|
||||
settings/SourceGroupSettingsCxxCdb.h
|
||||
settings/SourceGroupSettingsCxxEmpty.cpp
|
||||
settings/SourceGroupSettingsCxxEmpty.h
|
||||
settings/SourceGroupSettingsJava.cpp
|
||||
settings/SourceGroupSettingsJava.h
|
||||
settings/SourceGroupSettingsJavaEmpty.cpp
|
||||
settings/SourceGroupSettingsJavaEmpty.h
|
||||
settings/SourceGroupSettingsJavaGradle.cpp
|
||||
settings/SourceGroupSettingsJavaGradle.h
|
||||
settings/SourceGroupSettingsJavaMaven.cpp
|
||||
settings/SourceGroupSettingsJavaMaven.h
|
||||
settings/SourceGroupType.cpp
|
||||
|
||||
settings/SourceGroupType.h
|
||||
|
||||
@@ -45,7 +45,6 @@ Project::Project(std::shared_ptr<ProjectSettings> settings, StorageAccessProxy*
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Project::~Project()
|
||||
{
|
||||
}
|
||||
@@ -53,7 +52,7 @@ Project::~Project()
|
||||
bool Project::refresh(bool forceRefresh)
|
||||
{
|
||||
if (m_state == PROJECT_STATE_NOT_LOADED)
|
||||
{
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "project/SourceGroup.h"
|
||||
|
||||
#include "settings/SourceGroupSettings.h"
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
SourceGroup::~SourceGroup()
|
||||
@@ -21,6 +23,18 @@ bool SourceGroup::prepareIndexing()
|
||||
return true;
|
||||
}
|
||||
|
||||
void SourceGroup::fetchAllSourceFilePaths()
|
||||
{
|
||||
m_sourceFilePathsToIndex.clear();
|
||||
FileManager fileManager;
|
||||
fileManager.update(
|
||||
getAllSourcePaths(),
|
||||
getSourceGroupSettings()->getExcludePathsExpandedAndAbsolute(),
|
||||
getSourceGroupSettings()->getSourceExtensions()
|
||||
);
|
||||
m_allSourceFilePaths = fileManager.getAllSourceFilePaths();
|
||||
}
|
||||
|
||||
void SourceGroup::fetchSourceFilePathsToIndex(const std::set<FilePath>& staticSourceFilePaths)
|
||||
{
|
||||
for (const FilePath& sourceFilePath: m_allSourceFilePaths)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
class FilePath;
|
||||
class IndexerCommand;
|
||||
class SourceGroupSettings;
|
||||
|
||||
class SourceGroup
|
||||
{
|
||||
@@ -22,7 +23,7 @@ public:
|
||||
virtual bool prepareRefresh();
|
||||
virtual bool prepareIndexing();
|
||||
|
||||
virtual void fetchAllSourceFilePaths() = 0;
|
||||
void fetchAllSourceFilePaths();
|
||||
void fetchSourceFilePathsToIndex(const std::set<FilePath>& staticSourceFilePaths);
|
||||
|
||||
std::set<FilePath> getAllSourceFilePaths() const;
|
||||
@@ -34,6 +35,10 @@ public:
|
||||
protected:
|
||||
std::set<FilePath> m_allSourceFilePaths;
|
||||
std::set<FilePath> m_sourceFilePathsToIndex;
|
||||
|
||||
private:
|
||||
virtual std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() = 0;
|
||||
virtual std::vector<FilePath> getAllSourcePaths() const = 0;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_H
|
||||
|
||||
@@ -49,6 +49,8 @@ LanguageType getLanguageTypeForSourceGroupType(SourceGroupType t)
|
||||
return LANGUAGE_JAVA;
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
return LANGUAGE_JAVA;
|
||||
case SOURCE_GROUP_JAVA_GRADLE:
|
||||
return LANGUAGE_JAVA;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
#include "settings/migration/SettingsMigrationDeleteKey.h"
|
||||
#include "settings/migration/SettingsMigrationLambda.h"
|
||||
#include "settings/migration/SettingsMigrationMoveKey.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
#include "settings/SourceGroupSettingsCxxCdb.h"
|
||||
#include "settings/SourceGroupSettingsCxxEmpty.h"
|
||||
#include "settings/SourceGroupSettingsJavaEmpty.h"
|
||||
#include "settings/SourceGroupSettingsJavaMaven.h"
|
||||
#include "settings/SourceGroupSettingsJavaGradle.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/utilityUuid.h"
|
||||
|
||||
@@ -135,7 +139,7 @@ std::vector<std::shared_ptr<SourceGroupSettings>> ProjectSettings::getAllSourceG
|
||||
std::vector<std::shared_ptr<SourceGroupSettings>> allSettings;
|
||||
for (const std::string& key: m_config->getSublevelKeys("source_groups"))
|
||||
{
|
||||
const std::string id = key.substr(std::string("source_groups/source_group_").length());
|
||||
const std::string id = key.substr(std::string(SourceGroupSettings::s_keyPrefix).length());
|
||||
const SourceGroupType type = stringToSourceGroupType(getValue<std::string>(key + "/type", ""));
|
||||
|
||||
std::shared_ptr<SourceGroupSettings> settings;
|
||||
@@ -143,62 +147,36 @@ std::vector<std::shared_ptr<SourceGroupSettings>> ProjectSettings::getAllSourceG
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
settings = std::make_shared<SourceGroupSettingsCxxEmpty>(id, SOURCE_GROUP_C_EMPTY, this);
|
||||
break;
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
settings = std::make_shared<SourceGroupSettingsCxxEmpty>(id, SOURCE_GROUP_CPP_EMPTY, this);
|
||||
break;
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::make_shared<SourceGroupSettingsCxx>(id, type, this);
|
||||
cxxSettings->setHeaderSearchPaths(getPathValues(key + "/header_search_paths/header_search_path"));
|
||||
cxxSettings->setFrameworkSearchPaths(getPathValues(key + "/framework_search_paths/framework_search_path"));
|
||||
cxxSettings->setCompilerFlags(getValues<std::string>(key + "/compiler_flags/compiler_flag", std::vector<std::string>()));
|
||||
cxxSettings->setUseSourcePathsForHeaderSearch(getValue<bool>(key + "/use_source_paths_for_header_search", false));
|
||||
cxxSettings->setHasDefinedUseSourcePathsForHeaderSearch(isValueDefined(key + "/use_source_paths_for_header_search"));
|
||||
if (type == SOURCE_GROUP_CXX_CDB)
|
||||
{
|
||||
cxxSettings->setCompilationDatabasePath(FilePath(getValue<std::string>(key + "/build_file_path/compilation_db_path", "")));
|
||||
}
|
||||
if (type == SOURCE_GROUP_C_EMPTY || type == SOURCE_GROUP_CPP_EMPTY)
|
||||
{
|
||||
cxxSettings->setTargetOptionsEnabled(getValue<bool>(key + "/cross_compilation/target_options_enabled", false));
|
||||
cxxSettings->setTargetArch(getValue<std::string>(key + "/cross_compilation/target/arch", ""));
|
||||
cxxSettings->setTargetVendor(getValue<std::string>(key + "/cross_compilation/target/vendor", ""));
|
||||
cxxSettings->setTargetSys(getValue<std::string>(key + "/cross_compilation/target/sys", ""));
|
||||
cxxSettings->setTargetAbi(getValue<std::string>(key + "/cross_compilation/target/abi", ""));
|
||||
}
|
||||
cxxSettings->setShouldApplyAnonymousTypedefTransformation(getValue<bool>(key + "/should_apply_anonymous_typedef_transformation", true));
|
||||
settings = cxxSettings;
|
||||
}
|
||||
settings = std::make_shared<SourceGroupSettingsCxxCdb>(id, this);
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
settings = std::make_shared<SourceGroupSettingsJavaEmpty>(id, this);
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::make_shared<SourceGroupSettingsJava>(id, type, this);
|
||||
javaSettings->setClasspath(getPathValues(key + "/class_paths/class_path"));
|
||||
javaSettings->setUseJreSystemLibrary(getValue<bool>(key + "/use_jre_system_library", true));
|
||||
if (type == SOURCE_GROUP_JAVA_MAVEN)
|
||||
{
|
||||
javaSettings->setMavenProjectFilePath(FilePath(getValue<std::string>(key + "/maven/project_file_path", "")));
|
||||
javaSettings->setMavenDependenciesDirectory(FilePath(getValue<std::string>(key + "/maven/dependencies_directory", "")));
|
||||
javaSettings->setShouldIndexMavenTests(getValue<bool>(key + "/maven/should_index_tests", false));
|
||||
}
|
||||
settings = javaSettings;
|
||||
}
|
||||
settings = std::make_shared<SourceGroupSettingsJavaMaven>(id, this);
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_GRADLE:
|
||||
settings = std::make_shared<SourceGroupSettingsJavaGradle>(id, this);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::string name = getValue<std::string>(key + "/name", "");
|
||||
if (name.size())
|
||||
if (settings)
|
||||
{
|
||||
settings->setName(name);
|
||||
settings->load(m_config);
|
||||
allSettings.push_back(settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARNING("Sourcegroup with id \"" + id + "\" could not be loaded.");
|
||||
}
|
||||
|
||||
settings->setStandard(getValue<std::string>(key + "/standard", ""));
|
||||
settings->setSourcePaths(getPathValues(key + "/source_paths/source_path"));
|
||||
settings->setExcludePaths(getPathValues(key + "/exclude_paths/exclude_path"));
|
||||
settings->setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector<std::string>()));
|
||||
|
||||
allSettings.push_back(settings);
|
||||
}
|
||||
|
||||
return allSettings;
|
||||
@@ -213,63 +191,11 @@ void ProjectSettings::setAllSourceGroupSettings(const std::vector<std::shared_pt
|
||||
|
||||
for (const std::shared_ptr<SourceGroupSettings>& settings: allSettings)
|
||||
{
|
||||
const std::string key = "source_groups/source_group_" + settings->getId();
|
||||
const std::string key = SourceGroupSettings::s_keyPrefix + settings->getId();
|
||||
const SourceGroupType type = settings->getType();
|
||||
|
||||
setValue(key + "/type", sourceGroupTypeToString(type));
|
||||
setValue(key + "/name", settings->getName());
|
||||
setValue(key + "/standard", settings->getStandard());
|
||||
setPathValues(key + "/source_paths/source_path", settings->getSourcePaths());
|
||||
setPathValues(key + "/exclude_paths/exclude_path", settings->getExcludePaths());
|
||||
setValues(key + "/source_extensions/source_extension", settings->getSourceExtensions());
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
if (std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(settings))
|
||||
{
|
||||
setPathValues(key + "/header_search_paths/header_search_path", cxxSettings->getHeaderSearchPaths());
|
||||
setPathValues(key + "/framework_search_paths/framework_search_path", cxxSettings->getFrameworkSearchPaths());
|
||||
setValues(key + "/compiler_flags/compiler_flag", cxxSettings->getCompilerFlags());
|
||||
if (cxxSettings->getHasDefinedUseSourcePathsForHeaderSearch())
|
||||
{
|
||||
setValue(key + "/use_source_paths_for_header_search", cxxSettings->getUseSourcePathsForHeaderSearch());
|
||||
}
|
||||
if (type == SOURCE_GROUP_CXX_CDB)
|
||||
{
|
||||
setValue(key + "/build_file_path/compilation_db_path", cxxSettings->getCompilationDatabasePath().str());
|
||||
}
|
||||
if (type == SOURCE_GROUP_C_EMPTY || type == SOURCE_GROUP_CPP_EMPTY)
|
||||
{
|
||||
setValue(key + "/cross_compilation/target_options_enabled", cxxSettings->getTargetOptionsEnabled());
|
||||
setValue(key + "/cross_compilation/target/arch", cxxSettings->getTargetArch());
|
||||
setValue(key + "/cross_compilation/target/vendor", cxxSettings->getTargetVendor());
|
||||
setValue(key + "/cross_compilation/target/sys", cxxSettings->getTargetSys());
|
||||
setValue(key + "/cross_compilation/target/abi", cxxSettings->getTargetAbi());
|
||||
}
|
||||
setValue(key + "/should_apply_anonymous_typedef_transformation", cxxSettings->getShouldApplyAnonymousTypedefTransformation());
|
||||
}
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
if (std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(settings))
|
||||
{
|
||||
setPathValues(key + "/class_paths/class_path", javaSettings->getClasspath());
|
||||
setValue(key + "/use_jre_system_library", javaSettings->getUseJreSystemLibrary());
|
||||
|
||||
if (type == SOURCE_GROUP_JAVA_MAVEN)
|
||||
{
|
||||
setValue(key + "/maven/project_file_path", javaSettings->getMavenProjectFilePath().str());
|
||||
setValue(key + "/maven/dependencies_directory", javaSettings->getMavenDependenciesDirectory().str());
|
||||
setValue(key + "/maven/should_index_tests", javaSettings->getShouldIndexMavenTests());
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
settings->save(m_config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,6 +299,11 @@ SettingsMigrator ProjectSettings::getMigrations() const
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_MAVEN;
|
||||
}
|
||||
const std::string gradleProjectFilePath = migration->getValueFromSettings<std::string>(settings, sourceGroupKey + "/gradle/project_file_path", "");
|
||||
if (!gradleProjectFilePath.empty())
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_GRADLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = SOURCE_GROUP_JAVA_EMPTY;
|
||||
|
||||
@@ -118,9 +118,9 @@ std::vector<FilePath> Settings::getPathValues(const std::string& key) const
|
||||
values = getValues(key, values);
|
||||
|
||||
std::vector<FilePath> paths;
|
||||
for (const std::string& path : values)
|
||||
for (const std::string& value : values)
|
||||
{
|
||||
paths.push_back(FilePath(path));
|
||||
paths.push_back(FilePath(value));
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "utility/utility.h"
|
||||
|
||||
std::string SourceGroupSettings::s_keyPrefix = "source_groups/source_group_";
|
||||
|
||||
SourceGroupSettings::SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
|
||||
: m_projectSettings(projectSettings)
|
||||
, m_id(id)
|
||||
@@ -18,6 +20,33 @@ SourceGroupSettings::~SourceGroupSettings()
|
||||
{
|
||||
}
|
||||
|
||||
void SourceGroupSettings::load(std::shared_ptr<const ConfigManager> config)
|
||||
{
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
const std::string name = getValue<std::string>(key + "/name", "", config);
|
||||
if (!name.empty())
|
||||
{
|
||||
setName(name);
|
||||
}
|
||||
|
||||
setStandard(getValue<std::string>(key + "/standard", "", config));
|
||||
setSourcePaths(getPathValues(key + "/source_paths/source_path", config));
|
||||
setExcludePaths(getPathValues(key + "/exclude_paths/exclude_path", config));
|
||||
setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector<std::string>(), config));
|
||||
}
|
||||
|
||||
void SourceGroupSettings::save(std::shared_ptr<ConfigManager> config)
|
||||
{
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setValue(key + "/name", getName(), config);
|
||||
setValue(key + "/standard", getStandard(), config);
|
||||
setPathValues(key + "/source_paths/source_path", getSourcePaths(), config);
|
||||
setPathValues(key + "/exclude_paths/exclude_path", getExcludePaths(), config);
|
||||
setValues(key + "/source_extensions/source_extension", getSourceExtensions(), config);
|
||||
}
|
||||
|
||||
bool SourceGroupSettings::equals(std::shared_ptr<SourceGroupSettings> other) const
|
||||
{
|
||||
return (
|
||||
@@ -128,3 +157,27 @@ void SourceGroupSettings::setSourceExtensions(const std::vector<std::string>& so
|
||||
{
|
||||
m_sourceExtensions = sourceExtensions;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupSettings::getPathValues(const std::string& key, std::shared_ptr<const ConfigManager> config)
|
||||
{
|
||||
std::vector<std::string> values;
|
||||
values = getValues(key, values, config);
|
||||
|
||||
std::vector<FilePath> paths;
|
||||
for (const std::string& value : values)
|
||||
{
|
||||
paths.push_back(FilePath(value));
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
bool SourceGroupSettings::setPathValues(const std::string& key, const std::vector<FilePath>& paths, std::shared_ptr<ConfigManager> config)
|
||||
{
|
||||
std::vector<std::string> values;
|
||||
for (const FilePath& path : paths)
|
||||
{
|
||||
values.push_back(path.str());
|
||||
}
|
||||
|
||||
return setValues(key, values, config);
|
||||
}
|
||||
|
||||
@@ -12,9 +12,14 @@ class ProjectSettings;
|
||||
class SourceGroupSettings
|
||||
{
|
||||
public:
|
||||
static std::string s_keyPrefix;
|
||||
|
||||
SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettings();
|
||||
|
||||
virtual void load(std::shared_ptr<const ConfigManager> config);
|
||||
virtual void save(std::shared_ptr<ConfigManager> config);
|
||||
|
||||
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const;
|
||||
|
||||
std::string getId() const;
|
||||
@@ -45,6 +50,22 @@ public:
|
||||
void setSourceExtensions(const std::vector<std::string>& sourceExtensions);
|
||||
|
||||
protected:
|
||||
template<typename T>
|
||||
static T getValue(const std::string& key, T defaultValue, std::shared_ptr<const ConfigManager> config);
|
||||
|
||||
template<typename T>
|
||||
static std::vector<T> getValues(const std::string& key, std::vector<T> defaultValues, std::shared_ptr<const ConfigManager> config);
|
||||
|
||||
static std::vector<FilePath> getPathValues(const std::string& key, std::shared_ptr<const ConfigManager> config);
|
||||
|
||||
template<typename T>
|
||||
static bool setValue(const std::string& key, T value, std::shared_ptr<ConfigManager> config);
|
||||
|
||||
template<typename T>
|
||||
static bool setValues(const std::string& key, std::vector<T> values, std::shared_ptr<ConfigManager> config);
|
||||
|
||||
static bool setPathValues(const std::string& key, const std::vector<FilePath>& paths, std::shared_ptr<ConfigManager> config);
|
||||
|
||||
const ProjectSettings* m_projectSettings;
|
||||
|
||||
private:
|
||||
@@ -61,4 +82,54 @@ private:
|
||||
std::vector<std::string> m_sourceExtensions;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
T SourceGroupSettings::getValue(const std::string& key, T defaultValue, std::shared_ptr<const ConfigManager> config)
|
||||
{
|
||||
if (config)
|
||||
{
|
||||
T value;
|
||||
if (config->getValue(key, value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> SourceGroupSettings::getValues(const std::string& key, std::vector<T> defaultValues, std::shared_ptr<const ConfigManager> config)
|
||||
{
|
||||
if (config)
|
||||
{
|
||||
std::vector<T> values;
|
||||
if (config->getValues(key, values))
|
||||
{
|
||||
return values;
|
||||
}
|
||||
}
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool SourceGroupSettings::setValue(const std::string& key, T value, std::shared_ptr<ConfigManager> config)
|
||||
{
|
||||
if (config)
|
||||
{
|
||||
config->setValue(key, value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool SourceGroupSettings::setValues(const std::string& key, std::vector<T> values, std::shared_ptr<ConfigManager> config)
|
||||
{
|
||||
if (config)
|
||||
{
|
||||
config->setValues(key, values);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_H
|
||||
|
||||
@@ -3,156 +3,11 @@
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityApp.h"
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxx::getAvailableArchTypes()
|
||||
{
|
||||
return {
|
||||
"aarch64",
|
||||
"aarch64_be",
|
||||
"arm",
|
||||
"armeb",
|
||||
"avr",
|
||||
"bpfel",
|
||||
"bpfeb",
|
||||
"hexagon",
|
||||
"mips",
|
||||
"mipsel",
|
||||
"mips64",
|
||||
"mips64el",
|
||||
"msp430",
|
||||
"powerpc64",
|
||||
"powerpc64le",
|
||||
"powerpc",
|
||||
"r600",
|
||||
"amdgcn",
|
||||
"riscv32",
|
||||
"riscv64",
|
||||
"sparc",
|
||||
"sparcv9",
|
||||
"sparcel",
|
||||
"s390x",
|
||||
"tce",
|
||||
"tcele",
|
||||
"thumb",
|
||||
"thumbeb",
|
||||
"i386",
|
||||
"x86_64",
|
||||
"xcore",
|
||||
"nvptx",
|
||||
"nvptx64",
|
||||
"le32",
|
||||
"le64",
|
||||
"amdil",
|
||||
"amdil64",
|
||||
"hsail",
|
||||
"hsail64",
|
||||
"spir",
|
||||
"spir64",
|
||||
"kalimba",
|
||||
"lanai",
|
||||
"shave",
|
||||
"wasm32",
|
||||
"wasm64",
|
||||
"renderscript32",
|
||||
"renderscript64",
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxx::getAvailableVendorTypes()
|
||||
{
|
||||
return {
|
||||
"unknown",
|
||||
"apple",
|
||||
"pc",
|
||||
"scei",
|
||||
"bgp",
|
||||
"bgq",
|
||||
"fsl",
|
||||
"ibm",
|
||||
"img",
|
||||
"mti",
|
||||
"nvidia",
|
||||
"csr",
|
||||
"myriad",
|
||||
"amd",
|
||||
"mesa"
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxx::getAvailableOsTypes()
|
||||
{
|
||||
return {
|
||||
"unknown",
|
||||
"cloudabi",
|
||||
"darwin",
|
||||
"dragonfly",
|
||||
"freebsd",
|
||||
"fuchsia",
|
||||
"ios",
|
||||
"kfreebsd",
|
||||
"linux",
|
||||
"lv2",
|
||||
"macosx",
|
||||
"netbsd",
|
||||
"openbsd",
|
||||
"solaris",
|
||||
"windows",
|
||||
"haiku",
|
||||
"minix",
|
||||
"rtems",
|
||||
"nacl",
|
||||
"cnk",
|
||||
"bitrig",
|
||||
"aix",
|
||||
"cuda",
|
||||
"nvcl",
|
||||
"amdhsa",
|
||||
"ps4",
|
||||
"elfiamcu",
|
||||
"tvos",
|
||||
"watchos",
|
||||
"mesa3d",
|
||||
"contiki"
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxx::getAvailableEnvironmentTypes()
|
||||
{
|
||||
return {
|
||||
"unknown",
|
||||
"gnu",
|
||||
"gnuabi64",
|
||||
"gnueabihf",
|
||||
"gnueabi",
|
||||
"gnux32",
|
||||
"code16",
|
||||
"eabi",
|
||||
"eabihf",
|
||||
"android",
|
||||
"musl",
|
||||
"musleabi",
|
||||
"musleabihf",
|
||||
"msvc",
|
||||
"itanium",
|
||||
"cygnus",
|
||||
"amdopencl",
|
||||
"coreclr",
|
||||
"opencl"
|
||||
};
|
||||
}
|
||||
|
||||
SourceGroupSettingsCxx::SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
|
||||
: SourceGroupSettings(id, type, projectSettings)
|
||||
, m_headerSearchPaths(std::vector<FilePath>())
|
||||
, m_frameworkSearchPaths(std::vector<FilePath>())
|
||||
, m_targetOptionsEnabled(false)
|
||||
, m_targetArch("")
|
||||
, m_targetVendor("")
|
||||
, m_targetSys("")
|
||||
, m_targetAbi("")
|
||||
, m_compilerFlags(std::vector<std::string>())
|
||||
, m_useSourcePathsForHeaderSearch(false)
|
||||
, m_hasDefinedUseSourcePathsForHeaderSearch(false)
|
||||
, m_compilationDatabasePath(FilePath())
|
||||
, m_shouldApplyAnonymousTypedefTransformation(true)
|
||||
{
|
||||
}
|
||||
@@ -161,6 +16,30 @@ SourceGroupSettingsCxx::~SourceGroupSettingsCxx()
|
||||
{
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::load(std::shared_ptr<const ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettings::load(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setHeaderSearchPaths(getPathValues(key + "/header_search_paths/header_search_path", config));
|
||||
setFrameworkSearchPaths(getPathValues(key + "/framework_search_paths/framework_search_path", config));
|
||||
setCompilerFlags(getValues<std::string>(key + "/compiler_flags/compiler_flag", std::vector<std::string>(), config));
|
||||
setShouldApplyAnonymousTypedefTransformation(getValue<bool>(key + "/should_apply_anonymous_typedef_transformation", true, config));
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::save(std::shared_ptr<ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettings::save(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setPathValues(key + "/header_search_paths/header_search_path", getHeaderSearchPaths(), config);
|
||||
setPathValues(key + "/framework_search_paths/framework_search_path", getFrameworkSearchPaths(), config);
|
||||
setValues(key + "/compiler_flags/compiler_flag", getCompilerFlags(), config);
|
||||
setValue(key + "/should_apply_anonymous_typedef_transformation", getShouldApplyAnonymousTypedefTransformation(), config);
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxx::equals(std::shared_ptr<SourceGroupSettings> other) const
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsCxx> otherCxx = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(other);
|
||||
@@ -170,11 +49,7 @@ bool SourceGroupSettingsCxx::equals(std::shared_ptr<SourceGroupSettings> other)
|
||||
SourceGroupSettings::equals(other) &&
|
||||
utility::isPermutation(m_headerSearchPaths, otherCxx->m_headerSearchPaths) &&
|
||||
utility::isPermutation(m_frameworkSearchPaths, otherCxx->m_frameworkSearchPaths) &&
|
||||
utility::isPermutation(m_compilerFlags, otherCxx->m_compilerFlags) &&
|
||||
m_useSourcePathsForHeaderSearch == otherCxx->m_useSourcePathsForHeaderSearch &&
|
||||
m_hasDefinedUseSourcePathsForHeaderSearch == otherCxx->m_hasDefinedUseSourcePathsForHeaderSearch &&
|
||||
m_compilationDatabasePath == otherCxx->m_compilationDatabasePath &&
|
||||
getTargetFlag() == otherCxx->getTargetFlag()
|
||||
utility::isPermutation(m_compilerFlags, otherCxx->m_compilerFlags)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -271,70 +146,6 @@ void SourceGroupSettingsCxx::setFrameworkSearchPaths(const std::vector<FilePath>
|
||||
m_frameworkSearchPaths = frameworkSearchPaths;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxx::getTargetOptionsEnabled() const
|
||||
{
|
||||
return m_targetOptionsEnabled;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setTargetOptionsEnabled(bool targetOptionsEnabled)
|
||||
{
|
||||
m_targetOptionsEnabled = targetOptionsEnabled;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxx::getTargetArch() const
|
||||
{
|
||||
return m_targetArch;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setTargetArch(const std::string& arch)
|
||||
{
|
||||
m_targetArch = arch;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxx::getTargetVendor() const
|
||||
{
|
||||
return m_targetVendor;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setTargetVendor(const std::string& vendor)
|
||||
{
|
||||
m_targetVendor = vendor;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxx::getTargetSys() const
|
||||
{
|
||||
return m_targetSys;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setTargetSys(const std::string& sys)
|
||||
{
|
||||
m_targetSys = sys;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxx::getTargetAbi() const
|
||||
{
|
||||
return m_targetAbi;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setTargetAbi(const std::string& abi)
|
||||
{
|
||||
m_targetAbi = abi;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxx::getTargetFlag() const
|
||||
{
|
||||
std::string targetFlag = "";
|
||||
if (m_targetOptionsEnabled && !m_targetArch.empty())
|
||||
{
|
||||
targetFlag = "--target=";
|
||||
targetFlag += m_targetArch;
|
||||
targetFlag += "-" + (m_targetVendor.empty() ? "unknown" : m_targetVendor);
|
||||
targetFlag += "-" + (m_targetSys.empty() ? "unknown" : m_targetSys);
|
||||
targetFlag += "-" + (m_targetAbi.empty() ? "unknown" : m_targetAbi);
|
||||
}
|
||||
return targetFlag;
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxx::getCompilerFlags() const
|
||||
{
|
||||
return m_compilerFlags;
|
||||
@@ -345,41 +156,6 @@ void SourceGroupSettingsCxx::setCompilerFlags(const std::vector<std::string>& co
|
||||
m_compilerFlags = compilerFlags;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxx::getUseSourcePathsForHeaderSearch() const
|
||||
{
|
||||
return m_useSourcePathsForHeaderSearch;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch)
|
||||
{
|
||||
m_useSourcePathsForHeaderSearch = useSourcePathsForHeaderSearch;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxx::getHasDefinedUseSourcePathsForHeaderSearch() const
|
||||
{
|
||||
return m_hasDefinedUseSourcePathsForHeaderSearch;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setHasDefinedUseSourcePathsForHeaderSearch(bool hasDefinedUseSourcePathsForHeaderSearch)
|
||||
{
|
||||
m_hasDefinedUseSourcePathsForHeaderSearch = hasDefinedUseSourcePathsForHeaderSearch;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsCxx::getCompilationDatabasePath() const
|
||||
{
|
||||
return m_compilationDatabasePath;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsCxx::getCompilationDatabasePathExpandedAndAbsolute() const
|
||||
{
|
||||
return m_projectSettings->makePathExpandedAndAbsolute(getCompilationDatabasePath());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxx::setCompilationDatabasePath(const FilePath& compilationDatabasePath)
|
||||
{
|
||||
m_compilationDatabasePath = compilationDatabasePath;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxx::getShouldApplyAnonymousTypedefTransformation() const
|
||||
{
|
||||
return m_shouldApplyAnonymousTypedefTransformation;
|
||||
|
||||
@@ -7,14 +7,12 @@ class SourceGroupSettingsCxx
|
||||
: public SourceGroupSettings
|
||||
{
|
||||
public:
|
||||
static std::vector<std::string> getAvailableArchTypes();
|
||||
static std::vector<std::string> getAvailableVendorTypes();
|
||||
static std::vector<std::string> getAvailableOsTypes();
|
||||
static std::vector<std::string> getAvailableEnvironmentTypes();
|
||||
|
||||
SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettingsCxx();
|
||||
|
||||
virtual void load(std::shared_ptr<const ConfigManager> config);
|
||||
virtual void save(std::shared_ptr<ConfigManager> config);
|
||||
|
||||
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const;
|
||||
|
||||
virtual std::vector<std::string> getAvailableLanguageStandards() const;
|
||||
@@ -27,37 +25,9 @@ public:
|
||||
std::vector<FilePath> getFrameworkSearchPathsExpandedAndAbsolute() const;
|
||||
void setFrameworkSearchPaths(const std::vector<FilePath>& frameworkSearchPaths);
|
||||
|
||||
bool getTargetOptionsEnabled() const;
|
||||
void setTargetOptionsEnabled(bool targetOptionsEnabled);
|
||||
|
||||
std::string getTargetArch() const;
|
||||
void setTargetArch(const std::string& arch);
|
||||
|
||||
std::string getTargetVendor() const;
|
||||
void setTargetVendor(const std::string& vendor);
|
||||
|
||||
std::string getTargetSys() const;
|
||||
void setTargetSys(const std::string& sys);
|
||||
|
||||
std::string getTargetAbi() const;
|
||||
void setTargetAbi(const std::string& abi);
|
||||
|
||||
std::string getTargetFlag() const;
|
||||
|
||||
std::vector<std::string> getCompilerFlags() const;
|
||||
void setCompilerFlags(const std::vector<std::string>& compilerFlags);
|
||||
|
||||
// deprecated begin
|
||||
bool getUseSourcePathsForHeaderSearch() const;
|
||||
void setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch);
|
||||
bool getHasDefinedUseSourcePathsForHeaderSearch() const;
|
||||
void setHasDefinedUseSourcePathsForHeaderSearch(bool hasDefinedUseSourcePathsForHeaderSearch);
|
||||
// deprecated end
|
||||
|
||||
FilePath getCompilationDatabasePath() const;
|
||||
FilePath getCompilationDatabasePathExpandedAndAbsolute() const;
|
||||
void setCompilationDatabasePath(const FilePath& compilationDatabasePath);
|
||||
|
||||
bool getShouldApplyAnonymousTypedefTransformation() const;
|
||||
void setShouldApplyAnonymousTypedefTransformation(bool shouldApplyAnonymousTypedefTransformation);
|
||||
|
||||
@@ -67,15 +37,7 @@ private:
|
||||
|
||||
std::vector<FilePath> m_headerSearchPaths;
|
||||
std::vector<FilePath> m_frameworkSearchPaths;
|
||||
bool m_targetOptionsEnabled;
|
||||
std::string m_targetArch;
|
||||
std::string m_targetVendor;
|
||||
std::string m_targetSys;
|
||||
std::string m_targetAbi;
|
||||
std::vector<std::string> m_compilerFlags;
|
||||
bool m_useSourcePathsForHeaderSearch;
|
||||
bool m_hasDefinedUseSourcePathsForHeaderSearch;
|
||||
FilePath m_compilationDatabasePath;
|
||||
bool m_shouldApplyAnonymousTypedefTransformation;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#include "settings/SourceGroupSettingsCxxCdb.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityApp.h"
|
||||
|
||||
SourceGroupSettingsCxxCdb::SourceGroupSettingsCxxCdb(const std::string& id, const ProjectSettings* projectSettings)
|
||||
: SourceGroupSettingsCxx(id, SOURCE_GROUP_CXX_CDB, projectSettings)
|
||||
, m_compilationDatabasePath(FilePath())
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupSettingsCxxCdb::~SourceGroupSettingsCxxCdb()
|
||||
{
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxxCdb::load(std::shared_ptr<const ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettingsCxx::load(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setCompilationDatabasePath(FilePath(getValue<std::string>(key + "/build_file_path/compilation_db_path", "", config)));
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxxCdb::save(std::shared_ptr<ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettingsCxx::save(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setValue(key + "/build_file_path/compilation_db_path", getCompilationDatabasePath().str(), config);
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxxCdb::equals(std::shared_ptr<SourceGroupSettings> other) const
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsCxxCdb> otherCxxCdb = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(other);
|
||||
|
||||
return (
|
||||
otherCxxCdb &&
|
||||
SourceGroupSettingsCxx::equals(other) &&
|
||||
m_compilationDatabasePath == otherCxxCdb->m_compilationDatabasePath
|
||||
);
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsCxxCdb::getCompilationDatabasePath() const
|
||||
{
|
||||
return m_compilationDatabasePath;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsCxxCdb::getCompilationDatabasePathExpandedAndAbsolute() const
|
||||
{
|
||||
return m_projectSettings->makePathExpandedAndAbsolute(getCompilationDatabasePath());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxxCdb::setCompilationDatabasePath(const FilePath& compilationDatabasePath)
|
||||
{
|
||||
m_compilationDatabasePath = compilationDatabasePath;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef SOURCE_GROUP_SETTINGS_CXX_CDB_H
|
||||
#define SOURCE_GROUP_SETTINGS_CXX_CDB_H
|
||||
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
|
||||
class SourceGroupSettingsCxxCdb
|
||||
: public SourceGroupSettingsCxx
|
||||
{
|
||||
public:
|
||||
SourceGroupSettingsCxxCdb(const std::string& id, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettingsCxxCdb();
|
||||
|
||||
virtual void load(std::shared_ptr<const ConfigManager> config);
|
||||
virtual void save(std::shared_ptr<ConfigManager> config);
|
||||
|
||||
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const;
|
||||
|
||||
FilePath getCompilationDatabasePath() const;
|
||||
FilePath getCompilationDatabasePathExpandedAndAbsolute() const;
|
||||
void setCompilationDatabasePath(const FilePath& compilationDatabasePath);
|
||||
|
||||
private:
|
||||
FilePath m_compilationDatabasePath;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_CXX_CDB_H
|
||||
@@ -0,0 +1,256 @@
|
||||
#include "settings/SourceGroupSettingsCxxEmpty.h"
|
||||
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityApp.h"
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxxEmpty::getAvailableArchTypes()
|
||||
{
|
||||
return {
|
||||
"aarch64",
|
||||
"aarch64_be",
|
||||
"arm",
|
||||
"armeb",
|
||||
"avr",
|
||||
"bpfel",
|
||||
"bpfeb",
|
||||
"hexagon",
|
||||
"mips",
|
||||
"mipsel",
|
||||
"mips64",
|
||||
"mips64el",
|
||||
"msp430",
|
||||
"powerpc64",
|
||||
"powerpc64le",
|
||||
"powerpc",
|
||||
"r600",
|
||||
"amdgcn",
|
||||
"riscv32",
|
||||
"riscv64",
|
||||
"sparc",
|
||||
"sparcv9",
|
||||
"sparcel",
|
||||
"s390x",
|
||||
"tce",
|
||||
"tcele",
|
||||
"thumb",
|
||||
"thumbeb",
|
||||
"i386",
|
||||
"x86_64",
|
||||
"xcore",
|
||||
"nvptx",
|
||||
"nvptx64",
|
||||
"le32",
|
||||
"le64",
|
||||
"amdil",
|
||||
"amdil64",
|
||||
"hsail",
|
||||
"hsail64",
|
||||
"spir",
|
||||
"spir64",
|
||||
"kalimba",
|
||||
"lanai",
|
||||
"shave",
|
||||
"wasm32",
|
||||
"wasm64",
|
||||
"renderscript32",
|
||||
"renderscript64",
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxxEmpty::getAvailableVendorTypes()
|
||||
{
|
||||
return {
|
||||
"unknown",
|
||||
"apple",
|
||||
"pc",
|
||||
"scei",
|
||||
"bgp",
|
||||
"bgq",
|
||||
"fsl",
|
||||
"ibm",
|
||||
"img",
|
||||
"mti",
|
||||
"nvidia",
|
||||
"csr",
|
||||
"myriad",
|
||||
"amd",
|
||||
"mesa"
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxxEmpty::getAvailableOsTypes()
|
||||
{
|
||||
return {
|
||||
"unknown",
|
||||
"cloudabi",
|
||||
"darwin",
|
||||
"dragonfly",
|
||||
"freebsd",
|
||||
"fuchsia",
|
||||
"ios",
|
||||
"kfreebsd",
|
||||
"linux",
|
||||
"lv2",
|
||||
"macosx",
|
||||
"netbsd",
|
||||
"openbsd",
|
||||
"solaris",
|
||||
"windows",
|
||||
"haiku",
|
||||
"minix",
|
||||
"rtems",
|
||||
"nacl",
|
||||
"cnk",
|
||||
"bitrig",
|
||||
"aix",
|
||||
"cuda",
|
||||
"nvcl",
|
||||
"amdhsa",
|
||||
"ps4",
|
||||
"elfiamcu",
|
||||
"tvos",
|
||||
"watchos",
|
||||
"mesa3d",
|
||||
"contiki"
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsCxxEmpty::getAvailableEnvironmentTypes()
|
||||
{
|
||||
return {
|
||||
"unknown",
|
||||
"gnu",
|
||||
"gnuabi64",
|
||||
"gnueabihf",
|
||||
"gnueabi",
|
||||
"gnux32",
|
||||
"code16",
|
||||
"eabi",
|
||||
"eabihf",
|
||||
"android",
|
||||
"musl",
|
||||
"musleabi",
|
||||
"musleabihf",
|
||||
"msvc",
|
||||
"itanium",
|
||||
"cygnus",
|
||||
"amdopencl",
|
||||
"coreclr",
|
||||
"opencl"
|
||||
};
|
||||
}
|
||||
|
||||
SourceGroupSettingsCxxEmpty::SourceGroupSettingsCxxEmpty(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
|
||||
: SourceGroupSettingsCxx(id, type, projectSettings)
|
||||
, m_targetOptionsEnabled(false)
|
||||
, m_targetArch("")
|
||||
, m_targetVendor("")
|
||||
, m_targetSys("")
|
||||
, m_targetAbi("")
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupSettingsCxxEmpty::~SourceGroupSettingsCxxEmpty()
|
||||
{
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxxEmpty::load(std::shared_ptr<const ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettingsCxx::load(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setTargetOptionsEnabled(getValue<bool>(key + "/cross_compilation/target_options_enabled", false, config));
|
||||
setTargetArch(getValue<std::string>(key + "/cross_compilation/target/arch", "", config));
|
||||
setTargetVendor(getValue<std::string>(key + "/cross_compilation/target/vendor", "", config));
|
||||
setTargetSys(getValue<std::string>(key + "/cross_compilation/target/sys", "", config));
|
||||
setTargetAbi(getValue<std::string>(key + "/cross_compilation/target/abi", "", config));
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxxEmpty::save(std::shared_ptr<ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettingsCxx::save(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setValue(key + "/cross_compilation/target_options_enabled", getTargetOptionsEnabled(), config);
|
||||
setValue(key + "/cross_compilation/target/arch", getTargetArch(), config);
|
||||
setValue(key + "/cross_compilation/target/vendor", getTargetVendor(), config);
|
||||
setValue(key + "/cross_compilation/target/sys", getTargetSys(), config);
|
||||
setValue(key + "/cross_compilation/target/abi", getTargetAbi(), config);
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxxEmpty::equals(std::shared_ptr<SourceGroupSettings> other) const
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsCxxEmpty> otherCxxEmpty = std::dynamic_pointer_cast<SourceGroupSettingsCxxEmpty>(other);
|
||||
|
||||
return (
|
||||
otherCxxEmpty &&
|
||||
SourceGroupSettingsCxx::equals(other) &&
|
||||
getTargetFlag() == otherCxxEmpty->getTargetFlag()
|
||||
);
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsCxxEmpty::getTargetOptionsEnabled() const
|
||||
{
|
||||
return m_targetOptionsEnabled;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxxEmpty::setTargetOptionsEnabled(bool targetOptionsEnabled)
|
||||
{
|
||||
m_targetOptionsEnabled = targetOptionsEnabled;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxxEmpty::getTargetArch() const
|
||||
{
|
||||
return m_targetArch;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxxEmpty::setTargetArch(const std::string& arch)
|
||||
{
|
||||
m_targetArch = arch;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxxEmpty::getTargetVendor() const
|
||||
{
|
||||
return m_targetVendor;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxxEmpty::setTargetVendor(const std::string& vendor)
|
||||
{
|
||||
m_targetVendor = vendor;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxxEmpty::getTargetSys() const
|
||||
{
|
||||
return m_targetSys;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxxEmpty::setTargetSys(const std::string& sys)
|
||||
{
|
||||
m_targetSys = sys;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxxEmpty::getTargetAbi() const
|
||||
{
|
||||
return m_targetAbi;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsCxxEmpty::setTargetAbi(const std::string& abi)
|
||||
{
|
||||
m_targetAbi = abi;
|
||||
}
|
||||
|
||||
std::string SourceGroupSettingsCxxEmpty::getTargetFlag() const
|
||||
{
|
||||
std::string targetFlag = "";
|
||||
if (m_targetOptionsEnabled && !m_targetArch.empty())
|
||||
{
|
||||
targetFlag = "--target=";
|
||||
targetFlag += m_targetArch;
|
||||
targetFlag += "-" + (m_targetVendor.empty() ? "unknown" : m_targetVendor);
|
||||
targetFlag += "-" + (m_targetSys.empty() ? "unknown" : m_targetSys);
|
||||
targetFlag += "-" + (m_targetAbi.empty() ? "unknown" : m_targetAbi);
|
||||
}
|
||||
return targetFlag;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef SOURCE_GROUP_SETTINGS_CXX_EMPTY_H
|
||||
#define SOURCE_GROUP_SETTINGS_CXX_EMPTY_H
|
||||
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
|
||||
class SourceGroupSettingsCxxEmpty
|
||||
: public SourceGroupSettingsCxx
|
||||
{
|
||||
public:
|
||||
static std::vector<std::string> getAvailableArchTypes();
|
||||
static std::vector<std::string> getAvailableVendorTypes();
|
||||
static std::vector<std::string> getAvailableOsTypes();
|
||||
static std::vector<std::string> getAvailableEnvironmentTypes();
|
||||
|
||||
SourceGroupSettingsCxxEmpty(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettingsCxxEmpty();
|
||||
|
||||
virtual void load(std::shared_ptr<const ConfigManager> config);
|
||||
virtual void save(std::shared_ptr<ConfigManager> config);
|
||||
|
||||
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const;
|
||||
|
||||
bool getTargetOptionsEnabled() const;
|
||||
void setTargetOptionsEnabled(bool targetOptionsEnabled);
|
||||
|
||||
std::string getTargetArch() const;
|
||||
void setTargetArch(const std::string& arch);
|
||||
|
||||
std::string getTargetVendor() const;
|
||||
void setTargetVendor(const std::string& vendor);
|
||||
|
||||
std::string getTargetSys() const;
|
||||
void setTargetSys(const std::string& sys);
|
||||
|
||||
std::string getTargetAbi() const;
|
||||
void setTargetAbi(const std::string& abi);
|
||||
|
||||
std::string getTargetFlag() const;
|
||||
|
||||
private:
|
||||
bool m_targetOptionsEnabled;
|
||||
std::string m_targetArch;
|
||||
std::string m_targetVendor;
|
||||
std::string m_targetSys;
|
||||
std::string m_targetAbi;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_CXX_EMPTY_H
|
||||
@@ -4,10 +4,8 @@
|
||||
|
||||
SourceGroupSettingsJava::SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
|
||||
: SourceGroupSettings(id, type, projectSettings)
|
||||
, m_useJreSystemLibrary(true)
|
||||
, m_classpath(std::vector<FilePath>())
|
||||
, m_mavenProjectFilePath(FilePath())
|
||||
, m_mavenDependenciesDirectory(FilePath())
|
||||
, m_shouldIndexMavenTests(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -15,6 +13,26 @@ SourceGroupSettingsJava::~SourceGroupSettingsJava()
|
||||
{
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::load(std::shared_ptr<const ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettings::load(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setClasspath(getPathValues(key + "/class_paths/class_path", config));
|
||||
setUseJreSystemLibrary(getValue<bool>(key + "/use_jre_system_library", true, config));
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::save(std::shared_ptr<ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettings::save(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setPathValues(key + "/class_paths/class_path", getClasspath(), config);
|
||||
setValue(key + "/use_jre_system_library", getUseJreSystemLibrary(), config);
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsJava::equals(std::shared_ptr<SourceGroupSettings> other) const
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> otherJava = std::dynamic_pointer_cast<SourceGroupSettingsJava>(other);
|
||||
@@ -22,11 +40,8 @@ bool SourceGroupSettingsJava::equals(std::shared_ptr<SourceGroupSettings> other)
|
||||
return (
|
||||
otherJava &&
|
||||
SourceGroupSettings::equals(other) &&
|
||||
utility::isPermutation(m_classpath, otherJava->m_classpath) &&
|
||||
m_useJreSystemLibrary == otherJava->m_useJreSystemLibrary &&
|
||||
m_mavenProjectFilePath == otherJava->m_mavenProjectFilePath &&
|
||||
m_mavenDependenciesDirectory == otherJava->m_mavenDependenciesDirectory &&
|
||||
m_shouldIndexMavenTests == otherJava->m_shouldIndexMavenTests
|
||||
utility::isPermutation(m_classpath, otherJava->m_classpath)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -59,47 +74,6 @@ void SourceGroupSettingsJava::setClasspath(const std::vector<FilePath>& classpat
|
||||
{
|
||||
m_classpath = classpath;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJava::getMavenProjectFilePath() const
|
||||
{
|
||||
return m_mavenProjectFilePath;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJava::getMavenProjectFilePathExpandedAndAbsolute() const
|
||||
{
|
||||
return m_projectSettings->makePathExpandedAndAbsolute(getMavenProjectFilePath());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::setMavenProjectFilePath(const FilePath& path)
|
||||
{
|
||||
m_mavenProjectFilePath = path;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJava::getMavenDependenciesDirectory() const
|
||||
{
|
||||
return m_mavenDependenciesDirectory;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJava::getMavenDependenciesDirectoryExpandedAndAbsolute() const
|
||||
{
|
||||
return m_projectSettings->makePathExpandedAndAbsolute(getMavenDependenciesDirectory());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::setMavenDependenciesDirectory(const FilePath& path)
|
||||
{
|
||||
m_mavenDependenciesDirectory = path;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsJava::getShouldIndexMavenTests() const
|
||||
{
|
||||
return m_shouldIndexMavenTests;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJava::setShouldIndexMavenTests(bool value)
|
||||
{
|
||||
m_shouldIndexMavenTests = value;
|
||||
}
|
||||
|
||||
std::vector<std::string> SourceGroupSettingsJava::getDefaultSourceExtensions() const
|
||||
{
|
||||
return std::vector<std::string>(1, ".java");
|
||||
|
||||
@@ -13,6 +13,9 @@ public:
|
||||
SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettingsJava();
|
||||
|
||||
virtual void load(std::shared_ptr<const ConfigManager> config);
|
||||
virtual void save(std::shared_ptr<ConfigManager> config);
|
||||
|
||||
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const;
|
||||
|
||||
virtual std::vector<std::string> getAvailableLanguageStandards() const;
|
||||
@@ -24,26 +27,12 @@ public:
|
||||
std::vector<FilePath> getClasspathExpandedAndAbsolute() const;
|
||||
void setClasspath(const std::vector<FilePath>& classpath);
|
||||
|
||||
FilePath getMavenProjectFilePath() const;
|
||||
FilePath getMavenProjectFilePathExpandedAndAbsolute() const;
|
||||
void setMavenProjectFilePath(const FilePath& path);
|
||||
|
||||
FilePath getMavenDependenciesDirectory() const;
|
||||
FilePath getMavenDependenciesDirectoryExpandedAndAbsolute() const;
|
||||
void setMavenDependenciesDirectory(const FilePath& path);
|
||||
|
||||
bool getShouldIndexMavenTests() const;
|
||||
void setShouldIndexMavenTests(bool value);
|
||||
|
||||
private:
|
||||
virtual std::vector<std::string> getDefaultSourceExtensions() const;
|
||||
virtual std::string getDefaultStandard() const;
|
||||
|
||||
bool m_useJreSystemLibrary;
|
||||
std::vector<FilePath> m_classpath;
|
||||
FilePath m_mavenProjectFilePath;
|
||||
FilePath m_mavenDependenciesDirectory;
|
||||
bool m_shouldIndexMavenTests;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_JAVA_H
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "settings/SourceGroupSettingsJavaEmpty.h"
|
||||
|
||||
SourceGroupSettingsJavaEmpty::SourceGroupSettingsJavaEmpty(const std::string& id, const ProjectSettings* projectSettings)
|
||||
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_EMPTY, projectSettings)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupSettingsJavaEmpty::~SourceGroupSettingsJavaEmpty()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef SOURCE_GROUP_SETTINGS_JAVA_EMPTY_H
|
||||
#define SOURCE_GROUP_SETTINGS_JAVA_EMPTY_H
|
||||
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
|
||||
class SourceGroupSettingsJavaEmpty
|
||||
: public SourceGroupSettingsJava
|
||||
{
|
||||
public:
|
||||
SourceGroupSettingsJavaEmpty(const std::string& id, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettingsJavaEmpty();
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_JAVA_EMPTY_H
|
||||
@@ -0,0 +1,88 @@
|
||||
#include "settings/SourceGroupSettingsJavaGradle.h"
|
||||
|
||||
SourceGroupSettingsJavaGradle::SourceGroupSettingsJavaGradle(const std::string& id, const ProjectSettings* projectSettings)
|
||||
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_GRADLE, projectSettings)
|
||||
, m_gradleProjectFilePath(FilePath())
|
||||
, m_gradleDependenciesDirectory(FilePath())
|
||||
, m_shouldIndexGradleTests(false)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupSettingsJavaGradle::~SourceGroupSettingsJavaGradle()
|
||||
{
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJavaGradle::load(std::shared_ptr<const ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettingsJava::load(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setGradleProjectFilePath(FilePath(getValue<std::string>(key + "/gradle/project_file_path", "", config)));
|
||||
setGradleDependenciesDirectory(FilePath(getValue<std::string>(key + "/gradle/dependencies_directory", "", config)));
|
||||
setShouldIndexGradleTests(getValue<bool>(key + "/gradle/should_index_tests", false, config));
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJavaGradle::save(std::shared_ptr<ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettingsJava::save(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setValue(key + "/gradle/project_file_path", getGradleProjectFilePath().str(), config);
|
||||
setValue(key + "/gradle/dependencies_directory", getGradleDependenciesDirectory().str(), config);
|
||||
setValue(key + "/gradle/should_index_tests", getShouldIndexGradleTests(), config);
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsJavaGradle::equals(std::shared_ptr<SourceGroupSettings> other) const
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJavaGradle> otherJavaGradle = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(other);
|
||||
|
||||
return (
|
||||
otherJavaGradle &&
|
||||
SourceGroupSettingsJava::equals(other) &&
|
||||
m_gradleProjectFilePath == otherJavaGradle->m_gradleProjectFilePath &&
|
||||
m_gradleDependenciesDirectory == otherJavaGradle->m_gradleDependenciesDirectory &&
|
||||
m_shouldIndexGradleTests == otherJavaGradle->m_shouldIndexGradleTests
|
||||
);
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJavaGradle::getGradleProjectFilePath() const
|
||||
{
|
||||
return m_gradleProjectFilePath;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJavaGradle::getGradleProjectFilePathExpandedAndAbsolute() const
|
||||
{
|
||||
return m_projectSettings->makePathExpandedAndAbsolute(getGradleProjectFilePath());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJavaGradle::setGradleProjectFilePath(const FilePath& path)
|
||||
{
|
||||
m_gradleProjectFilePath = path;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJavaGradle::getGradleDependenciesDirectory() const
|
||||
{
|
||||
return m_gradleDependenciesDirectory;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJavaGradle::getGradleDependenciesDirectoryExpandedAndAbsolute() const
|
||||
{
|
||||
return m_projectSettings->makePathExpandedAndAbsolute(getGradleDependenciesDirectory());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJavaGradle::setGradleDependenciesDirectory(const FilePath& path)
|
||||
{
|
||||
m_gradleDependenciesDirectory = path;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsJavaGradle::getShouldIndexGradleTests() const
|
||||
{
|
||||
return m_shouldIndexGradleTests;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJavaGradle::setShouldIndexGradleTests(bool value)
|
||||
{
|
||||
m_shouldIndexGradleTests = value;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef SOURCE_GROUP_SETTINGS_JAVA_GRADLE_H
|
||||
#define SOURCE_GROUP_SETTINGS_JAVA_GRADLE_H
|
||||
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
|
||||
class SourceGroupSettingsJavaGradle
|
||||
: public SourceGroupSettingsJava
|
||||
{
|
||||
public:
|
||||
SourceGroupSettingsJavaGradle(const std::string& id, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettingsJavaGradle();
|
||||
|
||||
virtual void load(std::shared_ptr<const ConfigManager> config);
|
||||
virtual void save(std::shared_ptr<ConfigManager> config);
|
||||
|
||||
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const;
|
||||
|
||||
FilePath getGradleProjectFilePath() const;
|
||||
FilePath getGradleProjectFilePathExpandedAndAbsolute() const;
|
||||
void setGradleProjectFilePath(const FilePath& path);
|
||||
|
||||
FilePath getGradleDependenciesDirectory() const;
|
||||
FilePath getGradleDependenciesDirectoryExpandedAndAbsolute() const;
|
||||
void setGradleDependenciesDirectory(const FilePath& path);
|
||||
|
||||
bool getShouldIndexGradleTests() const;
|
||||
void setShouldIndexGradleTests(bool value);
|
||||
|
||||
private:
|
||||
FilePath m_gradleProjectFilePath;
|
||||
FilePath m_gradleDependenciesDirectory;
|
||||
bool m_shouldIndexGradleTests;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_JAVA_GRADLE_H
|
||||
@@ -0,0 +1,88 @@
|
||||
#include "settings/SourceGroupSettingsJavaMaven.h"
|
||||
|
||||
SourceGroupSettingsJavaMaven::SourceGroupSettingsJavaMaven(const std::string& id, const ProjectSettings* projectSettings)
|
||||
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_MAVEN, projectSettings)
|
||||
, m_mavenProjectFilePath(FilePath())
|
||||
, m_mavenDependenciesDirectory(FilePath())
|
||||
, m_shouldIndexMavenTests(false)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupSettingsJavaMaven::~SourceGroupSettingsJavaMaven()
|
||||
{
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJavaMaven::load(std::shared_ptr<const ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettingsJava::load(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setMavenProjectFilePath(FilePath(getValue<std::string>(key + "/maven/project_file_path", "", config)));
|
||||
setMavenDependenciesDirectory(FilePath(getValue<std::string>(key + "/maven/dependencies_directory", "", config)));
|
||||
setShouldIndexMavenTests(getValue<bool>(key + "/maven/should_index_tests", false, config));
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJavaMaven::save(std::shared_ptr<ConfigManager> config)
|
||||
{
|
||||
SourceGroupSettingsJava::save(config);
|
||||
|
||||
const std::string key = s_keyPrefix + getId();
|
||||
|
||||
setValue(key + "/maven/project_file_path", getMavenProjectFilePath().str(), config);
|
||||
setValue(key + "/maven/dependencies_directory", getMavenDependenciesDirectory().str(), config);
|
||||
setValue(key + "/maven/should_index_tests", getShouldIndexMavenTests(), config);
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsJavaMaven::equals(std::shared_ptr<SourceGroupSettings> other) const
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJavaMaven> otherJavaMaven = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(other);
|
||||
|
||||
return (
|
||||
otherJavaMaven &&
|
||||
SourceGroupSettingsJava::equals(other) &&
|
||||
m_mavenProjectFilePath == otherJavaMaven->m_mavenProjectFilePath &&
|
||||
m_mavenDependenciesDirectory == otherJavaMaven->m_mavenDependenciesDirectory &&
|
||||
m_shouldIndexMavenTests == otherJavaMaven->m_shouldIndexMavenTests
|
||||
);
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJavaMaven::getMavenProjectFilePath() const
|
||||
{
|
||||
return m_mavenProjectFilePath;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJavaMaven::getMavenProjectFilePathExpandedAndAbsolute() const
|
||||
{
|
||||
return m_projectSettings->makePathExpandedAndAbsolute(getMavenProjectFilePath());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJavaMaven::setMavenProjectFilePath(const FilePath& path)
|
||||
{
|
||||
m_mavenProjectFilePath = path;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJavaMaven::getMavenDependenciesDirectory() const
|
||||
{
|
||||
return m_mavenDependenciesDirectory;
|
||||
}
|
||||
|
||||
FilePath SourceGroupSettingsJavaMaven::getMavenDependenciesDirectoryExpandedAndAbsolute() const
|
||||
{
|
||||
return m_projectSettings->makePathExpandedAndAbsolute(getMavenDependenciesDirectory());
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJavaMaven::setMavenDependenciesDirectory(const FilePath& path)
|
||||
{
|
||||
m_mavenDependenciesDirectory = path;
|
||||
}
|
||||
|
||||
bool SourceGroupSettingsJavaMaven::getShouldIndexMavenTests() const
|
||||
{
|
||||
return m_shouldIndexMavenTests;
|
||||
}
|
||||
|
||||
void SourceGroupSettingsJavaMaven::setShouldIndexMavenTests(bool value)
|
||||
{
|
||||
m_shouldIndexMavenTests = value;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef SOURCE_GROUP_SETTINGS_JAVA_MAVEN_H
|
||||
#define SOURCE_GROUP_SETTINGS_JAVA_MAVEN_H
|
||||
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
|
||||
class SourceGroupSettingsJavaMaven
|
||||
: public SourceGroupSettingsJava
|
||||
{
|
||||
public:
|
||||
SourceGroupSettingsJavaMaven(const std::string& id, const ProjectSettings* projectSettings);
|
||||
virtual ~SourceGroupSettingsJavaMaven();
|
||||
|
||||
virtual void load(std::shared_ptr<const ConfigManager> config);
|
||||
virtual void save(std::shared_ptr<ConfigManager> config);
|
||||
|
||||
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const;
|
||||
|
||||
FilePath getMavenProjectFilePath() const;
|
||||
FilePath getMavenProjectFilePathExpandedAndAbsolute() const;
|
||||
void setMavenProjectFilePath(const FilePath& path);
|
||||
|
||||
FilePath getMavenDependenciesDirectory() const;
|
||||
FilePath getMavenDependenciesDirectoryExpandedAndAbsolute() const;
|
||||
void setMavenDependenciesDirectory(const FilePath& path);
|
||||
|
||||
bool getShouldIndexMavenTests() const;
|
||||
void setShouldIndexMavenTests(bool value);
|
||||
|
||||
private:
|
||||
FilePath m_mavenProjectFilePath;
|
||||
FilePath m_mavenDependenciesDirectory;
|
||||
bool m_shouldIndexMavenTests;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_SETTINGS_JAVA_MAVEN_H
|
||||
@@ -16,6 +16,8 @@ std::string sourceGroupTypeToString(SourceGroupType v)
|
||||
return "Java Source Group";
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
return "Java Source Group from Maven";
|
||||
case SOURCE_GROUP_JAVA_GRADLE:
|
||||
return "Java Source Group from Gradle";
|
||||
case SOURCE_GROUP_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
@@ -38,6 +40,8 @@ std::string sourceGroupTypeToProjectSetupString(SourceGroupType v)
|
||||
return "Empty Java Source Group";
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
return "Java Source Group from Maven";
|
||||
case SOURCE_GROUP_JAVA_GRADLE:
|
||||
return "Java Source Group from Gradle";
|
||||
case SOURCE_GROUP_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
@@ -70,6 +74,10 @@ SourceGroupType stringToSourceGroupType(std::string v)
|
||||
{
|
||||
return SOURCE_GROUP_JAVA_MAVEN;
|
||||
}
|
||||
else if (v == sourceGroupTypeToString(SOURCE_GROUP_JAVA_GRADLE))
|
||||
{
|
||||
return SOURCE_GROUP_JAVA_GRADLE;
|
||||
}
|
||||
|
||||
return SOURCE_GROUP_UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ enum SourceGroupType
|
||||
SOURCE_GROUP_CXX_VS,
|
||||
SOURCE_GROUP_JAVA_EMPTY,
|
||||
SOURCE_GROUP_JAVA_MAVEN,
|
||||
SOURCE_GROUP_JAVA_GRADLE,
|
||||
SOURCE_GROUP_UNKNOWN
|
||||
};
|
||||
|
||||
|
||||
@@ -84,10 +84,12 @@ add_files(
|
||||
project/IncludeValidation.h
|
||||
project/SourceGroupCxx.cpp
|
||||
project/SourceGroupCxx.h
|
||||
project/SourceGroupFactoryModuleCpp.cpp
|
||||
project/SourceGroupFactoryModuleCpp.h
|
||||
project/SourceGroupFactoryModuleC.cpp
|
||||
project/SourceGroupFactoryModuleC.h
|
||||
project/SourceGroupCxxCdb.cpp
|
||||
project/SourceGroupCxxCdb.h
|
||||
project/SourceGroupCxxEmpty.cpp
|
||||
project/SourceGroupCxxEmpty.h
|
||||
project/SourceGroupFactoryModuleCxx.cpp
|
||||
project/SourceGroupFactoryModuleCxx.h
|
||||
|
||||
utility/CompilationDatabase.cpp
|
||||
utility/CompilationDatabase.h
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
SourceGroupCxx::SourceGroupCxx(std::shared_ptr<SourceGroupSettingsCxx> settings)
|
||||
: m_settings(settings)
|
||||
SourceGroupCxx::SourceGroupCxx()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -23,185 +22,7 @@ SourceGroupCxx::~SourceGroupCxx()
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupType SourceGroupCxx::getType() const
|
||||
std::shared_ptr<SourceGroupSettings> SourceGroupCxx::getSourceGroupSettings()
|
||||
{
|
||||
return m_settings->getType();
|
||||
}
|
||||
|
||||
bool SourceGroupCxx::prepareRefresh()
|
||||
{
|
||||
FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute();
|
||||
if (!cdbPath.empty() && !cdbPath.exists())
|
||||
{
|
||||
MessageStatus("Can't refresh project").dispatch();
|
||||
|
||||
if (std::shared_ptr<Application> application = Application::getInstance())
|
||||
{
|
||||
if (application->hasGUI())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Ok");
|
||||
application->handleDialog(
|
||||
"Can't refresh. The compilation database of the project does not exist anymore: " + cdbPath.str(),
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SourceGroupCxx::fetchAllSourceFilePaths()
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
|
||||
FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute();
|
||||
if (cdbPath.exists())
|
||||
{
|
||||
sourcePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
sourcePaths = m_settings->getSourcePathsExpandedAndAbsolute();
|
||||
}
|
||||
|
||||
m_sourceFilePathsToIndex.clear();
|
||||
FileManager fileManager;
|
||||
fileManager.update(sourcePaths, m_settings->getExcludePathsExpandedAndAbsolute(), m_settings->getSourceExtensions());
|
||||
m_allSourceFilePaths = fileManager.getAllSourceFilePaths();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxx::getIndexerCommands(
|
||||
std::set<FilePath>* filesToIndex, bool fullRefresh)
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
|
||||
|
||||
std::vector<FilePath> systemHeaderSearchPaths;
|
||||
utility::append(systemHeaderSearchPaths, m_settings->getHeaderSearchPathsExpandedAndAbsolute());
|
||||
utility::append(systemHeaderSearchPaths, appSettings->getHeaderSearchPathsExpanded());
|
||||
|
||||
// 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())
|
||||
{
|
||||
if (sourcePath.isDirectory())
|
||||
{
|
||||
systemHeaderSearchPaths.push_back(sourcePath);
|
||||
}
|
||||
}
|
||||
|
||||
// Add all subdirectories of the header search paths
|
||||
if (m_settings->getUseSourcePathsForHeaderSearch())
|
||||
{
|
||||
std::vector<FilePath> headerSearchSubPaths;
|
||||
for (const FilePath& sourcePath : m_settings->getSourcePathsExpandedAndAbsolute())
|
||||
{
|
||||
utility::append(headerSearchSubPaths, FileSystem::getSubDirectories(sourcePath));
|
||||
}
|
||||
|
||||
utility::append(systemHeaderSearchPaths, utility::unique(headerSearchSubPaths));
|
||||
}
|
||||
|
||||
std::vector<FilePath> frameworkSearchPaths;
|
||||
utility::append(frameworkSearchPaths, m_settings->getFrameworkSearchPathsExpandedAndAbsolute());
|
||||
utility::append(frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded());
|
||||
|
||||
std::vector<std::string> compilerFlags;
|
||||
{
|
||||
const std::string targetFlag = m_settings->getTargetFlag();
|
||||
if (!targetFlag.empty())
|
||||
{
|
||||
compilerFlags.push_back(targetFlag);
|
||||
}
|
||||
}
|
||||
|
||||
utility::append(compilerFlags, m_settings->getCompilerFlags());
|
||||
|
||||
std::set<FilePath> indexedPaths;
|
||||
for (const FilePath& p : m_settings->getSourcePathsExpandedAndAbsolute())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
indexedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> excludedPaths;
|
||||
for (const FilePath& p: m_settings->getExcludePathsExpandedAndAbsolute())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
excludedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
const std::set<FilePath>& sourceFilePathsToIndex = (fullRefresh ? getAllSourceFilePaths() : getSourceFilePathsToIndex());
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
|
||||
FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute();
|
||||
if (cdbPath.exists())
|
||||
{
|
||||
std::string error;
|
||||
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
|
||||
(clang::tooling::JSONCompilationDatabase::loadFromFile(cdbPath.str(), error, clang::tooling::JSONCommandLineSyntax::AutoDetect));
|
||||
if (!error.empty())
|
||||
{
|
||||
const std::string message = "Loading Clang compilation database failed with error: \"" + error + "\"";
|
||||
LOG_ERROR(message);
|
||||
MessageStatus(message, true).dispatch();
|
||||
}
|
||||
|
||||
for (const clang::tooling::CompileCommand& command: cdb->getAllCompileCommands())
|
||||
{
|
||||
FilePath sourcePath = FilePath(command.Filename).canonical();
|
||||
if (!sourcePath.isAbsolute())
|
||||
{
|
||||
sourcePath = FilePath(command.Directory + '/' + command.Filename).canonical();
|
||||
}
|
||||
|
||||
if (filesToIndex->find(sourcePath) != filesToIndex->end() &&
|
||||
sourceFilePathsToIndex.find(sourcePath) != sourceFilePathsToIndex.end())
|
||||
{
|
||||
std::vector<std::string> currentCompilerFlags = compilerFlags;
|
||||
currentCompilerFlags.insert(currentCompilerFlags.end(), command.CommandLine.begin(), command.CommandLine.end());
|
||||
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCxxCdb>(
|
||||
sourcePath,
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
FilePath(command.Directory),
|
||||
currentCompilerFlags,
|
||||
systemHeaderSearchPaths,
|
||||
frameworkSearchPaths,
|
||||
m_settings->getShouldApplyAnonymousTypedefTransformation()
|
||||
));
|
||||
|
||||
filesToIndex->erase(sourcePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const FilePath& sourcePath: sourceFilePathsToIndex)
|
||||
{
|
||||
if (filesToIndex->find(sourcePath) != filesToIndex->end())
|
||||
{
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCxxManual>(
|
||||
sourcePath,
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
m_settings->getStandard(),
|
||||
systemHeaderSearchPaths,
|
||||
frameworkSearchPaths,
|
||||
compilerFlags,
|
||||
m_settings->getShouldApplyAnonymousTypedefTransformation()
|
||||
));
|
||||
|
||||
filesToIndex->erase(sourcePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return indexerCommands;
|
||||
return getSourceGroupSettingsCxx();
|
||||
}
|
||||
|
||||
@@ -10,20 +10,12 @@
|
||||
class SourceGroupCxx: public SourceGroup
|
||||
{
|
||||
public:
|
||||
SourceGroupCxx(std::shared_ptr<SourceGroupSettingsCxx> settings);
|
||||
SourceGroupCxx();
|
||||
virtual ~SourceGroupCxx();
|
||||
|
||||
virtual SourceGroupType getType() const;
|
||||
|
||||
virtual bool prepareRefresh();
|
||||
|
||||
virtual void fetchAllSourceFilePaths();
|
||||
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
|
||||
std::set<FilePath>* filesToIndex, bool fullRefresh);
|
||||
|
||||
private:
|
||||
std::shared_ptr<SourceGroupSettingsCxx> m_settings;
|
||||
virtual std::shared_ptr<SourceGroupSettingsCxx> getSourceGroupSettingsCxx() = 0;
|
||||
virtual std::shared_ptr<SourceGroupSettings> getSourceGroupSettings();
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_CXX_H
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
#include "project/SourceGroupCxxCdb.h"
|
||||
|
||||
#include "clang/Tooling/Tooling.h"
|
||||
#include "clang/Tooling/CompilationDatabase.h"
|
||||
#include "clang/Tooling/JSONCompilationDatabase.h"
|
||||
#include "data/indexer/IndexerCommandCxxCdb.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/utility.h"
|
||||
#include "Application.h"
|
||||
|
||||
SourceGroupCxxCdb::SourceGroupCxxCdb(std::shared_ptr<SourceGroupSettingsCxxCdb> settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupCxxCdb::~SourceGroupCxxCdb()
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupType SourceGroupCxxCdb::getType() const
|
||||
{
|
||||
return SOURCE_GROUP_CXX_CDB;
|
||||
}
|
||||
|
||||
bool SourceGroupCxxCdb::prepareRefresh()
|
||||
{
|
||||
FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute();
|
||||
if (!cdbPath.empty() && !cdbPath.exists())
|
||||
{
|
||||
MessageStatus("Can't refresh project").dispatch();
|
||||
|
||||
if (std::shared_ptr<Application> application = Application::getInstance())
|
||||
{
|
||||
if (application->hasGUI())
|
||||
{
|
||||
std::vector<std::string> options;
|
||||
options.push_back("Ok");
|
||||
application->handleDialog(
|
||||
"Can't refresh. The compilation database of the project does not exist anymore: " + cdbPath.str(),
|
||||
options
|
||||
);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxCdb::getIndexerCommands(
|
||||
std::set<FilePath>* filesToIndex, bool fullRefresh)
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
|
||||
|
||||
std::vector<FilePath> systemHeaderSearchPaths;
|
||||
utility::append(systemHeaderSearchPaths, m_settings->getHeaderSearchPathsExpandedAndAbsolute());
|
||||
utility::append(systemHeaderSearchPaths, appSettings->getHeaderSearchPathsExpanded());
|
||||
|
||||
// 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())
|
||||
{
|
||||
if (sourcePath.isDirectory())
|
||||
{
|
||||
systemHeaderSearchPaths.push_back(sourcePath);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<FilePath> frameworkSearchPaths;
|
||||
utility::append(frameworkSearchPaths, m_settings->getFrameworkSearchPathsExpandedAndAbsolute());
|
||||
utility::append(frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded());
|
||||
|
||||
std::vector<std::string> compilerFlags;
|
||||
utility::append(compilerFlags, m_settings->getCompilerFlags());
|
||||
|
||||
std::set<FilePath> indexedPaths;
|
||||
for (const FilePath& p : m_settings->getSourcePathsExpandedAndAbsolute())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
indexedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> excludedPaths;
|
||||
for (const FilePath& p: m_settings->getExcludePathsExpandedAndAbsolute())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
excludedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
const std::set<FilePath>& sourceFilePathsToIndex = (fullRefresh ? getAllSourceFilePaths() : getSourceFilePathsToIndex());
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
|
||||
FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute();
|
||||
if (cdbPath.exists())
|
||||
{
|
||||
std::string error;
|
||||
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = std::shared_ptr<clang::tooling::JSONCompilationDatabase>
|
||||
(clang::tooling::JSONCompilationDatabase::loadFromFile(cdbPath.str(), error, clang::tooling::JSONCommandLineSyntax::AutoDetect));
|
||||
if (!error.empty())
|
||||
{
|
||||
const std::string message = "Loading Clang compilation database failed with error: \"" + error + "\"";
|
||||
LOG_ERROR(message);
|
||||
MessageStatus(message, true).dispatch();
|
||||
}
|
||||
|
||||
for (const clang::tooling::CompileCommand& command: cdb->getAllCompileCommands())
|
||||
{
|
||||
FilePath sourcePath = FilePath(command.Filename).canonical();
|
||||
if (!sourcePath.isAbsolute())
|
||||
{
|
||||
sourcePath = FilePath(command.Directory + '/' + command.Filename).canonical();
|
||||
}
|
||||
|
||||
if (filesToIndex->find(sourcePath) != filesToIndex->end() &&
|
||||
sourceFilePathsToIndex.find(sourcePath) != sourceFilePathsToIndex.end())
|
||||
{
|
||||
std::vector<std::string> currentCompilerFlags = compilerFlags;
|
||||
currentCompilerFlags.insert(currentCompilerFlags.end(), command.CommandLine.begin(), command.CommandLine.end());
|
||||
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCxxCdb>(
|
||||
sourcePath,
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
FilePath(command.Directory),
|
||||
currentCompilerFlags,
|
||||
systemHeaderSearchPaths,
|
||||
frameworkSearchPaths,
|
||||
m_settings->getShouldApplyAnonymousTypedefTransformation()
|
||||
));
|
||||
|
||||
filesToIndex->erase(sourcePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return indexerCommands;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsCxx> SourceGroupCxxCdb::getSourceGroupSettingsCxx()
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupCxxCdb::getAllSourcePaths() const
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
|
||||
FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute();
|
||||
if (cdbPath.exists())
|
||||
{
|
||||
sourcePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath);
|
||||
}
|
||||
|
||||
return sourcePaths;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef SOURCE_GROUP_CXX_CDB_H
|
||||
#define SOURCE_GROUP_CXX_CDB_H
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "project/SourceGroupCxx.h"
|
||||
#include "settings/SourceGroupSettingsCxxCdb.h"
|
||||
|
||||
class SourceGroupCxxCdb: public SourceGroupCxx
|
||||
{
|
||||
public:
|
||||
SourceGroupCxxCdb(std::shared_ptr<SourceGroupSettingsCxxCdb> settings);
|
||||
virtual ~SourceGroupCxxCdb();
|
||||
|
||||
virtual SourceGroupType getType() const;
|
||||
|
||||
virtual bool prepareRefresh();
|
||||
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
|
||||
std::set<FilePath>* filesToIndex, bool fullRefresh);
|
||||
|
||||
private:
|
||||
virtual std::shared_ptr<SourceGroupSettingsCxx> getSourceGroupSettingsCxx();
|
||||
virtual std::vector<FilePath> getAllSourcePaths() const;
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsCxxCdb> m_settings;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_CXX_CDB_H
|
||||
@@ -0,0 +1,106 @@
|
||||
#include "project/SourceGroupCxxEmpty.h"
|
||||
|
||||
#include "data/indexer/IndexerCommandCxxManual.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/utility.h"
|
||||
#include "Application.h"
|
||||
|
||||
SourceGroupCxxEmpty::SourceGroupCxxEmpty(std::shared_ptr<SourceGroupSettingsCxxEmpty> settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupCxxEmpty::~SourceGroupCxxEmpty()
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupType SourceGroupCxxEmpty::getType() const
|
||||
{
|
||||
return m_settings->getType(); // may be either C or Cpp
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupCxxEmpty::getIndexerCommands(
|
||||
std::set<FilePath>* filesToIndex, bool fullRefresh)
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> appSettings = ApplicationSettings::getInstance();
|
||||
|
||||
std::vector<FilePath> systemHeaderSearchPaths;
|
||||
utility::append(systemHeaderSearchPaths, m_settings->getHeaderSearchPathsExpandedAndAbsolute());
|
||||
utility::append(systemHeaderSearchPaths, appSettings->getHeaderSearchPathsExpanded());
|
||||
|
||||
// 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())
|
||||
{
|
||||
if (sourcePath.isDirectory())
|
||||
{
|
||||
systemHeaderSearchPaths.push_back(sourcePath);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<FilePath> frameworkSearchPaths;
|
||||
utility::append(frameworkSearchPaths, m_settings->getFrameworkSearchPathsExpandedAndAbsolute());
|
||||
utility::append(frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded());
|
||||
|
||||
std::vector<std::string> compilerFlags;
|
||||
{
|
||||
const std::string targetFlag = m_settings->getTargetFlag();
|
||||
if (!targetFlag.empty())
|
||||
{
|
||||
compilerFlags.push_back(targetFlag);
|
||||
}
|
||||
}
|
||||
|
||||
utility::append(compilerFlags, m_settings->getCompilerFlags());
|
||||
|
||||
std::set<FilePath> indexedPaths;
|
||||
for (const FilePath& p : m_settings->getSourcePathsExpandedAndAbsolute())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
indexedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
std::set<FilePath> excludedPaths;
|
||||
for (const FilePath& p: m_settings->getExcludePathsExpandedAndAbsolute())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
excludedPaths.insert(p);
|
||||
}
|
||||
}
|
||||
|
||||
const std::set<FilePath>& sourceFilePathsToIndex = (fullRefresh ? getAllSourceFilePaths() : getSourceFilePathsToIndex());
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> indexerCommands;
|
||||
for (const FilePath& sourcePath: sourceFilePathsToIndex)
|
||||
{
|
||||
if (filesToIndex->find(sourcePath) != filesToIndex->end())
|
||||
{
|
||||
indexerCommands.push_back(std::make_shared<IndexerCommandCxxManual>(
|
||||
sourcePath,
|
||||
indexedPaths,
|
||||
excludedPaths,
|
||||
m_settings->getStandard(),
|
||||
systemHeaderSearchPaths,
|
||||
frameworkSearchPaths,
|
||||
compilerFlags,
|
||||
m_settings->getShouldApplyAnonymousTypedefTransformation()
|
||||
));
|
||||
|
||||
filesToIndex->erase(sourcePath);
|
||||
}
|
||||
}
|
||||
|
||||
return indexerCommands;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsCxx> SourceGroupCxxEmpty::getSourceGroupSettingsCxx()
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupCxxEmpty::getAllSourcePaths() const
|
||||
{
|
||||
return m_settings->getSourcePathsExpandedAndAbsolute();
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef SOURCE_GROUP_CXX_EMPTY_H
|
||||
#define SOURCE_GROUP_CXX_EMPTY_H
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "project/SourceGroupCxx.h"
|
||||
#include "settings/SourceGroupSettingsCxxEmpty.h"
|
||||
|
||||
class SourceGroupCxxEmpty: public SourceGroupCxx
|
||||
{
|
||||
public:
|
||||
SourceGroupCxxEmpty(std::shared_ptr<SourceGroupSettingsCxxEmpty> settings);
|
||||
virtual ~SourceGroupCxxEmpty();
|
||||
|
||||
virtual SourceGroupType getType() const;
|
||||
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
|
||||
std::set<FilePath>* filesToIndex, bool fullRefresh);
|
||||
|
||||
private:
|
||||
virtual std::shared_ptr<SourceGroupSettingsCxx> getSourceGroupSettingsCxx();
|
||||
virtual std::vector<FilePath> getAllSourcePaths() const;
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsCxxEmpty> m_settings;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_CXX_EMPTY_H
|
||||
@@ -1,30 +0,0 @@
|
||||
#include "project/SourceGroupFactoryModuleC.h"
|
||||
|
||||
#include "project/SourceGroupCxx.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
|
||||
SourceGroupFactoryModuleC::~SourceGroupFactoryModuleC()
|
||||
{
|
||||
}
|
||||
|
||||
bool SourceGroupFactoryModuleC::supports(SourceGroupType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroup> SourceGroupFactoryModuleC::createSourceGroup(std::shared_ptr<SourceGroupSettings> settings)
|
||||
{
|
||||
std::shared_ptr<SourceGroup> sourceGroup;
|
||||
if (std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupCxx(cxxSettings));
|
||||
}
|
||||
return sourceGroup;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef SOURCE_GROUP_FACTORY_MODULE_C_H
|
||||
#define SOURCE_GROUP_FACTORY_MODULE_C_H
|
||||
|
||||
#include "project/SourceGroupFactoryModule.h"
|
||||
|
||||
class SourceGroupFactoryModuleC: public SourceGroupFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~SourceGroupFactoryModuleC();
|
||||
virtual bool supports(SourceGroupType type) const;
|
||||
virtual std::shared_ptr<SourceGroup> createSourceGroup(std::shared_ptr<SourceGroupSettings> settings);
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_FACTORY_MODULE_C_H
|
||||
@@ -1,31 +0,0 @@
|
||||
#include "project/SourceGroupFactoryModuleCpp.h"
|
||||
|
||||
#include "project/SourceGroupCxx.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
|
||||
SourceGroupFactoryModuleCpp::~SourceGroupFactoryModuleCpp()
|
||||
{
|
||||
}
|
||||
|
||||
bool SourceGroupFactoryModuleCpp::supports(SourceGroupType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroup> SourceGroupFactoryModuleCpp::createSourceGroup(std::shared_ptr<SourceGroupSettings> settings)
|
||||
{
|
||||
std::shared_ptr<SourceGroup> sourceGroup;
|
||||
if (std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupCxx(cxxSettings));
|
||||
}
|
||||
return sourceGroup;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
#ifndef SOURCE_GROUP_FACTORY_MODULE_CPP_H
|
||||
#define SOURCE_GROUP_FACTORY_MODULE_CPP_H
|
||||
|
||||
#include "project/SourceGroupFactoryModule.h"
|
||||
|
||||
class SourceGroupFactoryModuleCpp: public SourceGroupFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~SourceGroupFactoryModuleCpp();
|
||||
virtual bool supports(SourceGroupType type) const;
|
||||
virtual std::shared_ptr<SourceGroup> createSourceGroup(std::shared_ptr<SourceGroupSettings> settings);
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_FACTORY_MODULE_CPP_H
|
||||
@@ -0,0 +1,38 @@
|
||||
#include "project/SourceGroupFactoryModuleCxx.h"
|
||||
|
||||
#include "project/SourceGroupCxxCdb.h"
|
||||
#include "project/SourceGroupCxxEmpty.h"
|
||||
#include "settings/SourceGroupSettingsCxxCdb.h"
|
||||
#include "settings/SourceGroupSettingsCxxEmpty.h"
|
||||
|
||||
SourceGroupFactoryModuleCxx::~SourceGroupFactoryModuleCxx()
|
||||
{
|
||||
}
|
||||
|
||||
bool SourceGroupFactoryModuleCxx::supports(SourceGroupType type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroup> SourceGroupFactoryModuleCxx::createSourceGroup(std::shared_ptr<SourceGroupSettings> settings)
|
||||
{
|
||||
std::shared_ptr<SourceGroup> sourceGroup;
|
||||
if (std::shared_ptr<SourceGroupSettingsCxxCdb> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupCxxCdb(cxxSettings));
|
||||
}
|
||||
else if (std::shared_ptr<SourceGroupSettingsCxxEmpty> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxEmpty>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupCxxEmpty(cxxSettings));
|
||||
}
|
||||
return sourceGroup;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef SOURCE_GROUP_FACTORY_MODULE_CXX_H
|
||||
#define SOURCE_GROUP_FACTORY_MODULE_CXX_H
|
||||
|
||||
#include "project/SourceGroupFactoryModule.h"
|
||||
|
||||
class SourceGroupFactoryModuleCxx: public SourceGroupFactoryModule
|
||||
{
|
||||
public:
|
||||
virtual ~SourceGroupFactoryModuleCxx();
|
||||
virtual bool supports(SourceGroupType type) const;
|
||||
virtual std::shared_ptr<SourceGroup> createSourceGroup(std::shared_ptr<SourceGroupSettings> settings);
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_FACTORY_MODULE_CXX_H
|
||||
@@ -188,8 +188,6 @@ add_files(
|
||||
qt/window/project_wizzard/QtProjectWizzardContentProjectData.h
|
||||
qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp
|
||||
qt/window/project_wizzard/QtProjectWizzardContentSelect.h
|
||||
qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp
|
||||
qt/window/project_wizzard/QtProjectWizzardContentSimple.h
|
||||
qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.cpp
|
||||
qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h
|
||||
qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentProjectData.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSelect.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h"
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentVS.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
#include "settings/SourceGroupSettingsCxxEmpty.h"
|
||||
#include "settings/SourceGroupSettingsCxxCdb.h"
|
||||
#include "settings/SourceGroupSettingsJavaEmpty.h"
|
||||
#include "settings/SourceGroupSettingsJavaGradle.h"
|
||||
#include "settings/SourceGroupSettingsJavaMaven.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
@@ -85,8 +87,8 @@ void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::ve
|
||||
|
||||
cancelSourceGroup();
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsCxx> sourceGroupSettings =
|
||||
std::make_shared<SourceGroupSettingsCxx>(utility::getUuidString(), SOURCE_GROUP_CXX_CDB, m_projectSettings.get());
|
||||
std::shared_ptr<SourceGroupSettingsCxxCdb> sourceGroupSettings =
|
||||
std::make_shared<SourceGroupSettingsCxxCdb>(utility::getUuidString(), m_projectSettings.get());
|
||||
sourceGroupSettings->setCompilationDatabasePath(filePath);
|
||||
sourceGroupSettings->setSourcePaths(headerPaths);
|
||||
m_newSourceGroupSettings = sourceGroupSettings;
|
||||
@@ -388,51 +390,39 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
|
||||
summary->addContent(content);
|
||||
summary->addSpace();
|
||||
|
||||
if (group->getType() == SOURCE_GROUP_JAVA_EMPTY || group->getType() == SOURCE_GROUP_JAVA_MAVEN)
|
||||
if (std::shared_ptr<SourceGroupSettingsJava> settingsJava = std::dynamic_pointer_cast<SourceGroupSettingsJava>(group))
|
||||
{
|
||||
bool isMaven = false;
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings =
|
||||
std::dynamic_pointer_cast<SourceGroupSettingsJava>(group);
|
||||
if (javaSettings)
|
||||
{
|
||||
isMaven = javaSettings->getMavenProjectFilePathExpandedAndAbsolute().exists();
|
||||
}
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentLanguageAndStandard(group, this));
|
||||
summary->addSpace();
|
||||
|
||||
if (isMaven)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathSourceMaven(group, this));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(group, this));
|
||||
}
|
||||
else
|
||||
if (std::shared_ptr<SourceGroupSettingsJavaEmpty> settingsJavaEmpty = std::dynamic_pointer_cast<SourceGroupSettingsJavaEmpty>(group))
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathsSource(group, this));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsClassJava(group, this));
|
||||
}
|
||||
else if (std::shared_ptr<SourceGroupSettingsJavaGradle> settingsJavaGradle = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(group))
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathSourceGradle(group, this));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathDependenciesGradle(group, this));
|
||||
}
|
||||
else if (std::shared_ptr<SourceGroupSettingsJavaMaven> settingsJavaMaven = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(group))
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathSourceMaven(group, this));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(group, this));
|
||||
}
|
||||
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(group, this));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathsExclude(group, this));
|
||||
}
|
||||
else
|
||||
else if (std::shared_ptr<SourceGroupSettingsCxx> settingsCxx = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(group))
|
||||
{
|
||||
const bool isCDB = group->getType() == SOURCE_GROUP_CXX_CDB;
|
||||
|
||||
if (isCDB)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathCDB(group, this));
|
||||
summary->addContent(new QtProjectWizzardContentCDBSource(group, this));
|
||||
summary->addSpace();
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsCDBHeader(group, this));
|
||||
summary->addSpace();
|
||||
}
|
||||
else
|
||||
bool isCDB = false;
|
||||
if (std::shared_ptr<SourceGroupSettingsCxxEmpty> settingsCxxEmpty = std::dynamic_pointer_cast<SourceGroupSettingsCxxEmpty>(group))
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentLanguageAndStandard(group, this));
|
||||
summary->addSpace();
|
||||
@@ -443,16 +433,20 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index)
|
||||
summary->addContent(new QtProjectWizzardContentExtensions(group, this));
|
||||
summary->addSpace();
|
||||
}
|
||||
else if (std::shared_ptr<SourceGroupSettingsCxxCdb> settingsCxxCdb = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(group))
|
||||
{
|
||||
isCDB = true;
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathCDB(group, this));
|
||||
summary->addContent(new QtProjectWizzardContentCDBSource(group, this));
|
||||
summary->addSpace();
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsCDBHeader(group, this));
|
||||
summary->addSpace();
|
||||
}
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(group, this, isCDB));
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(group);
|
||||
if (!isCDB && cxxSettings && cxxSettings->getHasDefinedUseSourcePathsForHeaderSearch())
|
||||
{
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentSimple(group, this));
|
||||
}
|
||||
|
||||
summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(this));
|
||||
summary->addSpace();
|
||||
|
||||
@@ -526,15 +520,26 @@ void QtProjectWizzard::duplicateSelectedSourceGroup()
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroupSettings> oldSourceGroup = m_allSourceGroupSettings[m_sourceGroupList->currentRow()];
|
||||
std::shared_ptr<SourceGroupSettings> newSourceGroup;
|
||||
|
||||
if (oldSourceGroup->getType() == SOURCE_GROUP_JAVA_EMPTY || oldSourceGroup->getType() == SOURCE_GROUP_JAVA_MAVEN)
|
||||
std::shared_ptr<SourceGroupSettings> newSourceGroup;
|
||||
switch (oldSourceGroup->getType())
|
||||
{
|
||||
newSourceGroup = std::make_shared<SourceGroupSettingsJava>(*dynamic_cast<SourceGroupSettingsJava*>(oldSourceGroup.get()));
|
||||
}
|
||||
else
|
||||
{
|
||||
newSourceGroup = std::make_shared<SourceGroupSettingsCxx>(*dynamic_cast<SourceGroupSettingsCxx*>(oldSourceGroup.get()));
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
newSourceGroup = std::make_shared<SourceGroupSettingsJavaEmpty>(*dynamic_cast<SourceGroupSettingsJavaEmpty*>(oldSourceGroup.get()));
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
newSourceGroup = std::make_shared<SourceGroupSettingsJavaMaven>(*dynamic_cast<SourceGroupSettingsJavaMaven*>(oldSourceGroup.get()));
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_GRADLE:
|
||||
newSourceGroup = std::make_shared<SourceGroupSettingsJavaGradle>(*dynamic_cast<SourceGroupSettingsJavaGradle*>(oldSourceGroup.get()));
|
||||
break;
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
newSourceGroup = std::make_shared<SourceGroupSettingsCxxEmpty>(*dynamic_cast<SourceGroupSettingsCxxEmpty*>(oldSourceGroup.get()));
|
||||
break;
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
newSourceGroup = std::make_shared<SourceGroupSettingsCxxCdb>(*dynamic_cast<SourceGroupSettingsCxxCdb*>(oldSourceGroup.get()));
|
||||
break;
|
||||
}
|
||||
|
||||
newSourceGroup->setId(utility::getUuidString());
|
||||
@@ -613,7 +618,7 @@ void QtProjectWizzard::selectedProjectType(SourceGroupType sourceGroupType)
|
||||
{
|
||||
case SOURCE_GROUP_C_EMPTY:
|
||||
case SOURCE_GROUP_CPP_EMPTY:
|
||||
m_newSourceGroupSettings = std::make_shared<SourceGroupSettingsCxx>(sourceGroupId, sourceGroupType, m_projectSettings.get());
|
||||
m_newSourceGroupSettings = std::make_shared<SourceGroupSettingsCxxEmpty>(sourceGroupId, sourceGroupType, m_projectSettings.get());
|
||||
if (applicationSettingsContainVisualStudioHeaderSearchPaths())
|
||||
{
|
||||
std::vector<std::string> flags;
|
||||
@@ -625,22 +630,25 @@ void QtProjectWizzard::selectedProjectType(SourceGroupType sourceGroupType)
|
||||
emptySourceGroup();
|
||||
break;
|
||||
case SOURCE_GROUP_CXX_CDB:
|
||||
m_newSourceGroupSettings = std::make_shared<SourceGroupSettingsCxx>(sourceGroupId, sourceGroupType, m_projectSettings.get());
|
||||
m_newSourceGroupSettings = std::make_shared<SourceGroupSettingsCxxCdb>(sourceGroupId, m_projectSettings.get());
|
||||
emptySourceGroupCDB();
|
||||
break;
|
||||
case SOURCE_GROUP_CXX_VS:
|
||||
m_newSourceGroupSettings =
|
||||
std::make_shared<SourceGroupSettingsCxx>(sourceGroupId, SOURCE_GROUP_CXX_CDB, m_projectSettings.get());
|
||||
m_newSourceGroupSettings = std::make_shared<SourceGroupSettingsCxxCdb>(sourceGroupId, m_projectSettings.get());
|
||||
emptySourceGroupCDBVS();
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
m_newSourceGroupSettings = std::make_shared<SourceGroupSettingsJava>(sourceGroupId, sourceGroupType, m_projectSettings.get());
|
||||
m_newSourceGroupSettings = std::make_shared<SourceGroupSettingsJavaEmpty>(sourceGroupId, m_projectSettings.get());
|
||||
emptySourceGroup();
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
m_newSourceGroupSettings = std::make_shared<SourceGroupSettingsJava>(sourceGroupId, sourceGroupType, m_projectSettings.get());
|
||||
m_newSourceGroupSettings = std::make_shared<SourceGroupSettingsJavaMaven>(sourceGroupId, m_projectSettings.get());
|
||||
sourcePathsJavaMaven();
|
||||
break;
|
||||
case SOURCE_GROUP_JAVA_GRADLE:
|
||||
m_newSourceGroupSettings = std::make_shared<SourceGroupSettingsJavaGradle>(sourceGroupId, m_projectSettings.get());
|
||||
sourcePathsJavaGradle();
|
||||
break;
|
||||
case SOURCE_GROUP_UNKNOWN:
|
||||
break;
|
||||
}
|
||||
@@ -786,7 +794,7 @@ void QtProjectWizzard::sourcePathsJava()
|
||||
|
||||
void QtProjectWizzard::sourcePathsJavaMaven()
|
||||
{
|
||||
std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_newSourceGroupSettings)->setMavenDependenciesDirectory(
|
||||
std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_newSourceGroupSettings)->setMavenDependenciesDirectory(
|
||||
FilePath("./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), " ", "_") + "/" + m_newSourceGroupSettings->getId() + "/maven")
|
||||
);
|
||||
|
||||
@@ -803,6 +811,25 @@ void QtProjectWizzard::sourcePathsJavaMaven()
|
||||
window->updateSubTitle("Indexed Paths");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::sourcePathsJavaGradle()
|
||||
{
|
||||
std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_newSourceGroupSettings)->setGradleDependenciesDirectory(
|
||||
FilePath("./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), " ", "_") + "/" + m_newSourceGroupSettings->getId() + "/gradle")
|
||||
);
|
||||
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
[this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary)
|
||||
{
|
||||
summary->addContent(new QtProjectWizzardContentPathSourceGradle(m_newSourceGroupSettings, window));
|
||||
summary->addSpace();
|
||||
summary->addContent(new QtProjectWizzardContentPathDependenciesGradle(m_newSourceGroupSettings, window));
|
||||
}
|
||||
);
|
||||
|
||||
connect(window, &QtProjectWizzardWindow::next, this, &QtProjectWizzard::advancedSettingsJava);
|
||||
window->updateSubTitle("Indexed Paths");
|
||||
}
|
||||
|
||||
void QtProjectWizzard::advancedSettingsCxx()
|
||||
{
|
||||
QtProjectWizzardWindow* window = createWindowWithSummary(
|
||||
|
||||
@@ -97,6 +97,7 @@ private slots:
|
||||
|
||||
void sourcePathsJava();
|
||||
void sourcePathsJavaMaven();
|
||||
void sourcePathsJavaGradle();
|
||||
|
||||
void advancedSettingsCxx();
|
||||
void advancedSettingsJava();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h"
|
||||
|
||||
#include "data/indexer/IndexerCommandCxxCdb.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "settings/SourceGroupSettingsCxxCdb.h"
|
||||
#include "utility/file/FilePath.h"
|
||||
|
||||
QtProjectWizzardContentCDBSource::QtProjectWizzardContentCDBSource(
|
||||
@@ -35,14 +35,12 @@ void QtProjectWizzardContentCDBSource::load()
|
||||
const FilePath projectPath = m_settings->getProjectFileLocation();
|
||||
std::vector<FilePath> excludePaths = m_settings->getExcludePathsExpandedAndAbsolute();
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
|
||||
if (cxxSettings)
|
||||
if (std::shared_ptr<SourceGroupSettingsCxxCdb> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings))
|
||||
{
|
||||
FilePath cdbPath = cxxSettings->getCompilationDatabasePathExpandedAndAbsolute();
|
||||
if (!cdbPath.empty() && cdbPath.exists())
|
||||
{
|
||||
std::vector<FilePath> filePaths =
|
||||
IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath);
|
||||
std::vector<FilePath> filePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath);
|
||||
|
||||
for (FilePath& path : filePaths)
|
||||
{
|
||||
|
||||
+7
-8
@@ -4,8 +4,7 @@
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
|
||||
#include "settings/SourceGroupSettings.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "settings/SourceGroupSettingsCxxEmpty.h"
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
QtProjectWizzardContentCrossCompilationOptions::QtProjectWizzardContentCrossCompilationOptions(
|
||||
@@ -61,7 +60,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou
|
||||
QLabel* label = new QLabel("Architecture:");
|
||||
|
||||
m_arch = new QComboBox();
|
||||
std::vector<std::string> archTypes = SourceGroupSettingsCxx::getAvailableArchTypes();
|
||||
std::vector<std::string> archTypes = SourceGroupSettingsCxxEmpty::getAvailableArchTypes();
|
||||
std::sort(archTypes.begin(), archTypes.end());
|
||||
for (size_t i = 0; i < archTypes.size(); i++)
|
||||
{
|
||||
@@ -77,7 +76,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou
|
||||
QLabel* label = new QLabel("Vendor:");
|
||||
|
||||
m_vendor = new QComboBox();
|
||||
std::vector<std::string> vendorTypes = SourceGroupSettingsCxx::getAvailableVendorTypes();
|
||||
std::vector<std::string> vendorTypes = SourceGroupSettingsCxxEmpty::getAvailableVendorTypes();
|
||||
std::sort(vendorTypes.begin() + 1, vendorTypes.end());
|
||||
for (size_t i = 0; i < vendorTypes.size(); i++)
|
||||
{
|
||||
@@ -92,7 +91,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou
|
||||
QLabel* label = new QLabel("OS:");
|
||||
|
||||
m_sys = new QComboBox();
|
||||
std::vector<std::string> osTypes = SourceGroupSettingsCxx::getAvailableOsTypes();
|
||||
std::vector<std::string> osTypes = SourceGroupSettingsCxxEmpty::getAvailableOsTypes();
|
||||
std::sort(osTypes.begin() + 1, osTypes.end());
|
||||
for (size_t i = 0; i < osTypes.size(); i++)
|
||||
{
|
||||
@@ -107,7 +106,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou
|
||||
QLabel* label = new QLabel("Environment:");
|
||||
|
||||
m_abi = new QComboBox();
|
||||
std::vector<std::string> environmentTypes = SourceGroupSettingsCxx::getAvailableEnvironmentTypes();
|
||||
std::vector<std::string> environmentTypes = SourceGroupSettingsCxxEmpty::getAvailableEnvironmentTypes();
|
||||
std::sort(environmentTypes.begin() + 1, environmentTypes.end());
|
||||
for (size_t i = 0; i < environmentTypes.size(); i++)
|
||||
{
|
||||
@@ -129,7 +128,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou
|
||||
|
||||
void QtProjectWizzardContentCrossCompilationOptions::load()
|
||||
{
|
||||
if (std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_sourceGroupSettings))
|
||||
if (std::shared_ptr<SourceGroupSettingsCxxEmpty> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxEmpty>(m_sourceGroupSettings))
|
||||
{
|
||||
m_useTargetOptions->setChecked(cxxSettings->getTargetOptionsEnabled());
|
||||
m_arch->setCurrentText(QString::fromStdString(cxxSettings->getTargetArch()));
|
||||
@@ -143,7 +142,7 @@ void QtProjectWizzardContentCrossCompilationOptions::load()
|
||||
|
||||
void QtProjectWizzardContentCrossCompilationOptions::save()
|
||||
{
|
||||
if (std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_sourceGroupSettings))
|
||||
if (std::shared_ptr<SourceGroupSettingsCxxEmpty> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxEmpty>(m_sourceGroupSettings))
|
||||
{
|
||||
cxxSettings->setTargetOptionsEnabled(m_useTargetOptions->isChecked());
|
||||
cxxSettings->setTargetArch(m_arch->currentText().toStdString());
|
||||
|
||||
@@ -10,11 +10,13 @@
|
||||
#include "qt/element/QtLocationPicker.h"
|
||||
#include "qt/view/QtDialogView.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
#include "settings/SourceGroupSettingsCxxCdb.h"
|
||||
#include "settings/SourceGroupSettingsJavaMaven.h"
|
||||
#include "settings/SourceGroupSettingsJavaGradle.h"
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/utilityGradle.h"
|
||||
#include "utility/utilityMaven.h"
|
||||
|
||||
QtProjectWizzardContentPath::QtProjectWizzardContentPath(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window)
|
||||
@@ -140,21 +142,21 @@ void QtProjectWizzardContentPathCDB::populate(QGridLayout* layout, int& row)
|
||||
|
||||
void QtProjectWizzardContentPathCDB::load()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings =
|
||||
std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
|
||||
if (cxxSettings)
|
||||
std::shared_ptr<SourceGroupSettingsCxxCdb> settings =
|
||||
std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings);
|
||||
if (settings)
|
||||
{
|
||||
m_picker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str()));
|
||||
m_picker->setText(QString::fromStdString(settings->getCompilationDatabasePath().str()));
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathCDB::save()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings =
|
||||
std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
|
||||
if (cxxSettings)
|
||||
std::shared_ptr<SourceGroupSettingsCxxCdb> m_settings =
|
||||
std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings);
|
||||
if (m_settings)
|
||||
{
|
||||
cxxSettings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdString()));
|
||||
m_settings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,30 +202,30 @@ void QtProjectWizzardContentPathSourceMaven::populate(QGridLayout* layout, int&
|
||||
|
||||
void QtProjectWizzardContentPathSourceMaven::load()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_settings);
|
||||
if (javaSettings)
|
||||
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
|
||||
if (settings)
|
||||
{
|
||||
m_picker->setText(QString::fromStdString(javaSettings->getMavenProjectFilePath().str()));
|
||||
m_shouldIndexTests->setChecked(javaSettings->getShouldIndexMavenTests());
|
||||
m_picker->setText(QString::fromStdString(settings->getMavenProjectFilePath().str()));
|
||||
m_shouldIndexTests->setChecked(settings->getShouldIndexMavenTests());
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathSourceMaven::save()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_settings);
|
||||
if (javaSettings)
|
||||
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
|
||||
if (settings)
|
||||
{
|
||||
javaSettings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdString()));
|
||||
javaSettings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked());
|
||||
settings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdString()));
|
||||
settings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames() const
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_settings);
|
||||
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
|
||||
|
||||
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
|
||||
const FilePath mavenProjectRoot = javaSettings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
const FilePath mavenProjectRoot = settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
|
||||
std::vector<std::string> list;
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
@@ -251,7 +253,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames()
|
||||
const std::vector<FilePath> sourceDirectories = utility::mavenGetAllDirectoriesFromEffectivePom(
|
||||
mavenPath,
|
||||
mavenProjectRoot,
|
||||
javaSettings->getShouldIndexMavenTests()
|
||||
settings->getShouldIndexMavenTests()
|
||||
);
|
||||
|
||||
FileManager fileManager;
|
||||
@@ -277,6 +279,7 @@ std::vector<std::string> QtProjectWizzardContentPathSourceMaven::getFileNames()
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDependenciesMaven(
|
||||
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
@@ -292,18 +295,149 @@ QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDepende
|
||||
|
||||
void QtProjectWizzardContentPathDependenciesMaven::load()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_settings);
|
||||
if (javaSettings)
|
||||
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
|
||||
if (settings)
|
||||
{
|
||||
m_picker->setText(QString::fromStdString(javaSettings->getMavenDependenciesDirectory().str()));
|
||||
m_picker->setText(QString::fromStdString(settings->getMavenDependenciesDirectory().str()));
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathDependenciesMaven::save()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(m_settings);
|
||||
if (javaSettings)
|
||||
std::shared_ptr<SourceGroupSettingsJavaMaven> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(m_settings);
|
||||
if (settings)
|
||||
{
|
||||
javaSettings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdString()));
|
||||
settings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QtProjectWizzardContentPathSourceGradle::QtProjectWizzardContentPathSourceGradle(
|
||||
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPath(settings, window)
|
||||
{
|
||||
setTitleString("Gradle Project File (build.gradle)");
|
||||
setHelpString(
|
||||
"Enter the path to the main build.gradle file of your Gradle project.<br />"
|
||||
"<br />"
|
||||
"You can make use of environment variables with ${ENV_VAR}."
|
||||
);
|
||||
setFileEndings({ ".gradle" });
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathSourceGradle::populate(QGridLayout* layout, int& row)
|
||||
{
|
||||
QtProjectWizzardContentPath::populate(layout, row);
|
||||
m_picker->setPickDirectory(false);
|
||||
m_picker->setFileFilter("Gradle Build File (build.gradle)");
|
||||
|
||||
QPushButton* filesButton = addFilesButton("show source files", nullptr, row);
|
||||
m_shouldIndexTests = new QCheckBox("Should Index Tests");
|
||||
|
||||
QHBoxLayout* hlayout = new QHBoxLayout();
|
||||
hlayout->setContentsMargins(0, 0, 0, 0);
|
||||
hlayout->addWidget(m_shouldIndexTests);
|
||||
hlayout->addStretch();
|
||||
hlayout->addWidget(filesButton);
|
||||
|
||||
layout->addLayout(hlayout, row, QtProjectWizzardWindow::BACK_COL);
|
||||
row++;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathSourceGradle::load()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
|
||||
if (settings)
|
||||
{
|
||||
m_picker->setText(QString::fromStdString(settings->getGradleProjectFilePath().str()));
|
||||
m_shouldIndexTests->setChecked(settings->getShouldIndexGradleTests());
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathSourceGradle::save()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
|
||||
if (settings)
|
||||
{
|
||||
settings->setGradleProjectFilePath(FilePath(m_picker->getText().toStdString()));
|
||||
settings->setShouldIndexGradleTests(m_shouldIndexTests->isChecked());
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> QtProjectWizzardContentPathSourceGradle::getFileNames() const
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
|
||||
|
||||
const FilePath gradleProjectRoot = settings->getGradleProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
|
||||
std::vector<std::string> list;
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
|
||||
ScopedFunctor scopedFunctor([&dialogView]() {
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
});
|
||||
|
||||
std::dynamic_pointer_cast<QtDialogView>(dialogView)->setParentWindow(m_window);
|
||||
{
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Gradle\nFetching Source Directories");
|
||||
const std::vector<FilePath> sourceDirectories = utility::gradleGetAllSourceDirectories(
|
||||
gradleProjectRoot,
|
||||
settings->getShouldIndexGradleTests()
|
||||
);
|
||||
|
||||
FileManager fileManager;
|
||||
fileManager.update(
|
||||
sourceDirectories,
|
||||
m_settings->getExcludePathsExpandedAndAbsolute(),
|
||||
m_settings->getSourceExtensions()
|
||||
);
|
||||
|
||||
const FilePath projectPath = m_settings->getProjectFileLocation();
|
||||
|
||||
for (FilePath path : fileManager.getAllSourceFilePaths())
|
||||
{
|
||||
if (projectPath.exists())
|
||||
{
|
||||
path = path.relativeTo(projectPath);
|
||||
}
|
||||
|
||||
list.push_back(path.str());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
QtProjectWizzardContentPathDependenciesGradle::QtProjectWizzardContentPathDependenciesGradle(
|
||||
std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window
|
||||
)
|
||||
: QtProjectWizzardContentPath(settings, window)
|
||||
{
|
||||
setTitleString("Intermediate Dependencies Directory");
|
||||
setHelpString(
|
||||
"This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Gradle project while it is indexed.<br />"
|
||||
"<br />"
|
||||
"You can make use of environment variables with ${ENV_VAR}."
|
||||
);
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathDependenciesGradle::load()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
|
||||
if (settings)
|
||||
{
|
||||
m_picker->setText(QString::fromStdString(settings->getGradleDependenciesDirectory().str()));
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentPathDependenciesGradle::save()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsJavaGradle> settings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(m_settings);
|
||||
if (settings)
|
||||
{
|
||||
settings->setGradleDependenciesDirectory(FilePath(m_picker->getText().toStdString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,4 +95,37 @@ public:
|
||||
virtual void save() override;
|
||||
};
|
||||
|
||||
|
||||
class QtProjectWizzardContentPathSourceGradle
|
||||
: public QtProjectWizzardContentPath
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtProjectWizzardContentPathSourceGradle(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populate(QGridLayout* layout, int& row) override;
|
||||
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
|
||||
virtual std::vector<std::string> getFileNames() const override;
|
||||
|
||||
private:
|
||||
QCheckBox* m_shouldIndexTests;
|
||||
};
|
||||
|
||||
|
||||
class QtProjectWizzardContentPathDependenciesGradle
|
||||
: public QtProjectWizzardContentPath
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QtProjectWizzardContentPathDependenciesGradle(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
};
|
||||
|
||||
#endif // QT_PROJECT_WIZZARD_CONTENT_PATH_H
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "qt/view/QtDialogView.h"
|
||||
#include "qt/window/QtSelectPathsDialog.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
#include "settings/SourceGroupSettingsCxxCdb.h"
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
#include "utility/CompilationDatabase.h"
|
||||
#include "utility/file/FileManager.h"
|
||||
@@ -269,7 +269,7 @@ void QtProjectWizzardContentPathsCDBHeader::buttonClicked()
|
||||
|
||||
if (!m_filesDialog)
|
||||
{
|
||||
FilePath cdbPath = dynamic_cast<SourceGroupSettingsCxx*>(m_settings.get())->getCompilationDatabasePathExpandedAndAbsolute();
|
||||
FilePath cdbPath = dynamic_cast<SourceGroupSettingsCxxCdb*>(m_settings.get())->getCompilationDatabasePathExpandedAndAbsolute(); // TODO: remove this cast
|
||||
if (!cdbPath.exists())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
|
||||
@@ -35,6 +35,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
|
||||
sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_VS));
|
||||
sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_EMPTY));
|
||||
sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_MAVEN));
|
||||
sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_GRADLE));
|
||||
|
||||
// define which icons should be used for which kind of source group
|
||||
m_sourceGroupTypeIconName[SOURCE_GROUP_C_EMPTY] = "empty_icon";
|
||||
@@ -43,6 +44,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
|
||||
m_sourceGroupTypeIconName[SOURCE_GROUP_CXX_VS] = "vs_icon";
|
||||
m_sourceGroupTypeIconName[SOURCE_GROUP_JAVA_EMPTY] = "empty_icon";
|
||||
m_sourceGroupTypeIconName[SOURCE_GROUP_JAVA_MAVEN] = "mvn_icon";
|
||||
m_sourceGroupTypeIconName[SOURCE_GROUP_JAVA_GRADLE] = "empty_icon"; // Todo: make and use gradle icon here
|
||||
|
||||
// define descriptions for each kind of Source Group
|
||||
m_sourceGroupTypeDescriptions[SOURCE_GROUP_C_EMPTY] = "Create a new Sourcetrail Source Group by defining which C files will be indexed.";
|
||||
@@ -54,7 +56,8 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row)
|
||||
"<b>Note: Requires a running Visual Studio instance with the "
|
||||
"<a href=\"https://sourcetrail.com/documentation/index.html#VisualStudio\">Visual Studio plugin</a> installed.";
|
||||
m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_EMPTY] = "Create a new Sourcetrail Source Group by defining which Java files will be indexed.";
|
||||
m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_MAVEN] = "Create a new Source Group from an existing Maven project.";
|
||||
m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_MAVEN] = "Create a new Source Group from an existing Maven project.";
|
||||
m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_GRADLE] = "Create a new Source Group from an existing Gradle project.";
|
||||
|
||||
QVBoxLayout* vlayout = new QVBoxLayout();
|
||||
vlayout->setContentsMargins(0, 30, 0, 0);
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QLabel>
|
||||
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
|
||||
QtProjectWizzardContentSimple::QtProjectWizzardContentSimple(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window)
|
||||
: QtProjectWizzardContent(window)
|
||||
, m_settings(settings)
|
||||
, m_checkBox(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentSimple::populate(QGridLayout* layout, int& row)
|
||||
{
|
||||
m_title = createFormLabel("Lazy Include Search (deprecated)");
|
||||
layout->addWidget(m_title, row, QtProjectWizzardWindow::FRONT_COL);
|
||||
|
||||
m_checkBox = new QCheckBox("Search included files within the project paths");
|
||||
layout->addWidget(m_checkBox, row, QtProjectWizzardWindow::BACK_COL);
|
||||
|
||||
addHelpButton(
|
||||
"If enabled Sourcetrail also uses the project paths and their subdirectories when resolving #include directives.<br />"
|
||||
"<br />"
|
||||
"Use this option when you know that the project is self contained but don't know which paths to "
|
||||
"specify as include paths.<br />"
|
||||
"<br />"
|
||||
"<b>Warning</b>: This slows down indexing speed.<br />"
|
||||
"<br />"
|
||||
"<b>Deprecated</b>: This option will be removed in future versions.", layout, row);
|
||||
|
||||
row++;
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentSimple::load()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
m_checkBox->setChecked(cxxSettings->getUseSourcePathsForHeaderSearch());
|
||||
}
|
||||
}
|
||||
|
||||
void QtProjectWizzardContentSimple::save()
|
||||
{
|
||||
std::shared_ptr<SourceGroupSettingsCxx> cxxSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(m_settings);
|
||||
if (cxxSettings)
|
||||
{
|
||||
cxxSettings->setUseSourcePathsForHeaderSearch(m_checkBox->isChecked());
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef QT_PROJECT_WIZZARD_CONTENT_SIMPLE_H
|
||||
#define QT_PROJECT_WIZZARD_CONTENT_SIMPLE_H
|
||||
|
||||
#include "qt/window/project_wizzard/QtProjectWizzardContent.h"
|
||||
|
||||
class QCheckBox;
|
||||
class QButtonGroup;
|
||||
class SourceGroupSettings;
|
||||
|
||||
class QtProjectWizzardContentSimple
|
||||
: public QtProjectWizzardContent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizzardContentSimple(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populate(QGridLayout* layout, int& row) override;
|
||||
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<SourceGroupSettings> m_settings;
|
||||
|
||||
QCheckBox* m_checkBox;
|
||||
QLabel* m_title;
|
||||
};
|
||||
|
||||
#endif // QT_PROJECT_WIZZARD_CONTENT_SIMPLE_H
|
||||
@@ -16,11 +16,21 @@ add_files(
|
||||
data/parser/java/JavaEnvironmentFactory.cpp
|
||||
data/parser/java/JavaEnvironmentFactory.h
|
||||
|
||||
project/SourceGroupJava.cpp
|
||||
project/SourceGroupJava.h
|
||||
project/SourceGroupFactoryModuleJava.cpp
|
||||
project/SourceGroupFactoryModuleJava.h
|
||||
project/SourceGroupJava.cpp
|
||||
project/SourceGroupJava.h
|
||||
project/SourceGroupJavaEmpty.cpp
|
||||
project/SourceGroupJavaEmpty.h
|
||||
project/SourceGroupJavaGradle.cpp
|
||||
project/SourceGroupJavaGradle.h
|
||||
project/SourceGroupJavaMaven.cpp
|
||||
project/SourceGroupJavaMaven.h
|
||||
|
||||
utility/utilityJava.cpp
|
||||
utility/utilityJava.h
|
||||
utility/utilityGradle.cpp
|
||||
utility/utilityGradle.h
|
||||
utility/utilityMaven.cpp
|
||||
utility/utilityMaven.h
|
||||
)
|
||||
|
||||
@@ -22,6 +22,21 @@ bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string me
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, const std::string& arg1, const std::string& arg2, const std::string& arg3)
|
||||
{
|
||||
jclass javaClass = getJavaClass(className);
|
||||
jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
|
||||
if (javaMethodId != nullptr)
|
||||
{
|
||||
jstring jarg1 = m_env->NewStringUTF(arg1.c_str());
|
||||
jstring jarg2 = m_env->NewStringUTF(arg2.c_str());
|
||||
jstring jarg3 = m_env->NewStringUTF(arg3.c_str());
|
||||
m_env->CallStaticVoidMethod(javaClass, javaMethodId, jarg1, jarg2, jarg3);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5)
|
||||
{
|
||||
jclass javaClass = getJavaClass(className);
|
||||
@@ -39,11 +54,11 @@ bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string me
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JavaEnvironment::callStaticMethod(std::string className, std::string methodName, std::string& ret, std::string arg1)
|
||||
bool JavaEnvironment::callStaticStringMethod(std::string className, std::string methodName, std::string& ret, const std::string& arg1)
|
||||
{
|
||||
jclass javaClass = getJavaClass(className);
|
||||
jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
if(javaMethodId != nullptr)
|
||||
jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
if (javaMethodId != nullptr)
|
||||
{
|
||||
jstring jarg1 = m_env->NewStringUTF(arg1.c_str());
|
||||
jstring jret = (jstring)m_env->CallStaticObjectMethod(javaClass, javaMethodId, jarg1);
|
||||
@@ -58,6 +73,26 @@ bool JavaEnvironment::callStaticMethod(std::string className, std::string method
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JavaEnvironment::callStaticStringMethod(std::string className, std::string methodName, std::string& ret, const std::string& arg1, const std::string& arg2)
|
||||
{
|
||||
jclass javaClass = getJavaClass(className);
|
||||
jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;");
|
||||
if (javaMethodId != nullptr)
|
||||
{
|
||||
jstring jarg1 = m_env->NewStringUTF(arg1.c_str());
|
||||
jstring jarg2 = m_env->NewStringUTF(arg2.c_str());
|
||||
jstring jret = (jstring)m_env->CallStaticObjectMethod(javaClass, javaMethodId, jarg1, jarg2);
|
||||
if (jret)
|
||||
{
|
||||
const char *buffer = m_env->GetStringUTFChars(jret, JNI_FALSE);
|
||||
ret = std::string(buffer);
|
||||
m_env->ReleaseStringUTFChars(jret, buffer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string JavaEnvironment::toStdString(jstring s)
|
||||
{
|
||||
const char *nativeString = m_env->GetStringUTFChars(s, 0);
|
||||
|
||||
@@ -33,8 +33,10 @@ public:
|
||||
|
||||
~JavaEnvironment();
|
||||
bool callStaticVoidMethod(std::string className, std::string methodName);
|
||||
bool callStaticVoidMethod(std::string className, std::string methodName, const std::string& arg1, const std::string& arg2, const std::string& arg3);
|
||||
bool callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5);
|
||||
bool callStaticMethod(std::string className, std::string methodName, std::string& ret, std::string arg1);
|
||||
bool callStaticStringMethod(std::string className, std::string methodName, std::string& ret, const std::string& arg1);
|
||||
bool callStaticStringMethod(std::string className, std::string methodName, std::string& ret, const std::string& arg1, const std::string& arg2);
|
||||
|
||||
std::string toStdString(jstring s);
|
||||
jstring toJString(std::string s);
|
||||
|
||||
@@ -11,65 +11,9 @@
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utilityJava.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
std::vector<std::string> JavaParser::getRequiredJarNames()
|
||||
{
|
||||
std::vector<std::string> jarNames = {
|
||||
|
||||
"java-indexer.jar",
|
||||
"org.eclipse.core.commands-3.8.1.jar",
|
||||
"org.eclipse.core.contenttype-3.5.100.jar",
|
||||
"org.eclipse.core.expressions-3.5.100.jar",
|
||||
"org.eclipse.core.filesystem-1.6.1.jar",
|
||||
"org.eclipse.core.jobs-3.8.0.jar",
|
||||
"org.eclipse.core.resources-3.11.1.jar",
|
||||
"org.eclipse.core.runtime-3.12.0.jar",
|
||||
"org.eclipse.equinox.app-1.3.400.jar",
|
||||
"org.eclipse.equinox.common-3.8.0.jar",
|
||||
"org.eclipse.equinox.preferences-3.6.1.jar",
|
||||
"org.eclipse.equinox.registry-3.6.100.jar",
|
||||
"org.eclipse.jdt.core-3.12.3.jar",
|
||||
"org.eclipse.osgi-3.11.3.jar",
|
||||
"org.eclipse.text-3.6.0.jar"
|
||||
};
|
||||
return jarNames;
|
||||
}
|
||||
|
||||
std::string JavaParser::prepareJavaEnvironment()
|
||||
{
|
||||
std::string errorString;
|
||||
|
||||
if (!JavaEnvironmentFactory::getInstance())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const std::string separator = ";";
|
||||
#else
|
||||
const std::string separator = ":";
|
||||
#endif
|
||||
|
||||
std::string classPath = "";
|
||||
{
|
||||
const std::vector<std::string> jarNames = getRequiredJarNames();
|
||||
for (size_t i = 0; i < jarNames.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
classPath += separator;
|
||||
}
|
||||
classPath += ResourcePaths::getJavaPath().str() + jarNames[i];
|
||||
}
|
||||
}
|
||||
|
||||
JavaEnvironmentFactory::createInstance(
|
||||
classPath,
|
||||
errorString
|
||||
);
|
||||
}
|
||||
|
||||
return errorString;
|
||||
}
|
||||
|
||||
void JavaParser::clearCaches()
|
||||
{
|
||||
std::shared_ptr<JavaEnvironmentFactory> factory = JavaEnvironmentFactory::getInstance();
|
||||
@@ -90,7 +34,7 @@ JavaParser::JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<Fil
|
||||
: Parser(client)
|
||||
, m_id(s_nextParserId++)
|
||||
{
|
||||
const std::string errorString = prepareJavaEnvironment();
|
||||
const std::string errorString = utility::prepareJavaEnvironment();
|
||||
if (errorString.size() > 0)
|
||||
{
|
||||
LOG_ERROR(errorString);
|
||||
|
||||
@@ -32,9 +32,6 @@ class FileRegister;
|
||||
class JavaParser: public Parser
|
||||
{
|
||||
public:
|
||||
static std::vector<std::string> getRequiredJarNames();
|
||||
// returns: error message
|
||||
static std::string prepareJavaEnvironment();
|
||||
static void clearCaches();
|
||||
|
||||
JavaParser(std::shared_ptr<ParserClient> client, std::shared_ptr<FileRegister> fileRegister);
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#include "project/SourceGroupFactoryModuleJava.h"
|
||||
|
||||
#include "project/SourceGroupJava.h"
|
||||
#include "project/SourceGroupJavaEmpty.h"
|
||||
#include "project/SourceGroupJavaGradle.h"
|
||||
#include "project/SourceGroupJavaMaven.h"
|
||||
#include "settings/SourceGroupSettingsJavaEmpty.h"
|
||||
#include "settings/SourceGroupSettingsJavaGradle.h"
|
||||
#include "settings/SourceGroupSettingsJavaMaven.h"
|
||||
|
||||
SourceGroupFactoryModuleJava::~SourceGroupFactoryModuleJava()
|
||||
{
|
||||
@@ -11,6 +16,7 @@ bool SourceGroupFactoryModuleJava::supports(SourceGroupType type) const
|
||||
switch (type)
|
||||
{
|
||||
case SOURCE_GROUP_JAVA_EMPTY:
|
||||
case SOURCE_GROUP_JAVA_GRADLE:
|
||||
case SOURCE_GROUP_JAVA_MAVEN:
|
||||
return true;
|
||||
default:
|
||||
@@ -22,9 +28,17 @@ bool SourceGroupFactoryModuleJava::supports(SourceGroupType type) const
|
||||
std::shared_ptr<SourceGroup> SourceGroupFactoryModuleJava::createSourceGroup(std::shared_ptr<SourceGroupSettings> settings)
|
||||
{
|
||||
std::shared_ptr<SourceGroup> sourceGroup;
|
||||
if (std::shared_ptr<SourceGroupSettingsJava> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJava>(settings))
|
||||
if (std::shared_ptr<SourceGroupSettingsJavaEmpty> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJavaEmpty>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupJava(javaSettings));
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupJavaEmpty(javaSettings));
|
||||
}
|
||||
else if (std::shared_ptr<SourceGroupSettingsJavaGradle> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJavaGradle>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupJavaGradle(javaSettings));
|
||||
}
|
||||
else if (std::shared_ptr<SourceGroupSettingsJavaMaven> javaSettings = std::dynamic_pointer_cast<SourceGroupSettingsJavaMaven>(settings))
|
||||
{
|
||||
sourceGroup = std::shared_ptr<SourceGroup>(new SourceGroupJavaMaven(javaSettings));
|
||||
}
|
||||
return sourceGroup;
|
||||
}
|
||||
|
||||
@@ -6,18 +6,14 @@
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
#include "data/parser/java/JavaParser.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileManager.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityMaven.h"
|
||||
#include "utility/utilityString.h"
|
||||
#include "utility/utilityJava.h"
|
||||
#include "Application.h"
|
||||
|
||||
SourceGroupJava::SourceGroupJava(std::shared_ptr<SourceGroupSettingsJava> settings)
|
||||
: m_settings(settings)
|
||||
SourceGroupJava::SourceGroupJava()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,58 +21,22 @@ SourceGroupJava::~SourceGroupJava()
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupType SourceGroupJava::getType() const
|
||||
{
|
||||
return m_settings->getType();
|
||||
}
|
||||
|
||||
bool SourceGroupJava::prepareIndexing()
|
||||
{
|
||||
if (!prepareJavaEnvironment())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!prepareMavenData())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SourceGroupJava::fetchAllSourceFilePaths()
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
if (m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists())
|
||||
{
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nFetching Source Directories");
|
||||
|
||||
const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath());
|
||||
const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_settings->getShouldIndexMavenTests());
|
||||
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
sourcePaths = m_settings->getSourcePathsExpandedAndAbsolute();
|
||||
}
|
||||
|
||||
m_sourceFilePathsToIndex.clear();
|
||||
FileManager fileManager;
|
||||
fileManager.update(sourcePaths, m_settings->getExcludePathsExpandedAndAbsolute(), m_settings->getSourceExtensions());
|
||||
m_allSourceFilePaths = fileManager.getAllSourceFilePaths();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJava::getIndexerCommands(
|
||||
std::set<FilePath>* filesToIndex, bool fullRefresh)
|
||||
{
|
||||
std::vector<FilePath> classPath = getClassPath();
|
||||
|
||||
std::set<FilePath> indexedPaths;
|
||||
for (const FilePath& p: m_settings->getSourcePathsExpandedAndAbsolute())
|
||||
for (const FilePath& p: getSourceGroupSettings()->getSourcePathsExpandedAndAbsolute())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
@@ -85,7 +45,7 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJava::getIndexerCommands
|
||||
}
|
||||
|
||||
std::set<FilePath> excludedPaths;
|
||||
for (const FilePath& p: m_settings->getExcludePathsExpandedAndAbsolute())
|
||||
for (const FilePath& p: getSourceGroupSettings()->getExcludePathsExpandedAndAbsolute())
|
||||
{
|
||||
if (p.exists())
|
||||
{
|
||||
@@ -110,9 +70,14 @@ std::vector<std::shared_ptr<IndexerCommand>> SourceGroupJava::getIndexerCommands
|
||||
return indexerCommands;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroupSettings> SourceGroupJava::getSourceGroupSettings()
|
||||
{
|
||||
return getSourceGroupSettingsJava();
|
||||
}
|
||||
|
||||
bool SourceGroupJava::prepareJavaEnvironment()
|
||||
{
|
||||
const std::string errorString = JavaParser::prepareJavaEnvironment();
|
||||
const std::string errorString = utility::prepareJavaEnvironment();
|
||||
|
||||
if (errorString.size() > 0)
|
||||
{
|
||||
@@ -139,55 +104,20 @@ bool SourceGroupJava::prepareJavaEnvironment()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SourceGroupJava::prepareMavenData()
|
||||
{
|
||||
if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists())
|
||||
{
|
||||
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
|
||||
const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nGenerating Source Files");
|
||||
|
||||
ScopedFunctor dialogHider([&dialogView](){
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
});
|
||||
|
||||
bool success = utility::mavenGenerateSources(mavenPath, projectRootPath);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
const std::string dialogMessage =
|
||||
"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);
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nExporting Dependencies");
|
||||
|
||||
success = utility::mavenCopyDependencies(
|
||||
mavenPath, projectRootPath, m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute()
|
||||
);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::vector<FilePath> SourceGroupJava::getClassPath()
|
||||
{
|
||||
LOG_INFO("Retrieving classpath for indexer commands");
|
||||
std::vector<FilePath> classPath = doGetClassPath();
|
||||
LOG_INFO("Found " + std::to_string(classPath.size()) + " paths for classpath.");
|
||||
return classPath;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupJava::doGetClassPath()
|
||||
{
|
||||
std::vector<FilePath> classPath;
|
||||
|
||||
for (const FilePath& classpath: m_settings->getClasspathExpandedAndAbsolute())
|
||||
for (const FilePath& classpath : getSourceGroupSettingsJava()->getClasspathExpandedAndAbsolute())
|
||||
{
|
||||
if (classpath.exists())
|
||||
{
|
||||
@@ -196,31 +126,16 @@ std::vector<FilePath> SourceGroupJava::getClassPath()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_settings->getUseJreSystemLibrary())
|
||||
if (getSourceGroupSettingsJava()->getUseJreSystemLibrary())
|
||||
{
|
||||
for (const FilePath& systemLibraryPath: ApplicationSettings::getInstance()->getJreSystemLibraryPathsExpanded())
|
||||
for (const FilePath& systemLibraryPath : ApplicationSettings::getInstance()->getJreSystemLibraryPathsExpanded())
|
||||
{
|
||||
LOG_INFO("Adding JRE system library path to classpath: " + systemLibraryPath.str());
|
||||
classPath.push_back(systemLibraryPath);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute().exists())
|
||||
{
|
||||
std::vector<FilePath> mavenJarPaths = FileSystem::getFilePathsFromDirectory(
|
||||
m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute(),
|
||||
utility::createVectorFromElements<std::string>(".jar")
|
||||
);
|
||||
|
||||
for (const FilePath& mavenJarPath: mavenJarPaths)
|
||||
{
|
||||
LOG_INFO("Adding jar to classpath: " + mavenJarPath.str());
|
||||
}
|
||||
|
||||
utility::append(classPath, mavenJarPaths);
|
||||
}
|
||||
|
||||
for (const FilePath& rootDirectory: fetchRootDirectories())
|
||||
for (const FilePath& rootDirectory : fetchRootDirectories())
|
||||
{
|
||||
if (rootDirectory.exists())
|
||||
{
|
||||
@@ -228,7 +143,6 @@ std::vector<FilePath> SourceGroupJava::getClassPath()
|
||||
classPath.push_back(rootDirectory);
|
||||
}
|
||||
}
|
||||
LOG_INFO("Found " + std::to_string(classPath.size()) + " paths for classpath.");
|
||||
|
||||
return classPath;
|
||||
}
|
||||
@@ -250,7 +164,7 @@ std::set<FilePath> SourceGroupJava::fetchRootDirectories()
|
||||
std::shared_ptr<TextAccess> textAccess = TextAccess::createFromFile(filePath);
|
||||
|
||||
std::string packageName = "";
|
||||
javaEnvironment->callStaticMethod("com/sourcetrail/JavaIndexer", "getPackageName", packageName, textAccess->getText());
|
||||
javaEnvironment->callStaticStringMethod("com/sourcetrail/JavaIndexer", "getPackageName", packageName, textAccess->getText());
|
||||
|
||||
if (packageName.empty())
|
||||
{
|
||||
|
||||
@@ -3,33 +3,34 @@
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "settings/SourceGroupSettingsJava.h"
|
||||
#include "project/SourceGroup.h"
|
||||
|
||||
class SourceGroupSettingsJava;
|
||||
|
||||
class SourceGroupJava: public SourceGroup
|
||||
{
|
||||
public:
|
||||
SourceGroupJava(std::shared_ptr<SourceGroupSettingsJava> settings);
|
||||
SourceGroupJava();
|
||||
virtual ~SourceGroupJava();
|
||||
|
||||
virtual SourceGroupType getType() const;
|
||||
|
||||
virtual bool prepareIndexing();
|
||||
|
||||
virtual void fetchAllSourceFilePaths();
|
||||
|
||||
virtual std::vector<std::shared_ptr<IndexerCommand>> getIndexerCommands(
|
||||
std::set<FilePath>* filesToIndex, bool fullRefresh);
|
||||
|
||||
protected:
|
||||
virtual std::vector<FilePath> doGetClassPath();
|
||||
|
||||
private:
|
||||
virtual std::shared_ptr<SourceGroupSettingsJava> getSourceGroupSettingsJava() = 0;
|
||||
|
||||
virtual std::shared_ptr<SourceGroupSettings> getSourceGroupSettings();
|
||||
bool prepareJavaEnvironment();
|
||||
bool prepareMavenData();
|
||||
|
||||
std::vector<FilePath> getClassPath();
|
||||
std::set<FilePath> fetchRootDirectories();
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsJava> m_settings;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_JAVA_H
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "project/SourceGroupJavaEmpty.h"
|
||||
|
||||
#include "settings/SourceGroupSettingsJavaEmpty.h"
|
||||
|
||||
SourceGroupJavaEmpty::SourceGroupJavaEmpty(std::shared_ptr<SourceGroupSettingsJavaEmpty> settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupJavaEmpty::~SourceGroupJavaEmpty()
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupType SourceGroupJavaEmpty::getType() const
|
||||
{
|
||||
return SOURCE_GROUP_JAVA_EMPTY;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsJava> SourceGroupJavaEmpty::getSourceGroupSettingsJava()
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupJavaEmpty::getAllSourcePaths() const
|
||||
{
|
||||
return m_settings->getSourcePathsExpandedAndAbsolute();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef SOURCE_GROUP_JAVA_EMPTY_H
|
||||
#define SOURCE_GROUP_JAVA_EMPTY_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "project/SourceGroupJava.h"
|
||||
|
||||
class SourceGroupSettingsJavaEmpty;
|
||||
|
||||
class SourceGroupJavaEmpty: public SourceGroupJava
|
||||
{
|
||||
public:
|
||||
SourceGroupJavaEmpty(std::shared_ptr<SourceGroupSettingsJavaEmpty> settings);
|
||||
virtual ~SourceGroupJavaEmpty();
|
||||
|
||||
virtual SourceGroupType getType() const;
|
||||
|
||||
private:
|
||||
virtual std::shared_ptr<SourceGroupSettingsJava> getSourceGroupSettingsJava();
|
||||
virtual std::vector<FilePath> getAllSourcePaths() const;
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsJavaEmpty> m_settings;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_JAVA_EMPTY_H
|
||||
@@ -0,0 +1,108 @@
|
||||
#include "project/SourceGroupJavaGradle.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityGradle.h"
|
||||
#include "Application.h"
|
||||
|
||||
SourceGroupJavaGradle::SourceGroupJavaGradle(std::shared_ptr<SourceGroupSettingsJavaGradle> settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupJavaGradle::~SourceGroupJavaGradle()
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupType SourceGroupJavaGradle::getType() const
|
||||
{
|
||||
return SOURCE_GROUP_JAVA_GRADLE;
|
||||
}
|
||||
|
||||
bool SourceGroupJavaGradle::prepareIndexing()
|
||||
{
|
||||
if (!SourceGroupJava::prepareIndexing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!prepareGradleData())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupJavaGradle::doGetClassPath()
|
||||
{
|
||||
std::vector<FilePath> classPath = SourceGroupJava::doGetClassPath();
|
||||
|
||||
if (m_settings->getGradleDependenciesDirectoryExpandedAndAbsolute().exists())
|
||||
{
|
||||
std::vector<FilePath> gradleJarPaths = FileSystem::getFilePathsFromDirectory(
|
||||
m_settings->getGradleDependenciesDirectoryExpandedAndAbsolute(),
|
||||
{".jar"}
|
||||
);
|
||||
|
||||
for (const FilePath& gradleJarPath : gradleJarPaths)
|
||||
{
|
||||
LOG_INFO("Adding jar to classpath: " + gradleJarPath.str());
|
||||
}
|
||||
|
||||
utility::append(classPath, gradleJarPaths);
|
||||
}
|
||||
|
||||
return classPath;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsJava> SourceGroupJavaGradle::getSourceGroupSettingsJava()
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupJavaGradle::getAllSourcePaths() const
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
if (m_settings->getGradleProjectFilePathExpandedAndAbsolute().exists())
|
||||
{
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Gradle\nFetching Source Directories");
|
||||
|
||||
const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
sourcePaths = utility::gradleGetAllSourceDirectories(projectRootPath, m_settings->getShouldIndexGradleTests());
|
||||
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
}
|
||||
return sourcePaths;
|
||||
}
|
||||
|
||||
bool SourceGroupJavaGradle::prepareGradleData()
|
||||
{
|
||||
if (m_settings && m_settings->getGradleProjectFilePathExpandedAndAbsolute().exists())
|
||||
{
|
||||
const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
|
||||
ScopedFunctor dialogHider([&dialogView]() {
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
});
|
||||
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Gradle\nExporting Dependencies");
|
||||
|
||||
bool success = utility::gradleCopyDependencies(
|
||||
projectRootPath,
|
||||
m_settings->getGradleDependenciesDirectoryExpandedAndAbsolute(),
|
||||
m_settings->getShouldIndexGradleTests()
|
||||
);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef SOURCE_GROUP_JAVA_GRADLE_H
|
||||
#define SOURCE_GROUP_JAVA_GRADLE_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "settings/SourceGroupSettingsJavaGradle.h"
|
||||
#include "project/SourceGroupJava.h"
|
||||
|
||||
class SourceGroupJavaGradle : public SourceGroupJava
|
||||
{
|
||||
public:
|
||||
SourceGroupJavaGradle(std::shared_ptr<SourceGroupSettingsJavaGradle> settings);
|
||||
virtual ~SourceGroupJavaGradle();
|
||||
virtual SourceGroupType getType() const;
|
||||
virtual bool prepareIndexing();
|
||||
|
||||
protected:
|
||||
virtual std::vector<FilePath> doGetClassPath();
|
||||
|
||||
private:
|
||||
virtual std::shared_ptr<SourceGroupSettingsJava> getSourceGroupSettingsJava();
|
||||
virtual std::vector<FilePath> getAllSourcePaths() const;
|
||||
bool prepareGradleData();
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsJavaGradle> m_settings;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_JAVA_GRADLE_H
|
||||
@@ -0,0 +1,124 @@
|
||||
#include "project/SourceGroupJavaMaven.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/ScopedFunctor.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityMaven.h"
|
||||
#include "Application.h"
|
||||
|
||||
SourceGroupJavaMaven::SourceGroupJavaMaven(std::shared_ptr<SourceGroupSettingsJavaMaven> settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupJavaMaven::~SourceGroupJavaMaven()
|
||||
{
|
||||
}
|
||||
|
||||
SourceGroupType SourceGroupJavaMaven::getType() const
|
||||
{
|
||||
return SOURCE_GROUP_JAVA_MAVEN;
|
||||
}
|
||||
|
||||
bool SourceGroupJavaMaven::prepareIndexing()
|
||||
{
|
||||
if (!SourceGroupJava::prepareIndexing())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!prepareMavenData())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupJavaMaven::doGetClassPath()
|
||||
{
|
||||
std::vector<FilePath> classPath = SourceGroupJava::doGetClassPath();
|
||||
|
||||
if (m_settings && m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute().exists())
|
||||
{
|
||||
std::vector<FilePath> mavenJarPaths = FileSystem::getFilePathsFromDirectory(
|
||||
m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute(),
|
||||
utility::createVectorFromElements<std::string>(".jar")
|
||||
);
|
||||
|
||||
for (const FilePath& mavenJarPath : mavenJarPaths)
|
||||
{
|
||||
LOG_INFO("Adding jar to classpath: " + mavenJarPath.str());
|
||||
}
|
||||
|
||||
utility::append(classPath, mavenJarPaths);
|
||||
}
|
||||
|
||||
return classPath;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsJava> SourceGroupJavaMaven::getSourceGroupSettingsJava()
|
||||
{
|
||||
return m_settings;
|
||||
}
|
||||
|
||||
std::vector<FilePath> SourceGroupJavaMaven::getAllSourcePaths() const
|
||||
{
|
||||
std::vector<FilePath> sourcePaths;
|
||||
if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists())
|
||||
{
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nFetching Source Directories");
|
||||
|
||||
const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath());
|
||||
const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_settings->getShouldIndexMavenTests());
|
||||
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
}
|
||||
return sourcePaths;
|
||||
}
|
||||
|
||||
bool SourceGroupJavaMaven::prepareMavenData()
|
||||
{
|
||||
if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists())
|
||||
{
|
||||
const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath();
|
||||
const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory();
|
||||
|
||||
std::shared_ptr<DialogView> dialogView = Application::getInstance()->getDialogView();
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nGenerating Source Files");
|
||||
|
||||
ScopedFunctor dialogHider([&dialogView](){
|
||||
dialogView->hideUnknownProgressDialog();
|
||||
});
|
||||
|
||||
bool success = utility::mavenGenerateSources(mavenPath, projectRootPath);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
const std::string dialogMessage =
|
||||
"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);
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nExporting Dependencies");
|
||||
|
||||
success = utility::mavenCopyDependencies(
|
||||
mavenPath, projectRootPath, m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute()
|
||||
);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef SOURCE_GROUP_JAVA_MAVEN_H
|
||||
#define SOURCE_GROUP_JAVA_MAVEN_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "settings/SourceGroupSettingsJavaMaven.h"
|
||||
#include "project/SourceGroupJava.h"
|
||||
|
||||
class SourceGroupJavaMaven: public SourceGroupJava
|
||||
{
|
||||
public:
|
||||
SourceGroupJavaMaven(std::shared_ptr<SourceGroupSettingsJavaMaven> settings);
|
||||
virtual ~SourceGroupJavaMaven();
|
||||
virtual SourceGroupType getType() const;
|
||||
virtual bool prepareIndexing();
|
||||
|
||||
protected:
|
||||
virtual std::vector<FilePath> doGetClassPath();
|
||||
|
||||
private:
|
||||
virtual std::shared_ptr<SourceGroupSettingsJava> getSourceGroupSettingsJava();
|
||||
virtual std::vector<FilePath> getAllSourcePaths() const;
|
||||
bool prepareMavenData();
|
||||
|
||||
std::shared_ptr<SourceGroupSettingsJavaMaven> m_settings;
|
||||
};
|
||||
|
||||
#endif // SOURCE_GROUP_JAVA_MAVEN_H
|
||||
@@ -0,0 +1,93 @@
|
||||
#include "utility/utilityGradle.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/utilityJava.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
void setJavaHomeVariableIfNotExists()
|
||||
{
|
||||
if (getenv("JAVA_HOME") == nullptr)
|
||||
{
|
||||
const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath());
|
||||
const FilePath javaHomePath = javaPath.parentDirectory().parentDirectory().parentDirectory();
|
||||
|
||||
LOG_WARNING("Environment variable \"JAVA_HOME\" not found on system. Setting value to \"" + javaHomePath.str() + "\" for this process.");
|
||||
|
||||
putenv(const_cast<char*>(("JAVA_HOME=" + javaHomePath.str()).c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace utility
|
||||
{
|
||||
bool gradleCopyDependencies(const FilePath& projectDirectoryPath, const FilePath& outputDirectoryPath, bool addTestDependencies)
|
||||
{
|
||||
const std::string gradleInitScriptPath = ResourcePaths::getJavaPath().str() + "gradle/init.gradle";
|
||||
|
||||
setJavaHomeVariableIfNotExists();
|
||||
utility::prepareJavaEnvironment();
|
||||
|
||||
std::shared_ptr<JavaEnvironment> javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment();
|
||||
bool success = javaEnvironment->callStaticVoidMethod("com/sourcetrail/gradle/InfoRetriever", "copyCompileLibs", projectDirectoryPath.str(), gradleInitScriptPath, outputDirectoryPath.str());
|
||||
|
||||
if (success && addTestDependencies)
|
||||
{
|
||||
success = javaEnvironment->callStaticVoidMethod("com/sourcetrail/gradle/InfoRetriever", "copyTestCompileLibs", projectDirectoryPath.str(), gradleInitScriptPath, outputDirectoryPath.str());
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
std::vector<FilePath> gradleGetAllSourceDirectories(const FilePath& projectDirectoryPath, bool addTestDirectories)
|
||||
{
|
||||
const std::string gradleInitScriptPath = ResourcePaths::getJavaPath().str() + "gradle/init.gradle";
|
||||
|
||||
setJavaHomeVariableIfNotExists();
|
||||
utility::prepareJavaEnvironment();
|
||||
|
||||
std::set<std::string> uncheckedDirectories;
|
||||
{
|
||||
std::shared_ptr<JavaEnvironment> javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment();
|
||||
{
|
||||
std::string mainSrcDirs = "";
|
||||
javaEnvironment->callStaticStringMethod("com/sourcetrail/gradle/InfoRetriever", "getMainSrcDirs", mainSrcDirs, projectDirectoryPath.str(), gradleInitScriptPath);
|
||||
for (const std::string mainSrcDir : utility::splitToVector(mainSrcDirs, ";"))
|
||||
{
|
||||
uncheckedDirectories.insert(mainSrcDir);
|
||||
}
|
||||
}
|
||||
|
||||
if (addTestDirectories)
|
||||
{
|
||||
std::string testSrcDirs = "";
|
||||
javaEnvironment->callStaticStringMethod("com/sourcetrail/gradle/InfoRetriever", "getTestSrcDirs", testSrcDirs, projectDirectoryPath.str(), gradleInitScriptPath);
|
||||
for (const std::string testSrcDir : utility::splitToVector(testSrcDirs, ";"))
|
||||
{
|
||||
uncheckedDirectories.insert(testSrcDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<FilePath> directories;
|
||||
for (const std::string& uncheckedDirectory: uncheckedDirectories)
|
||||
{
|
||||
FilePath uncheckedDirectoryPath(uncheckedDirectory);
|
||||
if (uncheckedDirectoryPath.exists())
|
||||
{
|
||||
directories.push_back(uncheckedDirectoryPath);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("Found " + std::to_string(directories.size()) + " of " + std::to_string(uncheckedDirectories.size()) + " directories on system.");
|
||||
|
||||
return directories;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#ifndef UTILITY_GRADLE_H
|
||||
#define UTILITY_GRADLE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
class FilePath;
|
||||
|
||||
namespace utility
|
||||
{
|
||||
bool gradleCopyDependencies(const FilePath& projectDirectoryPath, const FilePath& outputDirectoryPath, bool addTestDependencies);
|
||||
std::vector<FilePath> gradleGetAllSourceDirectories(const FilePath& projectDirectoryPath, bool addTestDirectories);
|
||||
}
|
||||
|
||||
#endif // UTILITY_GRADLE_H
|
||||
@@ -0,0 +1,68 @@
|
||||
#include "utility/utilityGradle.h"
|
||||
|
||||
#include "data/parser/java/JavaEnvironment.h"
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
namespace utility
|
||||
{
|
||||
std::vector<std::string> getRequiredJarNames()
|
||||
{
|
||||
std::vector<std::string> jarNames = {
|
||||
|
||||
"gradle-tooling-api-4.2.jar",
|
||||
"java-indexer.jar",
|
||||
"org.eclipse.core.commands-3.8.1.jar",
|
||||
"org.eclipse.core.contenttype-3.5.100.jar",
|
||||
"org.eclipse.core.expressions-3.5.100.jar",
|
||||
"org.eclipse.core.filesystem-1.6.1.jar",
|
||||
"org.eclipse.core.jobs-3.8.0.jar",
|
||||
"org.eclipse.core.resources-3.11.1.jar",
|
||||
"org.eclipse.core.runtime-3.12.0.jar",
|
||||
"org.eclipse.equinox.app-1.3.400.jar",
|
||||
"org.eclipse.equinox.common-3.8.0.jar",
|
||||
"org.eclipse.equinox.preferences-3.6.1.jar",
|
||||
"org.eclipse.equinox.registry-3.6.100.jar",
|
||||
"org.eclipse.jdt.core-3.12.3.jar",
|
||||
"org.eclipse.osgi-3.11.3.jar",
|
||||
"org.eclipse.text-3.6.0.jar",
|
||||
"slf4j-api-1.7.10.jar",
|
||||
"slf4j-simple-1.7.10.jar"
|
||||
};
|
||||
return jarNames;
|
||||
}
|
||||
|
||||
std::string prepareJavaEnvironment()
|
||||
{
|
||||
std::string errorString;
|
||||
|
||||
if (!JavaEnvironmentFactory::getInstance())
|
||||
{
|
||||
#ifdef _WIN32
|
||||
const std::string separator = ";";
|
||||
#else
|
||||
const std::string separator = ":";
|
||||
#endif
|
||||
|
||||
std::string classPath = "";
|
||||
{
|
||||
const std::vector<std::string> jarNames = getRequiredJarNames();
|
||||
for (size_t i = 0; i < jarNames.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
classPath += separator;
|
||||
}
|
||||
classPath += ResourcePaths::getJavaPath().str() + "lib/" + jarNames[i];
|
||||
}
|
||||
}
|
||||
|
||||
JavaEnvironmentFactory::createInstance(
|
||||
classPath,
|
||||
errorString
|
||||
);
|
||||
}
|
||||
|
||||
return errorString;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef UTILITY_JAVA_H
|
||||
#define UTILITY_JAVA_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class FilePath;
|
||||
|
||||
namespace utility
|
||||
{
|
||||
std::vector<std::string> getRequiredJarNames();
|
||||
std::string prepareJavaEnvironment();
|
||||
}
|
||||
|
||||
#endif // UTILITY_JAVA_H
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "utility/file/FileRegister.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityJava.h"
|
||||
#include "utility/utilityPathDetection.h"
|
||||
#include "utility/utilityString.h"
|
||||
|
||||
@@ -196,14 +197,14 @@ private:
|
||||
#endif
|
||||
std::string classPath = "";
|
||||
{
|
||||
const std::vector<std::string> jarNames = JavaParser::getRequiredJarNames();
|
||||
const std::vector<std::string> jarNames = utility::getRequiredJarNames();
|
||||
for (size_t i = 0; i < jarNames.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
classPath += separator;
|
||||
}
|
||||
classPath += "../app/data/java/" + jarNames[i];
|
||||
classPath += "../app/data/java/lib/" + jarNames[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/utilityPathDetection.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utility.h"
|
||||
|
||||
#include "data/parser/java/JavaEnvironmentFactory.h"
|
||||
#include "data/parser/java/JavaParser.h"
|
||||
|
||||
#include "helper/TestParserClient.h"
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/utilityPathDetection.h"
|
||||
#include "utility/text/TextAccess.h"
|
||||
#include "utility/utility.h"
|
||||
#include "utility/utilityJava.h"
|
||||
|
||||
class JavaParserTestSuite: public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
@@ -1175,14 +1176,14 @@ private:
|
||||
#endif
|
||||
std::string classPath = "";
|
||||
{
|
||||
const std::vector<std::string> jarNames = JavaParser::getRequiredJarNames();
|
||||
const std::vector<std::string> jarNames = utility::getRequiredJarNames();
|
||||
for (size_t i = 0; i < jarNames.size(); i++)
|
||||
{
|
||||
if (i != 0)
|
||||
{
|
||||
classPath += separator;
|
||||
}
|
||||
classPath += "../app/data/java/" + jarNames[i];
|
||||
classPath += "../app/data/java/lib/" + jarNames[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user