forked from qt-creator/qt-creator
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:
@@ -175,7 +175,8 @@ Class *isMemberFunction(const LookupContext &context, Function *function)
|
||||
return nullptr;
|
||||
|
||||
if (ClassOrNamespace *binding = context.lookupType(q->base(), enclosingScope)) {
|
||||
foreach (Symbol *s, binding->symbols()) {
|
||||
const QList<Symbol *> symbols = binding->symbols();
|
||||
for (Symbol *s : symbols) {
|
||||
if (Class *matchingClass = s->asClass())
|
||||
return matchingClass;
|
||||
}
|
||||
@@ -201,7 +202,8 @@ Namespace *isNamespaceFunction(const LookupContext &context, Function *function)
|
||||
|
||||
// global namespace
|
||||
if (!functionName->isQualifiedNameId()) {
|
||||
foreach (Symbol *s, context.globalNamespace()->symbols()) {
|
||||
const QList<Symbol *> symbols = context.globalNamespace()->symbols();
|
||||
for (Symbol *s : symbols) {
|
||||
if (Namespace *matchingNamespace = s->asNamespace())
|
||||
return matchingNamespace;
|
||||
}
|
||||
@@ -213,7 +215,8 @@ Namespace *isNamespaceFunction(const LookupContext &context, Function *function)
|
||||
return nullptr;
|
||||
|
||||
if (ClassOrNamespace *binding = context.lookupType(q->base(), enclosingScope)) {
|
||||
foreach (Symbol *s, binding->symbols()) {
|
||||
const QList<Symbol *> symbols = binding->symbols();
|
||||
for (Symbol *s : symbols) {
|
||||
if (Namespace *matchingNamespace = s->asNamespace())
|
||||
return matchingNamespace;
|
||||
}
|
||||
@@ -1337,7 +1340,8 @@ void TranslateStringLiteral::match(const CppQuickFixInterface &interface,
|
||||
ClassOrNamespace *b = interface.context().lookupType(function);
|
||||
if (b) {
|
||||
// Do we have a tr function?
|
||||
foreach (const LookupItem &r, b->find(trName)) {
|
||||
const QList<LookupItem> items = b->find(trName);
|
||||
for (const LookupItem &r : items) {
|
||||
Symbol *s = r.declaration();
|
||||
if (s->type()->isFunctionType()) {
|
||||
// no context required for tr
|
||||
@@ -1351,7 +1355,8 @@ void TranslateStringLiteral::match(const CppQuickFixInterface &interface,
|
||||
// We need to do a QCA::translate, so we need a context.
|
||||
// Use fully qualified class name:
|
||||
Overview oo;
|
||||
foreach (const Name *n, LookupContext::path(function)) {
|
||||
const QList<const Name *> names = LookupContext::path(function);
|
||||
for (const Name *n : names) {
|
||||
if (!trContext.isEmpty())
|
||||
trContext.append(QLatin1String("::"));
|
||||
trContext.append(oo.prettyName(n));
|
||||
@@ -1669,7 +1674,7 @@ void AddLocalDeclaration::match(const CppQuickFixInterface &interface, QuickFixO
|
||||
SimpleNameAST *nameAST = idExpr->name->asSimpleName();
|
||||
const QList<LookupItem> results = interface.context().lookup(nameAST->name, file->scopeAt(nameAST->firstToken()));
|
||||
Declaration *decl = nullptr;
|
||||
foreach (const LookupItem &r, results) {
|
||||
for (const LookupItem &r : results) {
|
||||
if (!r.declaration())
|
||||
continue;
|
||||
if (Declaration *d = r.declaration()->asDeclaration()) {
|
||||
@@ -1875,7 +1880,7 @@ QString findShortestInclude(const QString currentDocumentFilePath,
|
||||
if (fileInfo.path() == QFileInfo(currentDocumentFilePath).path()) {
|
||||
result = QLatin1Char('"') + fileInfo.fileName() + QLatin1Char('"');
|
||||
} else {
|
||||
foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
|
||||
for (const ProjectExplorer::HeaderPath &headerPath : headerPaths) {
|
||||
if (!candidateFilePath.startsWith(headerPath.path))
|
||||
continue;
|
||||
QString relativePath = candidateFilePath.mid(headerPath.path.size());
|
||||
@@ -1914,7 +1919,7 @@ ProjectExplorer::HeaderPaths relevantHeaderPaths(const QString &filePath)
|
||||
if (projectParts.isEmpty()) { // Not part of any project, better use all include paths than none
|
||||
headerPaths += modelManager->headerPaths();
|
||||
} else {
|
||||
foreach (const ProjectPart::ConstPtr &part, projectParts)
|
||||
for (const ProjectPart::ConstPtr &part : projectParts)
|
||||
headerPaths += part->headerPaths;
|
||||
}
|
||||
|
||||
@@ -1960,7 +1965,7 @@ LookupResult lookUpDefinition(const CppQuickFixInterface &interface, const NameA
|
||||
// Try to find the class/template definition
|
||||
const Name *name = nameAst->name;
|
||||
const QList<LookupItem> results = interface.context().lookup(name, scope);
|
||||
foreach (const LookupItem &item, results) {
|
||||
for (const LookupItem &item : results) {
|
||||
if (Symbol *declaration = item.declaration()) {
|
||||
if (declaration->isClass())
|
||||
return LookupResult::Declared;
|
||||
@@ -1991,7 +1996,8 @@ Snapshot forwardingHeaders(const CppQuickFixInterface &interface)
|
||||
{
|
||||
Snapshot result;
|
||||
|
||||
foreach (Document::Ptr doc, interface.snapshot()) {
|
||||
const Snapshot docs = interface.snapshot();
|
||||
for (Document::Ptr doc : docs) {
|
||||
if (doc->globalSymbolCount() == 0 && doc->resolvedIncludes().size() == 1)
|
||||
result.insert(doc);
|
||||
}
|
||||
@@ -2063,7 +2069,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
|
||||
if (matchName(nameAst->name, &matches, &className)) {
|
||||
QList<IndexItem::Ptr> indexItems;
|
||||
const Snapshot forwardHeaders = forwardingHeaders(interface);
|
||||
foreach (const Core::LocatorFilterEntry &entry, matches) {
|
||||
for (const Core::LocatorFilterEntry &entry : qAsConst(matches)) {
|
||||
IndexItem::Ptr info = entry.internalData.value<IndexItem::Ptr>();
|
||||
if (!info || info->symbolName() != className)
|
||||
continue;
|
||||
@@ -2075,7 +2081,7 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
|
||||
headerAndItsForwardingHeaders << Utils::FilePath::fromString(info->fileName());
|
||||
headerAndItsForwardingHeaders += localForwardHeaders.filesDependingOn(info->fileName());
|
||||
|
||||
foreach (const Utils::FilePath &header, headerAndItsForwardingHeaders) {
|
||||
for (const Utils::FilePath &header : qAsConst(headerAndItsForwardingHeaders)) {
|
||||
const QString include = findShortestInclude(currentDocumentFilePath,
|
||||
header.toString(),
|
||||
headerPaths);
|
||||
@@ -2328,7 +2334,7 @@ void ReformatPointerDeclaration::match(const CppQuickFixInterface &interface,
|
||||
} else {
|
||||
const QList<AST *> suitableASTs
|
||||
= ReformatPointerDeclarationASTPathResultsFilter().filter(path);
|
||||
foreach (AST *ast, suitableASTs) {
|
||||
for (AST *ast : suitableASTs) {
|
||||
change = formatter.format(ast);
|
||||
if (!change.isEmpty()) {
|
||||
result << new ReformatPointerDeclarationOp(interface, change);
|
||||
@@ -2421,7 +2427,7 @@ public:
|
||||
|
||||
static Enum *findEnum(const QList<LookupItem> &results, const LookupContext &ctxt)
|
||||
{
|
||||
foreach (const LookupItem &result, results) {
|
||||
for (const LookupItem &result : results) {
|
||||
const FullySpecifiedType fst = result.type();
|
||||
|
||||
Type *type = result.declaration() ? result.declaration()->type().type()
|
||||
@@ -2442,7 +2448,7 @@ static Enum *findEnum(const QList<LookupItem> &results, const LookupContext &ctx
|
||||
const Name *referenceName = namedType->name();
|
||||
if (const QualifiedNameId *qualifiedName = referenceName->asQualifiedNameId())
|
||||
referenceName = qualifiedName->name();
|
||||
foreach (Enum *e, enums) {
|
||||
for (Enum *e : qAsConst(enums)) {
|
||||
if (const Name *candidateName = e->name()) {
|
||||
if (candidateName->match(referenceName))
|
||||
return e;
|
||||
@@ -2505,9 +2511,9 @@ void CompleteSwitchCaseStatement::match(const CppQuickFixInterface &interface,
|
||||
Block *block = switchStatement->symbol;
|
||||
CaseStatementCollector caseValues(interface.semanticInfo().doc, interface.snapshot(),
|
||||
interface.semanticInfo().doc->scopeAt(block->line(), block->column()));
|
||||
QStringList usedValues = caseValues(switchStatement);
|
||||
const QStringList usedValues = caseValues(switchStatement);
|
||||
// save the values that would be added
|
||||
foreach (const QString &usedValue, usedValues)
|
||||
for (const QString &usedValue : usedValues)
|
||||
values.removeAll(usedValue);
|
||||
if (!values.isEmpty())
|
||||
result << new CompleteSwitchCaseStatementOp(interface, depth,
|
||||
@@ -2893,7 +2899,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
|
||||
// find appropriate implementation file, but do not use this
|
||||
// location, because insertLocationForMethodDefinition() should
|
||||
// be used in perform() to get consistent insert positions.
|
||||
foreach (const InsertionLocation &location,
|
||||
for (const InsertionLocation &location :
|
||||
locator.methodDefinition(decl, false, QString())) {
|
||||
if (!location.isValid())
|
||||
continue;
|
||||
@@ -5299,7 +5305,7 @@ void ExtractFunction::match(const CppQuickFixInterface &interface, QuickFixOpera
|
||||
bool usedAfterExtraction = false;
|
||||
bool usedInsideExtraction = false;
|
||||
const QList<SemanticInfo::Use> &uses = it.value();
|
||||
foreach (const SemanticInfo::Use &use, uses) {
|
||||
for (const SemanticInfo::Use &use : uses) {
|
||||
if (use.isInvalid())
|
||||
continue;
|
||||
|
||||
@@ -5781,7 +5787,8 @@ private:
|
||||
|
||||
// Fix all occurrences of the identifier in this function.
|
||||
ASTPath astPath(m_document);
|
||||
foreach (const SemanticInfo::Use &use, semanticInfo().localUses.value(m_symbol)) {
|
||||
const QList<SemanticInfo::Use> uses = semanticInfo().localUses.value(m_symbol);
|
||||
for (const SemanticInfo::Use &use : uses) {
|
||||
const QList<AST *> path = astPath(use.line, use.column);
|
||||
AST *idAST = path.last();
|
||||
bool declarationFound = false;
|
||||
@@ -5903,7 +5910,8 @@ private:
|
||||
|
||||
// Fix all occurrences of the identifier in this function.
|
||||
ASTPath astPath(m_document);
|
||||
foreach (const SemanticInfo::Use &use, semanticInfo().localUses.value(m_symbol)) {
|
||||
const QList<SemanticInfo::Use> uses = semanticInfo().localUses.value(m_symbol);
|
||||
for (const SemanticInfo::Use &use : uses) {
|
||||
const QList<AST *> path = astPath(use.line, use.column);
|
||||
AST *idAST = path.last();
|
||||
bool insertStar = true;
|
||||
@@ -6894,7 +6902,7 @@ void AssignToLocalVariable::match(const CppQuickFixInterface &interface, QuickFi
|
||||
TypeOfExpression::Preprocess);
|
||||
}
|
||||
|
||||
foreach (const LookupItem &item, items) {
|
||||
for (const LookupItem &item : qAsConst(items)) {
|
||||
if (!item.declaration())
|
||||
continue;
|
||||
|
||||
@@ -7310,7 +7318,7 @@ private:
|
||||
|
||||
Symbol *skipForwardDeclarations(const QList<Symbol *> &symbols)
|
||||
{
|
||||
foreach (Symbol *symbol, symbols) {
|
||||
for (Symbol *symbol : symbols) {
|
||||
if (!symbol->type()->isForwardClassDeclarationType())
|
||||
return symbol;
|
||||
}
|
||||
@@ -7342,7 +7350,7 @@ bool findRawAccessFunction(Class *klass, PointerType *pointerType, QString *objA
|
||||
break;
|
||||
default:
|
||||
// Multiple candidates - prefer a function named data
|
||||
foreach (Function *func, candidates) {
|
||||
for (Function *func : qAsConst(candidates)) {
|
||||
if (!strcmp(func->name()->identifier()->chars(), "data")) {
|
||||
funcName = func->name();
|
||||
break;
|
||||
|
@@ -122,7 +122,7 @@ SelectionList UseSelectionsTestCase::toSelectionList(
|
||||
const QList<QTextEdit::ExtraSelection> &extraSelections) const
|
||||
{
|
||||
SelectionList result;
|
||||
foreach (const QTextEdit::ExtraSelection &selection, extraSelections) {
|
||||
for (const QTextEdit::ExtraSelection &selection : extraSelections) {
|
||||
int line, column;
|
||||
const int position = qMin(selection.cursor.position(), selection.cursor.anchor());
|
||||
m_editorWidget->convertPosition(position, &line, &column);
|
||||
|
@@ -92,7 +92,7 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
|
||||
while (block.isValid()) {
|
||||
const QString &text = block.text();
|
||||
const Tokens &tks = lexer(text);
|
||||
foreach (const Token &tk, tks) {
|
||||
for (const Token &tk : tks) {
|
||||
if (tk.is(T_SEMICOLON) || tk.is(T_LBRACE)) {
|
||||
// No need to continue beyond this, we might already have something meaningful.
|
||||
cursor.setPosition(block.position() + tk.utf16charsEnd(), QTextCursor::KeepAnchor);
|
||||
|
@@ -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,7 +261,8 @@ 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);
|
||||
}
|
||||
@@ -269,7 +271,7 @@ void TestActionsTestCase::undoChangesInAllEditorWidgets()
|
||||
void TestActionsTestCase::executeActionsOnEditorWidget(CppEditorWidget *editorWidget,
|
||||
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();
|
||||
|
@@ -271,7 +271,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
||||
CppEditor::Tests::TemporaryDir temporaryDir;
|
||||
QVERIFY(temporaryDir.isValid());
|
||||
QString projectFileContent = "CppApplication { files: [";
|
||||
foreach (TestDocumentPtr testFile, testFiles) {
|
||||
for (TestDocumentPtr testFile : testFiles) {
|
||||
QVERIFY(testFile->baseDirectory().isEmpty());
|
||||
testFile->setBaseDirectory(temporaryDir.path());
|
||||
QVERIFY(testFile->writeToDisk());
|
||||
@@ -306,12 +306,12 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
||||
|
||||
// Update Code Model
|
||||
QSet<QString> filePaths;
|
||||
foreach (const TestDocumentPtr &testFile, testFiles)
|
||||
for (const TestDocumentPtr &testFile : testFiles)
|
||||
filePaths << testFile->filePath();
|
||||
QVERIFY(parseFiles(filePaths));
|
||||
|
||||
// Open Files
|
||||
foreach (TestDocumentPtr testFile, testFiles) {
|
||||
for (TestDocumentPtr testFile : testFiles) {
|
||||
QVERIFY(openCppEditor(testFile->filePath(), &testFile->m_editor,
|
||||
&testFile->m_editorWidget));
|
||||
if (!useClangd) // Editors get closed when unloading project.
|
||||
@@ -481,7 +481,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
||||
|
||||
TestDocumentPtr F2TestCase::testFileWithInitialCursorMarker(const QList<TestDocumentPtr> &testFiles)
|
||||
{
|
||||
foreach (const TestDocumentPtr testFile, testFiles) {
|
||||
for (const TestDocumentPtr &testFile : testFiles) {
|
||||
if (testFile->hasCursorMarker())
|
||||
return testFile;
|
||||
}
|
||||
@@ -490,7 +490,7 @@ TestDocumentPtr F2TestCase::testFileWithInitialCursorMarker(const QList<TestDocu
|
||||
|
||||
TestDocumentPtr F2TestCase::testFileWithTargetCursorMarker(const QList<TestDocumentPtr> &testFiles)
|
||||
{
|
||||
foreach (const TestDocumentPtr testFile, testFiles) {
|
||||
for (const TestDocumentPtr &testFile : testFiles) {
|
||||
if (testFile->hasTargetCursorMarker())
|
||||
return testFile;
|
||||
}
|
||||
|
@@ -128,10 +128,10 @@ static bool isVirtualFunction_helper(const Function *function,
|
||||
if (!firstVirtuals && res != Unknown)
|
||||
return res == True;
|
||||
|
||||
QList<LookupItem> results = context.lookup(function->name(), function->enclosingScope());
|
||||
const QList<LookupItem> results = context.lookup(function->name(), function->enclosingScope());
|
||||
if (!results.isEmpty()) {
|
||||
const bool isDestructor = function->name()->isDestructorNameId();
|
||||
foreach (const LookupItem &item, results) {
|
||||
for (const LookupItem &item : results) {
|
||||
if (Symbol *symbol = item.declaration()) {
|
||||
if (Function *functionType = symbol->type()->asFunctionType()) {
|
||||
if (functionType->name()->isDestructorNameId() != isDestructor)
|
||||
@@ -197,7 +197,7 @@ QList<Function *> FunctionUtils::overrides(Function *function, Class *functionsC
|
||||
Class *c = hierarchy.symbol()->asClass();
|
||||
QTC_ASSERT(c, continue);
|
||||
|
||||
foreach (const TypeHierarchy &t, hierarchy.hierarchy()) {
|
||||
for (const TypeHierarchy &t : hierarchy.hierarchy()) {
|
||||
if (!l.contains(t))
|
||||
l << t;
|
||||
}
|
||||
|
@@ -119,7 +119,7 @@ void GeneratedCodeModelSupport::update(const QList<ProjectExplorer::ExtraCompile
|
||||
|
||||
CppModelManager * const mm = CppModelManager::instance();
|
||||
|
||||
foreach (ExtraCompiler *generator, generators) {
|
||||
for (ExtraCompiler *generator : generators) {
|
||||
if (extraCompilerCache.contains(generator))
|
||||
continue;
|
||||
|
||||
|
@@ -139,7 +139,7 @@ LineForNewIncludeDirective::LineForNewIncludeDirective(const QTextDocument *text
|
||||
|
||||
// Ignore *.moc includes if requested
|
||||
if (mocIncludeMode == IgnoreMocIncludes) {
|
||||
foreach (const Document::Include &include, includes) {
|
||||
for (const Document::Include &include : qAsConst(includes)) {
|
||||
if (!include.unresolvedFileName().endsWith(QLatin1String(".moc")))
|
||||
m_includes << include;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ int LineForNewIncludeDirective::findInsertLineForVeryFirstInclude(unsigned *newL
|
||||
const QByteArray includeGuardMacroName = m_cppDocument->includeGuardMacroName();
|
||||
if (!includeGuardMacroName.isEmpty()) {
|
||||
const QList<Macro> definedMacros = m_cppDocument->definedMacros();
|
||||
foreach (const Macro &definedMacro, definedMacros) {
|
||||
for (const Macro &definedMacro : definedMacros) {
|
||||
if (definedMacro.name() == includeGuardMacroName) {
|
||||
if (newLinesToPrepend)
|
||||
*newLinesToPrepend = 1;
|
||||
@@ -256,7 +256,7 @@ int LineForNewIncludeDirective::operator()(const QString &newIncludeFileName,
|
||||
|
||||
IncludeGroups groupsSameIncludeDir;
|
||||
IncludeGroups groupsMixedIncludeDirs;
|
||||
foreach (const IncludeGroup &group, groupsMatchingIncludeType) {
|
||||
for (const IncludeGroup &group : qAsConst(groupsMatchingIncludeType)) {
|
||||
if (group.hasCommonIncludeDir())
|
||||
groupsSameIncludeDir << group;
|
||||
else
|
||||
@@ -264,7 +264,7 @@ int LineForNewIncludeDirective::operator()(const QString &newIncludeFileName,
|
||||
}
|
||||
|
||||
IncludeGroups groupsMatchingIncludeDir;
|
||||
foreach (const IncludeGroup &group, groupsSameIncludeDir) {
|
||||
for (const IncludeGroup &group : qAsConst(groupsSameIncludeDir)) {
|
||||
if (group.commonIncludeDir() == includeDir(pureIncludeFileName))
|
||||
groupsMatchingIncludeDir << group;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ int LineForNewIncludeDirective::operator()(const QString &newIncludeFileName,
|
||||
if (!groupsMatchingIncludeDir.isEmpty()) {
|
||||
// The group with the longest common matching prefix is the best group
|
||||
int longestPrefixSoFar = 0;
|
||||
foreach (const IncludeGroup &group, groupsMatchingIncludeDir) {
|
||||
for (const IncludeGroup &group : qAsConst(groupsMatchingIncludeDir)) {
|
||||
const int groupPrefixLength = group.commonPrefix().length();
|
||||
if (groupPrefixLength >= longestPrefixSoFar) {
|
||||
bestGroup = group;
|
||||
@@ -295,12 +295,12 @@ int LineForNewIncludeDirective::operator()(const QString &newIncludeFileName,
|
||||
// group with mixed include dirs
|
||||
} else {
|
||||
IncludeGroups groupsIncludeDir;
|
||||
foreach (const IncludeGroup &group, groupsMixedIncludeDirs) {
|
||||
for (const IncludeGroup &group : qAsConst(groupsMixedIncludeDirs)) {
|
||||
groupsIncludeDir.append(
|
||||
IncludeGroup::detectIncludeGroupsByIncludeDir(group.includes()));
|
||||
}
|
||||
IncludeGroup localBestIncludeGroup = IncludeGroup(QList<Include>());
|
||||
foreach (const IncludeGroup &group, groupsIncludeDir) {
|
||||
for (const IncludeGroup &group : qAsConst(groupsIncludeDir)) {
|
||||
if (group.commonIncludeDir() == includeDir(pureIncludeFileName))
|
||||
localBestIncludeGroup = group;
|
||||
}
|
||||
@@ -330,7 +330,7 @@ QList<IncludeGroup> IncludeGroup::detectIncludeGroupsByNewLines(QList<Document::
|
||||
int lastLine = 0;
|
||||
QList<Include> currentIncludes;
|
||||
bool isFirst = true;
|
||||
foreach (const Include &include, includes) {
|
||||
for (const Include &include : qAsConst(includes)) {
|
||||
// First include...
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
@@ -361,7 +361,7 @@ QList<IncludeGroup> IncludeGroup::detectIncludeGroupsByIncludeDir(const QList<In
|
||||
QString lastDir;
|
||||
QList<Include> currentIncludes;
|
||||
bool isFirst = true;
|
||||
foreach (const Include &include, includes) {
|
||||
for (const Include &include : includes) {
|
||||
const QString currentDirPrefix = includeDir(include.unresolvedFileName());
|
||||
|
||||
// First include...
|
||||
@@ -394,7 +394,7 @@ QList<IncludeGroup> IncludeGroup::detectIncludeGroupsByIncludeType(const QList<I
|
||||
Client::IncludeType lastIncludeType = Client::IncludeLocal;
|
||||
QList<Include> currentIncludes;
|
||||
bool isFirst = true;
|
||||
foreach (const Include &include, includes) {
|
||||
for (const Include &include : includes) {
|
||||
const Client::IncludeType currentIncludeType = include.type();
|
||||
|
||||
// First include...
|
||||
@@ -425,7 +425,7 @@ QList<IncludeGroup> IncludeGroup::filterIncludeGroups(const QList<IncludeGroup>
|
||||
Client::IncludeType includeType)
|
||||
{
|
||||
QList<IncludeGroup> result;
|
||||
foreach (const IncludeGroup &group, groups) {
|
||||
for (const IncludeGroup &group : groups) {
|
||||
if (group.hasOnlyIncludesOfType(includeType))
|
||||
result << group;
|
||||
}
|
||||
@@ -436,7 +436,7 @@ QList<IncludeGroup> IncludeGroup::filterIncludeGroups(const QList<IncludeGroup>
|
||||
QList<IncludeGroup> IncludeGroup::filterMixedIncludeGroups(const QList<IncludeGroup> &groups)
|
||||
{
|
||||
QList<IncludeGroup> result;
|
||||
foreach (const IncludeGroup &group, groups) {
|
||||
for (const IncludeGroup &group : groups) {
|
||||
if (!group.hasOnlyIncludesOfType(Client::IncludeLocal)
|
||||
&& !group.hasOnlyIncludesOfType(Client::IncludeGlobal)) {
|
||||
result << group;
|
||||
@@ -447,7 +447,7 @@ QList<IncludeGroup> IncludeGroup::filterMixedIncludeGroups(const QList<IncludeGr
|
||||
|
||||
bool IncludeGroup::hasOnlyIncludesOfType(Client::IncludeType includeType) const
|
||||
{
|
||||
foreach (const Include &include, m_includes) {
|
||||
for (const Include &include : qAsConst(m_includes)) {
|
||||
if (include.type() != includeType)
|
||||
return false;
|
||||
}
|
||||
@@ -490,7 +490,7 @@ int IncludeGroup::lineForNewInclude(const QString &newIncludeFileName,
|
||||
QStringList IncludeGroup::filesNames() const
|
||||
{
|
||||
QStringList names;
|
||||
foreach (const Include &include, m_includes)
|
||||
for (const Include &include : qAsConst(m_includes))
|
||||
names << include.unresolvedFileName();
|
||||
return names;
|
||||
}
|
||||
|
@@ -99,7 +99,7 @@ public:
|
||||
VisitorResult visitAllChildren(Visitor callback) const
|
||||
{
|
||||
VisitorResult result = Recurse;
|
||||
foreach (const IndexItem::Ptr &child, m_children) {
|
||||
for (const IndexItem::Ptr &child : qAsConst(m_children)) {
|
||||
result = callback(child);
|
||||
switch (result) {
|
||||
case Break:
|
||||
|
@@ -445,8 +445,8 @@ public:
|
||||
_bestToken.maybeSet(-1, lastToken);
|
||||
|
||||
if (lastToken >= 2) {
|
||||
QList<const Name *> names = LookupContext::fullyQualifiedName(decl);
|
||||
foreach (const Name *name, names) {
|
||||
const QList<const Name *> names = LookupContext::fullyQualifiedName(decl);
|
||||
for (const Name *name : names) {
|
||||
const Identifier *id = name->asNameId();
|
||||
if (!id)
|
||||
break;
|
||||
|
@@ -172,7 +172,8 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
|
||||
}
|
||||
|
||||
Hit best;
|
||||
foreach (const QString &fileName, fileIterationOrder(declFile, snapshot)) {
|
||||
const QStringList fileNames = fileIterationOrder(declFile, snapshot);
|
||||
for (const QString &fileName : fileNames) {
|
||||
Document::Ptr doc = snapshot.document(fileName);
|
||||
if (!doc) {
|
||||
clearCache(declFile, fileName);
|
||||
@@ -251,7 +252,8 @@ Symbol *SymbolFinder::findMatchingVarDefinition(Symbol *declaration, const Snaps
|
||||
using SymbolWithPriority = QPair<Symbol *, bool>;
|
||||
QList<SymbolWithPriority> candidates;
|
||||
QList<SymbolWithPriority> fallbacks;
|
||||
foreach (const QString &fileName, fileIterationOrder(declFile, snapshot)) {
|
||||
const QStringList fileNames = fileIterationOrder(declFile, snapshot);
|
||||
for (const QString &fileName : fileNames) {
|
||||
Document::Ptr doc = snapshot.document(fileName);
|
||||
if (!doc) {
|
||||
clearCache(declFile, fileName);
|
||||
@@ -320,7 +322,8 @@ Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Sna
|
||||
|
||||
QString declFile = QString::fromUtf8(declaration->fileName(), declaration->fileNameLength());
|
||||
|
||||
foreach (const QString &file, fileIterationOrder(declFile, snapshot)) {
|
||||
const QStringList fileNames = fileIterationOrder(declFile, snapshot);
|
||||
for (const QString &file : fileNames) {
|
||||
Document::Ptr doc = snapshot.document(file);
|
||||
if (!doc) {
|
||||
clearCache(declFile, file);
|
||||
@@ -337,7 +340,8 @@ Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Sna
|
||||
if (!type)
|
||||
continue;
|
||||
|
||||
foreach (Symbol *s, type->symbols()) {
|
||||
const QList<Symbol *> symbols = type->symbols();
|
||||
for (Symbol *s : symbols) {
|
||||
if (Class *c = s->asClass())
|
||||
return c;
|
||||
}
|
||||
@@ -411,7 +415,8 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context,
|
||||
operatorNameId = onid->kind();
|
||||
}
|
||||
|
||||
foreach (Symbol *s, binding->symbols()) {
|
||||
const QList<Symbol *> symbols = binding->symbols();
|
||||
for (Symbol *s : symbols) {
|
||||
Scope *scope = s->asScope();
|
||||
if (!scope)
|
||||
continue;
|
||||
@@ -460,7 +465,7 @@ QStringList SymbolFinder::fileIterationOrder(const QString &referenceFile, const
|
||||
if (m_filePriorityCache.contains(referenceFile)) {
|
||||
checkCacheConsistency(referenceFile, snapshot);
|
||||
} else {
|
||||
foreach (Document::Ptr doc, snapshot)
|
||||
for (Document::Ptr doc : snapshot)
|
||||
insertCache(referenceFile, doc->fileName());
|
||||
}
|
||||
|
||||
@@ -484,7 +489,7 @@ void SymbolFinder::checkCacheConsistency(const QString &referenceFile, const Sna
|
||||
// The counterpart validation for "old" files is done when one tries to access the
|
||||
// corresponding document and notices it's now null.
|
||||
const QSet<QString> &meta = m_fileMetaCache.value(referenceFile);
|
||||
foreach (const Document::Ptr &doc, snapshot) {
|
||||
for (const Document::Ptr &doc : snapshot) {
|
||||
if (!meta.contains(doc->fileName()))
|
||||
insertCache(referenceFile, doc->fileName());
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ QString toString(const TypeHierarchy &hierarchy, int indent = 0)
|
||||
Utils::sort(sortedHierarchy, [&oo](const TypeHierarchy &h1, const TypeHierarchy &h2) -> bool {
|
||||
return oo.prettyName(h1.symbol()->name()) < oo.prettyName(h2.symbol()->name());
|
||||
});
|
||||
foreach (TypeHierarchy childHierarchy, sortedHierarchy)
|
||||
for (const TypeHierarchy &childHierarchy : qAsConst(sortedHierarchy))
|
||||
result += toString(childHierarchy, indent + 2);
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user