forked from qt-creator/qt-creator
ClangToolsSettings: Reuse ClangToolType enum
Change-Id: I24d7bde71ccf3fc3ea33b78e0ed629fa0ce90c04 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -174,16 +174,20 @@ void ClangToolsSettings::writeSettings()
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void ClangToolsSettings::setClangTidyExecutable(const FilePath &path)
|
||||
FilePath ClangToolsSettings::executable(ClangToolType tool) const
|
||||
{
|
||||
m_clangTidyExecutable = path;
|
||||
m_clangTidyVersion = {};
|
||||
return tool == ClangToolType::Tidy ? m_clangTidyExecutable : m_clazyStandaloneExecutable;
|
||||
}
|
||||
|
||||
void ClangToolsSettings::setClazyStandaloneExecutable(const FilePath &path)
|
||||
void ClangToolsSettings::setExecutable(ClangToolType tool, const FilePath &path)
|
||||
{
|
||||
m_clazyStandaloneExecutable = path;
|
||||
m_clazyVersion = {};
|
||||
if (tool == ClangToolType::Tidy) {
|
||||
m_clangTidyExecutable = path;
|
||||
m_clangTidyVersion = {};
|
||||
} else {
|
||||
m_clazyStandaloneExecutable = path;
|
||||
m_clazyVersion = {};
|
||||
}
|
||||
}
|
||||
|
||||
static VersionAndSuffix getVersionNumber(VersionAndSuffix &version, const FilePath &toolFilePath)
|
||||
|
@@ -57,11 +57,8 @@ public:
|
||||
static ClangToolsSettings *instance();
|
||||
void writeSettings();
|
||||
|
||||
Utils::FilePath clangTidyExecutable() const { return m_clangTidyExecutable; }
|
||||
void setClangTidyExecutable(const Utils::FilePath &path);
|
||||
|
||||
Utils::FilePath clazyStandaloneExecutable() const { return m_clazyStandaloneExecutable; }
|
||||
void setClazyStandaloneExecutable(const Utils::FilePath &path);
|
||||
Utils::FilePath executable(CppEditor::ClangToolType tool) const;
|
||||
void setExecutable(CppEditor::ClangToolType tool, const Utils::FilePath &path);
|
||||
|
||||
CppEditor::ClangDiagnosticConfigs diagnosticConfigs() const { return m_diagnosticConfigs; }
|
||||
void setDiagnosticConfigs(const CppEditor::ClangDiagnosticConfigs &configs)
|
||||
|
@@ -200,7 +200,7 @@ FilePath clangTidyFallbackExecutable()
|
||||
|
||||
FilePath clangTidyExecutable()
|
||||
{
|
||||
const FilePath fromSettings = ClangToolsSettings::instance()->clangTidyExecutable();
|
||||
const FilePath fromSettings = ClangToolsSettings::instance()->executable(ClangToolType::Tidy);
|
||||
if (!fromSettings.isEmpty())
|
||||
return fullPath(fromSettings);
|
||||
return clangTidyFallbackExecutable();
|
||||
@@ -216,7 +216,7 @@ FilePath clazyStandaloneFallbackExecutable()
|
||||
|
||||
FilePath clazyStandaloneExecutable()
|
||||
{
|
||||
const FilePath fromSettings = ClangToolsSettings::instance()->clazyStandaloneExecutable();
|
||||
const FilePath fromSettings = ClangToolsSettings::instance()->executable(ClangToolType::Clazy);
|
||||
if (!fromSettings.isEmpty())
|
||||
return fullPath(fromSettings);
|
||||
return clazyStandaloneFallbackExecutable();
|
||||
|
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
using namespace CppEditor;
|
||||
using namespace Utils;
|
||||
|
||||
namespace ClangTools::Internal {
|
||||
@@ -36,7 +37,7 @@ SettingsWidget::SettingsWidget()
|
||||
resize(400, 300);
|
||||
|
||||
QString placeHolderText = shippedClangTidyExecutable().toUserOutput();
|
||||
FilePath path = m_settings->clangTidyExecutable();
|
||||
FilePath path = m_settings->executable(ClangToolType::Tidy);
|
||||
if (path.isEmpty() && placeHolderText.isEmpty())
|
||||
path = Constants::CLANG_TIDY_EXECUTABLE_NAME;
|
||||
m_clangTidyPathChooser = new PathChooser;
|
||||
@@ -47,7 +48,7 @@ SettingsWidget::SettingsWidget()
|
||||
m_clangTidyPathChooser->setHistoryCompleter("ClangTools.ClangTidyExecutable.History");
|
||||
|
||||
placeHolderText = shippedClazyStandaloneExecutable().toUserOutput();
|
||||
path = m_settings->clazyStandaloneExecutable();
|
||||
path = m_settings->executable(ClangToolType::Clazy);
|
||||
if (path.isEmpty() && placeHolderText.isEmpty())
|
||||
path = Constants::CLAZY_STANDALONE_EXECUTABLE_NAME;
|
||||
m_clazyStandalonePathChooser = new PathChooser;
|
||||
@@ -78,14 +79,14 @@ SettingsWidget::SettingsWidget()
|
||||
void SettingsWidget::apply()
|
||||
{
|
||||
// Executables
|
||||
m_settings->setClangTidyExecutable(clangTidyPath());
|
||||
m_settings->setClazyStandaloneExecutable(clazyStandalonePath());
|
||||
m_settings->setExecutable(ClangToolType::Tidy, clangTidyPath());
|
||||
m_settings->setExecutable(ClangToolType::Clazy, clazyStandalonePath());
|
||||
|
||||
// Run options
|
||||
m_settings->setRunSettings(m_runSettingsWidget->toSettings());
|
||||
|
||||
// Custom configs
|
||||
const CppEditor::ClangDiagnosticConfigs customConfigs
|
||||
const ClangDiagnosticConfigs customConfigs
|
||||
= m_runSettingsWidget->diagnosticSelectionWidget()->customConfigs();
|
||||
m_settings->setDiagnosticConfigs(customConfigs);
|
||||
|
||||
|
Reference in New Issue
Block a user