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:
Nikolai Kosjar
2019-07-23 10:04:01 +02:00
parent b06f235989
commit f240a9a947
10 changed files with 38 additions and 35 deletions

View File

@@ -463,7 +463,7 @@ void ClangTidyClazyTool::handleStateUpdate()
Debugger::showPermanentStatusMessage(message);
}
QList<Diagnostic> ClangTidyClazyTool::read(const QString &filePath,
Diagnostics ClangTidyClazyTool::read(const QString &filePath,
const QSet<Utils::FilePath> &projectFiles,
const QString &logFilePath,
QString *errorMessage) const
@@ -471,7 +471,7 @@ QList<Diagnostic> ClangTidyClazyTool::read(const QString &filePath,
return readSerializedDiagnostics(filePath, projectFiles, logFilePath, errorMessage);
}
void ClangTidyClazyTool::onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics)
void ClangTidyClazyTool::onNewDiagnosticsAvailable(const Diagnostics &diagnostics)
{
ClangTool::onNewDiagnosticsAvailable(diagnostics);
if (!m_diagnosticFilterModel->filterRegExp().pattern().isEmpty())

View File

@@ -53,12 +53,12 @@ public:
void startTool(bool askUserForFileSelection) final;
QList<Diagnostic> read(const QString &filePath,
Diagnostics read(const QString &filePath,
const QSet<Utils::FilePath> &projectFiles,
const QString &logFilePath,
QString *errorMessage) const final;
void onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics) override;
void onNewDiagnosticsAvailable(const Diagnostics &diagnostics) override;
private:
void handleStateUpdate() final;

View File

@@ -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);
m_diagnosticModel->addDiagnostics(diagnostics);

View File

@@ -26,6 +26,7 @@
#pragma once
#include "clangfileinfo.h"
#include "clangtoolsdiagnostic.h"
#include <projectexplorer/runconfiguration.h>
#include <cpptools/projectinfo.h>
@@ -49,7 +50,7 @@ public:
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 QString &logFilePath,
QString *errorMessage) const = 0;
@@ -62,7 +63,7 @@ public:
const QString &name() const;
virtual void onNewDiagnosticsAvailable(const QList<Diagnostic> &diagnostics);
virtual void onNewDiagnosticsAvailable(const Diagnostics &diagnostics);
signals:
void finished(bool success); // For testing.

View File

@@ -398,7 +398,7 @@ void ClangToolRunControl::onRunnerFinishedWithSuccess(const QString &filePath)
qCDebug(LOG) << "onRunnerFinishedWithSuccess:" << logFilePath;
QString errorMessage;
const QList<Diagnostic> diagnostics = tool()->read(filePath,
const Diagnostics diagnostics = tool()->read(filePath,
m_projectFiles,
logFilePath,
&errorMessage);

View File

@@ -62,6 +62,8 @@ public:
bool hasFixits = false;
};
using Diagnostics = QList<Diagnostic>;
quint32 qHash(const Diagnostic &diagnostic);
} // namespace Internal

View File

@@ -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) {
if (newStatus == FixitStatus::Scheduled)

View File

@@ -113,7 +113,7 @@ class ClangToolsDiagnosticModel : public ClangToolsDiagnosticModelBase
public:
ClangToolsDiagnosticModel(QObject *parent = nullptr);
void addDiagnostics(const QList<Diagnostic> &diagnostics);
void addDiagnostics(const Diagnostics &diagnostics);
QSet<Diagnostic> diagnostics() const;
enum ItemRole {

View File

@@ -182,11 +182,11 @@ static Diagnostic buildDiagnostic(const CXDiagnostic cxDiagnostic,
return diagnostic;
}
static QList<Diagnostic> readSerializedDiagnostics_helper(const QString &filePath,
static Diagnostics readSerializedDiagnostics_helper(const QString &filePath,
const QSet<Utils::FilePath> &projectFiles,
const QString &logFilePath)
{
QList<Diagnostic> list;
Diagnostics list;
CXLoadDiag_Error error;
CXString errorString;
@@ -231,13 +231,13 @@ static bool checkFilePath(const QString &filePath, QString *errorMessage)
return true;
}
QList<Diagnostic> readSerializedDiagnostics(const QString &filePath,
Diagnostics readSerializedDiagnostics(const QString &filePath,
const QSet<Utils::FilePath> &projectFiles,
const QString &logFilePath,
QString *errorMessage)
{
if (!checkFilePath(logFilePath, errorMessage))
return QList<Diagnostic>();
return {};
return readSerializedDiagnostics_helper(filePath, projectFiles, logFilePath);
}

View File

@@ -34,7 +34,7 @@ namespace Utils { class FilePath; }
namespace ClangTools {
namespace Internal {
QList<Diagnostic> readSerializedDiagnostics(const QString &filePath,
Diagnostics readSerializedDiagnostics(const QString &filePath,
const QSet<Utils::FilePath> &projectFiles,
const QString &logFilePath,
QString *errorMessage);