CppEditor: Remove foreach / Q_FOREACH usage part 3

Task-number: QTCREATORBUG-27464
Change-Id: Icbe620a83b6c2cf6b6166b76d01ca5f3c65ea87a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Artem Sokolovskii
2022-05-05 16:33:29 +02:00
parent f03868bd6b
commit 2be4e8c5d5
12 changed files with 83 additions and 68 deletions

View File

@@ -154,17 +154,18 @@ TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Acti
QList<QPointer<ProjectExplorer::Project> > projects;
const QList<ProjectInfo::ConstPtr> projectInfos = m_modelManager->projectInfos();
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
for (const ProjectInfo::ConstPtr &info : projectInfos) {
qDebug() << "Project" << info->projectFilePath().toUserOutput() << "- files to process:"
<< info->sourceFiles().size();
foreach (const QString &sourceFile, info->sourceFiles())
const QSet<QString> sourceFiles = info->sourceFiles();
for (const QString &sourceFile : sourceFiles)
filesToOpen << sourceFile;
}
Utils::sort(filesToOpen);
// Process all files from the projects
foreach (const QString filePath, filesToOpen) {
for (const QString &filePath : qAsConst(filesToOpen)) {
// Skip e.g. "<configuration>"
if (!QFileInfo::exists(filePath))
continue;
@@ -260,16 +261,17 @@ void TestActionsTestCase::undoChangesInDocument(TextDocument *editorDocument)
void TestActionsTestCase::undoChangesInAllEditorWidgets()
{
foreach (IDocument *document, DocumentModel::openedDocuments()) {
const QList<IDocument *> documents = DocumentModel::openedDocuments();
for (IDocument *document : documents) {
TextDocument *baseTextDocument = qobject_cast<TextDocument *>(document);
undoChangesInDocument(baseTextDocument);
}
}
void TestActionsTestCase::executeActionsOnEditorWidget(CppEditorWidget *editorWidget,
TestActionsTestCase::Actions actions)
TestActionsTestCase::Actions actions)
{
foreach (const ActionPointer &action, actions)
for (const ActionPointer &action : qAsConst(actions))
action->run(editorWidget);
QApplication::processEvents();
}
@@ -461,7 +463,7 @@ void RunAllQuickFixesTokenAction::run(CppEditorWidget *editorWidget)
cppQuickFixFactory->match(qfi, operations);
}
foreach (QuickFixOperation::Ptr operation, operations) {
for (QuickFixOperation::Ptr operation : qAsConst(operations)) {
qDebug() << " -- Performing Quick Fix" << operation->description();
operation->perform();
TestActionsTestCase::escape();