forked from qt-creator/qt-creator
ClangTools: Convert two persisting values to aspects
Change-Id: Ida296c35f08951eaef698f53bceb705728f55aa9 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -23,8 +23,6 @@ using namespace Utils;
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
|
||||
const char clangTidyExecutableKey[] = "ClangTidyExecutable";
|
||||
const char clazyStandaloneExecutableKey[] = "ClazyStandaloneExecutable";
|
||||
|
||||
const char parallelJobsKey[] = "ParallelJobs";
|
||||
const char preferConfigFileKey[] = "PreferConfigFile";
|
||||
@@ -89,17 +87,23 @@ bool RunSettings::hasConfigFileForSourceFile(const Utils::FilePath &sourceFile)
|
||||
return false;
|
||||
}
|
||||
|
||||
ClangToolsSettings::ClangToolsSettings()
|
||||
{
|
||||
readSettings();
|
||||
}
|
||||
|
||||
ClangToolsSettings *ClangToolsSettings::instance()
|
||||
{
|
||||
static ClangToolsSettings instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
ClangToolsSettings::ClangToolsSettings()
|
||||
{
|
||||
setSettingsGroup(Constants::SETTINGS_ID);
|
||||
|
||||
clangTidyExecutable.setSettingsKey("ClangTidyExecutable");
|
||||
|
||||
clazyStandaloneExecutable.setSettingsKey("ClazyStandaloneExecutable");
|
||||
|
||||
readSettings();
|
||||
}
|
||||
|
||||
static QVariantMap convertToMapFromVersionBefore410(QSettings *s)
|
||||
{
|
||||
const char oldParallelJobsKey[] = "simultaneousProcesses";
|
||||
@@ -141,10 +145,10 @@ void ClangToolsSettings::readSettings()
|
||||
if (!importedConfigs.isEmpty())
|
||||
write = true;
|
||||
|
||||
AspectContainer::readSettings();
|
||||
|
||||
QSettings *s = Core::ICore::settings();
|
||||
s->beginGroup(Constants::SETTINGS_ID);
|
||||
m_clangTidyExecutable = FilePath::fromSettings(s->value(clangTidyExecutableKey));
|
||||
m_clazyStandaloneExecutable = FilePath::fromSettings(s->value(clazyStandaloneExecutableKey));
|
||||
m_diagnosticConfigs.append(diagnosticConfigsFromSettings(s));
|
||||
|
||||
QVariantMap map;
|
||||
@@ -174,11 +178,11 @@ void ClangToolsSettings::readSettings()
|
||||
|
||||
void ClangToolsSettings::writeSettings()
|
||||
{
|
||||
AspectContainer::writeSettings();
|
||||
|
||||
QSettings *s = Core::ICore::settings();
|
||||
s->beginGroup(Constants::SETTINGS_ID);
|
||||
|
||||
s->setValue(clangTidyExecutableKey, m_clangTidyExecutable.toSettings());
|
||||
s->setValue(clazyStandaloneExecutableKey, m_clazyStandaloneExecutable.toSettings());
|
||||
diagnosticConfigsToSettings(s, m_diagnosticConfigs);
|
||||
|
||||
QVariantMap map;
|
||||
@@ -193,16 +197,16 @@ void ClangToolsSettings::writeSettings()
|
||||
|
||||
FilePath ClangToolsSettings::executable(ClangToolType tool) const
|
||||
{
|
||||
return tool == ClangToolType::Tidy ? m_clangTidyExecutable : m_clazyStandaloneExecutable;
|
||||
return tool == ClangToolType::Tidy ? clangTidyExecutable() : clazyStandaloneExecutable();
|
||||
}
|
||||
|
||||
void ClangToolsSettings::setExecutable(ClangToolType tool, const FilePath &path)
|
||||
{
|
||||
if (tool == ClangToolType::Tidy) {
|
||||
m_clangTidyExecutable = path;
|
||||
clangTidyExecutable.setValue(path);
|
||||
m_clangTidyVersion = {};
|
||||
} else {
|
||||
m_clazyStandaloneExecutable = path;
|
||||
clazyStandaloneExecutable.setValue(path);
|
||||
m_clazyVersion = {};
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <cppeditor/clangdiagnosticconfig.h>
|
||||
|
||||
#include <utils/aspects.h>
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/id.h>
|
||||
|
||||
@@ -55,14 +56,19 @@ private:
|
||||
bool m_analyzeOpenFiles = true;
|
||||
};
|
||||
|
||||
class ClangToolsSettings : public QObject
|
||||
class ClangToolsSettings : public Utils::AspectContainer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
ClangToolsSettings();
|
||||
public:
|
||||
static ClangToolsSettings *instance();
|
||||
void writeSettings();
|
||||
|
||||
// Executables
|
||||
Utils::FilePathAspect clangTidyExecutable{this};
|
||||
Utils::FilePathAspect clazyStandaloneExecutable{this};
|
||||
|
||||
Utils::FilePath executable(CppEditor::ClangToolType tool) const;
|
||||
void setExecutable(CppEditor::ClangToolType tool, const Utils::FilePath &path);
|
||||
|
||||
@@ -80,13 +86,8 @@ signals:
|
||||
void changed();
|
||||
|
||||
private:
|
||||
ClangToolsSettings();
|
||||
void readSettings();
|
||||
|
||||
// Executables
|
||||
Utils::FilePath m_clangTidyExecutable;
|
||||
Utils::FilePath m_clazyStandaloneExecutable;
|
||||
|
||||
// Diagnostic Configs
|
||||
CppEditor::ClangDiagnosticConfigs m_diagnosticConfigs;
|
||||
|
||||
|
Reference in New Issue
Block a user