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