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:
@@ -308,7 +308,7 @@ bool ArrayType::isLessThan(const Type *other) const
|
||||
QList<Symbol *> Struct::members() const
|
||||
{
|
||||
QList<Symbol *> m;
|
||||
for (Symbol *s : std::as_const(_members)) {
|
||||
for (Symbol *s : _members) {
|
||||
if (! s->name().isEmpty())
|
||||
m.append(s);
|
||||
}
|
||||
@@ -322,7 +322,7 @@ void Struct::add(Symbol *member)
|
||||
|
||||
Symbol *Struct::find(const QString &name) const
|
||||
{
|
||||
for (Symbol *s : std::as_const(_members)) {
|
||||
for (Symbol *s : _members) {
|
||||
if (s->name() == name)
|
||||
return s;
|
||||
}
|
||||
@@ -411,7 +411,7 @@ bool Function::isLessThan(const Type *other) const
|
||||
QList<Symbol *> Function::members() const
|
||||
{
|
||||
QList<Symbol *> m;
|
||||
for (Argument *arg : std::as_const(_arguments)) {
|
||||
for (Argument *arg : _arguments) {
|
||||
if (! arg->name().isEmpty())
|
||||
m.append(arg);
|
||||
}
|
||||
@@ -420,7 +420,7 @@ QList<Symbol *> Function::members() const
|
||||
|
||||
Symbol *Function::find(const QString &name) const
|
||||
{
|
||||
for (Argument *arg : std::as_const(_arguments)) {
|
||||
for (Argument *arg : _arguments) {
|
||||
if (arg->name() == name)
|
||||
return arg;
|
||||
}
|
||||
|
@@ -283,11 +283,11 @@ void FakeMetaObject::setExportMetaObjectRevision(int exportIndex, int metaObject
|
||||
m_exports[exportIndex].metaObjectRevision = metaObjectRevision;
|
||||
}
|
||||
|
||||
QList<FakeMetaObject::Export> FakeMetaObject::exports() const
|
||||
const QList<FakeMetaObject::Export> FakeMetaObject::exports() const
|
||||
{ return m_exports; }
|
||||
FakeMetaObject::Export FakeMetaObject::exportInPackage(const QString &package) const
|
||||
{
|
||||
for (const Export &exp : std::as_const(m_exports)) {
|
||||
for (const Export &exp : m_exports) {
|
||||
if (exp.package == package)
|
||||
return exp;
|
||||
}
|
||||
|
@@ -162,7 +162,7 @@ public:
|
||||
|
||||
void addExport(const QString &name, const QString &package, ComponentVersion version);
|
||||
void setExportMetaObjectRevision(int exportIndex, int metaObjectRevision);
|
||||
QList<Export> exports() const;
|
||||
const QList<Export> exports() const;
|
||||
Export exportInPackage(const QString &package) const;
|
||||
|
||||
void setSuperclassName(const QString &superclass);
|
||||
|
@@ -107,7 +107,7 @@ bool JsonCheck::visit(ObjectPattern *ast)
|
||||
}
|
||||
|
||||
QStringList missing;
|
||||
foreach (const QString &property, properties) {
|
||||
for (const QString &property : properties) {
|
||||
if (!propertiesFound.contains(property)) {
|
||||
m_schema->enterNestedPropertySchema(property);
|
||||
if (m_schema->required())
|
||||
|
@@ -75,7 +75,7 @@ public:
|
||||
_comments.append(QmlJS::SourceLocation(pos, len, line, col));
|
||||
}
|
||||
|
||||
QList<SourceLocation> comments() const { return _comments; }
|
||||
const QList<SourceLocation> comments() const { return _comments; }
|
||||
|
||||
Lexer *lexer() const { return _lexer; }
|
||||
void setLexer(Lexer *lexer) { _lexer = lexer; }
|
||||
|
@@ -96,7 +96,7 @@ void TrieNode::complete(QStringList &res, const TrieNode::Ptr &trie,
|
||||
complete(res, trie->postfixes[0],QString(), base2, flags);
|
||||
return;
|
||||
}
|
||||
foreach (TrieNode::Ptr t, trie->postfixes) {
|
||||
for (TrieNode::Ptr t : std::as_const(trie->postfixes)) {
|
||||
if ((flags & Partial) != 0)
|
||||
res.append(base2 + t->prefix);
|
||||
else
|
||||
@@ -104,7 +104,7 @@ void TrieNode::complete(QStringList &res, const TrieNode::Ptr &trie,
|
||||
}
|
||||
return;
|
||||
}
|
||||
foreach (const TrieNode::Ptr v, trie->postfixes) {
|
||||
for (const TrieNode::Ptr &v : std::as_const(trie->postfixes)) {
|
||||
QString::const_iterator vi = v->prefix.constBegin(), vEnd = v->prefix.constEnd();
|
||||
if (vi != vEnd && (*vi == *j || ((flags & CaseInsensitive) != 0
|
||||
&& vi->toLower() == j->toLower()) || ((flags & SkipChars) != 0)))
|
||||
@@ -199,7 +199,7 @@ bool TrieNode::contains(const TrieNode::Ptr &trie,
|
||||
if ((flags & Partial) != 0)
|
||||
return true;
|
||||
if (i == iEnd) {
|
||||
foreach (const TrieNode::Ptr t, trie->postfixes)
|
||||
for (const TrieNode::Ptr &t : std::as_const(trie->postfixes))
|
||||
if (t->prefix.isEmpty())
|
||||
return true;
|
||||
return trie->postfixes.isEmpty();
|
||||
@@ -209,7 +209,7 @@ bool TrieNode::contains(const TrieNode::Ptr &trie,
|
||||
if (i != iEnd)
|
||||
return false;
|
||||
bool res = false;
|
||||
foreach (const TrieNode::Ptr v, trie->postfixes) {
|
||||
for (const TrieNode::Ptr &v : std::as_const(trie->postfixes)) {
|
||||
QString::const_iterator vi = v->prefix.constBegin(), vEnd = v->prefix.constEnd();
|
||||
if (vi != vEnd && (*vi == *j || ((flags & CaseInsensitive) != 0
|
||||
&& vi->toLower() == j->toLower())))
|
||||
@@ -312,7 +312,7 @@ std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
|
||||
if (v1->postfixes.isEmpty() || v2->postfixes.isEmpty()) {
|
||||
if (v1->postfixes.isEmpty() && v2->postfixes.isEmpty())
|
||||
return std::make_pair(v1, 3);
|
||||
foreach (P t1, v1->postfixes)
|
||||
for (P t1 : std::as_const(v1->postfixes))
|
||||
if (t1->prefix.isEmpty()) {
|
||||
if (index1 == 0)
|
||||
return std::make_pair(v2, 2);
|
||||
@@ -320,7 +320,7 @@ std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
|
||||
return std::make_pair(TrieNode::create(
|
||||
v1->prefix.left(index1).append(v2->prefix), v2->postfixes),0);
|
||||
}
|
||||
foreach (P t2, v2->postfixes)
|
||||
for (P t2 : std::as_const(v2->postfixes))
|
||||
if (t2->prefix.isEmpty())
|
||||
return std::make_pair(v1,1);
|
||||
return std::make_pair(P(nullptr), 0);
|
||||
@@ -328,10 +328,10 @@ std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
|
||||
QMap<QString,int> p1, p2;
|
||||
QList<P> p3;
|
||||
int ii = 0;
|
||||
foreach (P t1, v1->postfixes)
|
||||
for (P t1 : std::as_const(v1->postfixes))
|
||||
p1[t1->prefix] = ii++;
|
||||
ii = 0;
|
||||
foreach (P t2, v2->postfixes)
|
||||
for (P t2 : std::as_const(v2->postfixes))
|
||||
p2[t2->prefix] = ii++;
|
||||
MapIterator p1Ptr = p1.constBegin(), p2Ptr = p2.constBegin(),
|
||||
p1End = p1.constEnd(), p2End = p2.constEnd();
|
||||
@@ -419,7 +419,7 @@ std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
|
||||
}
|
||||
}
|
||||
// i == iEnd && j != jEnd
|
||||
foreach (const P &t1, v1->postfixes)
|
||||
for (const P &t1 : std::as_const(v1->postfixes))
|
||||
if ((!t1->prefix.isEmpty()) && t1->prefix.at(0) == *j) {
|
||||
std::pair<P,int> res = intersectF(v2,t1,j-v2->prefix.constBegin());
|
||||
if (index1 == 0)
|
||||
@@ -432,7 +432,7 @@ std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
|
||||
return std::make_pair(P(nullptr), 0);
|
||||
} else {
|
||||
// i != iEnd && j == jEnd
|
||||
foreach (P t2, v2->postfixes)
|
||||
for (P t2 : std::as_const(v2->postfixes))
|
||||
if (!t2->prefix.isEmpty() && t2->prefix.at(0) == *i) {
|
||||
std::pair<P,int> res = intersectF(v1,t2,i-v1->prefix.constBegin());
|
||||
return std::make_pair(res.first, (res.second & 1));
|
||||
@@ -468,7 +468,8 @@ QDebug &TrieNode::printStrings(QDebug &dbg, const TrieNode::Ptr &trie)
|
||||
return dbg << "Trie{*NULL*}";
|
||||
dbg<<"Trie{ contents:[";
|
||||
bool first = true;
|
||||
foreach (const QString &s, stringList(trie)) {
|
||||
const QStringList list = stringList(trie);
|
||||
for (const QString &s : list) {
|
||||
if (!first)
|
||||
dbg << ",";
|
||||
else
|
||||
@@ -491,7 +492,7 @@ QDebug &TrieNode::describe(QDebug &dbg, const TrieNode::Ptr &trie,
|
||||
dbg << trie->prefix;
|
||||
int newIndent = indent + trie->prefix.size() + 3;
|
||||
bool newLine = false;
|
||||
foreach (TrieNode::Ptr sub, trie->postfixes) {
|
||||
for (TrieNode::Ptr sub : std::as_const(trie->postfixes)) {
|
||||
if (newLine) {
|
||||
dbg << "\n";
|
||||
for (int i=0; i < newIndent; ++i)
|
||||
|
@@ -88,7 +88,7 @@ template <typename T> void enumerateTrieNode(const TrieNode::Ptr &trie, T &t,
|
||||
if (trie.isNull())
|
||||
return;
|
||||
base.append(trie->prefix);
|
||||
foreach (const TrieNode::Ptr subT, trie->postfixes) {
|
||||
for (const TrieNode::Ptr subT : std::as_const(trie->postfixes)) {
|
||||
enumerateTrieNode(subT,t,base);
|
||||
}
|
||||
if (trie->postfixes.isEmpty())
|
||||
|
@@ -54,7 +54,7 @@ bool Bind::isJsLibrary() const
|
||||
return _isJsLibrary;
|
||||
}
|
||||
|
||||
QList<ImportInfo> Bind::imports() const
|
||||
const QList<ImportInfo> Bind::imports() const
|
||||
{
|
||||
return _imports;
|
||||
}
|
||||
@@ -86,7 +86,8 @@ bool Bind::usesQmlPrototype(ObjectValue *prototype,
|
||||
if (componentName.isEmpty())
|
||||
return false;
|
||||
|
||||
foreach (const ObjectValue *object, _qmlObjectsByPrototypeName.values(componentName)) {
|
||||
QList<const ObjectValue *> values = _qmlObjectsByPrototypeName.values(componentName);
|
||||
for (const ObjectValue *object : values) {
|
||||
// resolve and check the prototype
|
||||
const ObjectValue *resolvedPrototype = object->prototype(context);
|
||||
if (resolvedPrototype == prototype)
|
||||
|
@@ -25,7 +25,7 @@ public:
|
||||
~Bind();
|
||||
|
||||
bool isJsLibrary() const;
|
||||
QList<ImportInfo> imports() const;
|
||||
const QList<ImportInfo> imports() const;
|
||||
|
||||
ObjectValue *idEnvironment() const;
|
||||
ObjectValue *rootObjectValue() const;
|
||||
|
@@ -142,7 +142,8 @@ void QmlBundle::printEscaped(QTextStream &s, const QString &str)
|
||||
void QmlBundle::writeTrie(QTextStream &stream, const Trie &t, const QString &indent) {
|
||||
stream << QLatin1Char('[');
|
||||
bool firstLine = true;
|
||||
foreach (const QString &i, t.stringList()) {
|
||||
const QStringList list = t.stringList();
|
||||
for (const QString &i : list) {
|
||||
if (firstLine)
|
||||
firstLine = false;
|
||||
else
|
||||
@@ -197,7 +198,8 @@ QStringList QmlBundle::maybeReadTrie(Trie &trie, Utils::JsonObjectValue *config,
|
||||
Utils::JsonValue *imp0 = config->member(propertyName);
|
||||
Utils::JsonArrayValue *imp = ((imp0 != nullptr) ? imp0->toArray() : nullptr);
|
||||
if (imp != nullptr) {
|
||||
foreach (Utils::JsonValue *v, imp->elements()) {
|
||||
const QList<Utils::JsonValue *> elements = imp->elements();
|
||||
for (Utils::JsonValue *v : elements) {
|
||||
Utils::JsonStringValue *impStr = ((v != nullptr) ? v->toString() : nullptr);
|
||||
if (impStr != nullptr) {
|
||||
trie.insert(impStr->value());
|
||||
@@ -272,14 +274,14 @@ void QmlLanguageBundles::mergeBundleForLanguage(Dialect l, const QmlBundle &bund
|
||||
m_bundles.insert(l,bundle);
|
||||
}
|
||||
|
||||
QList<Dialect> QmlLanguageBundles::languages() const
|
||||
const QList<Dialect> QmlLanguageBundles::languages() const
|
||||
{
|
||||
return m_bundles.keys();
|
||||
}
|
||||
|
||||
void QmlLanguageBundles::mergeLanguageBundles(const QmlLanguageBundles &o)
|
||||
{
|
||||
foreach (Dialect l, o.languages())
|
||||
for (Dialect l : o.languages())
|
||||
mergeBundleForLanguage(l, o.bundleForLanguage(l));
|
||||
}
|
||||
|
||||
|
@@ -74,7 +74,7 @@ class QMLJS_EXPORT QmlLanguageBundles
|
||||
public:
|
||||
QmlBundle bundleForLanguage(Dialect l) const;
|
||||
void mergeBundleForLanguage(Dialect l, const QmlBundle &bundle);
|
||||
QList<Dialect> languages() const;
|
||||
const QList<Dialect> languages() const;
|
||||
void mergeLanguageBundles(const QmlLanguageBundles &);
|
||||
private:
|
||||
QHash<Dialect,QmlBundle> m_bundles;
|
||||
|
@@ -433,7 +433,8 @@ protected:
|
||||
}
|
||||
|
||||
if (_possiblyUndeclaredUses.contains(name)) {
|
||||
foreach (const SourceLocation &loc, _possiblyUndeclaredUses.value(name)) {
|
||||
const QList<SourceLocation> values = _possiblyUndeclaredUses.value(name);
|
||||
for (const SourceLocation &loc : values) {
|
||||
addMessage(WarnVarUsedBeforeDeclaration, loc, name);
|
||||
}
|
||||
_possiblyUndeclaredUses.remove(name);
|
||||
@@ -469,7 +470,8 @@ protected:
|
||||
|
||||
if (FunctionDeclaration *decl = cast<FunctionDeclaration *>(ast)) {
|
||||
if (_possiblyUndeclaredUses.contains(name)) {
|
||||
foreach (const SourceLocation &loc, _possiblyUndeclaredUses.value(name)) {
|
||||
const QList<SourceLocation> values = _possiblyUndeclaredUses.value(name);
|
||||
for (const SourceLocation &loc : values) {
|
||||
addMessage(WarnFunctionUsedBeforeDeclaration, loc, name);
|
||||
}
|
||||
_possiblyUndeclaredUses.remove(name);
|
||||
@@ -1642,7 +1644,7 @@ void Check::checkExtraParentheses(ExpressionNode *expression)
|
||||
|
||||
void Check::addMessages(const QList<Message> &messages)
|
||||
{
|
||||
foreach (const Message &msg, messages)
|
||||
for (const Message &msg : messages)
|
||||
addMessage(msg);
|
||||
}
|
||||
|
||||
@@ -1682,7 +1684,8 @@ void Check::scanCommentsForAnnotations()
|
||||
m_disabledMessageTypesByLine.clear();
|
||||
const QRegularExpression disableCommentPattern = Message::suppressionPattern();
|
||||
|
||||
foreach (const SourceLocation &commentLoc, _doc->engine()->comments()) {
|
||||
const QList<SourceLocation> comments = _doc->engine()->comments();
|
||||
for (const SourceLocation &commentLoc : comments) {
|
||||
const QString &comment = _doc->source().mid(int(commentLoc.begin()), int(commentLoc.length));
|
||||
|
||||
// enable all checks annotation
|
||||
@@ -1728,7 +1731,7 @@ void Check::warnAboutUnnecessarySuppressions()
|
||||
{
|
||||
for (auto it = m_disabledMessageTypesByLine.cbegin(), end = m_disabledMessageTypesByLine.cend();
|
||||
it != end; ++it) {
|
||||
foreach (const MessageTypeAndSuppression &entry, it.value()) {
|
||||
for (const MessageTypeAndSuppression &entry : it.value()) {
|
||||
if (!entry.wasSuppressed)
|
||||
addMessage(WarnUnnecessaryMessageSuppression, entry.suppressionSource);
|
||||
}
|
||||
@@ -1738,7 +1741,7 @@ void Check::warnAboutUnnecessarySuppressions()
|
||||
bool Check::isQtQuick2() const
|
||||
{
|
||||
if (_doc->language() == Dialect::Qml) {
|
||||
foreach (const Import &import, _imports->all()) {
|
||||
for (const Import &import : _imports->all()) {
|
||||
if (import.info.name() == "QtQuick"
|
||||
&& import.info.version().majorVersion() == 2)
|
||||
return true;
|
||||
@@ -2053,7 +2056,7 @@ void Check::checkCaseFallthrough(StatementList *statements, SourceLocation error
|
||||
afterLastStatement = it->statement->lastSourceLocation().end();
|
||||
}
|
||||
|
||||
foreach (const SourceLocation &comment, _doc->engine()->comments()) {
|
||||
for (const SourceLocation &comment : _doc->engine()->comments()) {
|
||||
if (comment.begin() < afterLastStatement
|
||||
|| comment.end() > nextLoc.begin())
|
||||
continue;
|
||||
|
@@ -1023,7 +1023,7 @@ void CodeFormatter::dump() const
|
||||
{
|
||||
qCDebug(formatterLog) << "Current token index" << m_tokenIndex;
|
||||
qCDebug(formatterLog) << "Current state:";
|
||||
foreach (const State &s, m_currentState) {
|
||||
for (const State &s : m_currentState) {
|
||||
qCDebug(formatterLog) << stateToString(s.type) << s.savedIndentDepth;
|
||||
}
|
||||
qCDebug(formatterLog) << "Current indent depth:" << m_indentDepth;
|
||||
|
@@ -372,7 +372,7 @@ QByteArray LibraryInfo::calculateFingerprint() const
|
||||
hash.addData(reinterpret_cast<const char *>(&_status), sizeof(_status));
|
||||
int len = _components.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const QmlDirParser::Component &component, _components) {
|
||||
for (const QmlDirParser::Component &component : _components) {
|
||||
len = component.fileName.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(component.fileName.constData()),
|
||||
@@ -388,7 +388,7 @@ QByteArray LibraryInfo::calculateFingerprint() const
|
||||
}
|
||||
len = _plugins.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const QmlDirParser::Plugin &plugin, _plugins) {
|
||||
for (const QmlDirParser::Plugin &plugin : _plugins) {
|
||||
len = plugin.path.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(plugin.path.constData()), len * sizeofQChar);
|
||||
@@ -398,7 +398,7 @@ QByteArray LibraryInfo::calculateFingerprint() const
|
||||
}
|
||||
len = _typeinfos.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const QString &typeinfo, _typeinfos) {
|
||||
for (const QString &typeinfo : _typeinfos) {
|
||||
len = typeinfo.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
hash.addData(reinterpret_cast<const char *>(typeinfo.constData()),
|
||||
@@ -407,10 +407,10 @@ QByteArray LibraryInfo::calculateFingerprint() const
|
||||
len = _metaObjects.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
QList<QByteArray> metaFingerprints;
|
||||
foreach (const LanguageUtils::FakeMetaObject::ConstPtr &metaObject, _metaObjects)
|
||||
for (const LanguageUtils::FakeMetaObject::ConstPtr &metaObject : _metaObjects)
|
||||
metaFingerprints.append(metaObject->fingerprint());
|
||||
std::sort(metaFingerprints.begin(), metaFingerprints.end());
|
||||
foreach (const QByteArray &fp, metaFingerprints)
|
||||
for (const QByteArray &fp : std::as_const(metaFingerprints))
|
||||
hash.addData(fp);
|
||||
hash.addData(reinterpret_cast<const char *>(&_dumpStatus), sizeof(_dumpStatus));
|
||||
len = _dumpError.size(); // localization dependent (avoid?)
|
||||
@@ -419,12 +419,12 @@ QByteArray LibraryInfo::calculateFingerprint() const
|
||||
|
||||
len = _moduleApis.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const ModuleApiInfo &moduleInfo, _moduleApis)
|
||||
for (const ModuleApiInfo &moduleInfo : _moduleApis)
|
||||
moduleInfo.addToHash(hash); // make it order independent?
|
||||
|
||||
len = _imports.size();
|
||||
hash.addData(reinterpret_cast<const char *>(&len), sizeof(len));
|
||||
foreach (const QmlDirParser::Import &import, _imports)
|
||||
for (const QmlDirParser::Import &import : _imports)
|
||||
hash.addData(import.module.toUtf8()); // import order matters, keep order-dependent
|
||||
|
||||
QByteArray res(hash.result());
|
||||
@@ -473,13 +473,14 @@ void Snapshot::insertLibraryInfo(const Utils::FilePath &path, const LibraryInfo
|
||||
cImport.importId = path.toString();
|
||||
cImport.language = Dialect::AnyLanguage;
|
||||
QSet<ImportKey> packages;
|
||||
foreach (const ModuleApiInfo &moduleInfo, info.moduleApis()) {
|
||||
for (const ModuleApiInfo &moduleInfo : info.moduleApis()) {
|
||||
ImportKey iKey(ImportType::Library, moduleInfo.uri, moduleInfo.version.majorVersion(),
|
||||
moduleInfo.version.minorVersion());
|
||||
packages.insert(iKey);
|
||||
}
|
||||
foreach (const LanguageUtils::FakeMetaObject::ConstPtr &metaO, info.metaObjects()) {
|
||||
foreach (const LanguageUtils::FakeMetaObject::Export &e, metaO->exports()) {
|
||||
const QList<LanguageUtils::FakeMetaObject::ConstPtr> metaObjects = info.metaObjects();
|
||||
for (const LanguageUtils::FakeMetaObject::ConstPtr &metaO : metaObjects) {
|
||||
for (const LanguageUtils::FakeMetaObject::Export &e : metaO->exports()) {
|
||||
ImportKey iKey(ImportType::Library, e.package, e.version.majorVersion(),
|
||||
e.version.minorVersion());
|
||||
packages.insert(iKey);
|
||||
@@ -489,7 +490,7 @@ void Snapshot::insertLibraryInfo(const Utils::FilePath &path, const LibraryInfo
|
||||
QStringList splitPath = path.path().split(QLatin1Char('/'));
|
||||
const QRegularExpression vNr(QLatin1String("^(.+)\\.([0-9]+)(?:\\.([0-9]+))?$"));
|
||||
const QRegularExpression safeName(QLatin1String("^[a-zA-Z_][[a-zA-Z0-9_]*$"));
|
||||
foreach (const ImportKey &importKey, packages) {
|
||||
for (const ImportKey &importKey : std::as_const(packages)) {
|
||||
if (importKey.splitPath.size() == 1 && importKey.splitPath.at(0).isEmpty() && splitPath.length() > 0) {
|
||||
// relocatable
|
||||
QStringList myPath = splitPath;
|
||||
@@ -522,7 +523,7 @@ void Snapshot::insertLibraryInfo(const Utils::FilePath &path, const LibraryInfo
|
||||
int majorVersion = LanguageUtils::ComponentVersion::NoVersion;
|
||||
int minorVersion = LanguageUtils::ComponentVersion::NoVersion;
|
||||
|
||||
foreach (const QmlDirParser::Component &component, info.components()) {
|
||||
for (const QmlDirParser::Component &component : info.components()) {
|
||||
if (component.majorVersion > majorVersion)
|
||||
majorVersion = component.majorVersion;
|
||||
if (component.minorVersion > minorVersion)
|
||||
@@ -555,8 +556,8 @@ void Snapshot::insertLibraryInfo(const Utils::FilePath &path, const LibraryInfo
|
||||
cImport.addPossibleExport(Export(iKey, newP, true));
|
||||
}
|
||||
}
|
||||
foreach (const QmlDirParser::Component &component, info.components()) {
|
||||
foreach (const Export &e, cImport.possibleExports)
|
||||
for (const QmlDirParser::Component &component : info.components()) {
|
||||
for (const Export &e : std::as_const(cImport.possibleExports))
|
||||
_dependencies.addExport(component.fileName, e.exportName, e.pathRequired, e.typeName);
|
||||
}
|
||||
|
||||
|
@@ -154,13 +154,13 @@ public:
|
||||
QByteArray fingerprint() const
|
||||
{ return _fingerprint; }
|
||||
|
||||
QList<QmlDirParser::Component> components() const
|
||||
const QList<QmlDirParser::Component> components() const
|
||||
{ return _components; }
|
||||
|
||||
QList<QmlDirParser::Plugin> plugins() const
|
||||
{ return _plugins; }
|
||||
|
||||
QStringList typeInfos() const
|
||||
const QStringList typeInfos() const
|
||||
{ return _typeinfos; }
|
||||
|
||||
FakeMetaObjectList metaObjects() const
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
void setMetaObjects(const FakeMetaObjectList &objects)
|
||||
{ _metaObjects = objects; }
|
||||
|
||||
QList<ModuleApiInfo> moduleApis() const
|
||||
const QList<ModuleApiInfo> moduleApis() const
|
||||
{ return _moduleApis; }
|
||||
|
||||
void setModuleApis(const QList<ModuleApiInfo> &apis)
|
||||
|
@@ -637,9 +637,9 @@ static QString toQmlType(const FullySpecifiedType &type)
|
||||
|
||||
static Class *lookupClass(const QString &expression, Scope *scope, TypeOfExpression &typeOf)
|
||||
{
|
||||
QList<LookupItem> results = typeOf(expression.toUtf8(), scope);
|
||||
const QList<LookupItem> results = typeOf(expression.toUtf8(), scope);
|
||||
Class *klass = nullptr;
|
||||
foreach (const LookupItem &item, results) {
|
||||
for (const LookupItem &item : results) {
|
||||
if (item.declaration()) {
|
||||
klass = item.declaration()->asClass();
|
||||
if (klass)
|
||||
@@ -707,8 +707,8 @@ static LanguageUtils::FakeMetaObject::Ptr buildFakeMetaObject(
|
||||
if (QtEnum *qtEnum = member->asQtEnum()) {
|
||||
// find the matching enum
|
||||
Enum *e = nullptr;
|
||||
QList<LookupItem> result = typeOf(namePrinter.prettyName(qtEnum->name()).toUtf8(), klass);
|
||||
foreach (const LookupItem &item, result) {
|
||||
const QList<LookupItem> result = typeOf(namePrinter.prettyName(qtEnum->name()).toUtf8(), klass);
|
||||
for (const LookupItem &item : result) {
|
||||
if (item.declaration()) {
|
||||
e = item.declaration()->asEnum();
|
||||
if (e)
|
||||
@@ -757,7 +757,7 @@ static void buildExportedQmlObjects(
|
||||
if (cppExports.isEmpty())
|
||||
return;
|
||||
|
||||
foreach (const ExportedQmlType &exportedType, cppExports) {
|
||||
for (const ExportedQmlType &exportedType : cppExports) {
|
||||
Class *klass = nullptr;
|
||||
if (!exportedType.typeExpression.isEmpty())
|
||||
klass = lookupClass(exportedType.typeExpression, exportedType.scope, typeOf);
|
||||
@@ -785,7 +785,7 @@ static void buildContextProperties(
|
||||
{
|
||||
using namespace LanguageUtils;
|
||||
|
||||
foreach (const ContextProperty &property, contextPropertyDescriptions) {
|
||||
for (const ContextProperty &property : contextPropertyDescriptions) {
|
||||
Scope *scope = doc->scopeAt(property.line, property.column);
|
||||
QList<LookupItem> results = typeOf(property.expression.toUtf8(), scope);
|
||||
QString typeName;
|
||||
@@ -880,7 +880,7 @@ QStringList FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &doc
|
||||
m_exportedTypes += it.value();
|
||||
fileNames += QLatin1String(it.key()->fileName());
|
||||
}
|
||||
foreach (const LanguageUtils::FakeMetaObject::Ptr &fmo, extraFakeMetaObjects) {
|
||||
for (const LanguageUtils::FakeMetaObject::Ptr &fmo : std::as_const(extraFakeMetaObjects)) {
|
||||
fmo->updateFingerprint();
|
||||
m_exportedTypes += fmo;
|
||||
}
|
||||
|
@@ -61,12 +61,14 @@ void Icons::setIconFilesPath(const QString &iconPath)
|
||||
if (debug)
|
||||
qCDebug(iconsLog) << "parsing" << iconPath;
|
||||
QDir topDir(iconPath);
|
||||
foreach (const QFileInfo &subDirInfo, topDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||
QList<QFileInfo> dirs = topDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (const QFileInfo &subDirInfo : dirs) {
|
||||
if (debug)
|
||||
qCDebug(iconsLog) << "parsing" << subDirInfo.absoluteFilePath();
|
||||
const QString packageName = subDirInfo.fileName();
|
||||
QDir subDir(subDirInfo.absoluteFilePath() + QLatin1String("/16x16"));
|
||||
foreach (const QFileInfo &iconFile, subDir.entryInfoList(QDir::Files)) {
|
||||
QList<QFileInfo> files = subDir.entryInfoList(QDir::Files);
|
||||
for (const QFileInfo &iconFile : files) {
|
||||
QIcon icon(iconFile.absoluteFilePath());
|
||||
if (icon.isNull()) {
|
||||
if (debug)
|
||||
|
@@ -188,7 +188,7 @@ void ImportKey::addToHash(QCryptographicHash &hash) const
|
||||
hash.addData(reinterpret_cast<const char *>(&type), sizeof(type));
|
||||
hash.addData(reinterpret_cast<const char *>(&majorVersion), sizeof(majorVersion));
|
||||
hash.addData(reinterpret_cast<const char *>(&minorVersion), sizeof(minorVersion));
|
||||
foreach (const QString &s, splitPath) {
|
||||
for (const QString &s : splitPath) {
|
||||
hash.addData("/", 1);
|
||||
hash.addData(reinterpret_cast<const char *>(s.constData()), sizeof(QChar) * s.size());
|
||||
}
|
||||
@@ -484,7 +484,7 @@ size_t qHash(const ImportKey &info)
|
||||
{
|
||||
size_t res = ::qHash(info.type) ^
|
||||
::qHash(info.majorVersion) ^ ::qHash(info.minorVersion);
|
||||
foreach (const QString &s, info.splitPath)
|
||||
for (const QString &s : std::as_const(info.splitPath))
|
||||
res = res ^ ::qHash(s);
|
||||
return res;
|
||||
}
|
||||
@@ -546,7 +546,7 @@ QByteArray DependencyInfo::calculateFingerprint(const ImportDependencies &deps)
|
||||
rootImport.addToHash(hash);
|
||||
QStringList coreImports = Utils::toList(allCoreImports);
|
||||
coreImports.sort();
|
||||
foreach (const QString importId, coreImports) {
|
||||
for (const QString &importId : std::as_const(coreImports)) {
|
||||
hash.addData(reinterpret_cast<const char*>(importId.constData()), importId.size() * sizeof(QChar));
|
||||
QByteArray coreImportFingerprint = deps.coreImport(importId).fingerprint;
|
||||
hash.addData(coreImportFingerprint);
|
||||
@@ -612,7 +612,7 @@ void ImportDependencies::filter(const ViewerContext &vContext)
|
||||
const CoreImport &cImport = j.value();
|
||||
if (languageIsCompatible(vContext.language, cImport.language)) {
|
||||
QList<Export> newExports;
|
||||
foreach (const Export &e, cImport.possibleExports) {
|
||||
for (const Export &e : std::as_const(cImport.possibleExports)) {
|
||||
++benchMark.nPossibleExports;
|
||||
if (e.visibleInVContext(vContext)) {
|
||||
newExports.append(e);
|
||||
@@ -660,10 +660,10 @@ void ImportDependencies::iterateOnCandidateImports(
|
||||
default:
|
||||
{
|
||||
const QStringList imp = m_importCache.value(key.flatKey());
|
||||
foreach (const QString &cImportName, imp) {
|
||||
for (const QString &cImportName : imp) {
|
||||
CoreImport cImport = coreImport(cImportName);
|
||||
if (languageIsCompatible(vContext.language, cImport.language)) {
|
||||
foreach (const Export e, cImport.possibleExports) {
|
||||
for (const Export e : std::as_const(cImport.possibleExports)) {
|
||||
++benchMark.nPossibleExports;
|
||||
if (e.visibleInVContext(vContext)) {
|
||||
ImportMatchStrength m = e.exportName.matchImport(key, vContext);
|
||||
@@ -683,10 +683,10 @@ void ImportDependencies::iterateOnCandidateImports(
|
||||
while (lb != end) {
|
||||
ImportKey::DirCompareInfo c = key.compareDir(lb.key());
|
||||
if (c == ImportKey::SameDir) {
|
||||
foreach (const QString &cImportName, lb.value()) {
|
||||
for (const QString &cImportName : std::as_const(lb.value())) {
|
||||
CoreImport cImport = coreImport(cImportName);
|
||||
if (languageIsCompatible(vContext.language, cImport.language)) {
|
||||
foreach (const Export e, cImport.possibleExports) {
|
||||
for (const Export e : std::as_const(cImport.possibleExports)) {
|
||||
++benchMark.nPossibleExports;
|
||||
if (e.visibleInVContext(vContext)) {
|
||||
ImportMatchStrength m = e.exportName.matchImport(key, vContext);
|
||||
@@ -754,19 +754,19 @@ void ImportDependencies::addCoreImport(const CoreImport &import)
|
||||
CoreImport newImport = import;
|
||||
if (m_coreImports.contains(import.importId)) {
|
||||
CoreImport oldVal = m_coreImports.value(import.importId);
|
||||
foreach (const Export &e, oldVal.possibleExports) {
|
||||
for (const Export &e : std::as_const(oldVal.possibleExports)) {
|
||||
if (e.intrinsic)
|
||||
removeImportCacheEntry(e.exportName, import.importId);
|
||||
else
|
||||
newImport.possibleExports.append(e);
|
||||
}
|
||||
}
|
||||
foreach (const Export &e, import.possibleExports)
|
||||
for (const Export &e : std::as_const(import.possibleExports))
|
||||
m_importCache[e.exportName].append(import.importId);
|
||||
m_coreImports.insert(newImport.importId, newImport);
|
||||
if (importsLog().isDebugEnabled()) {
|
||||
QString msg = QString::fromLatin1("added import %1 for").arg(newImport.importId);
|
||||
foreach (const Export &e, newImport.possibleExports)
|
||||
for (const Export &e : std::as_const(newImport.possibleExports))
|
||||
msg += QString::fromLatin1("\n %1(%2)")
|
||||
.arg(e.exportName.toString(), e.pathRequired.toUserOutput());
|
||||
qCDebug(importsLog) << msg;
|
||||
@@ -781,7 +781,7 @@ void ImportDependencies::removeCoreImport(const QString &importId)
|
||||
}
|
||||
CoreImport &cImport = m_coreImports[importId];
|
||||
QList<Export> newExports;
|
||||
foreach (const Export &e, cImport.possibleExports)
|
||||
for (const Export &e : std::as_const(cImport.possibleExports))
|
||||
if (e.intrinsic)
|
||||
removeImportCacheEntry(e.exportName, importId);
|
||||
else
|
||||
@@ -867,10 +867,10 @@ void ImportDependencies::iterateOnLibraryImports(
|
||||
iter_t end = m_importCache.constEnd();
|
||||
while (i != end && i.key().type == ImportType::Library) {
|
||||
qCDebug(importsLog) << "libloop:" << i.key().toString() << i.value();
|
||||
foreach (const QString &cImportName, i.value()) {
|
||||
for (const QString &cImportName : i.value()) {
|
||||
CoreImport cImport = coreImport(cImportName);
|
||||
if (languageIsCompatible(vContext.language, cImport.language)) {
|
||||
foreach (const Export &e, cImport.possibleExports) {
|
||||
for (const Export &e : std::as_const(cImport.possibleExports)) {
|
||||
++benchMark.nPossibleExports;
|
||||
if (e.visibleInVContext(vContext) && e.exportName.type == ImportType::Library) {
|
||||
ImportMatchStrength m = e.exportName.matchImport(i.key(), vContext);
|
||||
@@ -903,10 +903,10 @@ void ImportDependencies::iterateOnSubImports(
|
||||
ImportKey::DirCompareInfo c = baseKey.compareDir(i.key());
|
||||
if (c != ImportKey::SameDir && c != ImportKey::SecondInFirst)
|
||||
break;
|
||||
foreach (const QString &cImportName, i.value()) {
|
||||
for (const QString &cImportName : i.value()) {
|
||||
CoreImport cImport = coreImport(cImportName);
|
||||
if (languageIsCompatible(vContext.language, cImport.language)) {
|
||||
foreach (const Export &e, cImport.possibleExports) {
|
||||
for (const Export &e : std::as_const(cImport.possibleExports)) {
|
||||
++benchMark.nPossibleExports;
|
||||
if (e.visibleInVContext(vContext)) {
|
||||
ImportMatchStrength m = e.exportName.matchImport(i.key(), vContext);
|
||||
@@ -961,14 +961,15 @@ void ImportDependencies::checkConsistency() const
|
||||
for (auto j = m_importCache.cbegin(), end = m_importCache.cend(); j != end; ++j) {
|
||||
for (const QString &s : j.value()) {
|
||||
bool found = false;
|
||||
foreach (const Export &e, m_coreImports.value(s).possibleExports)
|
||||
const QList<Export> exports = m_coreImports.value(s).possibleExports;
|
||||
for (const Export &e : exports)
|
||||
if (e.exportName == j.key())
|
||||
found = true;
|
||||
Q_ASSERT(found); Q_UNUSED(found)
|
||||
}
|
||||
}
|
||||
for (auto i = m_coreImports.cbegin(), end = m_coreImports.cend(); i != end; ++i) {
|
||||
foreach (const Export &e, i.value().possibleExports) {
|
||||
for (const Export &e : std::as_const(i.value().possibleExports)) {
|
||||
if (!m_importCache.value(e.exportName).contains(i.key())) {
|
||||
qCWarning(importsLog) << e.exportName.toString();
|
||||
qCWarning(importsLog) << i.key();
|
||||
|
@@ -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);
|
||||
|
@@ -577,7 +577,7 @@ public:
|
||||
|
||||
using ObjectValue::prototype;
|
||||
const CppComponentValue *prototype() const;
|
||||
QList<const CppComponentValue *> prototypes() const;
|
||||
const QList<const CppComponentValue *> prototypes() const;
|
||||
|
||||
LanguageUtils::FakeMetaObject::ConstPtr metaObject() const;
|
||||
|
||||
|
@@ -105,7 +105,7 @@ QString LineInfo::trimmedCodeLine(const QString &t)
|
||||
yyLinizerState.tokens = scanner(t, startState);
|
||||
QString trimmed;
|
||||
int previousTokenEnd = 0;
|
||||
foreach (const Token &token, yyLinizerState.tokens) {
|
||||
for (const Token &token : std::as_const(yyLinizerState.tokens)) {
|
||||
trimmed.append(t.mid(previousTokenEnd, token.begin() - previousTokenEnd));
|
||||
|
||||
if (token.is(Token::String)) {
|
||||
@@ -131,7 +131,7 @@ QString LineInfo::trimmedCodeLine(const QString &t)
|
||||
}
|
||||
|
||||
bool isBinding = false;
|
||||
foreach (const Token &token, yyLinizerState.tokens) {
|
||||
for (const Token &token : std::as_const(yyLinizerState.tokens)) {
|
||||
if (token.is(Token::Colon)) {
|
||||
isBinding = true;
|
||||
break;
|
||||
|
@@ -133,14 +133,15 @@ void PluginDumper::onLoadPluginTypes(const Utils::FilePath &libraryPath,
|
||||
}
|
||||
|
||||
// add typeinfo files listed in qmldir
|
||||
foreach (const QString &typeInfo, libraryInfo.typeInfos()) {
|
||||
for (const QString &typeInfo : libraryInfo.typeInfos()) {
|
||||
const FilePath pathNow = canonicalLibraryPath.resolvePath(typeInfo);
|
||||
if (!plugin.typeInfoPaths.contains(pathNow) && pathNow.exists())
|
||||
plugin.typeInfoPaths += pathNow;
|
||||
}
|
||||
|
||||
// watch plugin libraries
|
||||
foreach (const QmlDirParser::Plugin &plugin, snapshot.libraryInfo(canonicalLibraryPath).plugins()) {
|
||||
const QList<QmlDirParser::Plugin> plugins = snapshot.libraryInfo(canonicalLibraryPath).plugins();
|
||||
for (const QmlDirParser::Plugin &plugin : plugins) {
|
||||
const QString pluginLibrary = resolvePlugin(canonicalLibraryPath.toString(), plugin.path, plugin.name);
|
||||
if (!pluginLibrary.isEmpty()) {
|
||||
if (!pluginWatcher()->watchesFile(pluginLibrary))
|
||||
@@ -165,7 +166,7 @@ void PluginDumper::onLoadPluginTypes(const Utils::FilePath &libraryPath,
|
||||
|
||||
void PluginDumper::dumpAllPlugins()
|
||||
{
|
||||
foreach (const Plugin &plugin, m_plugins) {
|
||||
for (const Plugin &plugin : std::as_const(m_plugins)) {
|
||||
dump(plugin);
|
||||
}
|
||||
}
|
||||
@@ -676,7 +677,7 @@ QString PluginDumper::resolvePlugin(const QDir &qmldirPath, const QString &qmldi
|
||||
if (!qmldirPluginPathIsRelative)
|
||||
searchPaths.prepend(qmldirPluginPath);
|
||||
|
||||
foreach (const QString &pluginPath, searchPaths) {
|
||||
for (const QString &pluginPath : std::as_const(searchPaths)) {
|
||||
|
||||
QString resolvedPath;
|
||||
|
||||
@@ -690,7 +691,7 @@ QString PluginDumper::resolvePlugin(const QDir &qmldirPath, const QString &qmldi
|
||||
}
|
||||
|
||||
QDir dir(resolvedPath);
|
||||
foreach (const QString &suffix, suffixes) {
|
||||
for (const QString &suffix : suffixes) {
|
||||
QString pluginFileName = prefix;
|
||||
|
||||
pluginFileName += baseName;
|
||||
|
@@ -273,7 +273,7 @@ protected:
|
||||
const int minContentLength = 10;
|
||||
|
||||
qreal result = badnessFromSplits;
|
||||
foreach (const QString &line, lines) {
|
||||
for (const QString &line : std::as_const(lines)) {
|
||||
// really long lines should be avoided at all cost
|
||||
if (line.size() > strongMaxLineLength) {
|
||||
result += 50 + (line.size() - strongMaxLineLength);
|
||||
|
@@ -48,7 +48,7 @@ void ScopeBuilder::push(AST::Node *node)
|
||||
const ObjectValue *owner = nullptr;
|
||||
const Value *value = nullptr;
|
||||
// try to find the name on the scope objects
|
||||
foreach (const ObjectValue *scope, _scopeChain->qmlScopeObjects()) {
|
||||
for (const ObjectValue *scope : _scopeChain->qmlScopeObjects()) {
|
||||
value = scope->lookupMember(name, _scopeChain->context(), &owner);
|
||||
if (value)
|
||||
break;
|
||||
@@ -84,7 +84,7 @@ void ScopeBuilder::push(AST::Node *node)
|
||||
|
||||
void ScopeBuilder::push(const QList<AST::Node *> &nodes)
|
||||
{
|
||||
foreach (Node *node, nodes)
|
||||
for (Node *node : nodes)
|
||||
push(node);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ const Value *ScopeBuilder::scopeObjectLookup(AST::UiQualifiedId *id)
|
||||
{
|
||||
// do a name lookup on the scope objects
|
||||
const Value *result = nullptr;
|
||||
foreach (const ObjectValue *scopeObject, _scopeChain->qmlScopeObjects()) {
|
||||
for (const ObjectValue *scopeObject : _scopeChain->qmlScopeObjects()) {
|
||||
const ObjectValue *object = scopeObject;
|
||||
for (UiQualifiedId *it = id; it; it = it->next) {
|
||||
if (it->name.isEmpty())
|
||||
|
@@ -47,7 +47,7 @@ Document::Ptr QmlComponentChain::document() const
|
||||
return m_document;
|
||||
}
|
||||
|
||||
QList<const QmlComponentChain *> QmlComponentChain::instantiatingComponents() const
|
||||
const QList<const QmlComponentChain *> QmlComponentChain::instantiatingComponents() const
|
||||
{
|
||||
return m_instantiatingComponents;
|
||||
}
|
||||
@@ -153,7 +153,7 @@ void ScopeChain::setQmlComponentChain(const QSharedPointer<const QmlComponentCha
|
||||
m_qmlComponentScope = qmlComponentChain;
|
||||
}
|
||||
|
||||
QList<const ObjectValue *> ScopeChain::qmlScopeObjects() const
|
||||
const QList<const ObjectValue *> ScopeChain::qmlScopeObjects() const
|
||||
{
|
||||
return m_qmlScopeObjects;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ QList<const ObjectValue *> ScopeChain::all() const
|
||||
|
||||
static void collectScopes(const QmlComponentChain *chain, QList<const ObjectValue *> *target)
|
||||
{
|
||||
foreach (const QmlComponentChain *parent, chain->instantiatingComponents())
|
||||
for (const QmlComponentChain *parent : chain->instantiatingComponents())
|
||||
collectScopes(parent, target);
|
||||
|
||||
if (!chain->document())
|
||||
@@ -237,7 +237,7 @@ void ScopeChain::update() const
|
||||
// the root scope in js files doesn't see instantiating components
|
||||
if (m_document->language() != Dialect::JavaScript || m_jsScopes.count() != 1) {
|
||||
if (m_qmlComponentScope) {
|
||||
foreach (const QmlComponentChain *parent, m_qmlComponentScope->instantiatingComponents())
|
||||
for (const QmlComponentChain *parent : m_qmlComponentScope->instantiatingComponents())
|
||||
collectScopes(parent, &m_all);
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ void ScopeChain::update() const
|
||||
static void addInstantiatingComponents(ContextPtr context, QmlComponentChain *chain)
|
||||
{
|
||||
const QRegularExpression importCommentPattern(QLatin1String("@scope\\s+(.*)"));
|
||||
foreach (const SourceLocation &commentLoc, chain->document()->engine()->comments()) {
|
||||
for (const SourceLocation &commentLoc : chain->document()->engine()->comments()) {
|
||||
const QString &comment = chain->document()->source().mid(commentLoc.begin(), commentLoc.length);
|
||||
|
||||
// find all @scope annotations
|
||||
@@ -283,10 +283,10 @@ static void addInstantiatingComponents(ContextPtr context, QmlComponentChain *ch
|
||||
.absoluteFilePath();
|
||||
}
|
||||
|
||||
foreach (const QmlComponentChain *c, chain->instantiatingComponents())
|
||||
for (const QmlComponentChain *c : chain->instantiatingComponents())
|
||||
additionalScopes.removeAll(c->document()->fileName());
|
||||
|
||||
foreach (const Utils::FilePath &scope, additionalScopes) {
|
||||
for (const Utils::FilePath &scope : std::as_const(additionalScopes)) {
|
||||
Document::Ptr doc = context->snapshot().document(scope);
|
||||
if (doc) {
|
||||
QmlComponentChain *ch = new QmlComponentChain(doc);
|
||||
@@ -322,8 +322,8 @@ void ScopeChain::initializeRootScope()
|
||||
// add scope chains for all components that import this file
|
||||
// unless there's .pragma library
|
||||
if (!m_document->bind()->isJsLibrary()) {
|
||||
foreach (Document::Ptr otherDoc, snapshot) {
|
||||
foreach (const ImportInfo &import, otherDoc->bind()->imports()) {
|
||||
for (Document::Ptr otherDoc : snapshot) {
|
||||
for (const ImportInfo &import : otherDoc->bind()->imports()) {
|
||||
if ((import.type() == ImportType::File
|
||||
&& m_document->fileName().toString() == import.path())
|
||||
|| (import.type() == ImportType::QrcFile
|
||||
@@ -358,7 +358,7 @@ void ScopeChain::makeComponentChain(
|
||||
const Bind *bind = doc->bind();
|
||||
|
||||
// add scopes for all components instantiating this one
|
||||
foreach (Document::Ptr otherDoc, snapshot) {
|
||||
for (Document::Ptr otherDoc : snapshot) {
|
||||
if (otherDoc == doc)
|
||||
continue;
|
||||
if (otherDoc->bind()->usesQmlPrototype(bind->rootObjectValue(), m_context)) {
|
||||
|
@@ -26,7 +26,7 @@ public:
|
||||
~QmlComponentChain();
|
||||
|
||||
Document::Ptr document() const;
|
||||
QList<const QmlComponentChain *> instantiatingComponents() const;
|
||||
const QList<const QmlComponentChain *> instantiatingComponents() const;
|
||||
|
||||
const ObjectValue *idScope() const;
|
||||
const ObjectValue *rootObjectScope() const;
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
QSharedPointer<const QmlComponentChain> qmlComponentChain() const;
|
||||
void setQmlComponentChain(const QSharedPointer<const QmlComponentChain> &qmlComponentChain);
|
||||
|
||||
QList<const ObjectValue *> qmlScopeObjects() const;
|
||||
const QList<const ObjectValue *> qmlScopeObjects() const;
|
||||
void setQmlScopeObjects(const QList<const ObjectValue *> &qmlScopeObjects);
|
||||
|
||||
const TypeScope *qmlTypes() const;
|
||||
|
Reference in New Issue
Block a user