forked from qt-creator/qt-creator
plugins: Remove foreach usage
Change-Id: Idf60caed3b5f4ec4c6e990a9e3188487bcc824f8 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -176,7 +176,7 @@ QString MimeType::comment() const
|
||||
QStringList languageList;
|
||||
languageList << QLocale::system().name();
|
||||
languageList << QLocale::system().uiLanguages();
|
||||
Q_FOREACH (const QString &language, languageList) {
|
||||
for (const QString &language : std::as_const(languageList)) {
|
||||
const QString lang = language == QLatin1String("C") ? QLatin1String("en_US") : language;
|
||||
const QString comm = d->localeComments.value(lang);
|
||||
if (!comm.isEmpty())
|
||||
|
@@ -439,9 +439,9 @@ static void dump()
|
||||
}
|
||||
}
|
||||
qDebug() << "------- dumping files with watch list";
|
||||
foreach (IDocument *key, d->m_filesWithWatch.keys()) {
|
||||
const QList<IDocument *> keys = d->m_filesWithWatch.keys()
|
||||
for (IDocument *key : keys)
|
||||
qDebug() << key->fileName() << d->m_filesWithWatch.value(key);
|
||||
}
|
||||
qDebug() << "------- dumping watch list";
|
||||
if (d->m_fileWatcher)
|
||||
qDebug() << d->m_fileWatcher->files();
|
||||
|
@@ -163,7 +163,7 @@ void LocalSymbolsTest::test()
|
||||
LocalSymbols localSymbols(document, functionDefinition);
|
||||
|
||||
const QList<Result> actualUses = Result::fromLocalUses(localSymbols.uses);
|
||||
// foreach (const Result &result, actualUses)
|
||||
// for (const Result &result : actualUses)
|
||||
// qDebug() << QTest::toString(result);
|
||||
QCOMPARE(actualUses, expectedUses);
|
||||
}
|
||||
|
@@ -89,7 +89,7 @@ UseSelectionsTestCase::UseSelectionsTestCase(CppTestDocument &testFile,
|
||||
QEXPECT_FAIL("non-local use as macro argument - argument expanded 1", "TODO", Abort);
|
||||
}
|
||||
QVERIFY(!hasTimedOut);
|
||||
// foreach (const Selection &selection, selections)
|
||||
// for (const Selection &selection : selections)
|
||||
// qDebug() << QTest::toString(selection);
|
||||
if (!clangCodeModel)
|
||||
QEXPECT_FAIL("non-local use as macro argument - argument expanded 2", "TODO", Abort);
|
||||
|
@@ -2998,7 +2998,7 @@ void CdbEngine::handleBreakPoints(const DebuggerResponse &response)
|
||||
}
|
||||
QTC_ASSERT(false, qDebug() << "bp not found in either of the pending maps");
|
||||
} // not pending reported
|
||||
} // foreach
|
||||
} // for
|
||||
if (m_pendingBreakpointMap.empty())
|
||||
str << "All breakpoints have been resolved.\n";
|
||||
else
|
||||
|
@@ -115,7 +115,7 @@ TextEditor::IndentationForBlock GlslIndenter::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);
|
||||
|
@@ -123,7 +123,8 @@ void SubComponentManager::removeImport(int index)
|
||||
if (!m_dirToQualifier.contains(canonicalDirPath))
|
||||
m_watcher.removePath(canonicalDirPath);
|
||||
|
||||
// foreach (const QFileInfo &monitoredFile, watchedFiles(canonicalDirPath)) { ### todo: proper support for import as
|
||||
// const QList<QFileInfo> files = watchedFiles(canonicalDirPath);
|
||||
// for (const QFileInfo &monitoredFile : files) { ### todo: proper support for import as
|
||||
// if (!m_dirToQualifier.contains(canonicalDirPath))
|
||||
// unregisterQmlFile(monitoredFile, import.qualifier());
|
||||
// }
|
||||
|
@@ -161,7 +161,8 @@ QmlBuildSystem::QmlBuildSystem(Target *target)
|
||||
// FIXME: Check. Probably bogus after the BuildSystem move.
|
||||
// // addedTarget calls updateEnabled on the runconfigurations
|
||||
// // which needs to happen after refresh
|
||||
// foreach (Target *t, targets())
|
||||
// const QLis<Target> targetList = targets();
|
||||
// for (Target *t : targetList)
|
||||
// addedTarget(t);
|
||||
|
||||
connect(target->project(), &Project::activeTargetChanged,
|
||||
|
@@ -130,7 +130,8 @@ FilePath QnxUtils::envFilePath(const FilePath &sdpPath)
|
||||
|
||||
QString QnxUtils::defaultTargetVersion(const QString &sdpPath)
|
||||
{
|
||||
foreach (const ConfigInstallInformation &sdpInfo, installedConfigs()) {
|
||||
const QList<ConfigInstallInformation> configs = installedConfigs();
|
||||
for (const ConfigInstallInformation &sdpInfo : configs) {
|
||||
if (!sdpInfo.path.compare(sdpPath, HostOsInfo::fileNameCaseSensitivity()))
|
||||
return sdpInfo.version;
|
||||
}
|
||||
@@ -146,10 +147,9 @@ QList<ConfigInstallInformation> QnxUtils::installedConfigs(const QString &config
|
||||
if (!QDir(sdpConfigPath).exists())
|
||||
return sdpList;
|
||||
|
||||
QFileInfoList sdpfileList =
|
||||
QDir(sdpConfigPath).entryInfoList(QStringList() << QLatin1String("*.xml"),
|
||||
QDir::Files, QDir::Time);
|
||||
foreach (const QFileInfo &sdpFile, sdpfileList) {
|
||||
const QFileInfoList sdpfileList
|
||||
= QDir(sdpConfigPath).entryInfoList(QStringList{"*.xml"}, QDir::Files, QDir::Time);
|
||||
for (const QFileInfo &sdpFile : sdpfileList) {
|
||||
QFile xmlFile(sdpFile.absoluteFilePath());
|
||||
if (!xmlFile.open(QIODevice::ReadOnly))
|
||||
continue;
|
||||
|
@@ -131,7 +131,7 @@ QString ExamplesWelcomePage::copyToAlternativeLocation(const QFileInfo& proFileI
|
||||
for (QStringList::Iterator it = filesToOpen.begin(); it != end; ++it)
|
||||
it->replace(projectDir, targetDir);
|
||||
|
||||
foreach (const QString &dependency, dependencies) {
|
||||
for (const QString &dependency : dependencies) {
|
||||
const FilePath targetFile = FilePath::fromString(targetDir)
|
||||
.pathAppended(QDir(dependency).dirName());
|
||||
if (!FileUtils::copyRecursively(FilePath::fromString(dependency), targetFile,
|
||||
|
@@ -86,7 +86,7 @@ ProFileReader::ProFileReader(QMakeGlobals *option, QMakeVfs *vfs)
|
||||
|
||||
ProFileReader::~ProFileReader()
|
||||
{
|
||||
foreach (ProFile *pf, m_proFiles)
|
||||
for (ProFile *pf : std::as_const(m_proFiles))
|
||||
pf->deref();
|
||||
}
|
||||
|
||||
|
@@ -33,7 +33,8 @@ QScxmlcGenerator::QScxmlcGenerator(const Project *project,
|
||||
Tasks QScxmlcGenerator::parseIssues(const QByteArray &processStderr)
|
||||
{
|
||||
Tasks issues;
|
||||
foreach (const QByteArray &line, processStderr.split('\n')) {
|
||||
const QList<QByteArray> lines = processStderr.split('\n');
|
||||
for (const QByteArray &line : lines) {
|
||||
QByteArrayList tokens = line.split(':');
|
||||
|
||||
if (tokens.length() > 4) {
|
||||
|
@@ -459,9 +459,10 @@ void BookmarkWidget::setup()
|
||||
void BookmarkWidget::expandItems()
|
||||
{
|
||||
QStandardItemModel *model = bookmarkManager->treeBookmarkModel();
|
||||
QList<QStandardItem*>list = model->findItems(QLatin1String("*"),
|
||||
Qt::MatchWildcard | Qt::MatchRecursive, 0);
|
||||
foreach (const QStandardItem* item, list) {
|
||||
const QList<QStandardItem *> list = model->findItems(QLatin1String("*"),
|
||||
Qt::MatchWildcard | Qt::MatchRecursive,
|
||||
0);
|
||||
for (const QStandardItem *item : list) {
|
||||
const QModelIndex& index = model->indexFromItem(item);
|
||||
treeView->setExpanded(filterBookmarkModel->mapFromSource(index),
|
||||
item->data(Qt::UserRole + 11).toBool());
|
||||
@@ -604,11 +605,12 @@ QStringList BookmarkManager::bookmarkFolders() const
|
||||
{
|
||||
QStringList folders(tr("Bookmarks"));
|
||||
|
||||
QList<QStandardItem*>list = treeModel->findItems(QLatin1String("*"),
|
||||
Qt::MatchWildcard | Qt::MatchRecursive, 0);
|
||||
const QList<QStandardItem *> list = treeModel->findItems(QLatin1String("*"),
|
||||
Qt::MatchWildcard | Qt::MatchRecursive,
|
||||
0);
|
||||
|
||||
QString data;
|
||||
foreach (const QStandardItem *item, list) {
|
||||
for (const QStandardItem *item : list) {
|
||||
data = item->data(Qt::UserRole + 10).toString();
|
||||
if (data == QLatin1String("Folder"))
|
||||
folders << item->data(Qt::DisplayRole).toString();
|
||||
@@ -649,8 +651,8 @@ void BookmarkManager::removeBookmarkItem(QTreeView *treeView,
|
||||
}
|
||||
|
||||
if (data != QLatin1String("Folder")) {
|
||||
QList<QStandardItem*>itemList = listModel->findItems(item->text());
|
||||
foreach (const QStandardItem *i, itemList) {
|
||||
const QList<QStandardItem *> itemList = listModel->findItems(item->text());
|
||||
for (const QStandardItem *i : itemList) {
|
||||
if (i->data(Qt::UserRole + 10) == data) {
|
||||
listModel->removeRow(i->row());
|
||||
break;
|
||||
@@ -754,11 +756,12 @@ void BookmarkManager::setupBookmarkModels()
|
||||
QString BookmarkManager::uniqueFolderName() const
|
||||
{
|
||||
QString folderName = tr("New Folder");
|
||||
QList<QStandardItem*> list = treeModel->findItems(folderName,
|
||||
Qt::MatchContains | Qt::MatchRecursive, 0);
|
||||
const QList<QStandardItem *> list = treeModel->findItems(folderName,
|
||||
Qt::MatchContains | Qt::MatchRecursive,
|
||||
0);
|
||||
if (!list.isEmpty()) {
|
||||
QStringList names;
|
||||
foreach (const QStandardItem *item, list)
|
||||
for (const QStandardItem *item : list)
|
||||
names << item->text();
|
||||
|
||||
QString folderNameBase = tr("New Folder") + QLatin1String(" %1");
|
||||
@@ -779,8 +782,8 @@ void BookmarkManager::removeBookmarkFolderItems(QStandardItem *item)
|
||||
removeBookmarkFolderItems(child);
|
||||
|
||||
QString data = child->data(Qt::UserRole + 10).toString();
|
||||
QList<QStandardItem*>itemList = listModel->findItems(child->text());
|
||||
foreach (const QStandardItem *i, itemList) {
|
||||
const QList<QStandardItem*> itemList = listModel->findItems(child->text());
|
||||
for (const QStandardItem *i : itemList) {
|
||||
if (i->data(Qt::UserRole + 10) == data) {
|
||||
listModel->removeRow(i->row());
|
||||
break;
|
||||
|
@@ -62,7 +62,8 @@ QVector<ProFileEvaluator::SourceFile> ProFileEvaluator::fixifiedValues(
|
||||
bool expandWildcards) const
|
||||
{
|
||||
QVector<SourceFile> result;
|
||||
foreach (const ProString &str, d->values(ProKey(variable))) {
|
||||
const ProStringList values = d->values(ProKey(variable));
|
||||
for (const ProString &str : values) {
|
||||
const QString &el = d->m_option->expandEnvVars(str.toQString());
|
||||
const QString fn = IoUtils::isAbsolutePath(el)
|
||||
? QDir::cleanPath(el) : QDir::cleanPath(baseDirectory + QLatin1Char('/') + el);
|
||||
@@ -115,7 +116,8 @@ QStringList ProFileEvaluator::absolutePathValues(
|
||||
const QString &variable, const QString &baseDirectory) const
|
||||
{
|
||||
QStringList result;
|
||||
foreach (const QString &el, values(variable)) {
|
||||
const QStringList valueList = values(variable);
|
||||
for (const QString &el : valueList) {
|
||||
QString absEl = IoUtils::resolvePath(baseDirectory, el);
|
||||
if (IoUtils::fileType(absEl) == IoUtils::FileIsDir)
|
||||
result << absEl;
|
||||
@@ -129,7 +131,8 @@ QVector<ProFileEvaluator::SourceFile> ProFileEvaluator::absoluteFileValues(
|
||||
{
|
||||
QMakeVfs::VfsFlags flags = (d->m_cumulative ? QMakeVfs::VfsCumulative : QMakeVfs::VfsExact);
|
||||
QVector<SourceFile> result;
|
||||
foreach (const ProString &str, d->values(ProKey(variable))) {
|
||||
const ProStringList values = d->values(ProKey(variable));
|
||||
for (const ProString &str : values) {
|
||||
bool &seen = (*handled)[str];
|
||||
if (seen)
|
||||
continue;
|
||||
@@ -144,7 +147,7 @@ QVector<ProFileEvaluator::SourceFile> ProFileEvaluator::absoluteFileValues(
|
||||
}
|
||||
absEl = fn;
|
||||
} else {
|
||||
foreach (const QString &dir, searchDirs) {
|
||||
for (const QString &dir : searchDirs) {
|
||||
QString fn = QDir::cleanPath(dir + QLatin1Char('/') + el);
|
||||
if (m_vfs->exists(fn, flags)) {
|
||||
result << SourceFile{fn, str.sourceFile()};
|
||||
@@ -169,7 +172,8 @@ QVector<ProFileEvaluator::SourceFile> ProFileEvaluator::absoluteFileValues(
|
||||
wildcard.detach(); // Keep m_tmp out of QRegExp's cache
|
||||
QDir theDir(absDir);
|
||||
theDir.setFilter(theDir.filter() & ~QDir::AllDirs);
|
||||
foreach (const QString &fn, theDir.entryList(QStringList(wildcard)))
|
||||
const QStringList list = theDir.entryList(QStringList(wildcard));
|
||||
for (const QString &fn : list)
|
||||
if (fn != QLatin1String(".") && fn != QLatin1String(".."))
|
||||
result << SourceFile{absDir + QLatin1Char('/') + fn, str.sourceFile()};
|
||||
QString directoryWithWildcard(absDir);
|
||||
|
@@ -546,7 +546,7 @@ void QMakeEvaluator::populateDeps(
|
||||
if (depends.isEmpty()) {
|
||||
rootSet.insert(first(ProKey(prefix + item + priosfx)).toInt(), item);
|
||||
} else {
|
||||
foreach (const ProString &dep, depends) {
|
||||
for (const ProString &dep : std::as_const(depends)) {
|
||||
dset.insert(dep.toKey());
|
||||
dependees[dep.toKey()] << item;
|
||||
}
|
||||
@@ -699,7 +699,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
|
||||
evalError(fL1S("num_add(num, ...) requires at least one argument."));
|
||||
} else {
|
||||
qlonglong sum = 0;
|
||||
foreach (const ProString &arg, args) {
|
||||
for (const ProString &arg : args) {
|
||||
if (arg.contains(QLatin1Char('.'))) {
|
||||
evalError(fL1S("num_add(): floats are currently not supported."));
|
||||
goto nafail;
|
||||
@@ -1174,7 +1174,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
|
||||
rootSet.erase(it);
|
||||
if ((func_t == E_RESOLVE_DEPENDS) || orgList.contains(item))
|
||||
ret.prepend(item);
|
||||
foreach (const ProString &dep, dependees[item.toKey()]) {
|
||||
for (const ProString &dep : std::as_const(dependees[item.toKey()])) {
|
||||
QSet<ProKey> &dset = dependencies[dep.toKey()];
|
||||
dset.remove(item.toKey());
|
||||
if (dset.isEmpty())
|
||||
@@ -1185,11 +1185,11 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
|
||||
break;
|
||||
case E_ENUMERATE_VARS: {
|
||||
QSet<ProString> keys;
|
||||
foreach (const ProValueMap &vmap, m_valuemapStack)
|
||||
for (const ProValueMap &vmap : std::as_const(m_valuemapStack))
|
||||
for (ProValueMap::ConstIterator it = vmap.constBegin(); it != vmap.constEnd(); ++it)
|
||||
keys.insert(it.key());
|
||||
ret.reserve(keys.size());
|
||||
foreach (const ProString &key, keys)
|
||||
for (const ProString &key : std::as_const(keys))
|
||||
ret << key;
|
||||
break; }
|
||||
case E_SHADOWED:
|
||||
|
@@ -1231,7 +1231,7 @@ bool QMakeEvaluator::loadSpec()
|
||||
qmakespec = m_hostBuild ? QLatin1String("default-host") : QLatin1String("default");
|
||||
#endif
|
||||
if (IoUtils::isRelativePath(qmakespec)) {
|
||||
foreach (const QString &root, m_mkspecPaths) {
|
||||
for (const QString &root : std::as_const(m_mkspecPaths)) {
|
||||
QString mkspec = root + QLatin1Char('/') + qmakespec;
|
||||
if (IoUtils::exists(mkspec)) {
|
||||
qmakespec = mkspec;
|
||||
@@ -1472,7 +1472,7 @@ void QMakeEvaluator::updateMkspecPaths()
|
||||
for (const QString &it : paths)
|
||||
ret << it + concat;
|
||||
|
||||
foreach (const QString &it, m_qmakepath)
|
||||
for (const QString &it : std::as_const(m_qmakepath))
|
||||
ret << it + concat;
|
||||
|
||||
if (!m_buildRoot.isEmpty())
|
||||
@@ -1514,7 +1514,7 @@ void QMakeEvaluator::updateFeaturePaths()
|
||||
for (const QString &item : items)
|
||||
feature_bases << (item + mkspecs_concat);
|
||||
|
||||
foreach (const QString &item, m_qmakepath)
|
||||
for (const QString &item : std::as_const(m_qmakepath))
|
||||
feature_bases << (item + mkspecs_concat);
|
||||
|
||||
if (!m_qmakespec.isEmpty()) {
|
||||
@@ -1536,7 +1536,7 @@ void QMakeEvaluator::updateFeaturePaths()
|
||||
feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/get")) + mkspecs_concat);
|
||||
feature_bases << (m_option->propertyValue(ProKey("QT_HOST_DATA/src")) + mkspecs_concat);
|
||||
|
||||
foreach (const QString &fb, feature_bases) {
|
||||
for (const QString &fb : std::as_const(feature_bases)) {
|
||||
const auto sfxs = values(ProKey("QMAKE_PLATFORM"));
|
||||
for (const ProString &sfx : sfxs)
|
||||
feature_roots << (fb + features_concat + sfx + QLatin1Char('/'));
|
||||
@@ -1550,7 +1550,7 @@ void QMakeEvaluator::updateFeaturePaths()
|
||||
feature_roots.removeDuplicates();
|
||||
|
||||
QStringList ret;
|
||||
foreach (const QString &root, feature_roots)
|
||||
for (const QString &root : std::as_const(feature_roots))
|
||||
if (IoUtils::exists(root))
|
||||
ret << root;
|
||||
m_featureRoots = new QMakeFeatureRoots(ret);
|
||||
|
@@ -168,7 +168,7 @@ void QMakeGlobals::commitCommandLineArguments(QMakeCmdLineParserState &state)
|
||||
{
|
||||
if (!state.extraargs.isEmpty()) {
|
||||
QString extra = fL1S("QMAKE_EXTRA_ARGS =");
|
||||
foreach (const QString &ea, state.extraargs)
|
||||
for (const QString &ea : std::as_const(state.extraargs))
|
||||
extra += QLatin1Char(' ') + QMakeEvaluator::quoteValue(ProString(ea));
|
||||
state.cmds[QMakeEvalBefore] << extra;
|
||||
}
|
||||
|
Reference in New Issue
Block a user