diff --git a/autotests/foldingtest.cpp b/autotests/foldingtest.cpp --- a/autotests/foldingtest.cpp +++ b/autotests/foldingtest.cpp @@ -77,7 +77,7 @@ } int offset = 0; - foreach (const auto &fold, m_folds) { + for (const auto &fold : qAsConst(m_folds)) { m_out << currentLine.mid(offset, fold.offset - offset); if (fold.region.type() == FoldingRegion::Begin) m_out << ""; @@ -139,7 +139,7 @@ QTest::addColumn("syntax"); const QDir dir(QStringLiteral(TESTSRCDIR "/input")); - foreach (const auto &fileName, dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name)) { + for (const auto &fileName : dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name)) { const auto inFile = dir.absoluteFilePath(fileName); if (inFile.endsWith(QLatin1String(".syntax"))) continue; diff --git a/autotests/highlighter_benchmark.cpp b/autotests/highlighter_benchmark.cpp --- a/autotests/highlighter_benchmark.cpp +++ b/autotests/highlighter_benchmark.cpp @@ -98,7 +98,7 @@ QTest::addColumn("syntax"); const QDir dir(QStringLiteral(TESTSRCDIR "/input")); - foreach (const auto &fileName, dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name)) { + for (const auto &fileName : dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name)) { const auto inFile = dir.absoluteFilePath(fileName); if (inFile.endsWith(QLatin1String(".syntax"))) continue; diff --git a/autotests/htmlhighlighter_test.cpp b/autotests/htmlhighlighter_test.cpp --- a/autotests/htmlhighlighter_test.cpp +++ b/autotests/htmlhighlighter_test.cpp @@ -67,7 +67,7 @@ QTest::addColumn("syntax"); const QDir dir(QStringLiteral(TESTSRCDIR "/input")); - foreach (const auto &fileName, dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name)) { + for (const auto &fileName : dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name)) { const auto inFile = dir.absoluteFilePath(fileName); if (inFile.endsWith(QLatin1String(".syntax"))) continue; diff --git a/autotests/syntaxrepository_test.cpp b/autotests/syntaxrepository_test.cpp --- a/autotests/syntaxrepository_test.cpp +++ b/autotests/syntaxrepository_test.cpp @@ -98,7 +98,7 @@ void testLoadAll() { - foreach (const auto &def, m_repo.definitions()) { + for (const auto &def : m_repo.definitions()) { QVERIFY(!def.name().isEmpty()); QVERIFY(!def.translatedName().isEmpty()); QVERIFY(!def.isValid() || !def.section().isEmpty()); @@ -183,7 +183,7 @@ // check all names are listed QStringList formatNames; - foreach (const auto & format, formats) { + for (const auto & format : qAsConst(formats)) { formatNames.append(format.name()); } @@ -226,11 +226,11 @@ void testIncludedFormats() { QStringList definitionNames; - foreach (const auto &def, m_repo.definitions()) { + for (const auto &def : m_repo.definitions()) { definitionNames.push_back(def.name()); } - foreach (const QString & name, definitionNames) { + for (const QString & name : qAsConst(definitionNames)) { Repository repo; initRepositorySearchPaths(repo); auto def = repo.definitionForName(name); diff --git a/autotests/testhighlighter.cpp b/autotests/testhighlighter.cpp --- a/autotests/testhighlighter.cpp +++ b/autotests/testhighlighter.cpp @@ -109,7 +109,7 @@ QVERIFY(uncoveredList.open(QFile::WriteOnly)); int count = 0; - foreach (const auto &def, m_repo->definitions()) { + for (const auto &def : m_repo->definitions()) { if (def.isHidden() || !def.isValid()) continue; ++count; @@ -133,7 +133,7 @@ QTest::addColumn("syntax"); const QDir dir(QStringLiteral(TESTSRCDIR "/input")); - foreach (const auto &fileName, dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name)) { + for (const auto &fileName : dir.entryList(QDir::Files | QDir::NoSymLinks | QDir::Readable, QDir::Name)) { const auto inFile = dir.absoluteFilePath(fileName); if (inFile.endsWith(QLatin1String(".syntax"))) continue; diff --git a/examples/codeeditor.cpp b/examples/codeeditor.cpp --- a/examples/codeeditor.cpp +++ b/examples/codeeditor.cpp @@ -137,7 +137,7 @@ auto hlGroupMenu = menu->addMenu(QStringLiteral("Syntax")); QMenu *hlSubMenu = hlGroupMenu; QString currentGroup; - foreach (const auto &def, m_repository.definitions()) { + for (const auto &def : m_repository.definitions()) { if (def.isHidden()) continue; if (currentGroup != def.section()) { @@ -163,7 +163,7 @@ auto themeGroup = new QActionGroup(menu); themeGroup->setExclusive(true); auto themeMenu = menu->addMenu(QStringLiteral("Theme")); - foreach (const auto &theme, m_repository.themes()) { + for (const auto &theme : m_repository.themes()) { auto action = themeMenu->addAction(theme.translatedName()); action->setCheckable(true); action->setData(theme.name()); diff --git a/src/cli/kate-syntax-highlighter.cpp b/src/cli/kate-syntax-highlighter.cpp --- a/src/cli/kate-syntax-highlighter.cpp +++ b/src/cli/kate-syntax-highlighter.cpp @@ -92,14 +92,14 @@ Repository repo; if (parser.isSet(listDefs)) { - foreach (const auto &def, repo.definitions()) { + for (const auto &def : repo.definitions()) { std::cout << qPrintable(def.name()) << std::endl; } return 0; } if (parser.isSet(listThemes)) { - foreach (const auto &theme, repo.themes()) + for (const auto &theme : repo.themes()) std::cout << qPrintable(theme.name()) << std::endl; return 0; } diff --git a/src/indexer/katehighlightingindexer.cpp b/src/indexer/katehighlightingindexer.cpp --- a/src/indexer/katehighlightingindexer.cpp +++ b/src/indexer/katehighlightingindexer.cpp @@ -536,7 +536,7 @@ KeywordIncludeChecker keywordIncludeChecker; QVariantMap hls; int anyError = 0; - foreach (const QString &hlFilename, hlFilenames) { + for (const QString &hlFilename : qAsConst(hlFilenames)) { QFile hlFile(hlFilename); if (!hlFile.open(QIODevice::ReadOnly)) { qWarning ("Failed to open %s", qPrintable(hlFilename)); diff --git a/src/lib/definition.cpp b/src/lib/definition.cpp --- a/src/lib/definition.cpp +++ b/src/lib/definition.cpp @@ -326,7 +326,7 @@ Context* DefinitionData::contextByName(const QString& name) const { - foreach (auto context, contexts) { + for (const auto context : contexts) { if (context->name() == name) return context; } @@ -394,7 +394,7 @@ it->setCaseSensitivity(caseSensitive); } - foreach (auto context, contexts) { + for (const auto context : qAsConst(contexts)) { context->resolveContexts(); context->resolveIncludes(); context->resolveAttributeFormat(); @@ -463,10 +463,10 @@ fileName = file; const auto exts = obj.value(QLatin1String("extensions")).toString(); - foreach (const auto &ext, exts.split(QLatin1Char(';'), QString::SkipEmptyParts)) + for (const auto &ext : exts.split(QLatin1Char(';'), QString::SkipEmptyParts)) extensions.push_back(ext); const auto mts = obj.value(QLatin1String("mimetype")).toString(); - foreach (const auto &mt, mts.split(QLatin1Char(';'), QString::SkipEmptyParts)) + for (const auto &mt : mts.split(QLatin1Char(';'), QString::SkipEmptyParts)) mimetypes.push_back(mt); return true; @@ -491,10 +491,10 @@ author = reader.attributes().value(QStringLiteral("author")).toString(); license = reader.attributes().value(QStringLiteral("license")).toString(); const auto exts = reader.attributes().value(QStringLiteral("extensions")).toString(); - foreach (const auto &ext, exts.split(QLatin1Char(';'), QString::SkipEmptyParts)) + for (const auto &ext : exts.split(QLatin1Char(';'), QString::SkipEmptyParts)) extensions.push_back(ext); const auto mts = reader.attributes().value(QStringLiteral("mimetype")).toString(); - foreach (const auto &mt, mts.split(QLatin1Char(';'), QString::SkipEmptyParts)) + for (const auto &mt : mts.split(QLatin1Char(';'), QString::SkipEmptyParts)) mimetypes.push_back(mt); if (reader.attributes().hasAttribute(QStringLiteral("casesensitive"))) caseSensitive = Xml::attrToBool(reader.attributes().value(QStringLiteral("casesensitive"))) ? Qt::CaseSensitive : Qt::CaseInsensitive; @@ -633,7 +633,7 @@ std::sort(wordDelimiters.begin(), wordDelimiters.end()); auto it = std::unique(wordDelimiters.begin(), wordDelimiters.end()); wordDelimiters.truncate(std::distance(wordDelimiters.begin(), it)); - foreach (const auto c, reader.attributes().value(QLatin1String("weakDeliminator"))) + for (const auto c : reader.attributes().value(QLatin1String("weakDeliminator"))) wordDelimiters.remove(c); // adaptWordWrapDelimiters, and sort diff --git a/src/lib/repository.cpp b/src/lib/repository.cpp --- a/src/lib/repository.cpp +++ b/src/lib/repository.cpp @@ -69,7 +69,7 @@ { // reset repo so we can detect in still alive definition instances // that the repo was deleted - foreach (const auto &def, d->m_sortedDefs) + for (const auto &def : qAsConst(d->m_sortedDefs)) DefinitionData::get(def)->repo = nullptr; } @@ -98,7 +98,7 @@ QVector candidates; for (auto it = d->m_defs.constBegin(); it != d->m_defs.constEnd(); ++it) { auto def = it.value(); - foreach (const auto &pattern, def.extensions()) { + for (const auto &pattern : def.extensions()) { if (WildcardMatcher::exactMatch(name, pattern)) { candidates.push_back(def); break; @@ -114,7 +114,7 @@ QVector candidates; for (auto it = d->m_defs.constBegin(); it != d->m_defs.constEnd(); ++it) { auto def = it.value(); - foreach (const auto &matchType, def.mimeTypes()) { + for (const auto &matchType : def.mimeTypes()) { if (mimeType == matchType) { candidates.push_back(def); break; @@ -160,19 +160,19 @@ // do lookup in standard paths, if not disabled #ifndef NO_STANDARD_PATHS - foreach (const auto &dir, QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("org.kde.syntax-highlighting/syntax"), QStandardPaths::LocateDirectory)) + for (const auto &dir : QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("org.kde.syntax-highlighting/syntax"), QStandardPaths::LocateDirectory)) loadSyntaxFolder(repo, dir); // backward compatibility with Kate - foreach (const auto &dir, QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("katepart5/syntax"), QStandardPaths::LocateDirectory)) + for (const auto &dir : QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("katepart5/syntax"), QStandardPaths::LocateDirectory)) loadSyntaxFolder(repo, dir); #endif // default resources are always used loadSyntaxFolder(repo, QStringLiteral(":/org.kde.syntax-highlighting/syntax")); // user given extra paths - foreach (const auto &path, m_customSearchPaths) + for (const auto &path : qAsConst(m_customSearchPaths)) loadSyntaxFolder(repo, path + QStringLiteral("/syntax")); m_sortedDefs.reserve(m_defs.size()); @@ -189,15 +189,15 @@ // do lookup in standard paths, if not disabled #ifndef NO_STANDARD_PATHS - foreach (const auto &dir, QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("org.kde.syntax-highlighting/themes"), QStandardPaths::LocateDirectory)) + for (const auto &dir : QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("org.kde.syntax-highlighting/themes"), QStandardPaths::LocateDirectory)) loadThemeFolder(dir); #endif // default resources are always used loadThemeFolder(QStringLiteral(":/org.kde.syntax-highlighting/themes")); // user given extra paths - foreach (const auto &path, m_customSearchPaths) + for (const auto &path : qAsConst(m_customSearchPaths)) loadThemeFolder(path + QStringLiteral("/themes")); } @@ -298,7 +298,7 @@ void Repository::reload() { qCDebug(Log) << "Reloading syntax definitions!"; - foreach (const auto &def, d->m_sortedDefs) + for (const auto &def : qAsConst(d->m_sortedDefs)) DefinitionData::get(def)->clear(); d->m_defs.clear(); d->m_sortedDefs.clear();