forked from qt-creator/qt-creator
CppEditor: Remove foreach / Q_FOREACH usage part 2
Task-number: QTCREATORBUG-27464 Change-Id: I352bf37bd017e7381fbd7b050fbb55c9a73bd668 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:
@@ -441,7 +441,7 @@ void DoxygenTest::runTest(const QByteArray &original,
|
||||
testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
|
||||
testDocument.setBaseDirectory(temporaryDir.path());
|
||||
QVERIFY(testDocument.writeToDisk());
|
||||
foreach (CppTestDocument testDocument, includedHeaderDocuments) {
|
||||
for (CppTestDocument testDocument : includedHeaderDocuments) {
|
||||
testDocument.setBaseDirectory(temporaryDir.path());
|
||||
QVERIFY(testDocument.writeToDisk());
|
||||
}
|
||||
|
||||
@@ -184,9 +184,9 @@ void CppClass::lookupBases(QFutureInterfaceBase &futureInterface,
|
||||
clazz = current.first;
|
||||
visited.insert(clazz);
|
||||
const QList<ClassOrNamespace *> &bases = clazz->usings();
|
||||
foreach (ClassOrNamespace *baseClass, bases) {
|
||||
for (ClassOrNamespace *baseClass : bases) {
|
||||
const QList<Symbol *> &symbols = baseClass->symbols();
|
||||
foreach (Symbol *symbol, symbols) {
|
||||
for (Symbol *symbol : symbols) {
|
||||
if (symbol->isClass() && (
|
||||
clazz = context.lookupType(symbol)) &&
|
||||
!visited.contains(clazz)) {
|
||||
@@ -220,7 +220,8 @@ void CppClass::lookupDerived(QFutureInterfaceBase &futureInterface,
|
||||
const Data ¤t = q.dequeue();
|
||||
CppClass *clazz = current.first;
|
||||
const TypeHierarchy &classHierarchy = current.second;
|
||||
foreach (const TypeHierarchy &derivedHierarchy, classHierarchy.hierarchy()) {
|
||||
const QList<TypeHierarchy> hierarchy = classHierarchy.hierarchy();
|
||||
for (const TypeHierarchy &derivedHierarchy : hierarchy) {
|
||||
clazz->derived.append(CppClass(derivedHierarchy.symbol()));
|
||||
q.enqueue(qMakePair(&clazz->derived.last(), derivedHierarchy));
|
||||
}
|
||||
@@ -633,8 +634,9 @@ QFuture<QSharedPointer<CppElement>> FromGuiFunctor::syncExec(
|
||||
|
||||
void FromGuiFunctor::checkDiagnosticMessage(int pos)
|
||||
{
|
||||
foreach (const QTextEdit::ExtraSelection &sel,
|
||||
m_editor->extraSelections(TextEditor::TextEditorWidget::CodeWarningsSelection)) {
|
||||
const QList<QTextEdit::ExtraSelection> &selections = m_editor->extraSelections(
|
||||
TextEditor::TextEditorWidget::CodeWarningsSelection);
|
||||
for (const QTextEdit::ExtraSelection &sel : selections) {
|
||||
if (pos >= sel.cursor.selectionStart() && pos <= sel.cursor.selectionEnd()) {
|
||||
m_diagnosis = sel.format.toolTip();
|
||||
break;
|
||||
|
||||
@@ -285,13 +285,15 @@ CppFileSettingsWidget::CppFileSettingsWidget(CppFileSettings *settings)
|
||||
// populate suffix combos
|
||||
const Utils::MimeType sourceMt = Utils::mimeTypeForName(QLatin1String(Constants::CPP_SOURCE_MIMETYPE));
|
||||
if (sourceMt.isValid()) {
|
||||
foreach (const QString &suffix, sourceMt.suffixes())
|
||||
const QStringList suffixes = sourceMt.suffixes();
|
||||
for (const QString &suffix : suffixes)
|
||||
m_ui.sourceSuffixComboBox->addItem(suffix);
|
||||
}
|
||||
|
||||
const Utils::MimeType headerMt = Utils::mimeTypeForName(QLatin1String(Constants::CPP_HEADER_MIMETYPE));
|
||||
if (headerMt.isValid()) {
|
||||
foreach (const QString &suffix, headerMt.suffixes())
|
||||
const QStringList suffixes = headerMt.suffixes();
|
||||
for (const QString &suffix : suffixes)
|
||||
m_ui.headerSuffixComboBox->addItem(suffix);
|
||||
}
|
||||
m_ui.licenseTemplatePathChooser->setExpectedKind(Utils::PathChooser::File);
|
||||
@@ -314,7 +316,7 @@ void CppFileSettingsWidget::setLicenseTemplatePath(const FilePath &lp)
|
||||
static QStringList trimmedPaths(const QString &paths)
|
||||
{
|
||||
QStringList res;
|
||||
foreach (const QString &path, paths.split(QLatin1Char(','), Qt::SkipEmptyParts))
|
||||
for (const QString &path : paths.split(QLatin1Char(','), Qt::SkipEmptyParts))
|
||||
res << path.trimmed();
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ public:
|
||||
|
||||
void operator()(QList<CPlusPlus::Usage> &, const QList<CPlusPlus::Usage> &usages)
|
||||
{
|
||||
foreach (const CPlusPlus::Usage &u, usages)
|
||||
for (const CPlusPlus::Usage &u : usages)
|
||||
future->reportResult(u);
|
||||
|
||||
future->setProgressValue(future->progressValue() + 1);
|
||||
@@ -724,7 +724,8 @@ restart_search:
|
||||
return usages;
|
||||
|
||||
usages.clear();
|
||||
foreach (const CPlusPlus::Document::MacroUse &use, doc->macroUses()) {
|
||||
const QList<CPlusPlus::Document::MacroUse> uses = doc->macroUses();
|
||||
for (const CPlusPlus::Document::MacroUse &use : uses) {
|
||||
const CPlusPlus::Macro &useMacro = use.macro();
|
||||
|
||||
if (useMacro.fileName() == macro.fileName()) { // Check if this is a match, but possibly against an outdated document.
|
||||
|
||||
@@ -207,7 +207,8 @@ Link findMacroLink_helper(const QByteArray &name, Document::Ptr doc, const Snaps
|
||||
if (doc && !name.startsWith('<') && !processed->contains(doc->fileName())) {
|
||||
processed->insert(doc->fileName());
|
||||
|
||||
foreach (const Macro ¯o, doc->definedMacros()) {
|
||||
const QList<Macro> macros = doc->definedMacros();
|
||||
for (const Macro ¯o : macros) {
|
||||
if (macro.name() == name) {
|
||||
Link link;
|
||||
link.targetFilePath = Utils::FilePath::fromString(macro.fileName());
|
||||
@@ -644,7 +645,8 @@ void FollowSymbolUnderCursor::findLink(
|
||||
// Handle include directives
|
||||
if (tk.is(T_STRING_LITERAL) || tk.is(T_ANGLE_STRING_LITERAL)) {
|
||||
const int lineno = cursor.blockNumber() + 1;
|
||||
foreach (const Document::Include &incl, doc->resolvedIncludes()) {
|
||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||
for (const Document::Include &incl : includes) {
|
||||
if (incl.line() == lineno) {
|
||||
link.targetFilePath = Utils::FilePath::fromString(incl.resolvedFileName());
|
||||
link.linkTextStart = beginOfToken + 1;
|
||||
@@ -702,7 +704,7 @@ void FollowSymbolUnderCursor::findLink(
|
||||
if (!resolvedSymbols.isEmpty()) {
|
||||
LookupItem result = skipForwardDeclarations(resolvedSymbols);
|
||||
|
||||
foreach (const LookupItem &r, resolvedSymbols) {
|
||||
for (const LookupItem &r : resolvedSymbols) {
|
||||
if (Symbol *d = r.declaration()) {
|
||||
if (d->isDeclaration() || d->isFunction()) {
|
||||
const QString fileName = QString::fromUtf8(d->fileName(), d->fileNameLength());
|
||||
@@ -856,7 +858,7 @@ void FollowSymbolUnderCursor::switchDeclDef(
|
||||
functionDefinitionSymbol->enclosingScope());
|
||||
|
||||
QList<Symbol *> best;
|
||||
foreach (const LookupItem &r, declarations) {
|
||||
for (const LookupItem &r : declarations) {
|
||||
if (Symbol *decl = r.declaration()) {
|
||||
if (Function *funTy = decl->type()->asFunctionType()) {
|
||||
if (funTy->match(functionDefinitionSymbol)) {
|
||||
|
||||
@@ -883,7 +883,7 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse
|
||||
for (auto it = renamedTargetParameters.cbegin(), end = renamedTargetParameters.cend();
|
||||
it != end; ++it) {
|
||||
const QList<SemanticInfo::Use> &uses = localSymbols.uses.value(it.key());
|
||||
foreach (const SemanticInfo::Use &use, uses) {
|
||||
for (const SemanticInfo::Use &use : uses) {
|
||||
if (use.isInvalid())
|
||||
continue;
|
||||
const int useStart = targetFile->position(use.line, use.column);
|
||||
|
||||
@@ -218,7 +218,7 @@ ClassItem::~ClassItem()
|
||||
|
||||
Qt::ItemFlags ClassItem::flags() const
|
||||
{
|
||||
foreach (FunctionItem *func, functions) {
|
||||
for (FunctionItem *func : qAsConst(functions)) {
|
||||
if (!func->alreadyFound)
|
||||
return Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled;
|
||||
}
|
||||
@@ -231,7 +231,7 @@ Qt::CheckState ClassItem::checkState() const
|
||||
if (functions.isEmpty())
|
||||
return Qt::Unchecked;
|
||||
Qt::CheckState state = functions.first()->checkState();
|
||||
foreach (FunctionItem *function, functions) {
|
||||
for (FunctionItem *function : qAsConst(functions)) {
|
||||
Qt::CheckState functionState = function->checkState();
|
||||
if (functionState != state)
|
||||
return Qt::PartiallyChecked;
|
||||
@@ -280,7 +280,7 @@ QStringList defaultOverrideReplacements()
|
||||
QStringList sortedAndTrimmedStringListWithoutEmptyElements(const QStringList &list)
|
||||
{
|
||||
QStringList result;
|
||||
foreach (const QString &replacement, list) {
|
||||
for (const QString &replacement : list) {
|
||||
const QString trimmedReplacement = replacement.trimmed();
|
||||
if (!trimmedReplacement.isEmpty())
|
||||
result << trimmedReplacement;
|
||||
@@ -491,7 +491,7 @@ public:
|
||||
}
|
||||
} else {
|
||||
auto classItem = static_cast<ClassItem *>(item);
|
||||
foreach (FunctionItem *funcItem, classItem->functions) {
|
||||
for (FunctionItem *funcItem : qAsConst(classItem->functions)) {
|
||||
if (funcItem->alreadyFound || funcItem->checked == checked)
|
||||
continue;
|
||||
QModelIndex funcIndex = createIndex(funcItem->row, 0, funcItem);
|
||||
@@ -578,8 +578,9 @@ public:
|
||||
ClassOrNamespace *clazz = baseClassQueue.dequeue();
|
||||
visitedBaseClasses.insert(clazz);
|
||||
const QList<ClassOrNamespace *> bases = clazz->usings();
|
||||
foreach (ClassOrNamespace *baseClass, bases) {
|
||||
foreach (Symbol *symbol, baseClass->symbols()) {
|
||||
for (const ClassOrNamespace *baseClass : bases) {
|
||||
const QList<Symbol *> symbols = baseClass->symbols();
|
||||
for (Symbol *symbol : symbols) {
|
||||
Class *base = symbol->asClass();
|
||||
if (base
|
||||
&& (clazz = interface.context().lookupType(symbol))
|
||||
@@ -597,7 +598,7 @@ public:
|
||||
Overview printer = CppCodeStyleSettings::currentProjectCodeStyleOverview();
|
||||
printer.showFunctionSignatures = true;
|
||||
QHash<const Function *, FunctionItem *> virtualFunctions;
|
||||
foreach (const Class *clazz, baseClasses) {
|
||||
for (const Class *clazz : qAsConst(baseClasses)) {
|
||||
ClassItem *itemBase = new ClassItem(printer.prettyName(clazz->name()), clazz);
|
||||
for (Scope::iterator it = clazz->memberBegin(); it != clazz->memberEnd(); ++it) {
|
||||
if (const Function *func = (*it)->type()->asFunctionType()) {
|
||||
@@ -794,14 +795,14 @@ public:
|
||||
UseMinimalNames useMinimalNames(targetCoN);
|
||||
Control *control = context().bindings()->control().data();
|
||||
QList<const Function *> insertedFunctions;
|
||||
foreach (ClassItem *classItem, m_factory->classFunctionModel->classes) {
|
||||
for (ClassItem *classItem : qAsConst(m_factory->classFunctionModel->classes)) {
|
||||
if (classItem->checkState() == Qt::Unchecked)
|
||||
continue;
|
||||
|
||||
// Insert Declarations (+ definitions)
|
||||
QString lastAccessSpecString;
|
||||
bool first = true;
|
||||
foreach (FunctionItem *funcItem, classItem->functions) {
|
||||
for (FunctionItem *funcItem : qAsConst(classItem->functions)) {
|
||||
if (funcItem->reimplemented || funcItem->alreadyFound || !funcItem->checked)
|
||||
continue;
|
||||
|
||||
@@ -1219,7 +1220,7 @@ void InsertVirtualMethodsDialog::setHideReimplementedFunctions(bool hide)
|
||||
void InsertVirtualMethodsDialog::updateOverrideReplacementsComboBox()
|
||||
{
|
||||
m_overrideReplacementComboBox->clear();
|
||||
foreach (const QString &replacement, m_availableOverrideReplacements)
|
||||
for (const QString &replacement : qAsConst(m_availableOverrideReplacements))
|
||||
m_overrideReplacementComboBox->addItem(replacement);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ struct Result
|
||||
for (auto it = localUses.cbegin(), end = localUses.cend(); it != end; ++it) {
|
||||
const CPlusPlus::Symbol *symbol = it.key();
|
||||
const QList<CppEditor::SemanticInfo::Use> &uses = it.value();
|
||||
foreach (const CppEditor::SemanticInfo::Use &use, uses)
|
||||
for (const CppEditor::SemanticInfo::Use &use : uses)
|
||||
result << fromHighlightingResult(symbol, use);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ void CppLocatorData::onAboutToRemoveFiles(const QStringList &files)
|
||||
|
||||
QMutexLocker locker(&m_pendingDocumentsMutex);
|
||||
|
||||
foreach (const QString &file, files) {
|
||||
for (const QString &file : files) {
|
||||
m_infosByFile.remove(file);
|
||||
|
||||
for (int i = 0; i < m_pendingDocuments.size(); ++i) {
|
||||
@@ -91,7 +91,7 @@ void CppLocatorData::flushPendingDocument(bool force) const
|
||||
if (m_pendingDocuments.isEmpty())
|
||||
return;
|
||||
|
||||
foreach (CPlusPlus::Document::Ptr doc, m_pendingDocuments)
|
||||
for (CPlusPlus::Document::Ptr doc : qAsConst(m_pendingDocuments))
|
||||
m_infosByFile.insert(Internal::StringTable::insert(doc->fileName()), m_search(doc));
|
||||
|
||||
m_pendingDocuments.clear();
|
||||
|
||||
@@ -259,7 +259,7 @@ QSet<QString> CppModelManager::timeStampModifiedFiles(const QList<Document::Ptr>
|
||||
{
|
||||
QSet<QString> sourceFiles;
|
||||
|
||||
foreach (const Document::Ptr doc, documentsToCheck) {
|
||||
for (const Document::Ptr &doc : documentsToCheck) {
|
||||
const QDateTime lastModified = doc->lastModified();
|
||||
|
||||
if (!lastModified.isNull()) {
|
||||
@@ -526,7 +526,7 @@ void CppModelManager::updateModifiedSourceFiles()
|
||||
{
|
||||
const Snapshot snapshot = this->snapshot();
|
||||
QList<Document::Ptr> documentsToCheck;
|
||||
foreach (const Document::Ptr document, snapshot)
|
||||
for (const Document::Ptr &document : snapshot)
|
||||
documentsToCheck << document;
|
||||
|
||||
updateSourceFiles(timeStampModifiedFiles(documentsToCheck));
|
||||
@@ -878,7 +878,8 @@ WorkingCopy CppModelManager::buildWorkingCopyList()
|
||||
{
|
||||
WorkingCopy workingCopy;
|
||||
|
||||
foreach (const CppEditorDocumentHandle *cppEditorDocument, cppEditorDocuments()) {
|
||||
const QList<CppEditorDocumentHandle *> cppEditorDocumentList = cppEditorDocuments();
|
||||
for (const CppEditorDocumentHandle *cppEditorDocument : cppEditorDocumentList) {
|
||||
workingCopy.insert(cppEditorDocument->filePath(),
|
||||
cppEditorDocument->contents(),
|
||||
cppEditorDocument->revision());
|
||||
@@ -957,9 +958,10 @@ ProjectInfo::ConstPtr CppModelManager::projectInfo(ProjectExplorer::Project *pro
|
||||
void CppModelManager::removeProjectInfoFilesAndIncludesFromSnapshot(const ProjectInfo &projectInfo)
|
||||
{
|
||||
QMutexLocker snapshotLocker(&d->m_snapshotMutex);
|
||||
foreach (const ProjectPart::ConstPtr &projectPart, projectInfo.projectParts()) {
|
||||
foreach (const ProjectFile &cxxFile, projectPart->files) {
|
||||
foreach (const QString &fileName, d->m_snapshot.allIncludesForDocument(cxxFile.path))
|
||||
for (const ProjectPart::ConstPtr &projectPart : projectInfo.projectParts()) {
|
||||
for (const ProjectFile &cxxFile : qAsConst(projectPart->files)) {
|
||||
const QSet<QString> fileNames = d->m_snapshot.allIncludesForDocument(cxxFile.path);
|
||||
for (const QString &fileName : fileNames)
|
||||
d->m_snapshot.remove(fileName);
|
||||
d->m_snapshot.remove(cxxFile.path);
|
||||
}
|
||||
@@ -1036,7 +1038,7 @@ private:
|
||||
{
|
||||
QSet<QString> ids;
|
||||
|
||||
foreach (const ProjectPart::ConstPtr &projectPart, projectParts)
|
||||
for (const ProjectPart::ConstPtr &projectPart : projectParts)
|
||||
ids.insert(projectPart->id());
|
||||
|
||||
return ids;
|
||||
@@ -1090,7 +1092,8 @@ void CppModelManager::updateCppEditorDocuments(bool projectsUpdated) const
|
||||
{
|
||||
// Refresh visible documents
|
||||
QSet<Core::IDocument *> visibleCppEditorDocuments;
|
||||
foreach (Core::IEditor *editor, Core::EditorManager::visibleEditors()) {
|
||||
const QList<Core::IEditor *> editors = Core::EditorManager::visibleEditors();
|
||||
for (Core::IEditor *editor: editors) {
|
||||
if (Core::IDocument *document = editor->document()) {
|
||||
const QString filePath = document->filePath().toString();
|
||||
if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) {
|
||||
@@ -1104,7 +1107,7 @@ void CppModelManager::updateCppEditorDocuments(bool projectsUpdated) const
|
||||
QSet<Core::IDocument *> invisibleCppEditorDocuments
|
||||
= Utils::toSet(Core::DocumentModel::openedDocuments());
|
||||
invisibleCppEditorDocuments.subtract(visibleCppEditorDocuments);
|
||||
foreach (Core::IDocument *document, invisibleCppEditorDocuments) {
|
||||
for (Core::IDocument *document : qAsConst(invisibleCppEditorDocuments)) {
|
||||
const QString filePath = document->filePath().toString();
|
||||
if (CppEditorDocumentHandle *theCppEditorDocument = cppEditorDocument(filePath)) {
|
||||
const CppEditorDocumentHandle::RefreshReason refreshReason = projectsUpdated
|
||||
@@ -1431,8 +1434,9 @@ void CppModelManager::renameIncludes(const Utils::FilePath &oldFilePath,
|
||||
|
||||
const TextEditor::RefactoringChanges changes;
|
||||
|
||||
foreach (Snapshot::IncludeLocation loc,
|
||||
snapshot().includeLocationsOfDocument(oldFilePath.toString())) {
|
||||
const QList<Snapshot::IncludeLocation> locations = snapshot().includeLocationsOfDocument(
|
||||
oldFilePath.toString());
|
||||
for (const Snapshot::IncludeLocation &loc : locations) {
|
||||
TextEditor::RefactoringFilePtr file = changes.file(
|
||||
Utils::FilePath::fromString(loc.first->fileName()));
|
||||
const QTextBlock &block = file->document()->findBlockByNumber(loc.second - 1);
|
||||
@@ -1555,10 +1559,12 @@ void CppModelManager::GC()
|
||||
|
||||
// Collect files of opened editors and editor supports (e.g. ui code model)
|
||||
QStringList filesInEditorSupports;
|
||||
foreach (const CppEditorDocumentHandle *editorDocument, cppEditorDocuments())
|
||||
const QList<CppEditorDocumentHandle *> editorDocuments = cppEditorDocuments();
|
||||
for (const CppEditorDocumentHandle *editorDocument : editorDocuments)
|
||||
filesInEditorSupports << editorDocument->filePath();
|
||||
|
||||
foreach (AbstractEditorSupport *abstractEditorSupport, abstractEditorSupports())
|
||||
const QSet<AbstractEditorSupport *> abstractEditorSupportList = abstractEditorSupports();
|
||||
for (AbstractEditorSupport *abstractEditorSupport : abstractEditorSupportList)
|
||||
filesInEditorSupports << abstractEditorSupport->fileName();
|
||||
|
||||
Snapshot currentSnapshot = snapshot();
|
||||
|
||||
@@ -91,7 +91,7 @@ QStringList toAbsolutePaths(const QStringList &relativePathList,
|
||||
const TemporaryCopiedDir &temporaryDir)
|
||||
{
|
||||
QStringList result;
|
||||
foreach (const QString &file, relativePathList)
|
||||
for (const QString &file : relativePathList)
|
||||
result << temporaryDir.absolutePath(file.toUtf8());
|
||||
return result;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
void create(const QString &name, const QString &dir, const QStringList &files)
|
||||
{
|
||||
const MyTestDataDir projectDir(dir);
|
||||
foreach (const QString &file, files)
|
||||
for (const QString &file : files)
|
||||
projectFiles << projectDir.file(file);
|
||||
|
||||
RawProjectPart rpp;
|
||||
@@ -489,7 +489,7 @@ void ModelManagerTest::testRefreshTimeStampModifiedIfSourcefilesChange()
|
||||
|
||||
QCOMPARE(refreshedFiles.size(), initialProjectFiles.size());
|
||||
snapshot = mm->snapshot();
|
||||
foreach (const QString &file, initialProjectFiles) {
|
||||
for (const QString &file : qAsConst(initialProjectFiles)) {
|
||||
QVERIFY(refreshedFiles.contains(file));
|
||||
QVERIFY(snapshot.contains(file));
|
||||
}
|
||||
@@ -518,7 +518,7 @@ void ModelManagerTest::testRefreshTimeStampModifiedIfSourcefilesChange()
|
||||
|
||||
QCOMPARE(refreshedFiles.size(), finalProjectFiles.size());
|
||||
snapshot = mm->snapshot();
|
||||
foreach (const QString &file, finalProjectFiles) {
|
||||
for (const QString &file : qAsConst(finalProjectFiles)) {
|
||||
QVERIFY(refreshedFiles.contains(file));
|
||||
QVERIFY(snapshot.contains(file));
|
||||
}
|
||||
@@ -569,7 +569,7 @@ void ModelManagerTest::testSnapshotAfterTwoProjects()
|
||||
QCOMPARE(refreshedFiles, Utils::toSet(project1.projectFiles));
|
||||
const int snapshotSizeAfterProject1 = mm->snapshot().size();
|
||||
|
||||
foreach (const QString &file, project1.projectFiles)
|
||||
for (const QString &file : qAsConst(project1.projectFiles))
|
||||
QVERIFY(mm->snapshot().contains(file));
|
||||
|
||||
// Project 2
|
||||
@@ -584,9 +584,9 @@ void ModelManagerTest::testSnapshotAfterTwoProjects()
|
||||
QVERIFY(snapshotSizeAfterProject2 > snapshotSizeAfterProject1);
|
||||
QVERIFY(snapshotSizeAfterProject2 >= snapshotSizeAfterProject1 + project2.projectFiles.size());
|
||||
|
||||
foreach (const QString &file, project1.projectFiles)
|
||||
for (const QString &file : qAsConst(project1.projectFiles))
|
||||
QVERIFY(mm->snapshot().contains(file));
|
||||
foreach (const QString &file, project2.projectFiles)
|
||||
for (const QString &file : qAsConst(project2.projectFiles))
|
||||
QVERIFY(mm->snapshot().contains(file));
|
||||
}
|
||||
|
||||
@@ -1014,7 +1014,7 @@ void ModelManagerTest::testRenameIncludes()
|
||||
|
||||
// Copy test files to a temporary directory
|
||||
QSet<QString> sourceFiles;
|
||||
foreach (const QString &fileName, fileNames) {
|
||||
for (const QString &fileName : qAsConst(fileNames)) {
|
||||
const QString &file = workingDir.filePath(fileName);
|
||||
QVERIFY(QFile::copy(testDir.file(fileName), file));
|
||||
// Saving source file names for the model manager update,
|
||||
@@ -1027,7 +1027,7 @@ void ModelManagerTest::testRenameIncludes()
|
||||
modelManager->updateSourceFiles(sourceFiles).waitForFinished();
|
||||
QCoreApplication::processEvents();
|
||||
CPlusPlus::Snapshot snapshot = modelManager->snapshot();
|
||||
foreach (const QString &sourceFile, sourceFiles)
|
||||
for (const QString &sourceFile : qAsConst(sourceFiles))
|
||||
QCOMPARE(snapshot.allIncludesForDocument(sourceFile), QSet<QString>() << oldHeader);
|
||||
|
||||
// Renaming the header
|
||||
@@ -1039,7 +1039,7 @@ void ModelManagerTest::testRenameIncludes()
|
||||
modelManager->updateSourceFiles(sourceFiles).waitForFinished();
|
||||
QCoreApplication::processEvents();
|
||||
snapshot = modelManager->snapshot();
|
||||
foreach (const QString &sourceFile, sourceFiles)
|
||||
for (const QString &sourceFile : qAsConst(sourceFiles))
|
||||
QCOMPARE(snapshot.allIncludesForDocument(sourceFile), QSet<QString>() << newHeader);
|
||||
}
|
||||
|
||||
@@ -1072,7 +1072,7 @@ void ModelManagerTest::testRenameIncludesInEditor()
|
||||
|
||||
// Copy test files to a temporary directory
|
||||
QSet<QString> sourceFiles;
|
||||
foreach (const QString &fileName, fileNames) {
|
||||
for (const QString &fileName : fileNames) {
|
||||
const QString &file = workingDir.filePath(fileName);
|
||||
QVERIFY(QFile::copy(testDir.file(fileName), file));
|
||||
// Saving source file names for the model manager update,
|
||||
@@ -1085,7 +1085,7 @@ void ModelManagerTest::testRenameIncludesInEditor()
|
||||
modelManager->updateSourceFiles(sourceFiles).waitForFinished();
|
||||
QCoreApplication::processEvents();
|
||||
CPlusPlus::Snapshot snapshot = modelManager->snapshot();
|
||||
foreach (const QString &sourceFile, sourceFiles)
|
||||
for (const QString &sourceFile : qAsConst(sourceFiles))
|
||||
QCOMPARE(snapshot.allIncludesForDocument(sourceFile), QSet<QString>() << headerWithPragmaOnce);
|
||||
|
||||
// Open a file in the editor
|
||||
@@ -1163,7 +1163,7 @@ void ModelManagerTest::testRenameIncludesInEditor()
|
||||
modelManager->updateSourceFiles(sourceFiles).waitForFinished();
|
||||
QCoreApplication::processEvents();
|
||||
snapshot = modelManager->snapshot();
|
||||
foreach (const QString &sourceFile, sourceFiles)
|
||||
for (const QString &sourceFile : qAsConst(sourceFiles))
|
||||
QCOMPARE(snapshot.allIncludesForDocument(sourceFile), QSet<QString>() << renamedHeaderWithPragmaOnce);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ ProjectFiles ProjectFileCategorizer::classifyFiles(const QStringList &filePaths,
|
||||
{
|
||||
ProjectFiles ambiguousHeaders;
|
||||
|
||||
foreach (const QString &filePath, filePaths) {
|
||||
for (const QString &filePath : filePaths) {
|
||||
const ProjectFile projectFile(filePath,
|
||||
getMimeType
|
||||
? ProjectFile::classifyByMimeType(getMimeType(filePath))
|
||||
|
||||
@@ -196,7 +196,7 @@ TextEditor::IndentationForBlock CppQtStyleIndenter::indentationForBlocks(
|
||||
codeFormatter.updateStateUntil(blocks.last());
|
||||
|
||||
TextEditor::IndentationForBlock ret;
|
||||
foreach (QTextBlock block, blocks) {
|
||||
for (const QTextBlock &block : blocks) {
|
||||
int indent;
|
||||
int padding;
|
||||
codeFormatter.indentFor(block, &indent, &padding);
|
||||
|
||||
@@ -91,7 +91,7 @@ BaseQuickFixTestCase::BaseQuickFixTestCase(const QList<TestDocumentPtr> &testDoc
|
||||
|
||||
// Check if there is exactly one cursor marker
|
||||
unsigned cursorMarkersCount = 0;
|
||||
foreach (const TestDocumentPtr document, m_testDocuments) {
|
||||
for (const TestDocumentPtr &document : qAsConst(m_testDocuments)) {
|
||||
if (document->hasCursorMarker())
|
||||
++cursorMarkersCount;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ BaseQuickFixTestCase::BaseQuickFixTestCase(const QList<TestDocumentPtr> &testDoc
|
||||
// Write documents to disk
|
||||
m_temporaryDirectory.reset(new TemporaryDir);
|
||||
QVERIFY(m_temporaryDirectory->isValid());
|
||||
foreach (TestDocumentPtr document, m_testDocuments) {
|
||||
for (const TestDocumentPtr &document : qAsConst(m_testDocuments)) {
|
||||
if (QFileInfo(document->m_fileName).isRelative())
|
||||
document->setBaseDirectory(m_temporaryDirectory->path());
|
||||
document->writeToDisk();
|
||||
@@ -115,12 +115,12 @@ BaseQuickFixTestCase::BaseQuickFixTestCase(const QList<TestDocumentPtr> &testDoc
|
||||
|
||||
// Update Code Model
|
||||
QSet<QString> filePaths;
|
||||
foreach (const TestDocumentPtr &document, m_testDocuments)
|
||||
for (const TestDocumentPtr &document : qAsConst(m_testDocuments))
|
||||
filePaths << document->filePath();
|
||||
QVERIFY(parseFiles(filePaths));
|
||||
|
||||
// Open Files
|
||||
foreach (TestDocumentPtr document, m_testDocuments) {
|
||||
for (const TestDocumentPtr &document : qAsConst(m_testDocuments)) {
|
||||
QVERIFY(openCppEditor(document->filePath(), &document->m_editor,
|
||||
&document->m_editorWidget));
|
||||
closeEditorAtEndOfTestCase(document->m_editor);
|
||||
@@ -149,7 +149,7 @@ BaseQuickFixTestCase::BaseQuickFixTestCase(const QList<TestDocumentPtr> &testDoc
|
||||
m_cppCodeStylePreferences->setCurrentDelegate("qt");
|
||||
|
||||
// Find the document having the cursor marker
|
||||
foreach (const TestDocumentPtr document, m_testDocuments) {
|
||||
for (const TestDocumentPtr &document : qAsConst(m_testDocuments)) {
|
||||
if (document->hasCursorMarker()){
|
||||
m_documentWithMarker = document;
|
||||
break;
|
||||
@@ -171,7 +171,7 @@ BaseQuickFixTestCase::~BaseQuickFixTestCase()
|
||||
m_modelManager->setHeaderPaths(m_headerPathsToRestore);
|
||||
|
||||
// Remove created files from file system
|
||||
foreach (const TestDocumentPtr &testDocument, m_testDocuments)
|
||||
for (const TestDocumentPtr &testDocument : qAsConst(m_testDocuments))
|
||||
QVERIFY(QFile::remove(testDocument->filePath()));
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ QuickFixOperationTest::QuickFixOperationTest(const QList<TestDocumentPtr> &testD
|
||||
operation->perform();
|
||||
|
||||
// Compare all files
|
||||
foreach (const TestDocumentPtr testDocument, m_testDocuments) {
|
||||
for (const TestDocumentPtr &testDocument : qAsConst(m_testDocuments)) {
|
||||
// Check
|
||||
QString result = testDocument->m_editorWidget->document()->toPlainText();
|
||||
removeTrailingWhitespace(result);
|
||||
@@ -269,7 +269,7 @@ QuickFixOfferedOperationsTest::QuickFixOfferedOperationsTest(
|
||||
|
||||
// Convert to QStringList
|
||||
QStringList actualOperationsAsStringList;
|
||||
foreach (const QuickFixOperation::Ptr &operation, actualOperations)
|
||||
for (const QuickFixOperation::Ptr &operation : qAsConst(actualOperations))
|
||||
actualOperationsAsStringList << operation->description();
|
||||
|
||||
QCOMPARE(actualOperationsAsStringList, expectedOperations);
|
||||
@@ -5874,7 +5874,7 @@ void QuickfixTest::testAddIncludeForUndefinedIdentifier()
|
||||
|
||||
TemporaryDir temporaryDir;
|
||||
QVERIFY(temporaryDir.isValid());
|
||||
foreach (TestDocumentPtr testDocument, testDocuments)
|
||||
for (const TestDocumentPtr &testDocument : qAsConst(testDocuments))
|
||||
testDocument->setBaseDirectory(temporaryDir.path());
|
||||
|
||||
QScopedPointer<CppQuickFixFactory> factory;
|
||||
|
||||
@@ -67,7 +67,7 @@ inline QByteArray generateFingerPrint(const QList<CPlusPlus::Macro> &definedMacr
|
||||
{
|
||||
QCryptographicHash hash(QCryptographicHash::Sha1);
|
||||
hash.addData(code);
|
||||
foreach (const CPlusPlus::Macro ¯o, definedMacros) {
|
||||
for (const CPlusPlus::Macro ¯o : definedMacros) {
|
||||
if (macro.isHidden()) {
|
||||
static const QByteArray undef("#undef ");
|
||||
hash.addData(undef);
|
||||
@@ -168,7 +168,8 @@ void CppSourceProcessor::addFrameworkPath(const ProjectExplorer::HeaderPath &fra
|
||||
|
||||
const QDir frameworkDir(cleanFrameworkPath.path);
|
||||
const QStringList filter = QStringList("*.framework");
|
||||
foreach (const QFileInfo &framework, frameworkDir.entryInfoList(filter)) {
|
||||
const QList<QFileInfo> frameworks = frameworkDir.entryInfoList(filter);
|
||||
for (const QFileInfo &framework : frameworks) {
|
||||
if (!framework.isDir())
|
||||
continue;
|
||||
const QFileInfo privateFrameworks(framework.absoluteFilePath(),
|
||||
@@ -400,7 +401,8 @@ void CppSourceProcessor::mergeEnvironment(Document::Ptr doc)
|
||||
|
||||
m_processed.insert(fn);
|
||||
|
||||
foreach (const Document::Include &incl, doc->resolvedIncludes()) {
|
||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||
for (const Document::Include &incl : includes) {
|
||||
const QString includedFile = incl.resolvedFileName();
|
||||
|
||||
if (Document::Ptr includedDoc = m_snapshot.document(includedFile))
|
||||
@@ -468,7 +470,7 @@ void CppSourceProcessor::sourceNeeded(int line, const QString &fileName, Include
|
||||
Document::Ptr document = Document::create(absoluteFileName);
|
||||
document->setEditorRevision(editorRevision);
|
||||
document->setLanguageFeatures(m_languageFeatures);
|
||||
foreach (const QString &include, initialIncludes) {
|
||||
for (const QString &include : initialIncludes) {
|
||||
m_included.insert(include);
|
||||
Document::Include inc(include, include, 0, IncludeLocal);
|
||||
document->addIncludeFile(inc);
|
||||
|
||||
@@ -187,7 +187,8 @@ void SourceProcessorTest::testMacroUses()
|
||||
|
||||
static bool isMacroDefinedInDocument(const QByteArray ¯oName, const Document::Ptr &document)
|
||||
{
|
||||
foreach (const Macro ¯o, document->definedMacros()) {
|
||||
const QList<Macro> macros = document->definedMacros();
|
||||
for (const Macro ¯o : macros) {
|
||||
if (macro.name() == macroName)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ ProjectOpenerAndCloser::~ProjectOpenerAndCloser()
|
||||
hasGcFinished = true;
|
||||
});
|
||||
|
||||
foreach (Project *project, m_openProjects)
|
||||
for (Project *project : qAsConst(m_openProjects))
|
||||
ProjectExplorerPlugin::unloadProject(project);
|
||||
|
||||
QElapsedTimer t;
|
||||
|
||||
@@ -275,7 +275,9 @@ QStandardItem *CppTypeHierarchyWidget::buildHierarchy(const CppClass &cppClass,
|
||||
if (m_showOldClass && cppClass.qualifiedName == m_oldClass)
|
||||
selectedItem = item;
|
||||
}
|
||||
foreach (const CppClass &klass, sortClasses(cppClass.*member)) {
|
||||
|
||||
const QList<CppClass> classes = sortClasses(cppClass.*member);
|
||||
for (const CppClass &klass : classes) {
|
||||
QStandardItem *item = buildHierarchy(klass, parent, false, member);
|
||||
if (!selectedItem)
|
||||
selectedItem = item;
|
||||
@@ -383,7 +385,7 @@ QMimeData *CppTypeHierarchyModel::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
auto data = new DropMimeData;
|
||||
data->setOverrideFileDropAction(Qt::CopyAction); // do not remove the item from the model
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
for (const QModelIndex &index : indexes) {
|
||||
auto link = index.data(LinkRole).value<Link>();
|
||||
if (link.hasValidTarget())
|
||||
data->addFile(link.targetFilePath, link.targetLine, link.targetColumn);
|
||||
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
return nullptr;
|
||||
|
||||
QList<AssistProposalItemInterface *> items;
|
||||
foreach (Function *func, overrides)
|
||||
for (Function *func : overrides)
|
||||
items << itemFromFunction(func);
|
||||
items.first()->setOrder(1000); // Ensure top position for function of static type
|
||||
|
||||
|
||||
Reference in New Issue
Block a user