forked from qt-creator/qt-creator
ClangTools: Add using for QList<Diagnostics>
Change-Id: Ie7978fc33386d083b786ad75b3b6700125b11fec Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -463,15 +463,15 @@ void ClangTidyClazyTool::handleStateUpdate()
|
|||||||
Debugger::showPermanentStatusMessage(message);
|
Debugger::showPermanentStatusMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Diagnostic> ClangTidyClazyTool::read(const QString &filePath,
|
Diagnostics ClangTidyClazyTool::read(const QString &filePath,
|
||||||
const QSet<Utils::FilePath> &projectFiles,
|
const QSet<Utils::FilePath> &projectFiles,
|
||||||
const QString &logFilePath,
|
const QString &logFilePath,
|
||||||
QString *errorMessage) const
|
QString *errorMessage) const
|
||||||
{
|
{
|
||||||
return readSerializedDiagnostics(filePath, projectFiles, logFilePath, errorMessage);
|
return readSerializedDiagnostics(filePath, projectFiles, logFilePath, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangTidyClazyTool::onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics)
|
void ClangTidyClazyTool::onNewDiagnosticsAvailable(const Diagnostics &diagnostics)
|
||||||
{
|
{
|
||||||
ClangTool::onNewDiagnosticsAvailable(diagnostics);
|
ClangTool::onNewDiagnosticsAvailable(diagnostics);
|
||||||
if (!m_diagnosticFilterModel->filterRegExp().pattern().isEmpty())
|
if (!m_diagnosticFilterModel->filterRegExp().pattern().isEmpty())
|
||||||
|
@@ -53,12 +53,12 @@ public:
|
|||||||
|
|
||||||
void startTool(bool askUserForFileSelection) final;
|
void startTool(bool askUserForFileSelection) final;
|
||||||
|
|
||||||
QList<Diagnostic> read(const QString &filePath,
|
Diagnostics read(const QString &filePath,
|
||||||
const QSet<Utils::FilePath> &projectFiles,
|
const QSet<Utils::FilePath> &projectFiles,
|
||||||
const QString &logFilePath,
|
const QString &logFilePath,
|
||||||
QString *errorMessage) const final;
|
QString *errorMessage) const final;
|
||||||
|
|
||||||
void onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics) override;
|
void onNewDiagnosticsAvailable(const Diagnostics &diagnostics) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handleStateUpdate() final;
|
void handleStateUpdate() final;
|
||||||
|
@@ -144,7 +144,7 @@ QSet<Diagnostic> ClangTool::diagnostics() const
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangTool::onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics)
|
void ClangTool::onNewDiagnosticsAvailable(const Diagnostics &diagnostics)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_diagnosticModel, return);
|
QTC_ASSERT(m_diagnosticModel, return);
|
||||||
m_diagnosticModel->addDiagnostics(diagnostics);
|
m_diagnosticModel->addDiagnostics(diagnostics);
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "clangfileinfo.h"
|
#include "clangfileinfo.h"
|
||||||
|
#include "clangtoolsdiagnostic.h"
|
||||||
|
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
#include <cpptools/projectinfo.h>
|
#include <cpptools/projectinfo.h>
|
||||||
@@ -49,10 +50,10 @@ public:
|
|||||||
|
|
||||||
virtual void startTool(bool askUserForFileSelection) = 0;
|
virtual void startTool(bool askUserForFileSelection) = 0;
|
||||||
|
|
||||||
virtual QList<Diagnostic> read(const QString &filePath,
|
virtual Diagnostics read(const QString &filePath,
|
||||||
const QSet<Utils::FilePath> &projectFiles,
|
const QSet<Utils::FilePath> &projectFiles,
|
||||||
const QString &logFilePath,
|
const QString &logFilePath,
|
||||||
QString *errorMessage) const = 0;
|
QString *errorMessage) const = 0;
|
||||||
|
|
||||||
FileInfos collectFileInfos(ProjectExplorer::Project *project,
|
FileInfos collectFileInfos(ProjectExplorer::Project *project,
|
||||||
bool askUserForFileSelection) const;
|
bool askUserForFileSelection) const;
|
||||||
@@ -62,7 +63,7 @@ public:
|
|||||||
|
|
||||||
const QString &name() const;
|
const QString &name() const;
|
||||||
|
|
||||||
virtual void onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics);
|
virtual void onNewDiagnosticsAvailable(const Diagnostics &diagnostics);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished(bool success); // For testing.
|
void finished(bool success); // For testing.
|
||||||
|
@@ -398,10 +398,10 @@ void ClangToolRunControl::onRunnerFinishedWithSuccess(const QString &filePath)
|
|||||||
qCDebug(LOG) << "onRunnerFinishedWithSuccess:" << logFilePath;
|
qCDebug(LOG) << "onRunnerFinishedWithSuccess:" << logFilePath;
|
||||||
|
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
const QList<Diagnostic> diagnostics = tool()->read(filePath,
|
const Diagnostics diagnostics = tool()->read(filePath,
|
||||||
m_projectFiles,
|
m_projectFiles,
|
||||||
logFilePath,
|
logFilePath,
|
||||||
&errorMessage);
|
&errorMessage);
|
||||||
QFile::remove(logFilePath); // Clean-up.
|
QFile::remove(logFilePath); // Clean-up.
|
||||||
|
|
||||||
if (!errorMessage.isEmpty()) {
|
if (!errorMessage.isEmpty()) {
|
||||||
|
@@ -62,6 +62,8 @@ public:
|
|||||||
bool hasFixits = false;
|
bool hasFixits = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using Diagnostics = QList<Diagnostic>;
|
||||||
|
|
||||||
quint32 qHash(const Diagnostic &diagnostic);
|
quint32 qHash(const Diagnostic &diagnostic);
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -99,7 +99,7 @@ QDebug operator<<(QDebug debug, const Diagnostic &d)
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangToolsDiagnosticModel::addDiagnostics(const QList<Diagnostic> &diagnostics)
|
void ClangToolsDiagnosticModel::addDiagnostics(const Diagnostics &diagnostics)
|
||||||
{
|
{
|
||||||
const auto onFixitStatusChanged = [this](FixitStatus newStatus) {
|
const auto onFixitStatusChanged = [this](FixitStatus newStatus) {
|
||||||
if (newStatus == FixitStatus::Scheduled)
|
if (newStatus == FixitStatus::Scheduled)
|
||||||
|
@@ -113,7 +113,7 @@ class ClangToolsDiagnosticModel : public ClangToolsDiagnosticModelBase
|
|||||||
public:
|
public:
|
||||||
ClangToolsDiagnosticModel(QObject *parent = nullptr);
|
ClangToolsDiagnosticModel(QObject *parent = nullptr);
|
||||||
|
|
||||||
void addDiagnostics(const QList<Diagnostic> &diagnostics);
|
void addDiagnostics(const Diagnostics &diagnostics);
|
||||||
QSet<Diagnostic> diagnostics() const;
|
QSet<Diagnostic> diagnostics() const;
|
||||||
|
|
||||||
enum ItemRole {
|
enum ItemRole {
|
||||||
|
@@ -182,11 +182,11 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic,
|
|||||||
return diagnostic;
|
return diagnostic;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<Diagnostic> readSerializedDiagnostics_helper(const QString &filePath,
|
static Diagnostics readSerializedDiagnostics_helper(const QString &filePath,
|
||||||
const QSet<Utils::FilePath> &projectFiles,
|
const QSet<Utils::FilePath> &projectFiles,
|
||||||
const QString &logFilePath)
|
const QString &logFilePath)
|
||||||
{
|
{
|
||||||
QList<Diagnostic> list;
|
Diagnostics list;
|
||||||
CXLoadDiag_Error error;
|
CXLoadDiag_Error error;
|
||||||
CXString errorString;
|
CXString errorString;
|
||||||
|
|
||||||
@@ -231,13 +231,13 @@ static bool checkFilePath(const QString &filePath, QString *errorMessage)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Diagnostic> readSerializedDiagnostics(const QString &filePath,
|
Diagnostics readSerializedDiagnostics(const QString &filePath,
|
||||||
const QSet<Utils::FilePath> &projectFiles,
|
const QSet<Utils::FilePath> &projectFiles,
|
||||||
const QString &logFilePath,
|
const QString &logFilePath,
|
||||||
QString *errorMessage)
|
QString *errorMessage)
|
||||||
{
|
{
|
||||||
if (!checkFilePath(logFilePath, errorMessage))
|
if (!checkFilePath(logFilePath, errorMessage))
|
||||||
return QList<Diagnostic>();
|
return {};
|
||||||
|
|
||||||
return readSerializedDiagnostics_helper(filePath, projectFiles, logFilePath);
|
return readSerializedDiagnostics_helper(filePath, projectFiles, logFilePath);
|
||||||
}
|
}
|
||||||
|
@@ -34,10 +34,10 @@ namespace Utils { class FilePath; }
|
|||||||
namespace ClangTools {
|
namespace ClangTools {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QList<Diagnostic> readSerializedDiagnostics(const QString &filePath,
|
Diagnostics readSerializedDiagnostics(const QString &filePath,
|
||||||
const QSet<Utils::FilePath> &projectFiles,
|
const QSet<Utils::FilePath> &projectFiles,
|
||||||
const QString &logFilePath,
|
const QString &logFilePath,
|
||||||
QString *errorMessage);
|
QString *errorMessage);
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace ClangTools
|
} // namespace ClangTools
|
||||||
|
Reference in New Issue
Block a user