forked from qt-creator/qt-creator
qmljs: Remove foreach usage
Task-number: QTCREATORBUG-27464 Change-Id: Ifdb8cf514dfe328e0a64bde1beff3e63a4b7fbc3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -427,7 +427,7 @@ const CppComponentValue *CppComponentValue::prototype() const
|
||||
Use this function rather than calling prototype() in a loop, as it avoids
|
||||
cycles.
|
||||
*/
|
||||
QList<const CppComponentValue *> CppComponentValue::prototypes() const
|
||||
const QList<const CppComponentValue *> CppComponentValue::prototypes() const
|
||||
{
|
||||
QList<const CppComponentValue *> protos;
|
||||
for (const CppComponentValue *it = this; it; it = it->prototype()) {
|
||||
@@ -457,7 +457,7 @@ QString CppComponentValue::defaultPropertyName() const
|
||||
|
||||
QString CppComponentValue::propertyType(const QString &propertyName) const
|
||||
{
|
||||
foreach (const CppComponentValue *it, prototypes()) {
|
||||
for (const CppComponentValue *it : prototypes()) {
|
||||
FakeMetaObject::ConstPtr iter = it->m_metaObject;
|
||||
int propIdx = iter->propertyIndex(propertyName);
|
||||
if (propIdx != -1)
|
||||
@@ -468,7 +468,7 @@ QString CppComponentValue::propertyType(const QString &propertyName) const
|
||||
|
||||
bool CppComponentValue::isListProperty(const QString &propertyName) const
|
||||
{
|
||||
foreach (const CppComponentValue *it, prototypes()) {
|
||||
for (const CppComponentValue *it : prototypes()) {
|
||||
FakeMetaObject::ConstPtr iter = it->m_metaObject;
|
||||
int propIdx = iter->propertyIndex(propertyName);
|
||||
if (propIdx != -1)
|
||||
@@ -479,7 +479,7 @@ bool CppComponentValue::isListProperty(const QString &propertyName) const
|
||||
|
||||
FakeMetaEnum CppComponentValue::getEnum(const QString &typeName, const CppComponentValue **foundInScope) const
|
||||
{
|
||||
foreach (const CppComponentValue *it, prototypes()) {
|
||||
for (const CppComponentValue *it : prototypes()) {
|
||||
FakeMetaObject::ConstPtr iter = it->m_metaObject;
|
||||
const int index = iter->enumeratorIndex(typeName);
|
||||
if (index != -1) {
|
||||
@@ -495,7 +495,7 @@ FakeMetaEnum CppComponentValue::getEnum(const QString &typeName, const CppCompon
|
||||
|
||||
const QmlEnumValue *CppComponentValue::getEnumValue(const QString &typeName, const CppComponentValue **foundInScope) const
|
||||
{
|
||||
foreach (const CppComponentValue *it, prototypes()) {
|
||||
for (const CppComponentValue *it : prototypes()) {
|
||||
if (const QmlEnumValue *e = it->m_enums.value(typeName)) {
|
||||
if (foundInScope)
|
||||
*foundInScope = it;
|
||||
@@ -544,7 +544,7 @@ const ObjectValue *CppComponentValue::signalScope(const QString &signalName) con
|
||||
|
||||
bool CppComponentValue::isWritable(const QString &propertyName) const
|
||||
{
|
||||
foreach (const CppComponentValue *it, prototypes()) {
|
||||
for (const CppComponentValue *it : prototypes()) {
|
||||
FakeMetaObject::ConstPtr iter = it->m_metaObject;
|
||||
int propIdx = iter->propertyIndex(propertyName);
|
||||
if (propIdx != -1)
|
||||
@@ -555,7 +555,7 @@ bool CppComponentValue::isWritable(const QString &propertyName) const
|
||||
|
||||
bool CppComponentValue::isPointer(const QString &propertyName) const
|
||||
{
|
||||
foreach (const CppComponentValue *it, prototypes()) {
|
||||
for (const CppComponentValue *it : prototypes()) {
|
||||
FakeMetaObject::ConstPtr iter = it->m_metaObject;
|
||||
int propIdx = iter->propertyIndex(propertyName);
|
||||
if (propIdx != -1)
|
||||
@@ -574,7 +574,7 @@ bool CppComponentValue::hasLocalProperty(const QString &typeName) const
|
||||
|
||||
bool CppComponentValue::hasProperty(const QString &propertyName) const
|
||||
{
|
||||
foreach (const CppComponentValue *it, prototypes()) {
|
||||
for (const CppComponentValue *it : prototypes()) {
|
||||
FakeMetaObject::ConstPtr iter = it->m_metaObject;
|
||||
int propIdx = iter->propertyIndex(propertyName);
|
||||
if (propIdx != -1)
|
||||
@@ -585,7 +585,7 @@ bool CppComponentValue::hasProperty(const QString &propertyName) const
|
||||
|
||||
bool CppComponentValue::isDerivedFrom(FakeMetaObject::ConstPtr base) const
|
||||
{
|
||||
foreach (const CppComponentValue *it, prototypes()) {
|
||||
for (const CppComponentValue *it : prototypes()) {
|
||||
FakeMetaObject::ConstPtr iter = it->m_metaObject;
|
||||
if (iter == base)
|
||||
return true;
|
||||
@@ -1326,7 +1326,7 @@ CppQmlTypesLoader::BuiltinObjects CppQmlTypesLoader::loadQmlTypes(const QFileInf
|
||||
QHash<QString, FakeMetaObject::ConstPtr> newObjects;
|
||||
QStringList newDependencies;
|
||||
|
||||
foreach (const QFileInfo &qmlTypeFile, qmlTypeFiles) {
|
||||
for (const QFileInfo &qmlTypeFile : qmlTypeFiles) {
|
||||
QString error, warning;
|
||||
QFile file(qmlTypeFile.absoluteFilePath());
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
@@ -1400,8 +1400,8 @@ template <typename T>
|
||||
void CppQmlTypes::load(const QString &originId, const T &fakeMetaObjects, const QString &overridePackage)
|
||||
{
|
||||
QList<CppComponentValue *> newCppTypes;
|
||||
foreach (const FakeMetaObject::ConstPtr &fmo, fakeMetaObjects) {
|
||||
foreach (const FakeMetaObject::Export &exp, fmo->exports()) {
|
||||
for (const FakeMetaObject::ConstPtr &fmo : fakeMetaObjects) {
|
||||
for (const FakeMetaObject::Export &exp : fmo->exports()) {
|
||||
QString package = exp.package;
|
||||
if (package.isEmpty())
|
||||
package = overridePackage;
|
||||
@@ -1422,7 +1422,7 @@ void CppQmlTypes::load(const QString &originId, const T &fakeMetaObjects, const
|
||||
}
|
||||
|
||||
// set prototypes of cpp types
|
||||
foreach (CppComponentValue *object, newCppTypes) {
|
||||
for (CppComponentValue *object : std::as_const(newCppTypes)) {
|
||||
const QString &protoCppName = object->metaObject()->superclassName();
|
||||
const CppComponentValue *proto = objectByCppName(protoCppName);
|
||||
if (proto)
|
||||
@@ -1441,11 +1441,12 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
|
||||
QList<const CppComponentValue *> newObjects;
|
||||
|
||||
// make new exported objects
|
||||
foreach (const FakeMetaObjectWithOrigin &fmoo, m_fakeMetaObjectsByPackage.value(package)) {
|
||||
const QSet<FakeMetaObjectWithOrigin> fmoos = m_fakeMetaObjectsByPackage.value(package);
|
||||
for (const FakeMetaObjectWithOrigin &fmoo : fmoos) {
|
||||
const FakeMetaObject::ConstPtr &fmo = fmoo.fakeMetaObject;
|
||||
// find the highest-version export for each alias
|
||||
QHash<QString, FakeMetaObject::Export> bestExports;
|
||||
foreach (const FakeMetaObject::Export &exp, fmo->exports()) {
|
||||
for (const FakeMetaObject::Export &exp : fmo->exports()) {
|
||||
if (exp.package != package || (version.isValid() && exp.version > version))
|
||||
continue;
|
||||
|
||||
@@ -1465,7 +1466,7 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
|
||||
continue;
|
||||
|
||||
ComponentVersion cppVersion;
|
||||
foreach (const FakeMetaObject::Export &bestExport, bestExports) {
|
||||
for (const FakeMetaObject::Export &bestExport : std::as_const(bestExports)) {
|
||||
QString name = bestExport.type;
|
||||
bool exported = true;
|
||||
if (name.isEmpty()) {
|
||||
@@ -1495,7 +1496,7 @@ QList<const CppComponentValue *> CppQmlTypes::createObjectsForImport(const QStri
|
||||
// set their prototypes, creating them if necessary
|
||||
// this ensures that the prototypes of C++ objects are resolved correctly and with the correct
|
||||
// revision, and cannot be hidden by other objects.
|
||||
foreach (const CppComponentValue *cobject, newObjects) {
|
||||
for (const CppComponentValue *cobject : std::as_const(newObjects)) {
|
||||
CppComponentValue *object = const_cast<CppComponentValue *>(cobject);
|
||||
while (!object->prototype()) {
|
||||
const QString &protoCppName = object->metaObject()->superclassName();
|
||||
@@ -1860,7 +1861,7 @@ bool ASTObjectValue::getSourceLocation(Utils::FilePath *fileName, int *line, int
|
||||
|
||||
void ASTObjectValue::processMembers(MemberProcessor *processor) const
|
||||
{
|
||||
foreach (ASTPropertyReference *ref, m_properties) {
|
||||
for (ASTPropertyReference *ref : m_properties) {
|
||||
uint pFlags = PropertyInfo::Readable;
|
||||
if (!ref->ast()->isReadonly())
|
||||
pFlags |= PropertyInfo::Writeable;
|
||||
@@ -1868,7 +1869,7 @@ void ASTObjectValue::processMembers(MemberProcessor *processor) const
|
||||
// ### Should get a different value?
|
||||
processor->processGeneratedSlot(ref->onChangedSlotName(), ref);
|
||||
}
|
||||
foreach (ASTSignal *ref, m_signals) {
|
||||
for (ASTSignal *ref : m_signals) {
|
||||
processor->processSignal(ref->ast()->name.toString(), ref);
|
||||
// ### Should get a different value?
|
||||
processor->processGeneratedSlot(ref->slotName(), ref);
|
||||
|
||||
Reference in New Issue
Block a user