forked from qt-creator/qt-creator
Clang: Add tooltip action to remove specific warnings/checks
...from the diagnostic configuration. If no custom diagnostic configuration is set in Projects Mode > Clang, one is created and set for the current project. Otherwise the current custom diagnostic set in the project settings is modified. Change-Id: I5c48280c90f0e807e7333122d504dda302a8b0a9 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "clangdiagnostictooltipwidget.h"
|
#include "clangdiagnostictooltipwidget.h"
|
||||||
#include "clangfixitoperation.h"
|
#include "clangfixitoperation.h"
|
||||||
|
#include "clangutils.h"
|
||||||
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
|
||||||
@@ -149,7 +150,7 @@ public:
|
|||||||
QTC_CHECK(!"Link target cannot be handled.");
|
QTC_CHECK(!"Link target cannot be handled.");
|
||||||
|
|
||||||
if (hideToolTipAfterLinkActivation)
|
if (hideToolTipAfterLinkActivation)
|
||||||
Utils::ToolTip::hideImmediately();
|
::Utils::ToolTip::hideImmediately();
|
||||||
});
|
});
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
@@ -171,50 +172,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
enum class IndentMode { Indent, DoNotIndent };
|
enum class IndentMode { Indent, DoNotIndent };
|
||||||
|
|
||||||
static bool isClazyOption(const QString &option) { return option.startsWith("-Wclazy"); }
|
|
||||||
|
|
||||||
class DiagnosticTextInfo
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DiagnosticTextInfo(const QString &text)
|
|
||||||
: m_text(text)
|
|
||||||
, m_squareBracketStartIndex(text.lastIndexOf('['))
|
|
||||||
{}
|
|
||||||
|
|
||||||
QString textWithoutOption() const
|
|
||||||
{
|
|
||||||
if (m_squareBracketStartIndex == -1)
|
|
||||||
return m_text;
|
|
||||||
|
|
||||||
return m_text.mid(0, m_squareBracketStartIndex - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString option() const
|
|
||||||
{
|
|
||||||
if (m_squareBracketStartIndex == -1)
|
|
||||||
return QString();
|
|
||||||
|
|
||||||
const int index = m_squareBracketStartIndex + 1;
|
|
||||||
return m_text.mid(index, m_text.count() - index - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString category() const
|
|
||||||
{
|
|
||||||
if (m_squareBracketStartIndex == -1)
|
|
||||||
return QString();
|
|
||||||
|
|
||||||
const int index = m_squareBracketStartIndex + 1;
|
|
||||||
if (isClazyOption(m_text.mid(index)))
|
|
||||||
return QCoreApplication::translate("ClangDiagnosticWidget", "Clazy Issue");
|
|
||||||
else
|
|
||||||
return QCoreApplication::translate("ClangDiagnosticWidget", "Clang-Tidy Issue");
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
const QString m_text;
|
|
||||||
const int m_squareBracketStartIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Diagnostics from clazy/tidy do not have any category or option set but
|
// Diagnostics from clazy/tidy do not have any category or option set but
|
||||||
// we will conclude them from the diagnostic message.
|
// we will conclude them from the diagnostic message.
|
||||||
//
|
//
|
||||||
@@ -233,6 +190,7 @@ private:
|
|||||||
|
|
||||||
ClangBackEnd::DiagnosticContainer supplementedDiagnostic = diagnostic;
|
ClangBackEnd::DiagnosticContainer supplementedDiagnostic = diagnostic;
|
||||||
|
|
||||||
|
using namespace ClangCodeModel::Utils;
|
||||||
DiagnosticTextInfo info(diagnostic.text);
|
DiagnosticTextInfo info(diagnostic.text);
|
||||||
supplementedDiagnostic.enableOption = info.option();
|
supplementedDiagnostic.enableOption = info.option();
|
||||||
supplementedDiagnostic.category = info.category();
|
supplementedDiagnostic.category = info.category();
|
||||||
@@ -269,7 +227,7 @@ private:
|
|||||||
QString option = optionAsUtf8String.toString();
|
QString option = optionAsUtf8String.toString();
|
||||||
|
|
||||||
// Clazy
|
// Clazy
|
||||||
if (isClazyOption(option)) {
|
if (ClangCodeModel::Utils::DiagnosticTextInfo::isClazyOption(option)) {
|
||||||
option = optionAsUtf8String.mid(8); // Remove "-Wclazy-" prefix.
|
option = optionAsUtf8String.mid(8); // Remove "-Wclazy-" prefix.
|
||||||
return QString::fromUtf8(CLAZY_DOCUMENTATION_URL_TEMPLATE).arg(option);
|
return QString::fromUtf8(CLAZY_DOCUMENTATION_URL_TEMPLATE).arg(option);
|
||||||
}
|
}
|
||||||
|
@@ -27,11 +27,20 @@
|
|||||||
|
|
||||||
#include "clangconstants.h"
|
#include "clangconstants.h"
|
||||||
#include "clangdiagnostictooltipwidget.h"
|
#include "clangdiagnostictooltipwidget.h"
|
||||||
|
#include "clangeditordocumentprocessor.h"
|
||||||
|
#include "clangmodelmanagersupport.h"
|
||||||
|
#include "clangprojectsettings.h"
|
||||||
#include "clangutils.h"
|
#include "clangutils.h"
|
||||||
|
|
||||||
#include <utils/utilsicons.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <cpptools/clangdiagnosticconfigsmodel.h>
|
||||||
|
#include <cpptools/cpptoolsreuse.h>
|
||||||
|
#include <cpptools/cppcodemodelsettings.h>
|
||||||
|
|
||||||
|
#include <utils/fadingindicator.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@@ -64,6 +73,102 @@ static Core::Id categoryForSeverity(ClangBackEnd::DiagnosticSeverity severity)
|
|||||||
return isWarningOrNote(severity) ? Constants::CLANG_WARNING : Constants::CLANG_ERROR;
|
return isWarningOrNote(severity) ? Constants::CLANG_WARNING : Constants::CLANG_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProjectExplorer::Project *projectForCurrentEditor()
|
||||||
|
{
|
||||||
|
using namespace CppTools;
|
||||||
|
using namespace ClangCodeModel::Internal;
|
||||||
|
|
||||||
|
const QString filePath = Utils::currentCppEditorDocumentFilePath();
|
||||||
|
if (filePath.isEmpty())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if (auto processor = ClangEditorDocumentProcessor::get(filePath)) {
|
||||||
|
if (ProjectPart::Ptr projectPart = processor->projectPart())
|
||||||
|
return projectPart->project;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void disableDiagnosticInConfig(CppTools::ClangDiagnosticConfig &config,
|
||||||
|
const ClangBackEnd::DiagnosticContainer &diagnostic)
|
||||||
|
{
|
||||||
|
// Clang check
|
||||||
|
if (!diagnostic.disableOption.isEmpty()) {
|
||||||
|
config.setClangOptions(config.clangOptions() + QStringList(diagnostic.disableOption));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clazy check
|
||||||
|
using namespace ClangCodeModel::Utils;
|
||||||
|
DiagnosticTextInfo textInfo(diagnostic.text);
|
||||||
|
if (DiagnosticTextInfo::isClazyOption(textInfo.option())) {
|
||||||
|
const QString checkName = DiagnosticTextInfo::clazyCheckName(textInfo.option());
|
||||||
|
QStringList newChecks = config.clazyChecks().split(',');
|
||||||
|
newChecks.removeOne(checkName);
|
||||||
|
config.setClazyChecks(newChecks.join(','));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tidy check
|
||||||
|
config.setClangTidyChecks(config.clangTidyChecks() + QString(",-") + textInfo.option());
|
||||||
|
}
|
||||||
|
|
||||||
|
void disableDiagnosticInCurrentProjectConfig(const ClangBackEnd::DiagnosticContainer &diagnostic)
|
||||||
|
{
|
||||||
|
using namespace CppTools;
|
||||||
|
using namespace ClangCodeModel::Internal;
|
||||||
|
|
||||||
|
ProjectExplorer::Project *project = projectForCurrentEditor();
|
||||||
|
QTC_ASSERT(project, return );
|
||||||
|
|
||||||
|
// Get settings
|
||||||
|
ClangProjectSettings &projectSettings = ClangModelManagerSupport::instance()->projectSettings(
|
||||||
|
project);
|
||||||
|
const QSharedPointer<CppCodeModelSettings> globalSettings = codeModelSettings();
|
||||||
|
|
||||||
|
// Get config id
|
||||||
|
Core::Id currentConfigId = projectSettings.warningConfigId();
|
||||||
|
if (projectSettings.useGlobalConfig())
|
||||||
|
currentConfigId = globalSettings->clangDiagnosticConfigId();
|
||||||
|
|
||||||
|
// Get config
|
||||||
|
const ClangDiagnosticConfigs originalConfigs = globalSettings->clangCustomDiagnosticConfigs();
|
||||||
|
ClangDiagnosticConfigsModel configsModel(globalSettings->clangCustomDiagnosticConfigs());
|
||||||
|
QTC_ASSERT(configsModel.hasConfigWithId(currentConfigId), return );
|
||||||
|
ClangDiagnosticConfig config = configsModel.configWithId(currentConfigId);
|
||||||
|
|
||||||
|
// Create copy if needed
|
||||||
|
if (config.isReadOnly()) {
|
||||||
|
const QString name = QCoreApplication::translate("ClangDiagnosticConfig",
|
||||||
|
"Project: %1 (based on %2)")
|
||||||
|
.arg(project->displayName(), config.displayName());
|
||||||
|
config = ClangDiagnosticConfigsModel::createCustomConfig(config, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify diagnostic config
|
||||||
|
disableDiagnosticInConfig(config, diagnostic);
|
||||||
|
configsModel.appendOrUpdate(config);
|
||||||
|
|
||||||
|
// Set global settings
|
||||||
|
globalSettings->setClangCustomDiagnosticConfigs(configsModel.customConfigs());
|
||||||
|
globalSettings->toSettings(Core::ICore::settings());
|
||||||
|
|
||||||
|
// Set project settings
|
||||||
|
if (projectSettings.useGlobalConfig())
|
||||||
|
projectSettings.setUseGlobalConfig(false);
|
||||||
|
projectSettings.setWarningConfigId(config.id());
|
||||||
|
projectSettings.store();
|
||||||
|
|
||||||
|
// Notify the user about changed project specific settings
|
||||||
|
const QString text
|
||||||
|
= QCoreApplication::translate("ClangDiagnosticConfig",
|
||||||
|
"Changes applied in Projects Mode > Clang Code Model");
|
||||||
|
::Utils::FadingIndicator::showText(Core::ICore::mainWindow(),
|
||||||
|
text,
|
||||||
|
::Utils::FadingIndicator::SmallText);
|
||||||
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
ClangTextMark::ClangTextMark(const FileName &fileName,
|
ClangTextMark::ClangTextMark(const FileName &fileName,
|
||||||
@@ -88,6 +193,8 @@ ClangTextMark::ClangTextMark(const FileName &fileName,
|
|||||||
: ::Utils::Theme::CodeModel_Error_TextMarkColor);
|
: ::Utils::Theme::CodeModel_Error_TextMarkColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy to clipboard action
|
||||||
|
QVector<QAction *> actions;
|
||||||
QAction *action = new QAction();
|
QAction *action = new QAction();
|
||||||
action->setIcon(QIcon::fromTheme("edit-copy", ::Utils::Icons::COPY.icon()));
|
action->setIcon(QIcon::fromTheme("edit-copy", ::Utils::Icons::COPY.icon()));
|
||||||
QObject::connect(action, &QAction::triggered, [diagnostic]() {
|
QObject::connect(action, &QAction::triggered, [diagnostic]() {
|
||||||
@@ -96,7 +203,19 @@ ClangTextMark::ClangTextMark(const FileName &fileName,
|
|||||||
ClangDiagnosticWidget::InfoBar);
|
ClangDiagnosticWidget::InfoBar);
|
||||||
QApplication::clipboard()->setText(text, QClipboard::Clipboard);
|
QApplication::clipboard()->setText(text, QClipboard::Clipboard);
|
||||||
});
|
});
|
||||||
setActions({action});
|
actions << action;
|
||||||
|
|
||||||
|
// Remove diagnostic warning action
|
||||||
|
if (projectForCurrentEditor()) {
|
||||||
|
action = new QAction();
|
||||||
|
action->setIcon(::Utils::Icons::BROKEN.icon());
|
||||||
|
QObject::connect(action, &QAction::triggered, [diagnostic]() {
|
||||||
|
disableDiagnosticInCurrentProjectConfig(diagnostic);
|
||||||
|
});
|
||||||
|
actions << action;
|
||||||
|
}
|
||||||
|
|
||||||
|
setActions(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangTextMark::updateIcon(bool valid)
|
void ClangTextMark::updateIcon(bool valid)
|
||||||
|
@@ -373,5 +373,51 @@ QString currentCppEditorDocumentFilePath()
|
|||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiagnosticTextInfo::DiagnosticTextInfo(const QString &text)
|
||||||
|
: m_text(text)
|
||||||
|
, m_squareBracketStartIndex(text.lastIndexOf('['))
|
||||||
|
{}
|
||||||
|
|
||||||
|
QString DiagnosticTextInfo::textWithoutOption() const
|
||||||
|
{
|
||||||
|
if (m_squareBracketStartIndex == -1)
|
||||||
|
return m_text;
|
||||||
|
|
||||||
|
return m_text.mid(0, m_squareBracketStartIndex - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DiagnosticTextInfo::option() const
|
||||||
|
{
|
||||||
|
if (m_squareBracketStartIndex == -1)
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
const int index = m_squareBracketStartIndex + 1;
|
||||||
|
return m_text.mid(index, m_text.count() - index - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DiagnosticTextInfo::category() const
|
||||||
|
{
|
||||||
|
if (m_squareBracketStartIndex == -1)
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
const int index = m_squareBracketStartIndex + 1;
|
||||||
|
if (isClazyOption(m_text.mid(index)))
|
||||||
|
return QCoreApplication::translate("ClangDiagnosticWidget", "Clazy Issue");
|
||||||
|
else
|
||||||
|
return QCoreApplication::translate("ClangDiagnosticWidget", "Clang-Tidy Issue");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DiagnosticTextInfo::isClazyOption(const QString &option)
|
||||||
|
{
|
||||||
|
return option.startsWith("-Wclazy");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DiagnosticTextInfo::clazyCheckName(const QString &option)
|
||||||
|
{
|
||||||
|
if (option.startsWith("-Wclazy"))
|
||||||
|
return option.mid(8); // Chop "-Wclazy-"
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
} // namespace Clang
|
} // namespace Clang
|
||||||
|
@@ -72,6 +72,23 @@ QString diagnosticCategoryPrefixRemoved(const QString &text);
|
|||||||
|
|
||||||
void generateCompilationDB(::Utils::FileName projectDir, CppTools::ProjectInfo projectInfo);
|
void generateCompilationDB(::Utils::FileName projectDir, CppTools::ProjectInfo projectInfo);
|
||||||
|
|
||||||
|
class DiagnosticTextInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DiagnosticTextInfo(const QString &text);
|
||||||
|
|
||||||
|
QString textWithoutOption() const;
|
||||||
|
QString option() const;
|
||||||
|
QString category() const;
|
||||||
|
|
||||||
|
static bool isClazyOption(const QString &option);
|
||||||
|
static QString clazyCheckName(const QString &option);
|
||||||
|
|
||||||
|
private:
|
||||||
|
const QString m_text;
|
||||||
|
const int m_squareBracketStartIndex;
|
||||||
|
};
|
||||||
|
|
||||||
namespace Text {
|
namespace Text {
|
||||||
|
|
||||||
template <class CharacterProvider>
|
template <class CharacterProvider>
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "clangdiagnosticconfigsmodel.h"
|
#include "clangdiagnosticconfigsmodel.h"
|
||||||
|
|
||||||
|
#include "cpptoolsreuse.h"
|
||||||
#include "cpptoolsconstants.h"
|
#include "cpptoolsconstants.h"
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
@@ -73,7 +74,6 @@ constexpr const char *DEFAULT_TIDY_CHECKS = "-*,"
|
|||||||
"-readability-braces-around-statements,"
|
"-readability-braces-around-statements,"
|
||||||
"-readability-implicit-bool-conversion,"
|
"-readability-implicit-bool-conversion,"
|
||||||
"-readability-named-parameter";
|
"-readability-named-parameter";
|
||||||
constexpr const char *DEFAULT_CLAZY_CHECKS = "level0";
|
|
||||||
|
|
||||||
static void addConfigForAlmostEveryWarning(ClangDiagnosticConfigsModel &model)
|
static void addConfigForAlmostEveryWarning(ClangDiagnosticConfigsModel &model)
|
||||||
{
|
{
|
||||||
@@ -141,7 +141,7 @@ static void addConfigForClazy(ClangDiagnosticConfigsModel &model)
|
|||||||
"Clazy level0 checks"));
|
"Clazy level0 checks"));
|
||||||
config.setIsReadOnly(true);
|
config.setIsReadOnly(true);
|
||||||
config.setClangOptions(QStringList{QStringLiteral("-w")});
|
config.setClangOptions(QStringList{QStringLiteral("-w")});
|
||||||
config.setClazyChecks(QString::fromUtf8(DEFAULT_CLAZY_CHECKS));
|
config.setClazyChecks(clazyChecksForLevel(0));
|
||||||
|
|
||||||
model.appendOrUpdate(config);
|
model.appendOrUpdate(config);
|
||||||
}
|
}
|
||||||
@@ -157,7 +157,7 @@ static void addConfigForTidyAndClazy(ClangDiagnosticConfigsModel &model)
|
|||||||
config.setClangTidyMode(ClangDiagnosticConfig::TidyMode::ChecksPrefixList);
|
config.setClangTidyMode(ClangDiagnosticConfig::TidyMode::ChecksPrefixList);
|
||||||
|
|
||||||
config.setClangTidyChecks(QString::fromUtf8(DEFAULT_TIDY_CHECKS));
|
config.setClangTidyChecks(QString::fromUtf8(DEFAULT_TIDY_CHECKS));
|
||||||
config.setClazyChecks(QString::fromUtf8(DEFAULT_CLAZY_CHECKS));
|
config.setClazyChecks(clazyChecksForLevel(0));
|
||||||
|
|
||||||
model.appendOrUpdate(config);
|
model.appendOrUpdate(config);
|
||||||
}
|
}
|
||||||
|
@@ -319,16 +319,6 @@ public:
|
|||||||
m_root->checked = Qt::Unchecked;
|
m_root->checked = Qt::Unchecked;
|
||||||
propagateDown(index(0, 0, QModelIndex()));
|
propagateDown(index(0, 0, QModelIndex()));
|
||||||
|
|
||||||
// <= Qt Creator 4.8 settings provide specific levels: {"level0"}
|
|
||||||
if (checks.size() == 1 && checks.first().startsWith("level")) {
|
|
||||||
bool ok = false;
|
|
||||||
const int level = checks.first().mid(5).toInt(&ok);
|
|
||||||
QTC_ASSERT(ok, return);
|
|
||||||
enableChecksByLevel(level);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// >= Qt Creator 4.9 settings provide specific checks: {c1, c2, ...}
|
|
||||||
for (const QString &check : checks) {
|
for (const QString &check : checks) {
|
||||||
const QModelIndex index = indexForCheck(check);
|
const QModelIndex index = indexForCheck(check);
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
@@ -437,23 +427,6 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void enableChecksByLevel(int level)
|
|
||||||
{
|
|
||||||
if (level < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ClazyChecksTree *node = m_levelNodes.value(level);
|
|
||||||
QTC_ASSERT(node, return);
|
|
||||||
const QModelIndex index = indexForTree(node);
|
|
||||||
QTC_ASSERT(index.isValid(), return);
|
|
||||||
|
|
||||||
node->checked = Qt::Checked;
|
|
||||||
propagateUp(index);
|
|
||||||
propagateDown(index);
|
|
||||||
|
|
||||||
enableChecksByLevel(--level);
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex indexForCheck(const QString &check) const {
|
QModelIndex indexForCheck(const QString &check) const {
|
||||||
if (check == "*")
|
if (check == "*")
|
||||||
return index(0, 0, QModelIndex());
|
return index(0, 0, QModelIndex());
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "clangdiagnosticconfigsmodel.h"
|
#include "clangdiagnosticconfigsmodel.h"
|
||||||
#include "cpptoolsconstants.h"
|
#include "cpptoolsconstants.h"
|
||||||
|
#include "cpptoolsreuse.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -79,6 +80,24 @@ static QString skipIndexingBigFilesKey()
|
|||||||
static QString indexerFileSizeLimitKey()
|
static QString indexerFileSizeLimitKey()
|
||||||
{ return QLatin1String(Constants::CPPTOOLS_INDEXER_FILE_SIZE_LIMIT); }
|
{ return QLatin1String(Constants::CPPTOOLS_INDEXER_FILE_SIZE_LIMIT); }
|
||||||
|
|
||||||
|
static QString convertToNewClazyChecksFormat(const QString &checks)
|
||||||
|
{
|
||||||
|
// Before Qt Creator 4.9 valid values for checks were: "", "levelN".
|
||||||
|
// Starting with Qt Creator 4.9, checks are a comma-separated string of checks: "x,y,z".
|
||||||
|
|
||||||
|
if (checks.isEmpty())
|
||||||
|
return checks;
|
||||||
|
|
||||||
|
if (checks.size() == 6 && checks.startsWith("level")) {
|
||||||
|
bool ok = false;
|
||||||
|
const int level = checks.mid(5).toInt(&ok);
|
||||||
|
QTC_ASSERT(ok, return QString());
|
||||||
|
return clazyChecksForLevel(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
return checks;
|
||||||
|
}
|
||||||
|
|
||||||
static ClangDiagnosticConfigs customDiagnosticConfigsFromSettings(QSettings *s)
|
static ClangDiagnosticConfigs customDiagnosticConfigsFromSettings(QSettings *s)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(s->group() == QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP),
|
QTC_ASSERT(s->group() == QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP),
|
||||||
@@ -98,7 +117,9 @@ static ClangDiagnosticConfigs customDiagnosticConfigsFromSettings(QSettings *s)
|
|||||||
s->value(clangDiagnosticConfigsArrayClangTidyModeKey()).toInt()));
|
s->value(clangDiagnosticConfigsArrayClangTidyModeKey()).toInt()));
|
||||||
config.setClangTidyChecks(
|
config.setClangTidyChecks(
|
||||||
s->value(clangDiagnosticConfigsArrayClangTidyChecksKey()).toString());
|
s->value(clangDiagnosticConfigsArrayClangTidyChecksKey()).toString());
|
||||||
config.setClazyChecks(s->value(clangDiagnosticConfigsArrayClazyChecksKey()).toString());
|
|
||||||
|
const QString clazyChecks = s->value(clangDiagnosticConfigsArrayClazyChecksKey()).toString();
|
||||||
|
config.setClazyChecks(convertToNewClazyChecksFormat(clazyChecks));
|
||||||
configs.append(config);
|
configs.append(config);
|
||||||
}
|
}
|
||||||
s->endArray();
|
s->endArray();
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "cppcodemodelsettings.h"
|
#include "cppcodemodelsettings.h"
|
||||||
#include "cpptoolsplugin.h"
|
#include "cpptoolsplugin.h"
|
||||||
|
#include "cpptools_clazychecks.h"
|
||||||
|
|
||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
@@ -287,4 +288,14 @@ UsePrecompiledHeaders getPchUsage()
|
|||||||
return UsePrecompiledHeaders::Yes;
|
return UsePrecompiledHeaders::Yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString clazyChecksForLevel(int level)
|
||||||
|
{
|
||||||
|
QStringList checks;
|
||||||
|
for (const Constants::ClazyCheckInfo &check : Constants::CLAZY_CHECKS) {
|
||||||
|
if (check.level == level)
|
||||||
|
checks << check.name;
|
||||||
|
}
|
||||||
|
return checks.join(',');
|
||||||
|
}
|
||||||
|
|
||||||
} // CppTools
|
} // CppTools
|
||||||
|
@@ -80,4 +80,6 @@ UsePrecompiledHeaders CPPTOOLS_EXPORT getPchUsage();
|
|||||||
int indexerFileSizeLimitInMb();
|
int indexerFileSizeLimitInMb();
|
||||||
bool fileSizeExceedsLimit(const QFileInfo &fileInfo, int sizeLimitInMb);
|
bool fileSizeExceedsLimit(const QFileInfo &fileInfo, int sizeLimitInMb);
|
||||||
|
|
||||||
|
QString clazyChecksForLevel(int level);
|
||||||
|
|
||||||
} // CppTools
|
} // CppTools
|
||||||
|
Reference in New Issue
Block a user