forked from qt-creator/qt-creator
ClangTools: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: I1c4711d87e5f95fc1653dd9aa6448b105d017435 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -615,7 +615,7 @@ private:
|
|||||||
const QStringList suffixes = mimeType.suffixes();
|
const QStringList suffixes = mimeType.suffixes();
|
||||||
|
|
||||||
QList<AssistProposalItemInterface *> completions;
|
QList<AssistProposalItemInterface *> completions;
|
||||||
foreach (const ProjectExplorer::HeaderPath &headerPath, allHeaderPaths) {
|
for (const ProjectExplorer::HeaderPath &headerPath : qAsConst(allHeaderPaths)) {
|
||||||
QString realPath = headerPath.path;
|
QString realPath = headerPath.path;
|
||||||
if (!directoryPrefix.isEmpty()) {
|
if (!directoryPrefix.isEmpty()) {
|
||||||
realPath += QLatin1Char('/');
|
realPath += QLatin1Char('/');
|
||||||
|
@@ -149,7 +149,7 @@ public:
|
|||||||
// For debugging, add: style='border-width:1px;border-color:black'
|
// For debugging, add: style='border-width:1px;border-color:black'
|
||||||
QString text = "<table cellspacing='0' cellpadding='0' width='100%'>";
|
QString text = "<table cellspacing='0' cellpadding='0' width='100%'>";
|
||||||
|
|
||||||
foreach (const ClangDiagnostic &diagnostic, diagnostics)
|
for (const ClangDiagnostic &diagnostic : diagnostics)
|
||||||
text.append(tableRows(diagnostic));
|
text.append(tableRows(diagnostic));
|
||||||
if (!source.isEmpty()) {
|
if (!source.isEmpty()) {
|
||||||
text.append(QString::fromUtf8("<tr><td colspan='2' align='left'>"
|
text.append(QString::fromUtf8("<tr><td colspan='2' align='left'>"
|
||||||
|
@@ -613,7 +613,7 @@ void ClangModelManagerSupport::onAbstractEditorSupportRemoved(const QString &fil
|
|||||||
|
|
||||||
void addFixItsActionsToMenu(QMenu *menu, const TextEditor::QuickFixOperations &fixItOperations)
|
void addFixItsActionsToMenu(QMenu *menu, const TextEditor::QuickFixOperations &fixItOperations)
|
||||||
{
|
{
|
||||||
foreach (const auto &fixItOperation, fixItOperations) {
|
for (const TextEditor::QuickFixOperation::Ptr &fixItOperation : fixItOperations) {
|
||||||
QAction *action = menu->addAction(fixItOperation->description());
|
QAction *action = menu->addAction(fixItOperation->description());
|
||||||
QObject::connect(action, &QAction::triggered, [fixItOperation]() {
|
QObject::connect(action, &QAction::triggered, [fixItOperation]() {
|
||||||
fixItOperation->perform();
|
fixItOperation->perform();
|
||||||
@@ -654,7 +654,7 @@ using ClangEditorDocumentProcessors = QVector<ClangEditorDocumentProcessor *>;
|
|||||||
static ClangEditorDocumentProcessors clangProcessors()
|
static ClangEditorDocumentProcessors clangProcessors()
|
||||||
{
|
{
|
||||||
ClangEditorDocumentProcessors result;
|
ClangEditorDocumentProcessors result;
|
||||||
foreach (auto *editorDocument, cppModelManager()->cppEditorDocuments())
|
for (const CppEditorDocumentHandle *editorDocument : cppModelManager()->cppEditorDocuments())
|
||||||
result.append(qobject_cast<ClangEditorDocumentProcessor *>(editorDocument->processor()));
|
result.append(qobject_cast<ClangEditorDocumentProcessor *>(editorDocument->processor()));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -729,8 +729,8 @@ clangProcessorsWithProjectParts(const QStringList &projectPartIds)
|
|||||||
|
|
||||||
void ClangModelManagerSupport::reinitializeBackendDocuments(const QStringList &projectPartIds)
|
void ClangModelManagerSupport::reinitializeBackendDocuments(const QStringList &projectPartIds)
|
||||||
{
|
{
|
||||||
const auto processors = clangProcessorsWithProjectParts(projectPartIds);
|
const ClangEditorDocumentProcessors processors = clangProcessorsWithProjectParts(projectPartIds);
|
||||||
foreach (ClangEditorDocumentProcessor *processor, processors) {
|
for (ClangEditorDocumentProcessor *processor : processors) {
|
||||||
processor->clearProjectPart();
|
processor->clearProjectPart();
|
||||||
processor->run();
|
processor->run();
|
||||||
}
|
}
|
||||||
|
@@ -732,7 +732,7 @@ bool runClangBatchFile(const QString &filePath)
|
|||||||
QTC_CHECK(Core::EditorManager::closeAllEditors(/*askAboutModifiedEditors=*/ false));
|
QTC_CHECK(Core::EditorManager::closeAllEditors(/*askAboutModifiedEditors=*/ false));
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (const Command::Ptr &command, commands) {
|
for (const Command::Ptr &command : commands) {
|
||||||
const bool runSucceeded = command->run();
|
const bool runSucceeded = command->run();
|
||||||
QCoreApplication::processEvents(); // Update GUI
|
QCoreApplication::processEvents(); // Update GUI
|
||||||
|
|
||||||
|
@@ -421,7 +421,7 @@ ClangTool::ClangTool()
|
|||||||
connect(m_diagnosticView, &DiagnosticView::filterOutCurrentKind,
|
connect(m_diagnosticView, &DiagnosticView::filterOutCurrentKind,
|
||||||
this, &ClangTool::filterOutCurrentKind);
|
this, &ClangTool::filterOutCurrentKind);
|
||||||
|
|
||||||
foreach (auto * const model,
|
for (QAbstractItemModel *const model :
|
||||||
QList<QAbstractItemModel *>({m_diagnosticModel, m_diagnosticFilterModel})) {
|
QList<QAbstractItemModel *>({m_diagnosticModel, m_diagnosticFilterModel})) {
|
||||||
connect(model, &QAbstractItemModel::rowsInserted,
|
connect(model, &QAbstractItemModel::rowsInserted,
|
||||||
this, &ClangTool::updateForCurrentState);
|
this, &ClangTool::updateForCurrentState);
|
||||||
|
@@ -225,7 +225,7 @@ static QString createExplainingStepToolTipString(const ExplainingStep &step)
|
|||||||
"<style>dt { font-weight:bold; } dd { font-family: monospace; }</style>\n"
|
"<style>dt { font-weight:bold; } dd { font-family: monospace; }</style>\n"
|
||||||
"<body><dl>");
|
"<body><dl>");
|
||||||
|
|
||||||
foreach (const StringPair &pair, lines) {
|
for (const StringPair &pair : qAsConst(lines)) {
|
||||||
html += QLatin1String("<dt>");
|
html += QLatin1String("<dt>");
|
||||||
html += pair.first;
|
html += pair.first;
|
||||||
html += QLatin1String("</dt><dd>");
|
html += QLatin1String("</dt><dd>");
|
||||||
@@ -273,7 +273,7 @@ static QString fullText(const Diagnostic &diagnostic)
|
|||||||
|
|
||||||
// Explaining steps.
|
// Explaining steps.
|
||||||
int explainingStepNumber = 1;
|
int explainingStepNumber = 1;
|
||||||
foreach (const ExplainingStep &explainingStep, diagnostic.explainingSteps) {
|
for (const ExplainingStep &explainingStep : qAsConst(diagnostic.explainingSteps)) {
|
||||||
text += createExplainingStepString(explainingStep, explainingStepNumber++)
|
text += createExplainingStepString(explainingStep, explainingStepNumber++)
|
||||||
+ QLatin1Char('\n');
|
+ QLatin1Char('\n');
|
||||||
}
|
}
|
||||||
@@ -645,7 +645,7 @@ bool DiagnosticFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Explicitly suppressed?
|
// Explicitly suppressed?
|
||||||
foreach (const SuppressedDiagnostic &d, m_suppressedDiagnostics) {
|
for (const SuppressedDiagnostic &d : qAsConst(m_suppressedDiagnostics)) {
|
||||||
if (d.description != diag.description)
|
if (d.description != diag.description)
|
||||||
continue;
|
continue;
|
||||||
Utils::FilePath filePath = d.filePath;
|
Utils::FilePath filePath = d.filePath;
|
||||||
|
@@ -130,7 +130,7 @@ void PreconfiguredSessionTests::testPreconfiguredSession()
|
|||||||
QCOMPARE(ClangTool::instance()->diagnostics().count(), 0);
|
QCOMPARE(ClangTool::instance()->diagnostics().count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<Project *> validProjects(const QList<Project *> projectsOfSession)
|
static const QList<Project *> validProjects(const QList<Project *> projectsOfSession)
|
||||||
{
|
{
|
||||||
QList<Project *> sortedProjects = projectsOfSession;
|
QList<Project *> sortedProjects = projectsOfSession;
|
||||||
Utils::sort(sortedProjects, [](Project *lhs, Project *rhs){
|
Utils::sort(sortedProjects, [](Project *lhs, Project *rhs){
|
||||||
@@ -196,8 +196,8 @@ void PreconfiguredSessionTests::testPreconfiguredSession_data()
|
|||||||
|
|
||||||
bool hasAddedTestData = false;
|
bool hasAddedTestData = false;
|
||||||
|
|
||||||
foreach (Project *project, validProjects(SessionManager::projects())) {
|
for (Project *project : validProjects(SessionManager::projects())) {
|
||||||
foreach (Target *target, validTargets(project)) {
|
for (Target *target : validTargets(project)) {
|
||||||
hasAddedTestData = true;
|
hasAddedTestData = true;
|
||||||
QTest::newRow(dataTagName(project, target)) << project << target;
|
QTest::newRow(dataTagName(project, target)) << project << target;
|
||||||
}
|
}
|
||||||
|
@@ -166,7 +166,7 @@ void ClangToolsProjectSettings::load()
|
|||||||
m_selectedFiles = Utils::transform<QSet>(files, toFileName);
|
m_selectedFiles = Utils::transform<QSet>(files, toFileName);
|
||||||
|
|
||||||
const QVariantList list = map.value(SETTINGS_KEY_SUPPRESSED_DIAGS).toList();
|
const QVariantList list = map.value(SETTINGS_KEY_SUPPRESSED_DIAGS).toList();
|
||||||
foreach (const QVariant &v, list) {
|
for (const QVariant &v : list) {
|
||||||
const QVariantMap diag = v.toMap();
|
const QVariantMap diag = v.toMap();
|
||||||
const QString fp = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH).toString();
|
const QString fp = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH).toString();
|
||||||
if (fp.isEmpty())
|
if (fp.isEmpty())
|
||||||
|
@@ -976,7 +976,7 @@ void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const Projec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<CppEditorDocumentHandle *> CppModelManager::cppEditorDocuments() const
|
const QList<CppEditorDocumentHandle *> CppModelManager::cppEditorDocuments() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
|
QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
|
||||||
return d->m_cppEditorDocuments.values();
|
return d->m_cppEditorDocuments.values();
|
||||||
|
@@ -141,7 +141,7 @@ public:
|
|||||||
void addExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
void addExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
||||||
void removeExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
void removeExtraEditorSupport(AbstractEditorSupport *editorSupport);
|
||||||
|
|
||||||
QList<CppEditorDocumentHandle *> cppEditorDocuments() const;
|
const QList<CppEditorDocumentHandle *> cppEditorDocuments() const;
|
||||||
CppEditorDocumentHandle *cppEditorDocument(const QString &filePath) const;
|
CppEditorDocumentHandle *cppEditorDocument(const QString &filePath) const;
|
||||||
static BaseEditorDocumentProcessor *cppEditorDocumentProcessor(const QString &filePath);
|
static BaseEditorDocumentProcessor *cppEditorDocumentProcessor(const QString &filePath);
|
||||||
void registerCppEditorDocument(CppEditorDocumentHandle *cppEditorDocument);
|
void registerCppEditorDocument(CppEditorDocumentHandle *cppEditorDocument);
|
||||||
|
Reference in New Issue
Block a user