ClangTools: Allow suppressing diagnostics for tidy/clazy

...copy/pasted from the static analyzer tool, which will vanish soon.

Change-Id: Ibbdd402b66af35b268896eff420bd1c6597d9ced
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Nikolai Kosjar
2018-05-08 17:02:40 +02:00
parent de751e5b69
commit 92ea3c93af
2 changed files with 24 additions and 2 deletions

View File

@@ -30,6 +30,7 @@
#include "clangtoolsdiagnosticmodel.h" #include "clangtoolsdiagnosticmodel.h"
#include "clangtoolslogfilereader.h" #include "clangtoolslogfilereader.h"
#include "clangtidyclazyruncontrol.h" #include "clangtidyclazyruncontrol.h"
#include "clangstaticanalyzerdiagnosticview.h"
#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/actionmanager.h>
@@ -64,12 +65,27 @@ ClangTidyClazyTool::ClangTidyClazyTool()
setObjectName("ClangTidyClazyTool"); setObjectName("ClangTidyClazyTool");
s_instance = this; s_instance = this;
m_diagnosticView = new Debugger::DetailedErrorView; m_diagnosticFilterModel = new ClangStaticAnalyzerDiagnosticFilterModel(this);
m_diagnosticFilterModel->setSourceModel(m_diagnosticModel);
m_diagnosticView = new ClangStaticAnalyzerDiagnosticView;
initDiagnosticView(); initDiagnosticView();
m_diagnosticView->setModel(m_diagnosticModel); m_diagnosticView->setModel(m_diagnosticFilterModel);
m_diagnosticView->setObjectName(QLatin1String("ClangTidyClazyIssuesView")); m_diagnosticView->setObjectName(QLatin1String("ClangTidyClazyIssuesView"));
m_diagnosticView->setWindowTitle(tr("Clang-Tidy and Clazy Issues")); m_diagnosticView->setWindowTitle(tr("Clang-Tidy and Clazy Issues"));
foreach (auto * const model,
QList<QAbstractItemModel *>() << m_diagnosticModel << m_diagnosticFilterModel) {
connect(model, &QAbstractItemModel::rowsInserted,
this, &ClangTidyClazyTool::handleStateUpdate);
connect(model, &QAbstractItemModel::rowsRemoved,
this, &ClangTidyClazyTool::handleStateUpdate);
connect(model, &QAbstractItemModel::modelReset,
this, &ClangTidyClazyTool::handleStateUpdate);
connect(model, &QAbstractItemModel::layoutChanged, // For QSortFilterProxyModel::invalidate()
this, &ClangTidyClazyTool::handleStateUpdate);
}
ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER); ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER);
const QString toolTip = tr("Clang-Tidy and Clazy use a customized Clang executable from the " const QString toolTip = tr("Clang-Tidy and Clazy use a customized Clang executable from the "
"Clang project to search for errors and warnings."); "Clang project to search for errors and warnings.");
@@ -141,6 +157,7 @@ void ClangTidyClazyTool::startTool(bool askUserForFileSelection)
m_diagnosticModel->clear(); m_diagnosticModel->clear();
setToolBusy(true); setToolBusy(true);
m_diagnosticFilterModel->setProject(project);
m_running = true; m_running = true;
handleStateUpdate(); handleStateUpdate();
updateRunActions(); updateRunActions();

View File

@@ -30,9 +30,12 @@
namespace ClangTools { namespace ClangTools {
namespace Internal { namespace Internal {
class ClangStaticAnalyzerDiagnosticFilterModel;
const char ClangTidyClazyPerspectiveId[] = "ClangTidyClazy.Perspective"; const char ClangTidyClazyPerspectiveId[] = "ClangTidyClazy.Perspective";
const char ClangTidyClazyDockId[] = "ClangTidyClazy.Dock"; const char ClangTidyClazyDockId[] = "ClangTidyClazy.Dock";
// TODO: Add "go next" and "go previous" button like for the static analyzer
class ClangTidyClazyTool final : public ClangTool class ClangTidyClazyTool final : public ClangTool
{ {
Q_OBJECT Q_OBJECT
@@ -52,6 +55,8 @@ private:
void handleStateUpdate() final; void handleStateUpdate() final;
void updateRunActions(); void updateRunActions();
ClangStaticAnalyzerDiagnosticFilterModel *m_diagnosticFilterModel = nullptr;
}; };
} // namespace Internal } // namespace Internal