logic: added project setup support for Sonargraph projects (Java and CMake-JSON modules supported)

* added classes for loading a Sonargraph project
* added Sonargraph options to project setup wizard
* added test for generating indexer commands from Sonargraph modules
* fixed sqlite storage crashing in constructor when parent directory of provided path does not exist
* removed unused FileRegister from Java indexing
* removed unused info from IndexerCommandJava
* refactored loading and saving of SourceGroupSettings
* extracted sourcepaths settings to own class that can be re-used
* merged CDB wizard contentents for source file and indexed paths
* unified wizard content for sonargraph project path
* removed include filters from default source groups
* extracted generation of RefreshInfo from Project to RefreshInfoGenerator
* added tests for RefreshInfoGenerator
* added language and standard selection to sonargraph project setup
* added auto-detection for indexed header paths of sonargraph cmake json modules
* Sonargraph::Project can enable/disable support for specific modules
* warn if sonargraph project contains no matching modules
* indexed headers can be detected from sonargraph project
This commit is contained in:
mlangkabel
2018-05-18 16:07:57 +02:00
parent e55ae5ba31
commit 7b735cfd17
164 changed files with 24770 additions and 1684 deletions
+4
View File
@@ -43,6 +43,8 @@ LanguageType getLanguageTypeForSourceGroupType(SourceGroupType t)
return LANGUAGE_CPP;
case SOURCE_GROUP_CXX_CDB:
return LANGUAGE_CPP;
case SOURCE_GROUP_CXX_SONARGRAPH:
return LANGUAGE_CPP;
case SOURCE_GROUP_CXX_VS:
return LANGUAGE_CPP;
case SOURCE_GROUP_JAVA_EMPTY:
@@ -51,6 +53,8 @@ LanguageType getLanguageTypeForSourceGroupType(SourceGroupType t)
return LANGUAGE_JAVA;
case SOURCE_GROUP_JAVA_GRADLE:
return LANGUAGE_JAVA;
case SOURCE_GROUP_JAVA_SONARGRAPH:
return LANGUAGE_JAVA;
default:
break;
}
+8
View File
@@ -5,9 +5,11 @@
#include "settings/migration/SettingsMigrationMoveKey.h"
#include "settings/SourceGroupSettingsCxxCdb.h"
#include "settings/SourceGroupSettingsCxxEmpty.h"
#include "settings/SourceGroupSettingsCxxSonargraph.h"
#include "settings/SourceGroupSettingsJavaEmpty.h"
#include "settings/SourceGroupSettingsJavaMaven.h"
#include "settings/SourceGroupSettingsJavaGradle.h"
#include "settings/SourceGroupSettingsJavaSonargraph.h"
#include "utility/logging/logging.h"
#include "utility/utilityString.h"
#include "utility/utilityUuid.h"
@@ -150,6 +152,9 @@ std::vector<std::shared_ptr<SourceGroupSettings>> ProjectSettings::getAllSourceG
case SOURCE_GROUP_CXX_CDB:
settings = std::make_shared<SourceGroupSettingsCxxCdb>(id, this);
break;
case SOURCE_GROUP_CXX_SONARGRAPH:
settings = std::make_shared<SourceGroupSettingsCxxSonargraph>(id, this);
break;
case SOURCE_GROUP_JAVA_EMPTY:
settings = std::make_shared<SourceGroupSettingsJavaEmpty>(id, this);
break;
@@ -159,6 +164,9 @@ std::vector<std::shared_ptr<SourceGroupSettings>> ProjectSettings::getAllSourceG
case SOURCE_GROUP_JAVA_GRADLE:
settings = std::make_shared<SourceGroupSettingsJavaGradle>(id, this);
break;
case SOURCE_GROUP_JAVA_SONARGRAPH:
settings = std::make_shared<SourceGroupSettingsJavaSonargraph>(id, this);
break;
default:
continue;
}
+29 -161
View File
@@ -1,7 +1,7 @@
#include "settings/SourceGroupSettings.h"
#include "utility/file/FileSystem.h"
#include "utility/utility.h"
#include "settings/ProjectSettings.h"
#include "utility/ConfigManager.h"
const size_t SourceGroupSettings::s_version = 1;
const std::string SourceGroupSettings::s_keyPrefix = "source_groups/source_group_";
@@ -15,13 +15,6 @@ SourceGroupSettings::SourceGroupSettings(
, m_type(type)
, m_status(SOURCE_GROUP_STATUS_ENABLED)
, m_standard("")
, m_sourcePaths(std::vector<FilePath>())
, m_excludeFilters(std::vector<std::wstring>())
, m_sourceExtensions(std::vector<std::wstring>())
{
}
SourceGroupSettings::~SourceGroupSettings()
{
}
@@ -29,30 +22,23 @@ 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);
const std::string name = config->getValueOrDefault<std::string>(key + "/name", "");
if (!name.empty())
{
setName(name);
}
setStatus(stringToSourceGroupStatusType(
getValue(key + "/status", sourceGroupStatusTypeToString(SOURCE_GROUP_STATUS_ENABLED), config)));
setStandard(getValue<std::string>(key + "/standard", "", config));
setSourcePaths(getPathValues(key + "/source_paths/source_path", config));
setExcludeFilterStrings(getValues(key + "/exclude_filters/exclude_filter", std::vector<std::wstring>(), config));
setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector<std::wstring>(), config));
setStatus(stringToSourceGroupStatusType(config->getValueOrDefault(key + "/status", sourceGroupStatusTypeToString(SOURCE_GROUP_STATUS_ENABLED))));
setStandard(config->getValueOrDefault<std::string>(key + "/standard", ""));
}
void SourceGroupSettings::save(std::shared_ptr<ConfigManager> config)
{
const std::string key = s_keyPrefix + getId();
setValue(key + "/status", sourceGroupStatusTypeToString(getStatus()), config);
setValue(key + "/name", getName(), config);
setValue(key + "/standard", getStandard(), config);
setPathValues(key + "/source_paths/source_path", getSourcePaths(), config);
setValues(key + "/exclude_filters/exclude_filter", getExcludeFilterStrings(), config);
setValues(key + "/source_extensions/source_extension", getSourceExtensions(), config);
config->setValue(key + "/status", sourceGroupStatusTypeToString(getStatus()));
config->setValue(key + "/name", getName());
config->setValue(key + "/standard", getStandard());
}
bool SourceGroupSettings::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -62,10 +48,7 @@ bool SourceGroupSettings::equals(std::shared_ptr<SourceGroupSettings> other) con
m_name == other->m_name &&
m_type == other->m_type &&
m_status == other->m_status &&
m_standard == other->m_standard &&
utility::isPermutation(m_sourcePaths, other->m_sourcePaths) &&
utility::isPermutation(m_excludeFilters, other->m_excludeFilters) &&
utility::isPermutation(m_sourceExtensions, other->m_sourceExtensions)
m_standard == other->m_standard
);
}
@@ -79,6 +62,16 @@ void SourceGroupSettings::setId(const std::string& id)
m_id = id;
}
SourceGroupType SourceGroupSettings::getType() const
{
return m_type;
}
LanguageType SourceGroupSettings::getLanguage() const
{
return getLanguageTypeForSourceGroupType(getType());
}
std::string SourceGroupSettings::getName() const
{
return m_name;
@@ -89,6 +82,16 @@ void SourceGroupSettings::setName(const std::string& name)
m_name = name;
}
SourceGroupStatusType SourceGroupSettings::getStatus() const
{
return m_status;
}
void SourceGroupSettings::setStatus(SourceGroupStatusType status)
{
m_status = status;
}
FilePath SourceGroupSettings::getProjectDirectoryPath() const
{
return m_projectSettings->getProjectDirectoryPath();
@@ -104,21 +107,6 @@ std::vector<FilePath> SourceGroupSettings::makePathsExpandedAndAbsolute(const st
return m_projectSettings->makePathsExpandedAndAbsolute(paths);
}
SourceGroupType SourceGroupSettings::getType() const
{
return m_type;
}
SourceGroupStatusType SourceGroupSettings::getStatus() const
{
return m_status;
}
void SourceGroupSettings::setStatus(SourceGroupStatusType status)
{
m_status = status;
}
std::string SourceGroupSettings::getStandard() const
{
if (m_standard.empty())
@@ -132,123 +120,3 @@ void SourceGroupSettings::setStandard(const std::string& standard)
{
m_standard = standard;
}
std::vector<FilePath> SourceGroupSettings::getSourcePaths() const
{
return m_sourcePaths;
}
std::vector<FilePath> SourceGroupSettings::getSourcePathsExpandedAndAbsolute() const
{
return m_projectSettings->makePathsExpandedAndAbsolute(getSourcePaths());
}
void SourceGroupSettings::setSourcePaths(const std::vector<FilePath>& sourcePaths)
{
m_sourcePaths = sourcePaths;
}
std::vector<std::wstring> SourceGroupSettings::getExcludeFilterStrings() const
{
return m_excludeFilters;
}
std::vector<FilePathFilter> SourceGroupSettings::getExcludeFiltersExpandedAndAbsolute() const
{
std::vector<FilePathFilter> result;
for (const std::wstring& filterString : m_excludeFilters)
{
if (!filterString.empty())
{
const size_t wildcardPos = filterString.find(L"*");
if (wildcardPos != filterString.npos)
{
std::wsmatch match;
if (std::regex_search(filterString, match, std::wregex(L"[\\\\/]")) && !match.empty() &&
match.position(0) < int(wildcardPos))
{
const FilePath p = m_projectSettings->makePathExpandedAndAbsolute(FilePath(match.prefix().str()));
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>(
utility::toVector(symLinkPaths),
[match](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + L"/" + match.suffix().str());
}
)
);
}
else
{
result.push_back(FilePathFilter(filterString));
}
}
else
{
const FilePath p = m_projectSettings->makePathExpandedAndAbsolute(FilePath(filterString));
const bool isFile = p.exists() && !p.isDirectory();
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>(
utility::toVector(symLinkPaths),
[isFile](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + (isFile ? L"" : L"**"));
}
)
);
}
}
}
return result;
}
void SourceGroupSettings::setExcludeFilterStrings(const std::vector<std::wstring>& excludeFilters)
{
m_excludeFilters = excludeFilters;
}
std::vector<std::wstring> SourceGroupSettings::getSourceExtensions() const
{
if (m_sourceExtensions.empty())
{
return getDefaultSourceExtensions();
}
return m_sourceExtensions;
}
void SourceGroupSettings::setSourceExtensions(const std::vector<std::wstring>& sourceExtensions)
{
m_sourceExtensions = sourceExtensions;
}
std::vector<FilePath> SourceGroupSettings::getPathValues(
const std::string& key, std::shared_ptr<const ConfigManager> config)
{
std::vector<FilePath> paths;
for (const std::wstring& value : getValues<std::wstring>(key, {}, config))
{
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::wstring> values;
for (const FilePath& path : paths)
{
values.push_back(path.wstr());
}
return setValues(key, values, config);
}
+10 -88
View File
@@ -4,11 +4,12 @@
#include <memory>
#include <vector>
#include "settings/ProjectSettings.h"
#include "settings/LanguageType.h"
#include "settings/SourceGroupStatusType.h"
#include "settings/SourceGroupType.h"
#include "utility/file/FilePathFilter.h"
class ConfigManager;
class FilePath;
class ProjectSettings;
class SourceGroupSettings
@@ -18,7 +19,7 @@ public:
static const std::string s_keyPrefix;
SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettings();
virtual ~SourceGroupSettings() = default;
virtual void load(std::shared_ptr<const ConfigManager> config);
virtual void save(std::shared_ptr<ConfigManager> config);
@@ -28,54 +29,28 @@ public:
std::string getId() const;
void setId(const std::string& id);
SourceGroupType getType() const;
LanguageType getLanguage() const;
std::string getName() const;
void setName(const std::string& name);
SourceGroupStatusType getStatus() const;
void setStatus(SourceGroupStatusType status);
FilePath getProjectDirectoryPath() const;
FilePath makePathExpandedAndAbsolute(const FilePath& path) const;
std::vector<FilePath> makePathsExpandedAndAbsolute(const std::vector<FilePath>& paths) const;
virtual std::vector<std::string> getAvailableLanguageStandards() const = 0;
virtual SourceGroupType getType() const;
SourceGroupStatusType getStatus() const;
void setStatus(SourceGroupStatusType status);
std::string getStandard() const;
void setStandard(const std::string& standard);
std::vector<FilePath> getSourcePaths() const;
std::vector<FilePath> getSourcePathsExpandedAndAbsolute() const;
void setSourcePaths(const std::vector<FilePath>& sourcePaths);
std::vector<std::wstring> getExcludeFilterStrings() const;
std::vector<FilePathFilter> getExcludeFiltersExpandedAndAbsolute() const;
void setExcludeFilterStrings(const std::vector<std::wstring>& excludeFilters);
std::vector<std::wstring> getSourceExtensions() const;
void setSourceExtensions(const std::vector<std::wstring>& 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:
virtual std::vector<std::wstring> getDefaultSourceExtensions() const = 0;
virtual std::string getDefaultStandard() const = 0;
std::string m_id;
@@ -84,59 +59,6 @@ private:
SourceGroupStatusType m_status;
std::string m_standard;
std::vector<FilePath> m_sourcePaths;
std::vector<std::wstring> m_excludeFilters;
std::vector<std::wstring> 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
+10 -33
View File
@@ -1,7 +1,8 @@
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/ProjectSettings.h"
#include "utility/ConfigManager.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
SourceGroupSettingsCxx::SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
: SourceGroupSettings(id, type, projectSettings)
@@ -11,19 +12,15 @@ SourceGroupSettingsCxx::SourceGroupSettingsCxx(const std::string& id, SourceGrou
{
}
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::wstring>(key + "/compiler_flags/compiler_flag", std::vector<std::wstring>(), config));
setHeaderSearchPaths(config->getValuesOrDefaults(key + "/header_search_paths/header_search_path", std::vector<FilePath>()));
setFrameworkSearchPaths(config->getValuesOrDefaults(key + "/framework_search_paths/framework_search_path", std::vector<FilePath>()));
setCompilerFlags(config->getValuesOrDefaults(key + "/compiler_flags/compiler_flag", std::vector<std::wstring>()));
}
void SourceGroupSettingsCxx::save(std::shared_ptr<ConfigManager> config)
@@ -32,9 +29,9 @@ void SourceGroupSettingsCxx::save(std::shared_ptr<ConfigManager> 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);
config->setValues(key + "/header_search_paths/header_search_path", getHeaderSearchPaths());
config->setValues(key + "/framework_search_paths/framework_search_path", getFrameworkSearchPaths());
config->setValues(key + "/compiler_flags/compiler_flag", getCompilerFlags());
}
bool SourceGroupSettingsCxx::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -58,6 +55,7 @@ std::vector<std::string> SourceGroupSettingsCxx::getAvailableLanguageStandards()
{
case SOURCE_GROUP_CPP_EMPTY:
case SOURCE_GROUP_CXX_CDB:
case SOURCE_GROUP_CXX_SONARGRAPH:
standards.push_back("c++2a");
standards.push_back("gnu++2a");
@@ -143,33 +141,12 @@ void SourceGroupSettingsCxx::setCompilerFlags(const std::vector<std::wstring>& c
m_compilerFlags = compilerFlags;
}
std::vector<std::wstring> SourceGroupSettingsCxx::getDefaultSourceExtensions() const
{
std::vector<std::wstring> defaultValues;
switch (getType())
{
case SOURCE_GROUP_CPP_EMPTY:
defaultValues.push_back(L".cpp");
defaultValues.push_back(L".cxx");
defaultValues.push_back(L".cc");
break;
case SOURCE_GROUP_C_EMPTY:
defaultValues.push_back(L".c");
break;
case SOURCE_GROUP_CXX_CDB:
default:
break;
}
return defaultValues;
}
std::string SourceGroupSettingsCxx::getDefaultStandard() const
{
switch (getType())
{
case SOURCE_GROUP_CPP_EMPTY:
case SOURCE_GROUP_CXX_SONARGRAPH:
return "c++17";
case SOURCE_GROUP_C_EMPTY:
return "c11";
+5 -7
View File
@@ -8,14 +8,13 @@ class SourceGroupSettingsCxx
{
public:
SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsCxx();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
virtual std::vector<std::string> getAvailableLanguageStandards() const override;
std::vector<std::string> getAvailableLanguageStandards() const override;
std::vector<FilePath> getHeaderSearchPaths() const;
std::vector<FilePath> getHeaderSearchPathsExpandedAndAbsolute() const;
@@ -29,8 +28,7 @@ public:
void setCompilerFlags(const std::vector<std::wstring>& compilerFlags);
private:
virtual std::vector<std::wstring> getDefaultSourceExtensions() const override;
virtual std::string getDefaultStandard() const override;
std::string getDefaultStandard() const override;
std::vector<FilePath> m_headerSearchPaths;
std::vector<FilePath> m_frameworkSearchPaths;
+15 -25
View File
@@ -1,7 +1,7 @@
#include "settings/SourceGroupSettingsCxxCdb.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
#include "settings/ProjectSettings.h"
#include "utility/ConfigManager.h"
SourceGroupSettingsCxxCdb::SourceGroupSettingsCxxCdb(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsCxx(id, SOURCE_GROUP_CXX_CDB, projectSettings)
@@ -9,18 +9,16 @@ SourceGroupSettingsCxxCdb::SourceGroupSettingsCxxCdb(const std::string& id, cons
{
}
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::wstring>(key + "/build_file_path/compilation_db_path", L"", config)));
setIndexedHeaderPaths(getPathValues(key + "/indexed_header_paths/indexed_header_path", config));
SourceGroupSettingsWithExcludeFilters::load(config, key);
SourceGroupSettingsWithIndexedHeaderPaths::load(config, key);
setCompilationDatabasePath(config->getValueOrDefault(key + "/build_file_path/compilation_db_path", FilePath(L"")));
}
void SourceGroupSettingsCxxCdb::save(std::shared_ptr<ConfigManager> config)
@@ -29,8 +27,10 @@ void SourceGroupSettingsCxxCdb::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setValue(key + "/build_file_path/compilation_db_path", getCompilationDatabasePath().wstr(), config);
setPathValues(key + "/indexed_header_paths/indexed_header_path", getIndexedHeaderPaths(), config);
SourceGroupSettingsWithExcludeFilters::save(config, key);
SourceGroupSettingsWithIndexedHeaderPaths::save(config, key);
config->setValue(key + "/build_file_path/compilation_db_path", getCompilationDatabasePath().wstr());
}
bool SourceGroupSettingsCxxCdb::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -40,8 +40,9 @@ bool SourceGroupSettingsCxxCdb::equals(std::shared_ptr<SourceGroupSettings> othe
return (
otherCxxCdb &&
SourceGroupSettingsCxx::equals(other) &&
m_compilationDatabasePath == otherCxxCdb->m_compilationDatabasePath &&
utility::isPermutation(m_indexedHeaderPaths, otherCxxCdb->m_indexedHeaderPaths)
SourceGroupSettingsWithExcludeFilters::equals(otherCxxCdb) &&
SourceGroupSettingsWithIndexedHeaderPaths::equals(otherCxxCdb) &&
m_compilationDatabasePath == otherCxxCdb->m_compilationDatabasePath
);
}
@@ -60,18 +61,7 @@ void SourceGroupSettingsCxxCdb::setCompilationDatabasePath(const FilePath& compi
m_compilationDatabasePath = compilationDatabasePath;
}
std::vector<FilePath> SourceGroupSettingsCxxCdb::getIndexedHeaderPaths() const
const ProjectSettings* SourceGroupSettingsCxxCdb::getProjectSettings() const
{
return m_indexedHeaderPaths;
return m_projectSettings;
}
std::vector<FilePath> SourceGroupSettingsCxxCdb::getIndexedHeaderPathsExpandedAndAbsolute() const
{
return m_projectSettings->makePathsExpandedAndAbsolute(getIndexedHeaderPaths());
}
void SourceGroupSettingsCxxCdb::setIndexedHeaderPaths(const std::vector<FilePath>& indexedHeaderPaths)
{
m_indexedHeaderPaths = indexedHeaderPaths;
}
+10 -9
View File
@@ -2,30 +2,31 @@
#define SOURCE_GROUP_SETTINGS_CXX_CDB_H
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/SourceGroupSettingsWithExcludeFilters.h"
#include "settings/SourceGroupSettingsWithIndexedHeaderPaths.h"
#include "utility/file/FilePath.h"
class SourceGroupSettingsCxxCdb
: public SourceGroupSettingsCxx
, public SourceGroupSettingsWithExcludeFilters
, public SourceGroupSettingsWithIndexedHeaderPaths
{
public:
SourceGroupSettingsCxxCdb(const std::string& id, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsCxxCdb();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
FilePath getCompilationDatabasePath() const;
FilePath getCompilationDatabasePathExpandedAndAbsolute() const;
void setCompilationDatabasePath(const FilePath& compilationDatabasePath);
std::vector<FilePath> getIndexedHeaderPaths() const;
std::vector<FilePath> getIndexedHeaderPathsExpandedAndAbsolute() const;
void setIndexedHeaderPaths(const std::vector<FilePath>& indexedHeaderPaths);
private:
const ProjectSettings* getProjectSettings() const override;
FilePath m_compilationDatabasePath;
std::vector<FilePath> m_indexedHeaderPaths;
};
#endif // SOURCE_GROUP_SETTINGS_CXX_CDB_H
@@ -1,5 +1,6 @@
#include "settings/SourceGroupSettingsCxxEmpty.h"
#include "utility/ConfigManager.h"
#include "utility/utility.h"
#include "utility/utilityApp.h"
@@ -150,21 +151,20 @@ SourceGroupSettingsCxxEmpty::SourceGroupSettingsCxxEmpty(const std::string& id,
{
}
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::wstring>(key + "/cross_compilation/target/arch", L"", config));
setTargetVendor(getValue<std::wstring>(key + "/cross_compilation/target/vendor", L"", config));
setTargetSys(getValue<std::wstring>(key + "/cross_compilation/target/sys", L"", config));
setTargetAbi(getValue<std::wstring>(key + "/cross_compilation/target/abi", L"", config));
SourceGroupSettingsWithSourcePaths::load(config, key);
SourceGroupSettingsWithExcludeFilters::load(config, key);
setTargetOptionsEnabled(config->getValueOrDefault<bool>(key + "/cross_compilation/target_options_enabled", false));
setTargetArch(config->getValueOrDefault<std::wstring>(key + "/cross_compilation/target/arch", L""));
setTargetVendor(config->getValueOrDefault<std::wstring>(key + "/cross_compilation/target/vendor", L""));
setTargetSys(config->getValueOrDefault<std::wstring>(key + "/cross_compilation/target/sys", L""));
setTargetAbi(config->getValueOrDefault<std::wstring>(key + "/cross_compilation/target/abi", L""));
}
void SourceGroupSettingsCxxEmpty::save(std::shared_ptr<ConfigManager> config)
@@ -173,11 +173,14 @@ void SourceGroupSettingsCxxEmpty::save(std::shared_ptr<ConfigManager> 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);
SourceGroupSettingsWithSourcePaths::save(config, key);
SourceGroupSettingsWithExcludeFilters::save(config, key);
config->setValue(key + "/cross_compilation/target_options_enabled", getTargetOptionsEnabled());
config->setValue(key + "/cross_compilation/target/arch", getTargetArch());
config->setValue(key + "/cross_compilation/target/vendor", getTargetVendor());
config->setValue(key + "/cross_compilation/target/sys", getTargetSys());
config->setValue(key + "/cross_compilation/target/abi", getTargetAbi());
}
bool SourceGroupSettingsCxxEmpty::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -187,6 +190,8 @@ bool SourceGroupSettingsCxxEmpty::equals(std::shared_ptr<SourceGroupSettings> ot
return (
otherCxxEmpty &&
SourceGroupSettingsCxx::equals(other) &&
SourceGroupSettingsWithSourcePaths::equals(otherCxxEmpty) &&
SourceGroupSettingsWithExcludeFilters::equals(otherCxxEmpty) &&
getTargetFlag() == otherCxxEmpty->getTargetFlag()
);
}
@@ -254,3 +259,29 @@ std::wstring SourceGroupSettingsCxxEmpty::getTargetFlag() const
}
return targetFlag;
}
const ProjectSettings* SourceGroupSettingsCxxEmpty::getProjectSettings() const
{
return m_projectSettings;
}
std::vector<std::wstring> SourceGroupSettingsCxxEmpty::getDefaultSourceExtensions() const
{
std::vector<std::wstring> defaultValues;
switch (getType())
{
case SOURCE_GROUP_CPP_EMPTY:
defaultValues.push_back(L".cpp");
defaultValues.push_back(L".cxx");
defaultValues.push_back(L".cc");
break;
case SOURCE_GROUP_C_EMPTY:
defaultValues.push_back(L".c");
break;
default:
break;
}
return defaultValues;
}
+10 -4
View File
@@ -2,9 +2,13 @@
#define SOURCE_GROUP_SETTINGS_CXX_EMPTY_H
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/SourceGroupSettingsWithExcludeFilters.h"
#include "settings/SourceGroupSettingsWithSourcePaths.h"
class SourceGroupSettingsCxxEmpty
: public SourceGroupSettingsCxx
, public SourceGroupSettingsWithExcludeFilters
, public SourceGroupSettingsWithSourcePaths
{
public:
static std::vector<std::wstring> getAvailableArchTypes();
@@ -13,12 +17,11 @@ public:
static std::vector<std::wstring> getAvailableEnvironmentTypes();
SourceGroupSettingsCxxEmpty(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsCxxEmpty();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool getTargetOptionsEnabled() const;
void setTargetOptionsEnabled(bool targetOptionsEnabled);
@@ -38,6 +41,9 @@ public:
std::wstring getTargetFlag() const;
private:
const ProjectSettings* getProjectSettings() const override;
std::vector<std::wstring> getDefaultSourceExtensions() const override;
bool m_targetOptionsEnabled;
std::wstring m_targetArch;
std::wstring m_targetVendor;
@@ -0,0 +1,43 @@
#include "settings/SourceGroupSettingsCxxSonargraph.h"
SourceGroupSettingsCxxSonargraph::SourceGroupSettingsCxxSonargraph(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsCxx(id, SOURCE_GROUP_CXX_SONARGRAPH, projectSettings)
{
}
void SourceGroupSettingsCxxSonargraph::load(std::shared_ptr<const ConfigManager> config)
{
SourceGroupSettingsCxx::load(config);
const std::string key = s_keyPrefix + getId();
SourceGroupSettingsWithIndexedHeaderPaths::load(config, key);
SourceGroupSettingsWithSonargraphProjectPath::load(config, key);
}
void SourceGroupSettingsCxxSonargraph::save(std::shared_ptr<ConfigManager> config)
{
SourceGroupSettingsCxx::save(config);
const std::string key = s_keyPrefix + getId();
SourceGroupSettingsWithIndexedHeaderPaths::save(config, key);
SourceGroupSettingsWithSonargraphProjectPath::save(config, key);
}
bool SourceGroupSettingsCxxSonargraph::equals(std::shared_ptr<SourceGroupSettings> other) const
{
std::shared_ptr<SourceGroupSettingsCxxSonargraph> otherCxxSonargraph = std::dynamic_pointer_cast<SourceGroupSettingsCxxSonargraph>(other);
return (
otherCxxSonargraph &&
SourceGroupSettingsCxx::equals(other) &&
SourceGroupSettingsWithIndexedHeaderPaths::equals(otherCxxSonargraph) &&
SourceGroupSettingsWithSonargraphProjectPath::equals(otherCxxSonargraph)
);
}
const ProjectSettings* SourceGroupSettingsCxxSonargraph::getProjectSettings() const
{
return m_projectSettings;
}
@@ -0,0 +1,25 @@
#ifndef SOURCE_GROUP_SETTINGS_CXX_SONARGRAPH_H
#define SOURCE_GROUP_SETTINGS_CXX_SONARGRAPH_H
#include "settings/SourceGroupSettingsCxx.h"
#include "settings/SourceGroupSettingsWithIndexedHeaderPaths.h"
#include "settings/SourceGroupSettingsWithSonargraphProjectPath.h"
class SourceGroupSettingsCxxSonargraph
: public SourceGroupSettingsCxx
, public SourceGroupSettingsWithIndexedHeaderPaths
, public SourceGroupSettingsWithSonargraphProjectPath
{
public:
SourceGroupSettingsCxxSonargraph(const std::string& id, const ProjectSettings* projectSettings);
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
private:
const ProjectSettings* getProjectSettings() const override;
};
#endif // SOURCE_GROUP_SETTINGS_CXX_SONARGRAPH_H
+11 -35
View File
@@ -1,15 +1,7 @@
#include "settings/SourceGroupSettingsJava.h"
#include "utility/utility.h"
SourceGroupSettingsJava::SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings)
: SourceGroupSettings(id, type, projectSettings)
, m_useJreSystemLibrary(true)
, m_classpath(std::vector<FilePath>())
{
}
SourceGroupSettingsJava::~SourceGroupSettingsJava()
{
}
@@ -19,8 +11,9 @@ void SourceGroupSettingsJava::load(std::shared_ptr<const ConfigManager> 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));
SourceGroupSettingsWithSourcePaths::load(config, key);
SourceGroupSettingsWithExcludeFilters::load(config, key);
SourceGroupSettingsWithClasspath::load(config, key);
}
void SourceGroupSettingsJava::save(std::shared_ptr<ConfigManager> config)
@@ -29,8 +22,9 @@ void SourceGroupSettingsJava::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setPathValues(key + "/class_paths/class_path", getClasspath(), config);
setValue(key + "/use_jre_system_library", getUseJreSystemLibrary(), config);
SourceGroupSettingsWithSourcePaths::save(config, key);
SourceGroupSettingsWithExcludeFilters::save(config, key);
SourceGroupSettingsWithClasspath::save(config, key);
}
bool SourceGroupSettingsJava::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -40,8 +34,9 @@ bool SourceGroupSettingsJava::equals(std::shared_ptr<SourceGroupSettings> other)
return (
otherJava &&
SourceGroupSettings::equals(other) &&
m_useJreSystemLibrary == otherJava->m_useJreSystemLibrary &&
utility::isPermutation(m_classpath, otherJava->m_classpath)
SourceGroupSettingsWithSourcePaths::equals(otherJava) &&
SourceGroupSettingsWithExcludeFilters::equals(otherJava) &&
SourceGroupSettingsWithClasspath::equals(otherJava)
);
}
@@ -50,30 +45,11 @@ std::vector<std::string> SourceGroupSettingsJava::getAvailableLanguageStandards(
return std::vector<std::string>{"1", "2", "3", "4", "5", "6", "7", "8"};
}
bool SourceGroupSettingsJava::getUseJreSystemLibrary() const
const ProjectSettings* SourceGroupSettingsJava::getProjectSettings() const
{
return m_useJreSystemLibrary;
return m_projectSettings;
}
void SourceGroupSettingsJava::setUseJreSystemLibrary(bool useJreSystemLibrary)
{
m_useJreSystemLibrary = useJreSystemLibrary;
}
std::vector<FilePath> SourceGroupSettingsJava::getClasspath() const
{
return m_classpath;
}
std::vector<FilePath> SourceGroupSettingsJava::getClasspathExpandedAndAbsolute() const
{
return m_projectSettings->makePathsExpandedAndAbsolute(getClasspath());
}
void SourceGroupSettingsJava::setClasspath(const std::vector<FilePath>& classpath)
{
m_classpath = classpath;
}
std::vector<std::wstring> SourceGroupSettingsJava::getDefaultSourceExtensions() const
{
return { L".java" };
+13 -17
View File
@@ -5,34 +5,30 @@
#include <vector>
#include "settings/SourceGroupSettings.h"
#include "settings/SourceGroupSettingsWithClasspath.h"
#include "settings/SourceGroupSettingsWithExcludeFilters.h"
#include "settings/SourceGroupSettingsWithSourcePaths.h"
class SourceGroupSettingsJava
: public SourceGroupSettings
, public SourceGroupSettingsWithSourcePaths
, public SourceGroupSettingsWithExcludeFilters
, public SourceGroupSettingsWithClasspath
{
public:
SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsJava();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
virtual std::vector<std::string> getAvailableLanguageStandards() const override;
bool getUseJreSystemLibrary() const;
void setUseJreSystemLibrary(bool useJreSystemLibrary);
std::vector<FilePath> getClasspath() const;
std::vector<FilePath> getClasspathExpandedAndAbsolute() const;
void setClasspath(const std::vector<FilePath>& classpath);
std::vector<std::string> getAvailableLanguageStandards() const override;
private:
virtual std::vector<std::wstring> getDefaultSourceExtensions() const override;
virtual std::string getDefaultStandard() const override;
bool m_useJreSystemLibrary;
std::vector<FilePath> m_classpath;
const ProjectSettings* getProjectSettings() const override;
std::vector<std::wstring> getDefaultSourceExtensions() const override;
std::string getDefaultStandard() const override;
};
#endif // SOURCE_GROUP_SETTINGS_JAVA_H
@@ -4,7 +4,3 @@ SourceGroupSettingsJavaEmpty::SourceGroupSettingsJavaEmpty(const std::string& id
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_EMPTY, projectSettings)
{
}
SourceGroupSettingsJavaEmpty::~SourceGroupSettingsJavaEmpty()
{
}
@@ -8,7 +8,6 @@ class SourceGroupSettingsJavaEmpty
{
public:
SourceGroupSettingsJavaEmpty(const std::string& id, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsJavaEmpty();
};
#endif // SOURCE_GROUP_SETTINGS_JAVA_EMPTY_H
@@ -1,5 +1,8 @@
#include "settings/SourceGroupSettingsJavaGradle.h"
#include "settings/ProjectSettings.h"
#include "utility/ConfigManager.h"
SourceGroupSettingsJavaGradle::SourceGroupSettingsJavaGradle(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_GRADLE, projectSettings)
, m_gradleProjectFilePath(FilePath())
@@ -8,19 +11,15 @@ SourceGroupSettingsJavaGradle::SourceGroupSettingsJavaGradle(const std::string&
{
}
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::wstring>(key + "/gradle/project_file_path", L"", config)));
setGradleDependenciesDirectory(FilePath(getValue<std::wstring>(key + "/gradle/dependencies_directory", L"", config)));
setShouldIndexGradleTests(getValue<bool>(key + "/gradle/should_index_tests", false, config));
setGradleProjectFilePath(config->getValueOrDefault(key + "/gradle/project_file_path", FilePath(L"")));
setGradleDependenciesDirectory(config->getValueOrDefault(key + "/gradle/dependencies_directory", FilePath(L"")));
setShouldIndexGradleTests(config->getValueOrDefault(key + "/gradle/should_index_tests", false));
}
void SourceGroupSettingsJavaGradle::save(std::shared_ptr<ConfigManager> config)
@@ -29,9 +28,9 @@ void SourceGroupSettingsJavaGradle::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setValue(key + "/gradle/project_file_path", getGradleProjectFilePath().wstr(), config);
setValue(key + "/gradle/dependencies_directory", getGradleDependenciesDirectory().wstr(), config);
setValue(key + "/gradle/should_index_tests", getShouldIndexGradleTests(), config);
config->setValue(key + "/gradle/project_file_path", getGradleProjectFilePath().wstr());
config->setValue(key + "/gradle/dependencies_directory", getGradleDependenciesDirectory().wstr());
config->setValue(key + "/gradle/should_index_tests", getShouldIndexGradleTests());
}
bool SourceGroupSettingsJavaGradle::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -8,12 +8,11 @@ class SourceGroupSettingsJavaGradle
{
public:
SourceGroupSettingsJavaGradle(const std::string& id, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsJavaGradle();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
FilePath getGradleProjectFilePath() const;
FilePath getGradleProjectFilePathExpandedAndAbsolute() const;
@@ -1,5 +1,8 @@
#include "settings/SourceGroupSettingsJavaMaven.h"
#include "settings/ProjectSettings.h"
#include "utility/ConfigManager.h"
SourceGroupSettingsJavaMaven::SourceGroupSettingsJavaMaven(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_MAVEN, projectSettings)
, m_mavenProjectFilePath(FilePath())
@@ -8,19 +11,15 @@ SourceGroupSettingsJavaMaven::SourceGroupSettingsJavaMaven(const std::string& id
{
}
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::wstring>(key + "/maven/project_file_path", L"", config)));
setMavenDependenciesDirectory(FilePath(getValue<std::wstring>(key + "/maven/dependencies_directory", L"", config)));
setShouldIndexMavenTests(getValue<bool>(key + "/maven/should_index_tests", false, config));
setMavenProjectFilePath(config->getValueOrDefault(key + "/maven/project_file_path", FilePath(L"")));
setMavenDependenciesDirectory(config->getValueOrDefault(key + "/maven/dependencies_directory", FilePath(L"")));
setShouldIndexMavenTests(config->getValueOrDefault(key + "/maven/should_index_tests", false));
}
void SourceGroupSettingsJavaMaven::save(std::shared_ptr<ConfigManager> config)
@@ -29,9 +28,9 @@ void SourceGroupSettingsJavaMaven::save(std::shared_ptr<ConfigManager> config)
const std::string key = s_keyPrefix + getId();
setValue(key + "/maven/project_file_path", getMavenProjectFilePath().wstr(), config);
setValue(key + "/maven/dependencies_directory", getMavenDependenciesDirectory().wstr(), config);
setValue(key + "/maven/should_index_tests", getShouldIndexMavenTests(), config);
config->setValue(key + "/maven/project_file_path", getMavenProjectFilePath().wstr());
config->setValue(key + "/maven/dependencies_directory", getMavenDependenciesDirectory().wstr());
config->setValue(key + "/maven/should_index_tests", getShouldIndexMavenTests());
}
bool SourceGroupSettingsJavaMaven::equals(std::shared_ptr<SourceGroupSettings> other) const
@@ -8,12 +8,11 @@ class SourceGroupSettingsJavaMaven
{
public:
SourceGroupSettingsJavaMaven(const std::string& id, const ProjectSettings* projectSettings);
virtual ~SourceGroupSettingsJavaMaven();
virtual void load(std::shared_ptr<const ConfigManager> config) override;
virtual void save(std::shared_ptr<ConfigManager> config) override;
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
virtual bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
FilePath getMavenProjectFilePath() const;
FilePath getMavenProjectFilePathExpandedAndAbsolute() const;
@@ -0,0 +1,53 @@
#include "settings/SourceGroupSettingsJavaSonargraph.h"
SourceGroupSettingsJavaSonargraph::SourceGroupSettingsJavaSonargraph(const std::string& id, const ProjectSettings* projectSettings)
: SourceGroupSettings(id, SOURCE_GROUP_JAVA_SONARGRAPH, projectSettings)
{
}
void SourceGroupSettingsJavaSonargraph::load(std::shared_ptr<const ConfigManager> config)
{
SourceGroupSettings::load(config);
const std::string key = s_keyPrefix + getId();
SourceGroupSettingsWithClasspath::load(config, key);
SourceGroupSettingsWithSonargraphProjectPath::load(config, key);
}
void SourceGroupSettingsJavaSonargraph::save(std::shared_ptr<ConfigManager> config)
{
SourceGroupSettings::save(config);
const std::string key = s_keyPrefix + getId();
SourceGroupSettingsWithClasspath::save(config, key);
SourceGroupSettingsWithSonargraphProjectPath::save(config, key);
}
bool SourceGroupSettingsJavaSonargraph::equals(std::shared_ptr<SourceGroupSettings> other) const
{
std::shared_ptr<SourceGroupSettingsJavaSonargraph> otherJavaSonargraph = std::dynamic_pointer_cast<SourceGroupSettingsJavaSonargraph>(other);
return (
otherJavaSonargraph &&
SourceGroupSettings::equals(other) &&
SourceGroupSettingsWithClasspath::equals(otherJavaSonargraph) &&
SourceGroupSettingsWithSonargraphProjectPath::equals(otherJavaSonargraph)
);
}
std::vector<std::string> SourceGroupSettingsJavaSonargraph::getAvailableLanguageStandards() const
{
return std::vector<std::string>{"1", "2", "3", "4", "5", "6", "7", "8"};
}
std::string SourceGroupSettingsJavaSonargraph::getDefaultStandard() const
{
return "8";
}
const ProjectSettings* SourceGroupSettingsJavaSonargraph::getProjectSettings() const
{
return m_projectSettings;
}
@@ -0,0 +1,28 @@
#ifndef SOURCE_GROUP_SETTINGS_JAVA_SONARGRAPH_H
#define SOURCE_GROUP_SETTINGS_JAVA_SONARGRAPH_H
#include "settings/SourceGroupSettings.h"
#include "settings/SourceGroupSettingsWithClasspath.h"
#include "settings/SourceGroupSettingsWithSonargraphProjectPath.h"
class SourceGroupSettingsJavaSonargraph
: public SourceGroupSettings
, public SourceGroupSettingsWithClasspath
, public SourceGroupSettingsWithSonargraphProjectPath
{
public:
SourceGroupSettingsJavaSonargraph(const std::string& id, const ProjectSettings* projectSettings);
void load(std::shared_ptr<const ConfigManager> config) override;
void save(std::shared_ptr<ConfigManager> config) override;
bool equals(std::shared_ptr<SourceGroupSettings> other) const override;
std::vector<std::string> getAvailableLanguageStandards() const override;
private:
std::string getDefaultStandard() const override;
const ProjectSettings* getProjectSettings() const override;
};
#endif // SOURCE_GROUP_SETTINGS_JAVA_SONARGRAPH_H
@@ -0,0 +1,55 @@
#include "settings/SourceGroupSettingsWithClasspath.h"
#include "settings/ProjectSettings.h"
#include "utility/utility.h"
SourceGroupSettingsWithClasspath::SourceGroupSettingsWithClasspath()
: m_classpath(std::vector<FilePath>())
, m_useJreSystemLibrary(true)
{
}
bool SourceGroupSettingsWithClasspath::equals(std::shared_ptr<SourceGroupSettingsWithClasspath> other) const
{
return (
(m_useJreSystemLibrary == other->m_useJreSystemLibrary) &&
utility::isPermutation(m_classpath, other->m_classpath)
);
}
void SourceGroupSettingsWithClasspath::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setClasspath(config->getValuesOrDefaults(key + "/class_paths/class_path", std::vector<FilePath>()));
setUseJreSystemLibrary(config->getValueOrDefault(key + "/use_jre_system_library", true));
}
void SourceGroupSettingsWithClasspath::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValues(key + "/class_paths/class_path", getClasspath());
config->setValue(key + "/use_jre_system_library", getUseJreSystemLibrary());
}
std::vector<FilePath> SourceGroupSettingsWithClasspath::getClasspath() const
{
return m_classpath;
}
std::vector<FilePath> SourceGroupSettingsWithClasspath::getClasspathExpandedAndAbsolute() const
{
return getProjectSettings()->makePathsExpandedAndAbsolute(getClasspath());
}
void SourceGroupSettingsWithClasspath::setClasspath(const std::vector<FilePath>& classpath)
{
m_classpath = classpath;
}
bool SourceGroupSettingsWithClasspath::getUseJreSystemLibrary() const
{
return m_useJreSystemLibrary;
}
void SourceGroupSettingsWithClasspath::setUseJreSystemLibrary(bool useJreSystemLibrary)
{
m_useJreSystemLibrary = useJreSystemLibrary;
}
@@ -0,0 +1,39 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_CLASSPATH_H
#define SOURCE_GROUP_SETTINGS_WITH_CLASSPATH_H
#include <memory>
#include <string>
#include <vector>
#include "utility/file/FilePath.h"
class ConfigManager;
class ProjectSettings;
class SourceGroupSettingsWithClasspath
{
public:
SourceGroupSettingsWithClasspath();
virtual ~SourceGroupSettingsWithClasspath() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithClasspath> other) const;
std::vector<FilePath> getClasspath() const;
std::vector<FilePath> getClasspathExpandedAndAbsolute() const;
void setClasspath(const std::vector<FilePath>& classpath);
bool getUseJreSystemLibrary() const;
void setUseJreSystemLibrary(bool useJreSystemLibrary);
protected:
void load(std::shared_ptr<const ConfigManager> config, const std::string& key);
void save(std::shared_ptr<ConfigManager> config, const std::string& key);
private:
virtual const ProjectSettings* getProjectSettings() const = 0;
std::vector<FilePath> m_classpath;
bool m_useJreSystemLibrary;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_CLASSPATH_H
@@ -0,0 +1,103 @@
#include "settings/SourceGroupSettingsWithExcludeFilters.h"
#include "settings/ProjectSettings.h"
#include "utility/file/FilePathFilter.h"
#include "utility/file/FileSystem.h"
#include "utility/utility.h"
SourceGroupSettingsWithExcludeFilters::SourceGroupSettingsWithExcludeFilters()
: m_excludeFilters(std::vector<std::wstring>())
{
}
bool SourceGroupSettingsWithExcludeFilters::equals(std::shared_ptr<SourceGroupSettingsWithExcludeFilters> other) const
{
return (
utility::isPermutation(m_excludeFilters, other->m_excludeFilters)
);
}
void SourceGroupSettingsWithExcludeFilters::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setExcludeFilterStrings(config->getValuesOrDefaults(key + "/exclude_filters/exclude_filter", std::vector<std::wstring>()));
}
void SourceGroupSettingsWithExcludeFilters::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValues(key + "/exclude_filters/exclude_filter", getExcludeFilterStrings());
}
std::vector<std::wstring> SourceGroupSettingsWithExcludeFilters::getExcludeFilterStrings() const
{
return m_excludeFilters;
}
std::vector<FilePathFilter> SourceGroupSettingsWithExcludeFilters::getExcludeFiltersExpandedAndAbsolute() const
{
return getFiltersExpandedAndAbsolute(getExcludeFilterStrings());
}
void SourceGroupSettingsWithExcludeFilters::setExcludeFilterStrings(const std::vector<std::wstring>& excludeFilters)
{
m_excludeFilters = excludeFilters;
}
std::vector<FilePathFilter> SourceGroupSettingsWithExcludeFilters::getFiltersExpandedAndAbsolute(const std::vector<std::wstring>& filterStrings) const
{
std::vector<FilePathFilter> result;
for (const std::wstring& filterString : filterStrings)
{
if (!filterString.empty())
{
const size_t wildcardPos = filterString.find(L"*");
if (wildcardPos != filterString.npos)
{
std::wsmatch match;
if (std::regex_search(filterString, match, std::wregex(L"[\\\\/]")) && !match.empty() &&
match.position(0) < int(wildcardPos))
{
const FilePath p = getProjectSettings()->makePathExpandedAndAbsolute(FilePath(match.prefix().str()));
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>(
utility::toVector(symLinkPaths),
[match](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + L"/" + match.suffix().str());
}
)
);
}
else
{
result.push_back(FilePathFilter(filterString));
}
}
else
{
const FilePath p = getProjectSettings()->makePathExpandedAndAbsolute(FilePath(filterString));
const bool isFile = p.exists() && !p.isDirectory();
std::set<FilePath> symLinkPaths = FileSystem::getSymLinkedDirectories(p);
symLinkPaths.insert(p);
utility::append(result,
utility::convert<FilePath, FilePathFilter>
(
utility::toVector(symLinkPaths),
[isFile](const FilePath& filePath)
{
return FilePathFilter(filePath.wstr() + (isFile ? L"" : L"**"));
}
)
);
}
}
}
return result;
}
@@ -0,0 +1,35 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_EXCLUDE_FILTERS_H
#define SOURCE_GROUP_SETTINGS_WITH_EXCLUDE_FILTERS_H
#include <memory>
#include <string>
#include <vector>
class ConfigManager;
class FilePathFilter;
class ProjectSettings;
class SourceGroupSettingsWithExcludeFilters
{
public:
SourceGroupSettingsWithExcludeFilters();
virtual ~SourceGroupSettingsWithExcludeFilters() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithExcludeFilters> other) const;
std::vector<std::wstring> getExcludeFilterStrings() const;
std::vector<FilePathFilter> getExcludeFiltersExpandedAndAbsolute() const;
void setExcludeFilterStrings(const std::vector<std::wstring>& excludeFilters);
protected:
void load(std::shared_ptr<const ConfigManager> config, const std::string& key);
void save(std::shared_ptr<ConfigManager> config, const std::string& key);
private:
virtual const ProjectSettings* getProjectSettings() const = 0;
std::vector<FilePathFilter> getFiltersExpandedAndAbsolute(const std::vector<std::wstring>& filterStrings) const;
std::vector<std::wstring> m_excludeFilters;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_EXCLUDE_FILTERS_H
@@ -0,0 +1,41 @@
#include "settings/SourceGroupSettingsWithIndexedHeaderPaths.h"
#include "settings/ProjectSettings.h"
#include "utility/utility.h"
SourceGroupSettingsWithIndexedHeaderPaths::SourceGroupSettingsWithIndexedHeaderPaths()
: m_indexedHeaderPaths(std::vector<FilePath>())
{
}
bool SourceGroupSettingsWithIndexedHeaderPaths::equals(std::shared_ptr<SourceGroupSettingsWithIndexedHeaderPaths> other) const
{
return (
utility::isPermutation(m_indexedHeaderPaths, other->m_indexedHeaderPaths)
);
}
void SourceGroupSettingsWithIndexedHeaderPaths::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setIndexedHeaderPaths(config->getValuesOrDefaults(key + "/indexed_header_paths/indexed_header_path", std::vector<FilePath>()));
}
void SourceGroupSettingsWithIndexedHeaderPaths::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValues(key + "/indexed_header_paths/indexed_header_path", getIndexedHeaderPaths());
}
std::vector<FilePath> SourceGroupSettingsWithIndexedHeaderPaths::getIndexedHeaderPaths() const
{
return m_indexedHeaderPaths;
}
std::vector<FilePath> SourceGroupSettingsWithIndexedHeaderPaths::getIndexedHeaderPathsExpandedAndAbsolute() const
{
return getProjectSettings()->makePathsExpandedAndAbsolute(getIndexedHeaderPaths());
}
void SourceGroupSettingsWithIndexedHeaderPaths::setIndexedHeaderPaths(const std::vector<FilePath>& indexedHeaderPaths)
{
m_indexedHeaderPaths = indexedHeaderPaths;
}
@@ -0,0 +1,34 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_INDEXED_HEADER_PATHS_H
#define SOURCE_GROUP_SETTINGS_WITH_INDEXED_HEADER_PATHS_H
#include <memory>
#include <string>
#include <vector>
class ConfigManager;
class FilePath;
class ProjectSettings;
class SourceGroupSettingsWithIndexedHeaderPaths
{
public:
SourceGroupSettingsWithIndexedHeaderPaths();
virtual ~SourceGroupSettingsWithIndexedHeaderPaths() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithIndexedHeaderPaths> other) const;
std::vector<FilePath> getIndexedHeaderPaths() const;
std::vector<FilePath> getIndexedHeaderPathsExpandedAndAbsolute() const;
void setIndexedHeaderPaths(const std::vector<FilePath>& indexedHeaderPaths);
protected:
void load(std::shared_ptr<const ConfigManager> config, const std::string& key);
void save(std::shared_ptr<ConfigManager> config, const std::string& key);
private:
virtual const ProjectSettings* getProjectSettings() const = 0;
std::vector<FilePath> m_indexedHeaderPaths;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_INDEXED_HEADER_PATHS_H
@@ -0,0 +1,40 @@
#include "settings/SourceGroupSettingsWithSonargraphProjectPath.h"
#include "settings/ProjectSettings.h"
SourceGroupSettingsWithSonargraphProjectPath::SourceGroupSettingsWithSonargraphProjectPath()
{
}
bool SourceGroupSettingsWithSonargraphProjectPath::equals(std::shared_ptr<SourceGroupSettingsWithSonargraphProjectPath> other) const
{
return (
other &&
m_sonargraphProjectPath == other->m_sonargraphProjectPath
);
}
void SourceGroupSettingsWithSonargraphProjectPath::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setSonargraphProjectPath(config->getValueOrDefault(key + "/sonargraph_project_path", FilePath(L"")));
}
void SourceGroupSettingsWithSonargraphProjectPath::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValue(key + "/sonargraph_project_path", getSonargraphProjectPath().wstr());
}
FilePath SourceGroupSettingsWithSonargraphProjectPath::getSonargraphProjectPath() const
{
return m_sonargraphProjectPath;
}
FilePath SourceGroupSettingsWithSonargraphProjectPath::getSonargraphProjectPathExpandedAndAbsolute() const
{
return getProjectSettings()->makePathExpandedAndAbsolute(getSonargraphProjectPath());
}
void SourceGroupSettingsWithSonargraphProjectPath::setSonargraphProjectPath(const FilePath& sonargraphProjectPath)
{
m_sonargraphProjectPath = sonargraphProjectPath;
}
@@ -0,0 +1,34 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_SONARGRAPH_PROJECT_PATH_H
#define SOURCE_GROUP_SETTINGS_WITH_SONARGRAPH_PROJECT_PATH_H
#include <memory>
#include <string>
#include "utility/file/FilePath.h"
class ConfigManager;
class ProjectSettings;
class SourceGroupSettingsWithSonargraphProjectPath
{
public:
SourceGroupSettingsWithSonargraphProjectPath();
virtual ~SourceGroupSettingsWithSonargraphProjectPath() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithSonargraphProjectPath> other) const;
FilePath getSonargraphProjectPath() const;
FilePath getSonargraphProjectPathExpandedAndAbsolute() const;
void setSonargraphProjectPath(const FilePath& sonargraphProjectPath);
protected:
void load(std::shared_ptr<const ConfigManager> config, const std::string& key);
void save(std::shared_ptr<ConfigManager> config, const std::string& key);
private:
virtual const ProjectSettings* getProjectSettings() const = 0;
FilePath m_sonargraphProjectPath;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_SONARGRAPH_PROJECT_PATH_H
@@ -0,0 +1,59 @@
#include "settings/SourceGroupSettingsWithSourcePaths.h"
#include "settings/ProjectSettings.h"
#include "utility/utility.h"
SourceGroupSettingsWithSourcePaths::SourceGroupSettingsWithSourcePaths()
: m_sourcePaths(std::vector<FilePath>())
, m_sourceExtensions(std::vector<std::wstring>())
{
}
bool SourceGroupSettingsWithSourcePaths::equals(std::shared_ptr<SourceGroupSettingsWithSourcePaths> other) const
{
return (
utility::isPermutation(m_sourcePaths, other->m_sourcePaths) &&
utility::isPermutation(m_sourceExtensions, other->m_sourceExtensions)
);
}
void SourceGroupSettingsWithSourcePaths::load(std::shared_ptr<const ConfigManager> config, const std::string& key)
{
setSourcePaths(config->getValuesOrDefaults(key + "/source_paths/source_path", std::vector<FilePath>()));
setSourceExtensions(config->getValuesOrDefaults(key + "/source_extensions/source_extension", std::vector<std::wstring>()));
}
void SourceGroupSettingsWithSourcePaths::save(std::shared_ptr<ConfigManager> config, const std::string& key)
{
config->setValues(key + "/source_paths/source_path", getSourcePaths());
config->setValues(key + "/source_extensions/source_extension", getSourceExtensions());
}
std::vector<FilePath> SourceGroupSettingsWithSourcePaths::getSourcePaths() const
{
return m_sourcePaths;
}
std::vector<FilePath> SourceGroupSettingsWithSourcePaths::getSourcePathsExpandedAndAbsolute() const
{
return getProjectSettings()->makePathsExpandedAndAbsolute(getSourcePaths());
}
void SourceGroupSettingsWithSourcePaths::setSourcePaths(const std::vector<FilePath>& sourcePaths)
{
m_sourcePaths = sourcePaths;
}
std::vector<std::wstring> SourceGroupSettingsWithSourcePaths::getSourceExtensions() const
{
if (m_sourceExtensions.empty())
{
return getDefaultSourceExtensions();
}
return m_sourceExtensions;
}
void SourceGroupSettingsWithSourcePaths::setSourceExtensions(const std::vector<std::wstring>& sourceExtensions)
{
m_sourceExtensions = sourceExtensions;
}
@@ -0,0 +1,39 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_SOURCE_PATHS_H
#define SOURCE_GROUP_SETTINGS_WITH_SOURCE_PATHS_H
#include <memory>
#include <string>
#include <vector>
class ConfigManager;
class FilePath;
class ProjectSettings;
class SourceGroupSettingsWithSourcePaths
{
public:
SourceGroupSettingsWithSourcePaths();
virtual ~SourceGroupSettingsWithSourcePaths() = default;
bool equals(std::shared_ptr<SourceGroupSettingsWithSourcePaths> other) const;
std::vector<FilePath> getSourcePaths() const;
std::vector<FilePath> getSourcePathsExpandedAndAbsolute() const;
void setSourcePaths(const std::vector<FilePath>& sourcePaths);
std::vector<std::wstring> getSourceExtensions() const;
void setSourceExtensions(const std::vector<std::wstring>& sourceExtensions);
protected:
void load(std::shared_ptr<const ConfigManager> config, const std::string& key);
void save(std::shared_ptr<ConfigManager> config, const std::string& key);
private:
virtual const ProjectSettings* getProjectSettings() const = 0;
virtual std::vector<std::wstring> getDefaultSourceExtensions() const = 0;
std::vector<FilePath> m_sourcePaths;
std::vector<std::wstring> m_sourceExtensions;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_SOURCE_PATHS_H
+17 -1
View File
@@ -10,6 +10,8 @@ std::string sourceGroupTypeToString(SourceGroupType v)
return "C++ Source Group";
case SOURCE_GROUP_CXX_CDB:
return "C/C++ from Compilation Database";
case SOURCE_GROUP_CXX_SONARGRAPH:
return "C/C++ from Sonargraph";
case SOURCE_GROUP_CXX_VS:
return "C/C++ from Visual Studio";
case SOURCE_GROUP_JAVA_EMPTY:
@@ -18,6 +20,8 @@ std::string sourceGroupTypeToString(SourceGroupType v)
return "Java Source Group from Maven";
case SOURCE_GROUP_JAVA_GRADLE:
return "Java Source Group from Gradle";
case SOURCE_GROUP_JAVA_SONARGRAPH:
return "Java from Sonargraph";
case SOURCE_GROUP_UNKNOWN:
break;
}
@@ -34,6 +38,8 @@ std::string sourceGroupTypeToProjectSetupString(SourceGroupType v)
return "Empty C++ Source Group";
case SOURCE_GROUP_CXX_CDB:
return "C/C++ from Compilation Database";
case SOURCE_GROUP_CXX_SONARGRAPH:
return "C/C++ from Sonargraph";
case SOURCE_GROUP_CXX_VS:
return "C/C++ from Visual Studio";
case SOURCE_GROUP_JAVA_EMPTY:
@@ -42,13 +48,15 @@ std::string sourceGroupTypeToProjectSetupString(SourceGroupType v)
return "Java Source Group from Maven";
case SOURCE_GROUP_JAVA_GRADLE:
return "Java Source Group from Gradle";
case SOURCE_GROUP_JAVA_SONARGRAPH:
return "Java from Sonargraph";
case SOURCE_GROUP_UNKNOWN:
break;
}
return "unknown";
}
SourceGroupType stringToSourceGroupType(std::string v)
SourceGroupType stringToSourceGroupType(const std::string& v)
{
if (v == sourceGroupTypeToString(SOURCE_GROUP_C_EMPTY))
{
@@ -62,6 +70,10 @@ SourceGroupType stringToSourceGroupType(std::string v)
{
return SOURCE_GROUP_CXX_CDB;
}
else if (v == sourceGroupTypeToString(SOURCE_GROUP_CXX_SONARGRAPH))
{
return SOURCE_GROUP_CXX_SONARGRAPH;
}
else if (v == sourceGroupTypeToString(SOURCE_GROUP_CXX_VS))
{
return SOURCE_GROUP_CXX_VS;
@@ -78,6 +90,10 @@ SourceGroupType stringToSourceGroupType(std::string v)
{
return SOURCE_GROUP_JAVA_GRADLE;
}
else if (v == sourceGroupTypeToString(SOURCE_GROUP_JAVA_SONARGRAPH))
{
return SOURCE_GROUP_JAVA_SONARGRAPH;
}
return SOURCE_GROUP_UNKNOWN;
}
+3 -1
View File
@@ -8,15 +8,17 @@ enum SourceGroupType
SOURCE_GROUP_C_EMPTY,
SOURCE_GROUP_CPP_EMPTY,
SOURCE_GROUP_CXX_CDB,
SOURCE_GROUP_CXX_SONARGRAPH,
SOURCE_GROUP_CXX_VS,
SOURCE_GROUP_JAVA_EMPTY,
SOURCE_GROUP_JAVA_MAVEN,
SOURCE_GROUP_JAVA_GRADLE,
SOURCE_GROUP_JAVA_SONARGRAPH,
SOURCE_GROUP_UNKNOWN
};
std::string sourceGroupTypeToString(SourceGroupType v);
std::string sourceGroupTypeToProjectSetupString(SourceGroupType v);
SourceGroupType stringToSourceGroupType(std::string v);
SourceGroupType stringToSourceGroupType(const std::string& v);
#endif // SOURCE_GROUP_TYPE_H