diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-03-16 11:20:47 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-03-16 14:08:17 +0100 |
commit | 3e57c56aa1d54ac4587284727ca9c952d33f3e43 (patch) | |
tree | 751d0f973c9e440fbfa24af68b3ed508b167bc52 /tools | |
parent | 61413825960870ac9390d0aa0431702431c620f2 (diff) |
qmllint: Add QFont to the list of unknown builtins
And also check them when analyzing JavaScript access.
Task-number: QTBUG-82817
Change-Id: I677e7883fb24ab80ff20d1998e2d7df440ef4112
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/scopetree.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/tools/qmllint/scopetree.cpp b/tools/qmllint/scopetree.cpp index e7e0113f35..5c0fa526a4 100644 --- a/tools/qmllint/scopetree.cpp +++ b/tools/qmllint/scopetree.cpp @@ -134,6 +134,15 @@ private: QStringRef m_afterText; }; +static const QStringList unknownBuiltins = { + // TODO: "string" should be added to builtins.qmltypes, and the special handling below removed + QStringLiteral("alias"), // TODO: we cannot properly resolve aliases, yet + QStringLiteral("QRectF"), // TODO: should be added to builtins.qmltypes + QStringLiteral("QFont"), // TODO: should be added to builtins.qmltypes + QStringLiteral("QJSValue"), // We cannot say anything intelligent about untyped JS values. + QStringLiteral("variant"), // Same for generic variants +}; + bool ScopeTree::checkMemberAccess( const QString &code, FieldMemberList *members, @@ -169,10 +178,14 @@ bool ScopeTree::checkMemberAccess( } return true; } - const ScopeTree *type = (scopeIt->type() && access->m_parentType.isEmpty()) - ? scopeIt->type() - : types.value(typeName).get(); - return checkMemberAccess(code, access.get(), type, types, colorOut); + + if (const ScopeTree *type = scopeIt->type()) { + if (access->m_parentType.isEmpty()) + return checkMemberAccess(code, access.get(), type, types, colorOut); + } + + return unknownBuiltins.contains(typeName) || checkMemberAccess( + code, access.get(), types.value(typeName).get(), types, colorOut); } const auto scopeMethodIt = scope->m_methods.find(access->m_name); @@ -251,13 +264,6 @@ bool ScopeTree::checkMemberAccess( return false; } -static const QStringList unknownBuiltins = { - QStringLiteral("alias"), // TODO: we cannot properly resolve aliases, yet - QStringLiteral("QRectF"), // TODO: should be added to builtins.qmltypes - QStringLiteral("QJSValue"), // We cannot say anything intelligent about untyped JS values. - QStringLiteral("variant"), // Same for generic variants -}; - bool ScopeTree::recheckIdentifiers( const QString &code, const QHash<QString, const ScopeTree *> &qmlIDs, |