forked from qt-creator/qt-creator
CppEditor: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: I9915cf2c07bdcc570efc20601752d60f2ec82f34 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -77,7 +77,7 @@ public:
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override
|
||||
{
|
||||
auto mimeData = new Utils::DropMimeData;
|
||||
foreach (const QModelIndex &index, indexes) {
|
||||
for (const QModelIndex &index : indexes) {
|
||||
const QVariant fileName = data(index, FileNameRole);
|
||||
if (!fileName.canConvert<QString>())
|
||||
continue;
|
||||
|
||||
@@ -209,7 +209,7 @@ private:
|
||||
const SemanticUses &uses = it.value();
|
||||
|
||||
bool good = false;
|
||||
foreach (const SemanticInfo::Use &use, uses) {
|
||||
for (const SemanticInfo::Use &use : uses) {
|
||||
if (m_line == use.line && m_column >= use.column
|
||||
&& m_column <= static_cast<int>(use.column + use.length)) {
|
||||
good = true;
|
||||
@@ -296,7 +296,8 @@ bool handleMacroCase(const Document::Ptr document,
|
||||
ranges->append(toRange(textCursor, macro->utf16CharOffset(), length));
|
||||
|
||||
// Other macro uses
|
||||
foreach (const Document::MacroUse &use, document->macroUses()) {
|
||||
const QList<Document::MacroUse> macroUses = document->macroUses();
|
||||
for (const Document::MacroUse &use : macroUses) {
|
||||
if (isMacroUseOf(use, *macro))
|
||||
ranges->append(toRange(textCursor, use.utf16charsBegin(), length));
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
||||
} else {
|
||||
// Remove changed files from the snapshot
|
||||
QSet<Utils::FilePath> toRemove;
|
||||
foreach (const Document::Ptr &doc, state.snapshot) {
|
||||
for (const Document::Ptr &doc : qAsConst(state.snapshot)) {
|
||||
const Utils::FilePath fileName = Utils::FilePath::fromString(doc->fileName());
|
||||
if (workingCopy.contains(fileName)) {
|
||||
if (workingCopy.get(fileName).second != doc->editorRevision())
|
||||
@@ -169,7 +169,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
||||
|
||||
if (!toRemove.isEmpty()) {
|
||||
invalidateSnapshot = true;
|
||||
foreach (const Utils::FilePath &fileName, toRemove)
|
||||
for (const Utils::FilePath &fileName : qAsConst(toRemove))
|
||||
state.snapshot.remove(fileName);
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ void BuiltinEditorDocumentParser::updateImpl(const QFutureInterface<void> &futur
|
||||
sourceProcessor.setLanguageFeatures(features);
|
||||
sourceProcessor.run(configurationFileName);
|
||||
if (baseConfig.usePrecompiledHeaders) {
|
||||
foreach (const QString &precompiledHeader, state.precompiledHeaders)
|
||||
for (const QString &precompiledHeader : qAsConst(state.precompiledHeaders))
|
||||
sourceProcessor.run(precompiledHeader);
|
||||
}
|
||||
if (!baseState.editorDefines.isEmpty())
|
||||
|
||||
@@ -62,7 +62,7 @@ QList<QTextEdit::ExtraSelection> toTextEditorSelections(
|
||||
QTextCharFormat errorFormat = fontSettings.toTextCharFormat(TextEditor::C_ERROR);
|
||||
|
||||
QList<QTextEdit::ExtraSelection> result;
|
||||
foreach (const CPlusPlus::Document::DiagnosticMessage &m, diagnostics) {
|
||||
for (const CPlusPlus::Document::DiagnosticMessage &m : diagnostics) {
|
||||
QTextEdit::ExtraSelection sel;
|
||||
if (m.isWarning())
|
||||
sel.format = warningFormat;
|
||||
@@ -108,7 +108,8 @@ CheckSymbols *createHighlighter(const CPlusPlus::Document::Ptr &doc,
|
||||
using Utils::Text::convertPosition;
|
||||
|
||||
// Get macro definitions
|
||||
foreach (const CPlusPlus::Macro& macro, doc->definedMacros()) {
|
||||
const QList<CPlusPlus::Macro> definedMacros = doc->definedMacros();
|
||||
for (const CPlusPlus::Macro ¯o : definedMacros) {
|
||||
int line, column;
|
||||
convertPosition(textDocument, macro.utf16CharOffset(), &line, &column);
|
||||
|
||||
@@ -119,7 +120,8 @@ CheckSymbols *createHighlighter(const CPlusPlus::Document::Ptr &doc,
|
||||
const LanguageFeatures features = doc->languageFeatures();
|
||||
|
||||
// Get macro uses
|
||||
foreach (const Document::MacroUse ¯o, doc->macroUses()) {
|
||||
const QList<Document::MacroUse> macroUseList = doc->macroUses();
|
||||
for (const Document::MacroUse ¯o : macroUseList) {
|
||||
const QString name = macro.macro().nameToQString();
|
||||
|
||||
//Filter out QtKeywords
|
||||
@@ -150,7 +152,7 @@ QList<TextEditor::BlockRange> toTextEditorBlocks(
|
||||
{
|
||||
QList<TextEditor::BlockRange> result;
|
||||
result.reserve(skippedBlocks.size());
|
||||
foreach (const CPlusPlus::Document::Block &block, skippedBlocks)
|
||||
for (const CPlusPlus::Document::Block &block : skippedBlocks)
|
||||
result.append(TextEditor::BlockRange(block.utf16charsBegin(), block.utf16charsEnd()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,8 @@ public:
|
||||
using namespace CPlusPlus;
|
||||
const QString fileName = document->fileName();
|
||||
|
||||
foreach (const Document::DiagnosticMessage &message, document->diagnosticMessages()) {
|
||||
const QList<Document::DiagnosticMessage> messages = document->diagnosticMessages();
|
||||
for (const Document::DiagnosticMessage &message : messages) {
|
||||
++m_processedDiagnostics;
|
||||
|
||||
QString type;
|
||||
@@ -125,7 +126,7 @@ private:
|
||||
|
||||
void classifyFiles(const QSet<QString> &files, QStringList *headers, QStringList *sources)
|
||||
{
|
||||
foreach (const QString &file, files) {
|
||||
for (const QString &file : files) {
|
||||
if (ProjectFile::isSource(ProjectFile::classify(file)))
|
||||
sources->append(file);
|
||||
else
|
||||
@@ -189,7 +190,7 @@ void index(QFutureInterface<void> &indexingFuture,
|
||||
QStringList headers;
|
||||
classifyFiles(params.sourceFiles, &headers, &sources);
|
||||
|
||||
foreach (const QString &file, params.sourceFiles)
|
||||
for (const QString &file : qAsConst(params.sourceFiles))
|
||||
sourceProcessor->removeFromCache(file);
|
||||
|
||||
const int sourceCount = sources.size();
|
||||
|
||||
@@ -97,7 +97,8 @@ protected:
|
||||
if (!processed->contains(doc->globalNamespace())) {
|
||||
processed->insert(doc->globalNamespace());
|
||||
|
||||
foreach (const Document::Include &i, doc->resolvedIncludes())
|
||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||
for (const Document::Include &i : includes)
|
||||
process(_snapshot.document(i.resolvedFileName()), processed);
|
||||
|
||||
_mainDocument = (doc == _doc); // ### improve
|
||||
@@ -752,7 +753,8 @@ bool CheckSymbols::visit(NewExpressionAST *ast)
|
||||
}
|
||||
|
||||
Scope *scope = enclosingScope();
|
||||
foreach (Symbol *s, binding->symbols()) {
|
||||
const QList<Symbol *> symbols = binding->symbols();
|
||||
for (Symbol *s : symbols) {
|
||||
if (Class *klass = s->asClass()) {
|
||||
scope = klass;
|
||||
break;
|
||||
@@ -787,7 +789,8 @@ void CheckSymbols::checkNamespace(NameAST *name)
|
||||
getTokenStartPosition(name->firstToken(), &line, &column);
|
||||
|
||||
if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) {
|
||||
foreach (Symbol *s, b->symbols()) {
|
||||
const QList<Symbol *> symbols = b->symbols();
|
||||
for (const Symbol *s : symbols) {
|
||||
if (s->isNamespace())
|
||||
return;
|
||||
}
|
||||
@@ -829,7 +832,8 @@ bool CheckSymbols::hasVirtualDestructor(ClassOrNamespace *binding) const
|
||||
ClassOrNamespace *b = todo.takeFirst();
|
||||
if (b && !processed.contains(b)) {
|
||||
processed.insert(b);
|
||||
foreach (Symbol *s, b->symbols()) {
|
||||
const QList<Symbol *> symbols = b->symbols();
|
||||
for (Symbol *s : symbols) {
|
||||
if (Class *k = s->asClass()) {
|
||||
if (hasVirtualDestructor(k))
|
||||
return true;
|
||||
@@ -1006,7 +1010,8 @@ bool CheckSymbols::visit(MemInitializerAST *ast)
|
||||
if (FunctionDefinitionAST *enclosingFunction = enclosingFunctionDefinition()) {
|
||||
if (ast->name && enclosingFunction->symbol) {
|
||||
if (ClassOrNamespace *binding = _context.lookupType(enclosingFunction->symbol)) {
|
||||
foreach (Symbol *s, binding->symbols()) {
|
||||
const QList<Symbol *> symbols = binding->symbols();
|
||||
for (Symbol *s : symbols) {
|
||||
if (Class *klass = s->asClass()) {
|
||||
NameAST *nameAST = ast->name;
|
||||
if (QualifiedNameAST *q = nameAST->asQualifiedName()) {
|
||||
@@ -1137,8 +1142,8 @@ bool CheckSymbols::visit(FunctionDefinitionAST *ast)
|
||||
accept(ast->function_body);
|
||||
|
||||
const Internal::LocalSymbols locals(_doc, ast);
|
||||
foreach (const QList<Result> &uses, locals.uses) {
|
||||
foreach (const Result &u, uses)
|
||||
for (const QList<Result> &uses : qAsConst(locals.uses)) {
|
||||
for (const Result &u : uses)
|
||||
addUse(u);
|
||||
}
|
||||
|
||||
@@ -1257,7 +1262,7 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
|
||||
if (tok.generated())
|
||||
return false;
|
||||
|
||||
foreach (const LookupItem &r, candidates) {
|
||||
for (const LookupItem &r : candidates) {
|
||||
Symbol *c = r.declaration();
|
||||
if (c->isUsingDeclaration()) // skip using declarations...
|
||||
continue;
|
||||
@@ -1300,7 +1305,7 @@ bool CheckSymbols::maybeAddField(const QList<LookupItem> &candidates, NameAST *a
|
||||
if (tok.generated())
|
||||
return false;
|
||||
|
||||
foreach (const LookupItem &r, candidates) {
|
||||
for (const LookupItem &r : candidates) {
|
||||
Symbol *c = r.declaration();
|
||||
if (!c)
|
||||
continue;
|
||||
@@ -1345,7 +1350,7 @@ bool CheckSymbols::maybeAddFunction(const QList<LookupItem> &candidates, NameAST
|
||||
|
||||
Kind kind = functionKind == FunctionDeclaration ? SemanticHighlighter::FunctionDeclarationUse
|
||||
: SemanticHighlighter::FunctionUse;
|
||||
foreach (const LookupItem &r, candidates) {
|
||||
for (const LookupItem &r : candidates) {
|
||||
Symbol *c = r.declaration();
|
||||
|
||||
// Skip current if there's no declaration or name.
|
||||
|
||||
@@ -1112,9 +1112,9 @@ void CodeFormatter::dump() const
|
||||
|
||||
qDebug() << "Current token index" << m_tokenIndex;
|
||||
qDebug() << "Current state:";
|
||||
foreach (const State &s, m_currentState) {
|
||||
for (const State &s : qAsConst(m_currentState))
|
||||
qDebug() << metaEnum.valueToKey(s.type) << s.savedIndentDepth << s.savedPaddingDepth;
|
||||
}
|
||||
|
||||
qDebug() << "Current indent depth:" << m_indentDepth;
|
||||
qDebug() << "Current padding depth:" << m_paddingDepth;
|
||||
}
|
||||
|
||||
@@ -1139,8 +1139,9 @@ void ProjectPartsModel::configure(const QList<ProjectInfo::ConstPtr> &projectInf
|
||||
{
|
||||
emit layoutAboutToBeChanged();
|
||||
m_projectPartsList.clear();
|
||||
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
|
||||
foreach (const ProjectPart::ConstPtr &projectPart, info->projectParts()) {
|
||||
for (const ProjectInfo::ConstPtr &info : qAsConst(projectInfos)) {
|
||||
const QVector<ProjectPart::ConstPtr> projectParts = info->projectParts();
|
||||
for (const ProjectPart::ConstPtr &projectPart : projectParts) {
|
||||
if (!m_projectPartsList.contains(projectPart)) {
|
||||
m_projectPartsList << projectPart;
|
||||
if (projectPart == currentEditorsProjectPart)
|
||||
@@ -1160,7 +1161,7 @@ QModelIndex ProjectPartsModel::indexForCurrentEditorsProjectPart() const
|
||||
|
||||
ProjectPart::ConstPtr ProjectPartsModel::projectPartForProjectId(const QString &projectPartId) const
|
||||
{
|
||||
foreach (const ProjectPart::ConstPtr &part, m_projectPartsList) {
|
||||
for (const ProjectPart::ConstPtr &part : qAsConst(m_projectPartsList)) {
|
||||
if (part->id() == projectPartId)
|
||||
return part;
|
||||
}
|
||||
|
||||
@@ -411,7 +411,7 @@ QString Utils::partsForFile(const QString &fileName)
|
||||
const QList<ProjectPart::ConstPtr> parts
|
||||
= CppModelManager::instance()->projectPart(fileName);
|
||||
QString result;
|
||||
foreach (const ProjectPart::ConstPtr &part, parts)
|
||||
for (const ProjectPart::ConstPtr &part : parts)
|
||||
result += part->displayName + QLatin1Char(',');
|
||||
if (result.endsWith(QLatin1Char(',')))
|
||||
result.chop(1);
|
||||
@@ -429,7 +429,7 @@ QString Utils::unresolvedFileNameWithDelimiters(const CPlusPlus::Document::Inclu
|
||||
QString Utils::pathListToString(const QStringList &pathList)
|
||||
{
|
||||
QStringList result;
|
||||
foreach (const QString &path, pathList)
|
||||
for (const QString &path : pathList)
|
||||
result << QDir::toNativeSeparators(path);
|
||||
return result.join(QLatin1Char('\n'));
|
||||
}
|
||||
@@ -437,10 +437,10 @@ QString Utils::pathListToString(const QStringList &pathList)
|
||||
QString Utils::pathListToString(const ProjectExplorer::HeaderPaths &pathList)
|
||||
{
|
||||
QStringList result;
|
||||
foreach (const ProjectExplorer::HeaderPath &path, pathList) {
|
||||
for (const ProjectExplorer::HeaderPath &path : pathList)
|
||||
result << QString(QLatin1String("%1 (%2 path)")).arg(
|
||||
QDir::toNativeSeparators(path.path), toString(path.type));
|
||||
}
|
||||
|
||||
return result.join(QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
@@ -509,12 +509,12 @@ void Dumper::dumpProjectInfos(const QList<ProjectInfo::ConstPtr> &projectInfos)
|
||||
const QByteArray i4 = indent(4);
|
||||
|
||||
m_out << "Projects loaded: " << projectInfos.size() << "{{{1\n";
|
||||
foreach (const ProjectInfo::ConstPtr &info, projectInfos) {
|
||||
for (const ProjectInfo::ConstPtr &info : projectInfos) {
|
||||
m_out << i1 << "Project " << info->projectName()
|
||||
<< " (" << info->projectFilePath().toUserOutput() << "){{{2\n";
|
||||
|
||||
const QVector<ProjectPart::ConstPtr> projectParts = info->projectParts();
|
||||
foreach (const ProjectPart::ConstPtr &part, projectParts) {
|
||||
for (const ProjectPart::ConstPtr &part : projectParts) {
|
||||
QString projectName = QLatin1String("<None>");
|
||||
QString projectFilePath = "<None>";
|
||||
if (part->hasProject()) {
|
||||
@@ -543,7 +543,7 @@ void Dumper::dumpProjectInfos(const QList<ProjectInfo::ConstPtr> &projectInfos)
|
||||
|
||||
if (!part->files.isEmpty()) {
|
||||
m_out << i3 << "Files:{{{4\n";
|
||||
foreach (const ProjectFile &projectFile, part->files) {
|
||||
for (const ProjectFile &projectFile : qAsConst(part->files)) {
|
||||
m_out << i4 << Utils::toString(projectFile.kind) << ": " << projectFile.path;
|
||||
if (!projectFile.active)
|
||||
m_out << " (inactive)";
|
||||
@@ -555,20 +555,20 @@ void Dumper::dumpProjectInfos(const QList<ProjectInfo::ConstPtr> &projectInfos)
|
||||
m_out << i3 << "Toolchain Defines:{{{4\n";
|
||||
const QList<QByteArray> defineLines =
|
||||
ProjectExplorer::Macro::toByteArray(part->toolChainMacros).split('\n');
|
||||
foreach (const QByteArray &defineLine, defineLines)
|
||||
for (const QByteArray &defineLine : defineLines)
|
||||
m_out << i4 << defineLine << "\n";
|
||||
}
|
||||
if (!part->projectMacros.isEmpty()) {
|
||||
m_out << i3 << "Project Defines:{{{4\n";
|
||||
const QList<QByteArray> defineLines =
|
||||
ProjectExplorer::Macro::toByteArray(part->projectMacros).split('\n');
|
||||
foreach (const QByteArray &defineLine, defineLines)
|
||||
for (const QByteArray &defineLine : defineLines)
|
||||
m_out << i4 << defineLine << "\n";
|
||||
}
|
||||
|
||||
if (!part->headerPaths.isEmpty()) {
|
||||
m_out << i3 << "Header Paths:{{{4\n";
|
||||
foreach (const ProjectExplorer::HeaderPath &headerPath, part->headerPaths) {
|
||||
for (const ProjectExplorer::HeaderPath &headerPath : qAsConst(part->headerPaths)) {
|
||||
m_out << i4 << headerPath.path;
|
||||
printIncludeType(m_out, headerPath.type);
|
||||
m_out << "\n";
|
||||
@@ -577,7 +577,7 @@ void Dumper::dumpProjectInfos(const QList<ProjectInfo::ConstPtr> &projectInfos)
|
||||
|
||||
if (!part->precompiledHeaders.isEmpty()) {
|
||||
m_out << i3 << "Precompiled Headers:{{{4\n";
|
||||
foreach (const QString &precompiledHeader, part->precompiledHeaders)
|
||||
for (const QString &precompiledHeader : qAsConst(part->precompiledHeaders))
|
||||
m_out << i4 << precompiledHeader << "\n";
|
||||
}
|
||||
} // for part
|
||||
@@ -601,7 +601,7 @@ void Dumper::dumpSnapshot(const CPlusPlus::Snapshot &snapshot, const QString &ti
|
||||
// Divide into shared and not shared
|
||||
QList<CPlusPlus::Document::Ptr> globallyShared;
|
||||
QList<CPlusPlus::Document::Ptr> notGloballyShared;
|
||||
foreach (const CPlusPlus::Document::Ptr &document, documents) {
|
||||
for (const CPlusPlus::Document::Ptr &document : documents) {
|
||||
CPlusPlus::Document::Ptr globalDocument = m_globalSnapshot.document(document->fileName());
|
||||
if (globalDocument && globalDocument->fingerprint() == document->fingerprint())
|
||||
globallyShared.append(document);
|
||||
@@ -641,7 +641,7 @@ void Dumper::dumpMergedEntities(const ProjectExplorer::HeaderPaths &mergedHeader
|
||||
const QByteArray i3 = indent(3);
|
||||
|
||||
m_out << i2 << "Merged Header Paths{{{2\n";
|
||||
foreach (const ProjectExplorer::HeaderPath &hp, mergedHeaderPaths) {
|
||||
for (const ProjectExplorer::HeaderPath &hp : mergedHeaderPaths) {
|
||||
m_out << i3 << hp.path;
|
||||
printIncludeType(m_out, hp.type);
|
||||
m_out << "\n";
|
||||
@@ -652,7 +652,7 @@ void Dumper::dumpMergedEntities(const ProjectExplorer::HeaderPaths &mergedHeader
|
||||
|
||||
void Dumper::dumpStringList(const QStringList &list, const QByteArray &indent)
|
||||
{
|
||||
foreach (const QString &item, list)
|
||||
for (const QString &item : list)
|
||||
m_out << indent << item << "\n";
|
||||
}
|
||||
|
||||
@@ -661,7 +661,7 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo
|
||||
const QByteArray i2 = indent(2);
|
||||
const QByteArray i3 = indent(3);
|
||||
const QByteArray i4 = indent(4);
|
||||
foreach (const CPlusPlus::Document::Ptr &document, documents) {
|
||||
for (const CPlusPlus::Document::Ptr &document : documents) {
|
||||
if (skipDetails) {
|
||||
m_out << i2 << "\"" << document->fileName() << "\"\n";
|
||||
continue;
|
||||
@@ -680,7 +680,7 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo
|
||||
+ document->resolvedIncludes();
|
||||
if (!includes.isEmpty()) {
|
||||
m_out << i3 << "Includes:{{{4\n";
|
||||
foreach (const CPlusPlus::Document::Include &include, includes) {
|
||||
for (const CPlusPlus::Document::Include &include : includes) {
|
||||
m_out << i4 << "at line " << include.line() << ": "
|
||||
<< Utils::unresolvedFileNameWithDelimiters(include) << " ==> "
|
||||
<< include.resolvedFileName() << "\n";
|
||||
@@ -691,7 +691,7 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo
|
||||
= document->diagnosticMessages();
|
||||
if (!diagnosticMessages.isEmpty()) {
|
||||
m_out << i3 << "Diagnostic Messages:{{{4\n";
|
||||
foreach (const CPlusPlus::Document::DiagnosticMessage &msg, diagnosticMessages) {
|
||||
for (const CPlusPlus::Document::DiagnosticMessage &msg : diagnosticMessages) {
|
||||
const auto level =
|
||||
static_cast<CPlusPlus::Document::DiagnosticMessage::Level>(msg.level());
|
||||
m_out << i4 << "at " << msg.line() << ":" << msg.column() << ", " << Utils::toString(level)
|
||||
@@ -702,14 +702,14 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo
|
||||
const QList<CPlusPlus::Macro> macroDefinitions = document->definedMacros();
|
||||
if (!macroDefinitions.isEmpty()) {
|
||||
m_out << i3 << "(Un)Defined Macros:{{{4\n";
|
||||
foreach (const CPlusPlus::Macro ¯o, macroDefinitions)
|
||||
for (const CPlusPlus::Macro ¯o : macroDefinitions)
|
||||
m_out << i4 << "at line " << macro.line() << ": " << macro.toString() << "\n";
|
||||
}
|
||||
|
||||
const QList<CPlusPlus::Document::MacroUse> macroUses = document->macroUses();
|
||||
if (!macroUses.isEmpty()) {
|
||||
m_out << i3 << "Macro Uses:{{{4\n";
|
||||
foreach (const CPlusPlus::Document::MacroUse &use, macroUses) {
|
||||
for (const CPlusPlus::Document::MacroUse &use : macroUses) {
|
||||
const QString type = use.isFunctionLike()
|
||||
? QLatin1String("function-like") : QLatin1String("object-like");
|
||||
m_out << i4 << "at line " << use.beginLine() << ", "
|
||||
|
||||
@@ -307,7 +307,7 @@ void CppCodeStylePreferencesWidget::updatePreview()
|
||||
const CppCodeStyleSettings ccss = cppCodeStylePreferences->currentCodeStyleSettings();
|
||||
const TabSettings ts = cppCodeStylePreferences->currentTabSettings();
|
||||
QtStyleCodeFormatter formatter(ts, ccss);
|
||||
foreach (SnippetEditorWidget *preview, m_previews) {
|
||||
for (SnippetEditorWidget *preview : qAsConst(m_previews)) {
|
||||
preview->textDocument()->setTabSettings(ts);
|
||||
preview->setCodeStyle(cppCodeStylePreferences);
|
||||
|
||||
@@ -329,7 +329,7 @@ void CppCodeStylePreferencesWidget::updatePreview()
|
||||
|
||||
void CppCodeStylePreferencesWidget::decorateEditors(const FontSettings &fontSettings)
|
||||
{
|
||||
foreach (SnippetEditorWidget *editor, m_previews) {
|
||||
for (SnippetEditorWidget *editor : qAsConst(m_previews)) {
|
||||
editor->textDocument()->setFontSettings(fontSettings);
|
||||
SnippetProvider::decorateEditor(editor, CppEditor::Constants::CPP_SNIPPETS_GROUP_ID);
|
||||
}
|
||||
@@ -337,7 +337,7 @@ void CppCodeStylePreferencesWidget::decorateEditors(const FontSettings &fontSett
|
||||
|
||||
void CppCodeStylePreferencesWidget::setVisualizeWhitespace(bool on)
|
||||
{
|
||||
foreach (SnippetEditorWidget *editor, m_previews) {
|
||||
for (SnippetEditorWidget *editor : qAsConst(m_previews)) {
|
||||
DisplaySettings displaySettings = editor->displaySettings();
|
||||
displaySettings.m_visualizeWhitespace = on;
|
||||
editor->setDisplaySettings(displaySettings);
|
||||
|
||||
@@ -277,7 +277,7 @@ void CompletionTest::testCompletionTemplateFunction()
|
||||
|
||||
QStringList actualCompletions = test.getCompletions();
|
||||
QString errorPattern(QLatin1String("Completion not found: %1"));
|
||||
foreach (const QString &completion, expectedCompletions) {
|
||||
for (const QString &completion : qAsConst(expectedCompletions)) {
|
||||
QByteArray errorMessage = errorPattern.arg(completion).toUtf8();
|
||||
QVERIFY2(actualCompletions.contains(completion), errorMessage.data());
|
||||
}
|
||||
@@ -371,7 +371,7 @@ void CompletionTest::testGlobalCompletion_data()
|
||||
"<REPLACEMENT>\n"
|
||||
"@\n";
|
||||
const QStringList replacements = QStringList({"// text", "// text.", "/// text", "/// text."});
|
||||
foreach (const QString &replacement, replacements) {
|
||||
for (const QString &replacement : replacements) {
|
||||
QByteArray code = codeTemplate;
|
||||
code.replace("<REPLACEMENT>", replacement.toUtf8());
|
||||
const QByteArray tag = _("completion after comment: ") + replacement.toUtf8();
|
||||
|
||||
@@ -790,7 +790,8 @@ Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &co
|
||||
if (!b)
|
||||
return nullptr;
|
||||
|
||||
foreach (Symbol *s, b->symbols()) {
|
||||
const QList<Symbol *> symbols = b->symbols();
|
||||
for (Symbol *s : symbols) {
|
||||
if (Class *klass = s->asClass())
|
||||
return klass;
|
||||
}
|
||||
@@ -1105,7 +1106,7 @@ bool InternalCppCompletionAssistProcessor::tryObjCCompletion()
|
||||
const QList<LookupItem> items = (*m_model->m_typeOfExpression)(expr.toUtf8(), scope);
|
||||
LookupContext lookupContext(thisDocument, m_interface->snapshot());
|
||||
|
||||
foreach (const LookupItem &item, items) {
|
||||
for (const LookupItem &item : items) {
|
||||
FullySpecifiedType ty = item.type().simplified();
|
||||
if (ty->isPointerType()) {
|
||||
ty = ty->asPointerType()->elementType().simplified();
|
||||
@@ -1169,12 +1170,14 @@ void InternalCppCompletionAssistProcessor::completeObjCMsgSend(ClassOrNamespace
|
||||
bool staticClassAccess)
|
||||
{
|
||||
QList<Scope*> memberScopes;
|
||||
foreach (Symbol *s, binding->symbols()) {
|
||||
|
||||
const QList<Symbol *> symbols = binding->symbols();
|
||||
for (Symbol *s : symbols) {
|
||||
if (ObjCClass *c = s->asObjCClass())
|
||||
memberScopes.append(c);
|
||||
}
|
||||
|
||||
foreach (Scope *scope, memberScopes) {
|
||||
for (Scope *scope : qAsConst(memberScopes)) {
|
||||
for (int i = 0; i < scope->memberCount(); ++i) {
|
||||
Symbol *symbol = scope->memberAt(i);
|
||||
|
||||
@@ -1239,7 +1242,7 @@ bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cu
|
||||
|
||||
const QStringList suffixes = Utils::mimeTypeForName(QLatin1String("text/x-c++hdr")).suffixes();
|
||||
|
||||
foreach (const ProjectExplorer::HeaderPath &headerPath, headerPaths) {
|
||||
for (const ProjectExplorer::HeaderPath &headerPath : qAsConst(headerPaths)) {
|
||||
QString realPath = headerPath.path;
|
||||
if (!directoryPrefix.isEmpty()) {
|
||||
realPath += QLatin1Char('/');
|
||||
@@ -1272,7 +1275,8 @@ void InternalCppCompletionAssistProcessor::completeInclude(const QString &realPa
|
||||
|
||||
void InternalCppCompletionAssistProcessor::completePreprocessor()
|
||||
{
|
||||
foreach (const QString &preprocessorCompletion, preprocessorCompletions())
|
||||
const QStringList preprocessorCompletionList = preprocessorCompletions();
|
||||
for (const QString &preprocessorCompletion : preprocessorCompletionList)
|
||||
addCompletionItem(preprocessorCompletion);
|
||||
|
||||
if (objcKeywordsWanted())
|
||||
@@ -1351,7 +1355,7 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString
|
||||
TypeOfExpression::Preprocess);
|
||||
|
||||
// If it's a class, add completions for the constructors
|
||||
foreach (const LookupItem &result, results) {
|
||||
for (const LookupItem &result : results) {
|
||||
if (result.type()->isClassType()) {
|
||||
if (completeConstructorOrFunction(results, endOfExpression, true))
|
||||
return m_positionForProposal;
|
||||
@@ -1482,7 +1486,8 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
|
||||
break;
|
||||
processed.insert(currentBinding);
|
||||
|
||||
foreach (ClassOrNamespace* u, currentBinding->usings())
|
||||
const QList<ClassOrNamespace*> usings = currentBinding->usings();
|
||||
for (ClassOrNamespace* u : usings)
|
||||
usingBindings.append(u);
|
||||
|
||||
const QList<Symbol *> symbols = currentBinding->symbols();
|
||||
@@ -1495,7 +1500,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ClassOrNamespace *b, usingBindings)
|
||||
for (ClassOrNamespace *b : qAsConst(usingBindings))
|
||||
completeNamespace(b);
|
||||
|
||||
addKeywords();
|
||||
@@ -1547,7 +1552,7 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem>
|
||||
if (results.isEmpty())
|
||||
return false;
|
||||
|
||||
foreach (const LookupItem &result, results) {
|
||||
for (const LookupItem &result : results) {
|
||||
FullySpecifiedType ty = result.type();
|
||||
Scope *scope = result.scope();
|
||||
|
||||
@@ -1625,12 +1630,14 @@ void InternalCppCompletionAssistProcessor::completeNamespace(ClassOrNamespace *b
|
||||
QList<Scope *> scopesToVisit;
|
||||
QSet<Scope *> scopesVisited;
|
||||
|
||||
foreach (Symbol *bb, binding->symbols()) {
|
||||
const QList<Symbol *> symbols = binding->symbols();
|
||||
for (Symbol *bb : symbols) {
|
||||
if (Scope *scope = bb->asScope())
|
||||
scopesToVisit.append(scope);
|
||||
}
|
||||
|
||||
foreach (Enum *e, binding->unscopedEnums())
|
||||
const QList<Enum *> enums = binding->unscopedEnums();
|
||||
for (Enum *e : enums)
|
||||
scopesToVisit.append(e);
|
||||
|
||||
while (!scopesToVisit.isEmpty()) {
|
||||
@@ -1665,14 +1672,16 @@ void InternalCppCompletionAssistProcessor::completeClass(ClassOrNamespace *b, bo
|
||||
QList<Scope *> scopesToVisit;
|
||||
QSet<Scope *> scopesVisited;
|
||||
|
||||
foreach (Symbol *bb, binding->symbols()) {
|
||||
const QList<Symbol *> symbols = binding->symbols();
|
||||
for (Symbol *bb : symbols) {
|
||||
if (Class *k = bb->asClass())
|
||||
scopesToVisit.append(k);
|
||||
else if (Block *b = bb->asBlock())
|
||||
scopesToVisit.append(b);
|
||||
}
|
||||
|
||||
foreach (Enum *e, binding->unscopedEnums())
|
||||
const QList<Enum *> enums = binding->unscopedEnums();
|
||||
for (Enum *e : enums)
|
||||
scopesToVisit.append(e);
|
||||
|
||||
while (!scopesToVisit.isEmpty()) {
|
||||
@@ -1740,7 +1749,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
|
||||
o.showFunctionSignatures = true;
|
||||
|
||||
QSet<QString> signatures;
|
||||
foreach (const LookupItem &lookupItem, results) {
|
||||
for (const LookupItem &lookupItem : results) {
|
||||
ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context);
|
||||
if (!b)
|
||||
continue;
|
||||
@@ -1754,7 +1763,8 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
|
||||
if (!processed.contains(binding)) {
|
||||
processed.insert(binding);
|
||||
|
||||
foreach (Symbol *s, binding->symbols())
|
||||
const QList<Symbol *> symbols = binding->symbols();
|
||||
for (Symbol *s : symbols)
|
||||
if (Class *clazz = s->asClass())
|
||||
scopes.append(clazz);
|
||||
|
||||
@@ -1764,7 +1774,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt
|
||||
|
||||
const bool wantSignals = type == CompleteQt4Signals || type == CompleteQt5Signals;
|
||||
const bool wantQt5SignalOrSlot = type == CompleteQt5Signals || type == CompleteQt5Slots;
|
||||
foreach (Scope *scope, scopes) {
|
||||
for (Scope *scope : qAsConst(scopes)) {
|
||||
Class *klass = scope->asClass();
|
||||
if (!klass)
|
||||
continue;
|
||||
@@ -1821,7 +1831,7 @@ bool InternalCppCompletionAssistProcessor::completeQtMethodClassName(
|
||||
const QIcon classIcon = Utils::CodeModelIcon::iconForType(Utils::CodeModelIcon::Class);
|
||||
Overview overview;
|
||||
|
||||
foreach (const LookupItem &lookupItem, results) {
|
||||
for (const LookupItem &lookupItem : results) {
|
||||
Class *klass = classFromLookupItem(lookupItem, context);
|
||||
if (!klass)
|
||||
continue;
|
||||
@@ -1864,7 +1874,7 @@ void InternalCppCompletionAssistProcessor::addMacros(const QString &fileName,
|
||||
|
||||
addMacros_helper(snapshot, fileName, &processed, &definedMacros);
|
||||
|
||||
foreach (const QString ¯oName, definedMacros)
|
||||
for (const QString ¯oName : qAsConst(definedMacros))
|
||||
addCompletionItem(macroName, Icons::macroIcon(), MacrosOrder);
|
||||
}
|
||||
|
||||
@@ -1880,10 +1890,12 @@ void InternalCppCompletionAssistProcessor::addMacros_helper(const Snapshot &snap
|
||||
|
||||
processed->insert(doc->fileName());
|
||||
|
||||
foreach (const Document::Include &i, doc->resolvedIncludes())
|
||||
const QList<Document::Include> includes = doc->resolvedIncludes();
|
||||
for (const Document::Include &i : includes)
|
||||
addMacros_helper(snapshot, i.resolvedFileName(), processed, definedMacros);
|
||||
|
||||
foreach (const CPlusPlus::Macro ¯o, doc->definedMacros()) {
|
||||
const QList<CPlusPlus::Macro> macros = doc->definedMacros();
|
||||
for (const CPlusPlus::Macro ¯o : macros) {
|
||||
const QString macroName = macro.nameToQString();
|
||||
if (!macro.isHidden())
|
||||
definedMacros->insert(macroName);
|
||||
@@ -1899,7 +1911,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
||||
const LookupContext &context = m_model->m_typeOfExpression->context();
|
||||
QList<Function *> functions;
|
||||
|
||||
foreach (const LookupItem &result, results) {
|
||||
for (const LookupItem &result : results) {
|
||||
FullySpecifiedType exprTy = result.type().simplified();
|
||||
|
||||
if (Class *klass = asClassOrTemplateClassType(exprTy)) {
|
||||
@@ -1930,7 +1942,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
||||
}
|
||||
|
||||
if (functions.isEmpty()) {
|
||||
foreach (const LookupItem &result, results) {
|
||||
for (const LookupItem &result : results) {
|
||||
FullySpecifiedType ty = result.type().simplified();
|
||||
|
||||
if (Function *fun = asFunctionOrTemplateFunctionType(ty)) {
|
||||
@@ -1945,7 +1957,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
||||
|
||||
bool newOverload = true;
|
||||
|
||||
foreach (Function *f, functions) {
|
||||
for (Function *f : qAsConst(functions)) {
|
||||
if (fun->match(f)) {
|
||||
newOverload = false;
|
||||
break;
|
||||
@@ -1961,13 +1973,14 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
||||
if (functions.isEmpty()) {
|
||||
const Name *functionCallOp = context.bindings()->control()->operatorNameId(OperatorNameId::FunctionCallOp);
|
||||
|
||||
foreach (const LookupItem &result, results) {
|
||||
for (const LookupItem &result : results) {
|
||||
FullySpecifiedType ty = result.type().simplified();
|
||||
Scope *scope = result.scope();
|
||||
|
||||
if (NamedType *namedTy = ty->asNamedType()) {
|
||||
if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) {
|
||||
foreach (const LookupItem &r, b->lookup(functionCallOp)) {
|
||||
const QList<LookupItem> items = b->lookup(functionCallOp);
|
||||
for (const LookupItem &r : items) {
|
||||
Symbol *overload = r.declaration();
|
||||
FullySpecifiedType overloadTy = overload->type().simplified();
|
||||
|
||||
@@ -2057,7 +2070,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q
|
||||
Control *control = context.bindings()->control().data();
|
||||
|
||||
// set up signature autocompletion
|
||||
foreach (Function *f, functions) {
|
||||
for (Function *f : qAsConst(functions)) {
|
||||
Overview overview;
|
||||
overview.showArgumentNames = true;
|
||||
overview.showDefaultArguments = false;
|
||||
|
||||
Reference in New Issue
Block a user