src: Refactored SourceGroupSettings into components as bases architecture

This commit is contained in:
Eberhard Graether
2019-10-18 13:05:27 +02:00
parent 941e5dbcaa
commit bd09cc4feb
105 changed files with 1610 additions and 1827 deletions
@@ -0,0 +1,52 @@
#include "SourceGroupSettingsWithClasspath.h"
#include "ProjectSettings.h"
#include "utility.h"
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;
}
bool SourceGroupSettingsWithClasspath::equals(const SourceGroupSettingsBase* other) const
{
const SourceGroupSettingsWithClasspath* otherPtr = dynamic_cast<const SourceGroupSettingsWithClasspath*>(other);
return (
otherPtr &&
(m_useJreSystemLibrary == otherPtr->m_useJreSystemLibrary) &&
utility::isPermutation(m_classpath, otherPtr->m_classpath)
);
}
void SourceGroupSettingsWithClasspath::load(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(ConfigManager* config, const std::string& key)
{
config->setValues(key + "/class_paths/class_path", getClasspath());
config->setValue(key + "/use_jre_system_library", getUseJreSystemLibrary());
}
@@ -0,0 +1,33 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_CLASSPATH_H
#define SOURCE_GROUP_SETTINGS_WITH_CLASSPATH_H
#include <vector>
#include "FilePath.h"
#include "SourceGroupSettingsComponent.h"
class SourceGroupSettingsWithClasspath
: public SourceGroupSettingsComponent
{
public:
virtual ~SourceGroupSettingsWithClasspath() = default;
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:
bool equals(const SourceGroupSettingsBase* other) const override;
void load(const ConfigManager* config, const std::string& key) override;
void save(ConfigManager* config, const std::string& key) override;
private:
std::vector<FilePath> m_classpath;
bool m_useJreSystemLibrary = true;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_CLASSPATH_H
@@ -0,0 +1,58 @@
#include "SourceGroupSettingsWithJavaGradle.h"
#include "ConfigManager.h"
#include "ProjectSettings.h"
#include "utilityFile.h"
FilePath SourceGroupSettingsWithJavaGradle::getGradleDependenciesDirectoryPath() const
{
return getSourceGroupDependenciesDirectoryPath().concatenate(L"gradle");
}
FilePath SourceGroupSettingsWithJavaGradle::getGradleProjectFilePath() const
{
return m_gradleProjectFilePath;
}
FilePath SourceGroupSettingsWithJavaGradle::getGradleProjectFilePathExpandedAndAbsolute() const
{
return utility::getExpandedAndAbsolutePath(getGradleProjectFilePath(), getProjectSettings()->getProjectDirectoryPath());
}
void SourceGroupSettingsWithJavaGradle::setGradleProjectFilePath(const FilePath& path)
{
m_gradleProjectFilePath = path;
}
bool SourceGroupSettingsWithJavaGradle::getShouldIndexGradleTests() const
{
return m_shouldIndexGradleTests;
}
void SourceGroupSettingsWithJavaGradle::setShouldIndexGradleTests(bool value)
{
m_shouldIndexGradleTests = value;
}
bool SourceGroupSettingsWithJavaGradle::equals(const SourceGroupSettingsBase* other) const
{
const SourceGroupSettingsWithJavaGradle* otherPtr = dynamic_cast<const SourceGroupSettingsWithJavaGradle*>(other);
return (
otherPtr &&
m_gradleProjectFilePath == otherPtr->m_gradleProjectFilePath &&
m_shouldIndexGradleTests == otherPtr->m_shouldIndexGradleTests
);
}
void SourceGroupSettingsWithJavaGradle::load(const ConfigManager* config, const std::string& key)
{
setGradleProjectFilePath(config->getValueOrDefault(key + "/gradle/project_file_path", FilePath(L"")));
setShouldIndexGradleTests(config->getValueOrDefault(key + "/gradle/should_index_tests", false));
}
void SourceGroupSettingsWithJavaGradle::save(ConfigManager* config, const std::string& key)
{
config->setValue(key + "/gradle/project_file_path", getGradleProjectFilePath().wstr());
config->setValue(key + "/gradle/should_index_tests", getShouldIndexGradleTests());
}
@@ -0,0 +1,33 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_JAVA_GRADLE_H
#define SOURCE_GROUP_SETTINGS_WITH_JAVA_GRADLE_H
#include "FilePath.h"
#include "SourceGroupSettingsComponent.h"
class SourceGroupSettingsWithJavaGradle
: public SourceGroupSettingsComponent
{
public:
virtual ~SourceGroupSettingsWithJavaGradle() = default;
FilePath getGradleDependenciesDirectoryPath() const;
FilePath getGradleProjectFilePath() const;
FilePath getGradleProjectFilePathExpandedAndAbsolute() const;
void setGradleProjectFilePath(const FilePath& path);
bool getShouldIndexGradleTests() const;
void setShouldIndexGradleTests(bool value);
protected:
bool equals(const SourceGroupSettingsBase* other) const override;
void load(const ConfigManager* config, const std::string& key) override;
void save(ConfigManager* config, const std::string& key) override;
private:
FilePath m_gradleProjectFilePath;
bool m_shouldIndexGradleTests = false;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_JAVA_GRADLE_H
@@ -0,0 +1,58 @@
#include "SourceGroupSettingsWithJavaMaven.h"
#include "ConfigManager.h"
#include "ProjectSettings.h"
#include "utilityFile.h"
FilePath SourceGroupSettingsWithJavaMaven::getMavenDependenciesDirectoryPath() const
{
return getSourceGroupDependenciesDirectoryPath().concatenate(L"maven");
}
FilePath SourceGroupSettingsWithJavaMaven::getMavenProjectFilePath() const
{
return m_mavenProjectFilePath;
}
FilePath SourceGroupSettingsWithJavaMaven::getMavenProjectFilePathExpandedAndAbsolute() const
{
return utility::getExpandedAndAbsolutePath(getMavenProjectFilePath(), getProjectSettings()->getProjectDirectoryPath());
}
void SourceGroupSettingsWithJavaMaven::setMavenProjectFilePath(const FilePath& path)
{
m_mavenProjectFilePath = path;
}
bool SourceGroupSettingsWithJavaMaven::getShouldIndexMavenTests() const
{
return m_shouldIndexMavenTests;
}
void SourceGroupSettingsWithJavaMaven::setShouldIndexMavenTests(bool value)
{
m_shouldIndexMavenTests = value;
}
bool SourceGroupSettingsWithJavaMaven::equals(const SourceGroupSettingsBase* other) const
{
const SourceGroupSettingsWithJavaMaven* otherPtr = dynamic_cast<const SourceGroupSettingsWithJavaMaven*>(other);
return (
otherPtr &&
m_mavenProjectFilePath == otherPtr->m_mavenProjectFilePath &&
m_shouldIndexMavenTests == otherPtr->m_shouldIndexMavenTests
);
}
void SourceGroupSettingsWithJavaMaven::load(const ConfigManager* config, const std::string& key)
{
setMavenProjectFilePath(config->getValueOrDefault(key + "/maven/project_file_path", FilePath(L"")));
setShouldIndexMavenTests(config->getValueOrDefault(key + "/maven/should_index_tests", false));
}
void SourceGroupSettingsWithJavaMaven::save(ConfigManager* config, const std::string& key)
{
config->setValue(key + "/maven/project_file_path", getMavenProjectFilePath().wstr());
config->setValue(key + "/maven/should_index_tests", getShouldIndexMavenTests());
}
@@ -0,0 +1,33 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_JAVA_MAVEN_H
#define SOURCE_GROUP_SETTINGS_WITH_JAVA_MAVEN_H
#include "FilePath.h"
#include "SourceGroupSettingsComponent.h"
class SourceGroupSettingsWithJavaMaven
: public SourceGroupSettingsComponent
{
public:
virtual ~SourceGroupSettingsWithJavaMaven() = default;
FilePath getMavenDependenciesDirectoryPath() const;
FilePath getMavenProjectFilePath() const;
FilePath getMavenProjectFilePathExpandedAndAbsolute() const;
void setMavenProjectFilePath(const FilePath& path);
bool getShouldIndexMavenTests() const;
void setShouldIndexMavenTests(bool value);
protected:
bool equals(const SourceGroupSettingsBase* other) const override;
void load(const ConfigManager* config, const std::string& key) override;
void save(ConfigManager* config, const std::string& key) override;
private:
FilePath m_mavenProjectFilePath;
bool m_shouldIndexMavenTests = false;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_JAVA_MAVEN_H
@@ -0,0 +1,52 @@
#include "SourceGroupSettingsWithJavaStandard.h"
#include "ProjectSettings.h"
std::wstring SourceGroupSettingsWithJavaStandard::getDefaultJavaStandardStatic()
{
return L"8";
}
std::wstring SourceGroupSettingsWithJavaStandard::getJavaStandard() const
{
if (m_javaStandard.empty())
{
return getDefaultJavaStandard();
}
return m_javaStandard;
}
void SourceGroupSettingsWithJavaStandard::setJavaStandard(const std::wstring& standard)
{
m_javaStandard = standard;
}
std::vector<std::wstring> SourceGroupSettingsWithJavaStandard::getAvailableJavaStandards() const
{
return {L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9", L"10"};
}
bool SourceGroupSettingsWithJavaStandard::equals(const SourceGroupSettingsBase* other) const
{
const SourceGroupSettingsWithJavaStandard* otherPtr = dynamic_cast<const SourceGroupSettingsWithJavaStandard*>(other);
return (
otherPtr &&
m_javaStandard == otherPtr->m_javaStandard
);
}
void SourceGroupSettingsWithJavaStandard::load(const ConfigManager* config, const std::string& key)
{
setJavaStandard(config->getValueOrDefault<std::wstring>(key + "/java_standard", L""));
}
void SourceGroupSettingsWithJavaStandard::save(ConfigManager* config, const std::string& key)
{
config->setValue(key + "/java_standard", getJavaStandard());
}
std::wstring SourceGroupSettingsWithJavaStandard::getDefaultJavaStandard() const
{
return getDefaultJavaStandardStatic();
}
@@ -0,0 +1,33 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_JAVA_STANDARD_H
#define SOURCE_GROUP_SETTINGS_WITH_JAVA_STANDARD_H
#include <vector>
#include "SourceGroupSettingsComponent.h"
class SourceGroupSettingsWithJavaStandard
: public SourceGroupSettingsComponent
{
public:
static std::wstring getDefaultJavaStandardStatic();
virtual ~SourceGroupSettingsWithJavaStandard() = default;
std::wstring getJavaStandard() const;
void setJavaStandard(const std::wstring& standard);
std::vector<std::wstring> getAvailableJavaStandards() const;
protected:
bool equals(const SourceGroupSettingsBase* other) const override;
void load(const ConfigManager* config, const std::string& key) override;
void save(ConfigManager* config, const std::string& key) override;
private:
std::wstring getDefaultJavaStandard() const;
std::wstring m_javaStandard;
};
#endif // SOURCE_GROUP_SETTINGS_WITH_JAVA_STANDARD_H
@@ -0,0 +1,16 @@
#ifndef SOURCE_GROUP_SETTINGS_WITH_SOURCE_EXTENSIONS_JAVA_H
#define SOURCE_GROUP_SETTINGS_WITH_SOURCE_EXTENSIONS_JAVA_H
#include "SourceGroupSettingsWithSourceExtensions.h"
class SourceGroupSettingsWithSourceExtensionsJava
: public SourceGroupSettingsWithSourceExtensions
{
private:
std::vector<std::wstring> getDefaultSourceExtensions() const override
{
return { L".java" };
}
};
#endif // SOURCE_GROUP_SETTINGS_WITH_SOURCE_EXTENSIONS_JAVA_H