forked from qt-creator/qt-creator
ClangTools: Move CSA's project settings into ClangToolsProjectSettings
Change-Id: I830c280e718aae416cd487eb5d02caf1e873f7c1 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -26,8 +26,7 @@
|
|||||||
#include "clangstaticanalyzerdiagnosticview.h"
|
#include "clangstaticanalyzerdiagnosticview.h"
|
||||||
|
|
||||||
#include "clangtoolsdiagnosticmodel.h"
|
#include "clangtoolsdiagnosticmodel.h"
|
||||||
#include "clangstaticanalyzerprojectsettings.h"
|
#include "clangtoolsprojectsettings.h"
|
||||||
#include "clangstaticanalyzerprojectsettingsmanager.h"
|
|
||||||
#include "clangtoolsutils.h"
|
#include "clangtoolsutils.h"
|
||||||
|
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
@@ -70,7 +69,7 @@ void ClangStaticAnalyzerDiagnosticView::suppressCurrentDiagnostic()
|
|||||||
filePath = relativeFilePath;
|
filePath = relativeFilePath;
|
||||||
const SuppressedDiagnostic supDiag(filePath, diag.description, diag.issueContextKind,
|
const SuppressedDiagnostic supDiag(filePath, diag.description, diag.issueContextKind,
|
||||||
diag.issueContext, diag.explainingSteps.count());
|
diag.issueContext, diag.explainingSteps.count());
|
||||||
ProjectSettingsManager::getSettings(project)->addSuppressedDiagnostic(supDiag);
|
ClangToolsProjectSettingsManager::getSettings(project)->addSuppressedDiagnostic(supDiag);
|
||||||
} else {
|
} else {
|
||||||
filterModel->addSuppressedDiagnostic(SuppressedDiagnostic(diag));
|
filterModel->addSuppressedDiagnostic(SuppressedDiagnostic(diag));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,145 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "clangstaticanalyzerprojectsettings.h"
|
|
||||||
|
|
||||||
#include "clangtoolsdiagnostic.h"
|
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
namespace ClangTools {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
static QString suppressedDiagnosticsKey()
|
|
||||||
{
|
|
||||||
return QLatin1String("ClangStaticAnalyzer.SuppressedDiagnostics");
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString suppressedDiagnosticFilePathKey()
|
|
||||||
{
|
|
||||||
return QLatin1String("ClangStaticAnalyzer.SuppressedDiagnosticFilePath");
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString suppressedDiagnosticMessageKey()
|
|
||||||
{
|
|
||||||
return QLatin1String("ClangStaticAnalyzer.SuppressedDiagnosticMessage");
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString suppressedDiagnosticContextKindKey()
|
|
||||||
{
|
|
||||||
return QLatin1String("ClangStaticAnalyzer.SuppressedDiagnosticContextKind");
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString suppressedDiagnosticContextKey()
|
|
||||||
{
|
|
||||||
return QLatin1String("ClangStaticAnalyzer.SuppressedDiagnosticContext");
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString suppressedDiagnosticUniquifierKey()
|
|
||||||
{
|
|
||||||
return QLatin1String("ClangStaticAnalyzer.SuppressedDiagnosticUniquifier");
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectSettings::ProjectSettings(ProjectExplorer::Project *project) : m_project(project)
|
|
||||||
{
|
|
||||||
load();
|
|
||||||
connect(project, &ProjectExplorer::Project::aboutToSaveSettings, this,
|
|
||||||
&ProjectSettings::store);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectSettings::addSuppressedDiagnostic(const SuppressedDiagnostic &diag)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(!m_suppressedDiagnostics.contains(diag), return);
|
|
||||||
m_suppressedDiagnostics << diag;
|
|
||||||
emit suppressedDiagnosticsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectSettings::removeSuppressedDiagnostic(const SuppressedDiagnostic &diag)
|
|
||||||
{
|
|
||||||
const bool wasPresent = m_suppressedDiagnostics.removeOne(diag);
|
|
||||||
QTC_ASSERT(wasPresent, return);
|
|
||||||
emit suppressedDiagnosticsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectSettings::removeAllSuppressedDiagnostics()
|
|
||||||
{
|
|
||||||
m_suppressedDiagnostics.clear();
|
|
||||||
emit suppressedDiagnosticsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectSettings::load()
|
|
||||||
{
|
|
||||||
const QVariantList list = m_project->namedSettings(suppressedDiagnosticsKey()).toList();
|
|
||||||
foreach (const QVariant &v, list) {
|
|
||||||
const QVariantMap diag = v.toMap();
|
|
||||||
const QString fp = diag.value(suppressedDiagnosticFilePathKey()).toString();
|
|
||||||
if (fp.isEmpty())
|
|
||||||
continue;
|
|
||||||
const QString message = diag.value(suppressedDiagnosticMessageKey()).toString();
|
|
||||||
if (message.isEmpty())
|
|
||||||
continue;
|
|
||||||
Utils::FileName fullPath = Utils::FileName::fromString(fp);
|
|
||||||
if (fullPath.toFileInfo().isRelative()) {
|
|
||||||
fullPath = m_project->projectDirectory();
|
|
||||||
fullPath.appendPath(fp);
|
|
||||||
}
|
|
||||||
if (!fullPath.exists())
|
|
||||||
continue;
|
|
||||||
const QString contextKind = diag.value(suppressedDiagnosticContextKindKey()).toString();
|
|
||||||
const QString context = diag.value(suppressedDiagnosticContextKey()).toString();
|
|
||||||
const int uniquifier = diag.value(suppressedDiagnosticUniquifierKey()).toInt();
|
|
||||||
m_suppressedDiagnostics << SuppressedDiagnostic(Utils::FileName::fromString(fp), message,
|
|
||||||
contextKind, context, uniquifier);
|
|
||||||
}
|
|
||||||
emit suppressedDiagnosticsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectSettings::store()
|
|
||||||
{
|
|
||||||
QVariantList list;
|
|
||||||
foreach (const SuppressedDiagnostic &diag, m_suppressedDiagnostics) {
|
|
||||||
QVariantMap diagMap;
|
|
||||||
diagMap.insert(suppressedDiagnosticFilePathKey(), diag.filePath.toString());
|
|
||||||
diagMap.insert(suppressedDiagnosticMessageKey(), diag.description);
|
|
||||||
diagMap.insert(suppressedDiagnosticContextKindKey(), diag.contextKind);
|
|
||||||
diagMap.insert(suppressedDiagnosticContextKey(), diag.context);
|
|
||||||
diagMap.insert(suppressedDiagnosticUniquifierKey(), diag.uniquifier);
|
|
||||||
list << diagMap;
|
|
||||||
}
|
|
||||||
m_project->setNamedSettings(suppressedDiagnosticsKey(), list);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SuppressedDiagnostic::SuppressedDiagnostic(const Diagnostic &diag)
|
|
||||||
: filePath(Utils::FileName::fromString(diag.location.filePath))
|
|
||||||
, description(diag.description)
|
|
||||||
, contextKind(diag.issueContextKind)
|
|
||||||
, context(diag.issueContext)
|
|
||||||
, uniquifier(diag.explainingSteps.count())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace ClangTools
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
|
||||||
#include <utils/fileutils.h>
|
|
||||||
|
|
||||||
#include <QList>
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
namespace ClangTools {
|
|
||||||
namespace Internal {
|
|
||||||
class Diagnostic;
|
|
||||||
|
|
||||||
class SuppressedDiagnostic
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SuppressedDiagnostic(const Utils::FileName &filePath, const QString &description,
|
|
||||||
const QString &contextKind, const QString &context, int uniquifier)
|
|
||||||
: filePath(filePath)
|
|
||||||
, description(description)
|
|
||||||
, contextKind(contextKind)
|
|
||||||
, context(context)
|
|
||||||
, uniquifier(uniquifier)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
SuppressedDiagnostic(const Diagnostic &diag);
|
|
||||||
|
|
||||||
Utils::FileName filePath; // Relative for files in project, absolute otherwise.
|
|
||||||
QString description;
|
|
||||||
QString contextKind;
|
|
||||||
QString context;
|
|
||||||
int uniquifier;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool operator==(const SuppressedDiagnostic &d1, const SuppressedDiagnostic &d2)
|
|
||||||
{
|
|
||||||
return d1.filePath == d2.filePath && d1.description == d2.description
|
|
||||||
&& d1.contextKind == d2.contextKind && d1.context == d2.context
|
|
||||||
&& d1.uniquifier == d2.uniquifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef QList<SuppressedDiagnostic> SuppressedDiagnosticsList;
|
|
||||||
|
|
||||||
class ProjectSettings : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
ProjectSettings(ProjectExplorer::Project *project);
|
|
||||||
|
|
||||||
SuppressedDiagnosticsList suppressedDiagnostics() const { return m_suppressedDiagnostics; }
|
|
||||||
void addSuppressedDiagnostic(const SuppressedDiagnostic &diag);
|
|
||||||
void removeSuppressedDiagnostic(const SuppressedDiagnostic &diag);
|
|
||||||
void removeAllSuppressedDiagnostics();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void suppressedDiagnosticsChanged();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void load();
|
|
||||||
void store();
|
|
||||||
|
|
||||||
ProjectExplorer::Project * const m_project;
|
|
||||||
SuppressedDiagnosticsList m_suppressedDiagnostics;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace ClangTools
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "clangstaticanalyzerprojectsettingsmanager.h"
|
|
||||||
|
|
||||||
#include "clangstaticanalyzerprojectsettings.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/session.h>
|
|
||||||
|
|
||||||
namespace ClangTools {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
ProjectSettingsManager::ProjectSettingsManager()
|
|
||||||
{
|
|
||||||
QObject::connect(ProjectExplorer::SessionManager::instance(),
|
|
||||||
&ProjectExplorer::SessionManager::aboutToRemoveProject,
|
|
||||||
&ProjectSettingsManager::handleProjectToBeRemoved);
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectSettings *ProjectSettingsManager::getSettings(ProjectExplorer::Project *project)
|
|
||||||
{
|
|
||||||
auto &settings = m_settings[project];
|
|
||||||
if (!settings)
|
|
||||||
settings.reset(new ProjectSettings(project));
|
|
||||||
return settings.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectSettingsManager::handleProjectToBeRemoved(ProjectExplorer::Project *project)
|
|
||||||
{
|
|
||||||
m_settings.remove(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectSettingsManager::SettingsMap ProjectSettingsManager::m_settings;
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace ClangTools
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace ProjectExplorer { class Project; }
|
|
||||||
|
|
||||||
#include <QHash>
|
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
namespace ClangTools {
|
|
||||||
namespace Internal {
|
|
||||||
class ProjectSettings;
|
|
||||||
|
|
||||||
class ProjectSettingsManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProjectSettingsManager();
|
|
||||||
|
|
||||||
static ProjectSettings *getSettings(ProjectExplorer::Project *project);
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void handleProjectToBeRemoved(ProjectExplorer::Project *project);
|
|
||||||
|
|
||||||
typedef QHash<ProjectExplorer::Project *, QSharedPointer<ProjectSettings>> SettingsMap;
|
|
||||||
static SettingsMap m_settings;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace ClangTools
|
|
||||||
@@ -26,8 +26,7 @@
|
|||||||
#include "clangstaticanalyzerprojectsettingswidget.h"
|
#include "clangstaticanalyzerprojectsettingswidget.h"
|
||||||
#include "ui_clangstaticanalyzerprojectsettingswidget.h"
|
#include "ui_clangstaticanalyzerprojectsettingswidget.h"
|
||||||
|
|
||||||
#include "clangstaticanalyzerprojectsettings.h"
|
#include "clangtoolsprojectsettings.h"
|
||||||
#include "clangstaticanalyzerprojectsettingsmanager.h"
|
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -59,12 +58,12 @@ private:
|
|||||||
ProjectSettingsWidget::ProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent) :
|
ProjectSettingsWidget::ProjectSettingsWidget(ProjectExplorer::Project *project, QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
m_ui(new Ui::ProjectSettingsWidget)
|
m_ui(new Ui::ProjectSettingsWidget)
|
||||||
, m_projectSettings(ProjectSettingsManager::getSettings(project))
|
, m_projectSettings(ClangToolsProjectSettingsManager::getSettings(project))
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
auto * const model = new SuppressedDiagnosticsModel(this);
|
auto * const model = new SuppressedDiagnosticsModel(this);
|
||||||
model->setDiagnostics(m_projectSettings->suppressedDiagnostics());
|
model->setDiagnostics(m_projectSettings->suppressedDiagnostics());
|
||||||
connect(m_projectSettings, &ProjectSettings::suppressedDiagnosticsChanged,
|
connect(m_projectSettings, &ClangToolsProjectSettings::suppressedDiagnosticsChanged,
|
||||||
[model, this] {
|
[model, this] {
|
||||||
model->setDiagnostics(m_projectSettings->suppressedDiagnostics());
|
model->setDiagnostics(m_projectSettings->suppressedDiagnostics());
|
||||||
updateButtonStates();
|
updateButtonStates();
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace ProjectExplorer { class Project; }
|
|||||||
|
|
||||||
namespace ClangTools {
|
namespace ClangTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class ProjectSettings;
|
class ClangToolsProjectSettings;
|
||||||
|
|
||||||
namespace Ui { class ProjectSettingsWidget; }
|
namespace Ui { class ProjectSettingsWidget; }
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ private:
|
|||||||
void removeSelected();
|
void removeSelected();
|
||||||
|
|
||||||
Ui::ProjectSettingsWidget * const m_ui;
|
Ui::ProjectSettingsWidget * const m_ui;
|
||||||
ProjectSettings * const m_projectSettings;
|
ClangToolsProjectSettings * const m_projectSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ INCLUDEPATH += $$LLVM_INCLUDEPATH
|
|||||||
SOURCES += \
|
SOURCES += \
|
||||||
clangselectablefilesdialog.cpp \
|
clangselectablefilesdialog.cpp \
|
||||||
clangstaticanalyzerdiagnosticview.cpp \
|
clangstaticanalyzerdiagnosticview.cpp \
|
||||||
clangstaticanalyzerprojectsettings.cpp \
|
|
||||||
clangstaticanalyzerprojectsettingsmanager.cpp \
|
|
||||||
clangstaticanalyzerprojectsettingswidget.cpp \
|
clangstaticanalyzerprojectsettingswidget.cpp \
|
||||||
clangstaticanalyzerruncontrol.cpp \
|
clangstaticanalyzerruncontrol.cpp \
|
||||||
clangstaticanalyzerrunner.cpp \
|
clangstaticanalyzerrunner.cpp \
|
||||||
@@ -36,8 +34,6 @@ HEADERS += \
|
|||||||
clangfileinfo.h \
|
clangfileinfo.h \
|
||||||
clangselectablefilesdialog.h \
|
clangselectablefilesdialog.h \
|
||||||
clangstaticanalyzerdiagnosticview.h \
|
clangstaticanalyzerdiagnosticview.h \
|
||||||
clangstaticanalyzerprojectsettings.h \
|
|
||||||
clangstaticanalyzerprojectsettingsmanager.h \
|
|
||||||
clangstaticanalyzerprojectsettingswidget.h \
|
clangstaticanalyzerprojectsettingswidget.h \
|
||||||
clangstaticanalyzerruncontrol.h \
|
clangstaticanalyzerruncontrol.h \
|
||||||
clangstaticanalyzerrunner.h \
|
clangstaticanalyzerrunner.h \
|
||||||
|
|||||||
@@ -47,10 +47,6 @@ QtcPlugin {
|
|||||||
"clangselectablefilesdialog.ui",
|
"clangselectablefilesdialog.ui",
|
||||||
"clangstaticanalyzerdiagnosticview.cpp",
|
"clangstaticanalyzerdiagnosticview.cpp",
|
||||||
"clangstaticanalyzerdiagnosticview.h",
|
"clangstaticanalyzerdiagnosticview.h",
|
||||||
"clangstaticanalyzerprojectsettings.cpp",
|
|
||||||
"clangstaticanalyzerprojectsettings.h",
|
|
||||||
"clangstaticanalyzerprojectsettingsmanager.cpp",
|
|
||||||
"clangstaticanalyzerprojectsettingsmanager.h",
|
|
||||||
"clangstaticanalyzerprojectsettingswidget.cpp",
|
"clangstaticanalyzerprojectsettingswidget.cpp",
|
||||||
"clangstaticanalyzerprojectsettingswidget.h",
|
"clangstaticanalyzerprojectsettingswidget.h",
|
||||||
"clangstaticanalyzerprojectsettingswidget.ui",
|
"clangstaticanalyzerprojectsettingswidget.ui",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include "clangtoolsdiagnosticmodel.h"
|
#include "clangtoolsdiagnosticmodel.h"
|
||||||
|
|
||||||
#include "clangstaticanalyzerdiagnosticview.h"
|
#include "clangstaticanalyzerdiagnosticview.h"
|
||||||
#include "clangstaticanalyzerprojectsettingsmanager.h"
|
#include "clangtoolsprojectsettings.h"
|
||||||
#include "clangtoolsutils.h"
|
#include "clangtoolsutils.h"
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
@@ -323,14 +323,14 @@ void ClangStaticAnalyzerDiagnosticFilterModel::setProject(ProjectExplorer::Proje
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(project, return);
|
QTC_ASSERT(project, return);
|
||||||
if (m_project) {
|
if (m_project) {
|
||||||
disconnect(ProjectSettingsManager::getSettings(m_project),
|
disconnect(ClangToolsProjectSettingsManager::getSettings(m_project),
|
||||||
&ProjectSettings::suppressedDiagnosticsChanged, this,
|
&ClangToolsProjectSettings::suppressedDiagnosticsChanged, this,
|
||||||
&ClangStaticAnalyzerDiagnosticFilterModel::handleSuppressedDiagnosticsChanged);
|
&ClangStaticAnalyzerDiagnosticFilterModel::handleSuppressedDiagnosticsChanged);
|
||||||
}
|
}
|
||||||
m_project = project;
|
m_project = project;
|
||||||
m_lastProjectDirectory = m_project->projectDirectory();
|
m_lastProjectDirectory = m_project->projectDirectory();
|
||||||
connect(ProjectSettingsManager::getSettings(m_project),
|
connect(ClangToolsProjectSettingsManager::getSettings(m_project),
|
||||||
&ProjectSettings::suppressedDiagnosticsChanged,
|
&ClangToolsProjectSettings::suppressedDiagnosticsChanged,
|
||||||
this, &ClangStaticAnalyzerDiagnosticFilterModel::handleSuppressedDiagnosticsChanged);
|
this, &ClangStaticAnalyzerDiagnosticFilterModel::handleSuppressedDiagnosticsChanged);
|
||||||
handleSuppressedDiagnosticsChanged();
|
handleSuppressedDiagnosticsChanged();
|
||||||
}
|
}
|
||||||
@@ -367,7 +367,7 @@ void ClangStaticAnalyzerDiagnosticFilterModel::handleSuppressedDiagnosticsChange
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(m_project, return);
|
QTC_ASSERT(m_project, return);
|
||||||
m_suppressedDiagnostics
|
m_suppressedDiagnostics
|
||||||
= ProjectSettingsManager::getSettings(m_project)->suppressedDiagnostics();
|
= ClangToolsProjectSettingsManager::getSettings(m_project)->suppressedDiagnostics();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "clangtoolsdiagnostic.h"
|
#include "clangtoolsdiagnostic.h"
|
||||||
#include "clangstaticanalyzerprojectsettings.h"
|
#include "clangtoolsprojectsettings.h"
|
||||||
|
|
||||||
#include <debugger/analyzer/detailederrorview.h>
|
#include <debugger/analyzer/detailederrorview.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|||||||
@@ -24,16 +24,24 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "clangtoolsprojectsettings.h"
|
#include "clangtoolsprojectsettings.h"
|
||||||
|
#include "clangtoolsdiagnostic.h"
|
||||||
|
|
||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
namespace ClangTools {
|
namespace ClangTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static const char SETTINGS_KEY_SELECTED_DIRS[] = "ClangTools.SelectedDirs";
|
static const char SETTINGS_KEY_SELECTED_DIRS[] = "ClangTools.SelectedDirs";
|
||||||
static const char SETTINGS_KEY_SELECTED_FILES[] = "ClangTools.SelectedFiles";
|
static const char SETTINGS_KEY_SELECTED_FILES[] = "ClangTools.SelectedFiles";
|
||||||
|
static const char SETTINGS_KEY_SUPPRESSED_DIAGS[] = "ClangTools.SuppressedDiagnostics";
|
||||||
|
static const char SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH[] = "ClangTools.SuppressedDiagnosticFilePath";
|
||||||
|
static const char SETTINGS_KEY_SUPPRESSED_DIAGS_MESSAGE[] = "ClangTools.SuppressedDiagnosticMessage";
|
||||||
|
static const char SETTINGS_KEY_SUPPRESSED_DIAGS_CONTEXTKIND[] = "ClangTools.SuppressedDiagnosticContextKind";
|
||||||
|
static const char SETTINGS_KEY_SUPPRESSED_DIAGS_CONTEXT[] = "ClangTools.SuppressedDiagnosticContext";
|
||||||
|
static const char SETTINGS_KEY_SUPPRESSED_DIAGS_UNIQIFIER[] = "ClangTools.SuppressedDiagnosticUniquifier";
|
||||||
|
|
||||||
ClangToolsProjectSettings::ClangToolsProjectSettings(ProjectExplorer::Project *project)
|
ClangToolsProjectSettings::ClangToolsProjectSettings(ProjectExplorer::Project *project)
|
||||||
: m_project(project)
|
: m_project(project)
|
||||||
@@ -50,6 +58,26 @@ ClangToolsProjectSettings::~ClangToolsProjectSettings()
|
|||||||
store();
|
store();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClangToolsProjectSettings::addSuppressedDiagnostic(const SuppressedDiagnostic &diag)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(!m_suppressedDiagnostics.contains(diag), return);
|
||||||
|
m_suppressedDiagnostics << diag;
|
||||||
|
emit suppressedDiagnosticsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClangToolsProjectSettings::removeSuppressedDiagnostic(const SuppressedDiagnostic &diag)
|
||||||
|
{
|
||||||
|
const bool wasPresent = m_suppressedDiagnostics.removeOne(diag);
|
||||||
|
QTC_ASSERT(wasPresent, return);
|
||||||
|
emit suppressedDiagnosticsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClangToolsProjectSettings::removeAllSuppressedDiagnostics()
|
||||||
|
{
|
||||||
|
m_suppressedDiagnostics.clear();
|
||||||
|
emit suppressedDiagnosticsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void ClangToolsProjectSettings::load()
|
void ClangToolsProjectSettings::load()
|
||||||
{
|
{
|
||||||
auto toFileName = [](const QString &s) { return Utils::FileName::fromString(s); };
|
auto toFileName = [](const QString &s) { return Utils::FileName::fromString(s); };
|
||||||
@@ -59,6 +87,30 @@ void ClangToolsProjectSettings::load()
|
|||||||
|
|
||||||
const QStringList files = m_project->namedSettings(SETTINGS_KEY_SELECTED_FILES).toStringList();
|
const QStringList files = m_project->namedSettings(SETTINGS_KEY_SELECTED_FILES).toStringList();
|
||||||
m_selectedFiles = Utils::transform<QSet>(files, toFileName);
|
m_selectedFiles = Utils::transform<QSet>(files, toFileName);
|
||||||
|
|
||||||
|
const QVariantList list = m_project->namedSettings(SETTINGS_KEY_SUPPRESSED_DIAGS).toList();
|
||||||
|
foreach (const QVariant &v, list) {
|
||||||
|
const QVariantMap diag = v.toMap();
|
||||||
|
const QString fp = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH).toString();
|
||||||
|
if (fp.isEmpty())
|
||||||
|
continue;
|
||||||
|
const QString message = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_MESSAGE).toString();
|
||||||
|
if (message.isEmpty())
|
||||||
|
continue;
|
||||||
|
Utils::FileName fullPath = Utils::FileName::fromString(fp);
|
||||||
|
if (fullPath.toFileInfo().isRelative()) {
|
||||||
|
fullPath = m_project->projectDirectory();
|
||||||
|
fullPath.appendPath(fp);
|
||||||
|
}
|
||||||
|
if (!fullPath.exists())
|
||||||
|
continue;
|
||||||
|
const QString contextKind = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_CONTEXTKIND).toString();
|
||||||
|
const QString context = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_CONTEXT).toString();
|
||||||
|
const int uniquifier = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_UNIQIFIER).toInt();
|
||||||
|
m_suppressedDiagnostics << SuppressedDiagnostic(Utils::FileName::fromString(fp), message,
|
||||||
|
contextKind, context, uniquifier);
|
||||||
|
}
|
||||||
|
emit suppressedDiagnosticsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangToolsProjectSettings::store()
|
void ClangToolsProjectSettings::store()
|
||||||
@@ -68,6 +120,18 @@ void ClangToolsProjectSettings::store()
|
|||||||
|
|
||||||
const QStringList files = Utils::transform(m_selectedFiles.toList(), &Utils::FileName::toString);
|
const QStringList files = Utils::transform(m_selectedFiles.toList(), &Utils::FileName::toString);
|
||||||
m_project->setNamedSettings(SETTINGS_KEY_SELECTED_FILES, files);
|
m_project->setNamedSettings(SETTINGS_KEY_SELECTED_FILES, files);
|
||||||
|
|
||||||
|
QVariantList list;
|
||||||
|
foreach (const SuppressedDiagnostic &diag, m_suppressedDiagnostics) {
|
||||||
|
QVariantMap diagMap;
|
||||||
|
diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH, diag.filePath.toString());
|
||||||
|
diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_MESSAGE, diag.description);
|
||||||
|
diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_CONTEXTKIND, diag.contextKind);
|
||||||
|
diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_CONTEXT, diag.context);
|
||||||
|
diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_UNIQIFIER, diag.uniquifier);
|
||||||
|
list << diagMap;
|
||||||
|
}
|
||||||
|
m_project->setNamedSettings(SETTINGS_KEY_SUPPRESSED_DIAGS, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClangToolsProjectSettingsManager::ClangToolsProjectSettingsManager()
|
ClangToolsProjectSettingsManager::ClangToolsProjectSettingsManager()
|
||||||
@@ -93,5 +157,14 @@ void ClangToolsProjectSettingsManager::handleProjectToBeRemoved(ProjectExplorer:
|
|||||||
|
|
||||||
ClangToolsProjectSettingsManager::SettingsMap ClangToolsProjectSettingsManager::m_settings;
|
ClangToolsProjectSettingsManager::SettingsMap ClangToolsProjectSettingsManager::m_settings;
|
||||||
|
|
||||||
|
SuppressedDiagnostic::SuppressedDiagnostic(const Diagnostic &diag)
|
||||||
|
: filePath(Utils::FileName::fromString(diag.location.filePath))
|
||||||
|
, description(diag.description)
|
||||||
|
, contextKind(diag.issueContextKind)
|
||||||
|
, context(diag.issueContext)
|
||||||
|
, uniquifier(diag.explainingSteps.count())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ClangTools
|
} // namespace ClangTools
|
||||||
|
|||||||
@@ -33,8 +33,39 @@
|
|||||||
|
|
||||||
namespace ClangTools {
|
namespace ClangTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
class Diagnostic;
|
||||||
|
|
||||||
|
class SuppressedDiagnostic
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SuppressedDiagnostic(const Utils::FileName &filePath, const QString &description,
|
||||||
|
const QString &contextKind, const QString &context, int uniquifier)
|
||||||
|
: filePath(filePath)
|
||||||
|
, description(description)
|
||||||
|
, contextKind(contextKind)
|
||||||
|
, context(context)
|
||||||
|
, uniquifier(uniquifier)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SuppressedDiagnostic(const Diagnostic &diag);
|
||||||
|
|
||||||
|
Utils::FileName filePath; // Relative for files in project, absolute otherwise.
|
||||||
|
QString description;
|
||||||
|
QString contextKind;
|
||||||
|
QString context;
|
||||||
|
int uniquifier;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator==(const SuppressedDiagnostic &d1, const SuppressedDiagnostic &d2)
|
||||||
|
{
|
||||||
|
return d1.filePath == d2.filePath && d1.description == d2.description
|
||||||
|
&& d1.contextKind == d2.contextKind && d1.context == d2.context
|
||||||
|
&& d1.uniquifier == d2.uniquifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef QList<SuppressedDiagnostic> SuppressedDiagnosticsList;
|
||||||
|
|
||||||
// TODO: Incorporate Clang Static Analyzer's ProjectSettings
|
|
||||||
class ClangToolsProjectSettings : public QObject
|
class ClangToolsProjectSettings : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -49,6 +80,14 @@ public:
|
|||||||
QSet<Utils::FileName> selectedFiles() const { return m_selectedFiles; }
|
QSet<Utils::FileName> selectedFiles() const { return m_selectedFiles; }
|
||||||
void setSelectedFiles(const QSet<Utils::FileName> &value) { m_selectedFiles = value; }
|
void setSelectedFiles(const QSet<Utils::FileName> &value) { m_selectedFiles = value; }
|
||||||
|
|
||||||
|
SuppressedDiagnosticsList suppressedDiagnostics() const { return m_suppressedDiagnostics; }
|
||||||
|
void addSuppressedDiagnostic(const SuppressedDiagnostic &diag);
|
||||||
|
void removeSuppressedDiagnostic(const SuppressedDiagnostic &diag);
|
||||||
|
void removeAllSuppressedDiagnostics();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void suppressedDiagnosticsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void load();
|
void load();
|
||||||
void store();
|
void store();
|
||||||
@@ -56,9 +95,9 @@ private:
|
|||||||
ProjectExplorer::Project *m_project;
|
ProjectExplorer::Project *m_project;
|
||||||
QSet<Utils::FileName> m_selectedDirs;
|
QSet<Utils::FileName> m_selectedDirs;
|
||||||
QSet<Utils::FileName> m_selectedFiles;
|
QSet<Utils::FileName> m_selectedFiles;
|
||||||
|
SuppressedDiagnosticsList m_suppressedDiagnostics;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Incorporate Clang Static Analyzer's ProjectSettingsManager
|
|
||||||
class ClangToolsProjectSettingsManager
|
class ClangToolsProjectSettingsManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user