diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-11-14 15:59:56 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-01-13 16:54:17 +0100 |
commit | 2677de3c79de984e88e4a950c915b4f3f54786dd (patch) | |
tree | 57a4cdf058f7af9d36c776955803e384853b361d /tools | |
parent | 6c68a39a56299c72da30a4bac3ca7fe8420687a4 (diff) |
qmllint: Assume "parent" property is always document parent
... except if the document parent is Component. Then leave the type
alone.
Change-Id: Id7b2e6efdefe18a8d375967ddedcdf9e07a07946
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmllint/findunqualified.cpp | 2 | ||||
-rw-r--r-- | tools/qmllint/scopetree.cpp | 9 | ||||
-rw-r--r-- | tools/qmllint/scopetree.h | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/tools/qmllint/findunqualified.cpp b/tools/qmllint/findunqualified.cpp index 359510f5f7..d0dc3a3711 100644 --- a/tools/qmllint/findunqualified.cpp +++ b/tools/qmllint/findunqualified.cpp @@ -888,7 +888,9 @@ bool FindUnqualifiedIDVisitor::visit(QQmlJS::AST::PatternElement *element) void FindUnqualifiedIDVisitor::endVisit(QQmlJS::AST::UiObjectDefinition *) { + auto childScope = m_currentScope; leaveEnvironment(); + childScope->updateParentProperty(m_currentScope); } bool FindUnqualifiedIDVisitor::visit(QQmlJS::AST::FieldMemberExpression *) diff --git a/tools/qmllint/scopetree.cpp b/tools/qmllint/scopetree.cpp index cac064eb27..e5b0eecc5f 100644 --- a/tools/qmllint/scopetree.cpp +++ b/tools/qmllint/scopetree.cpp @@ -448,6 +448,15 @@ void ScopeTree::setExportMetaObjectRevision(int exportIndex, int metaObjectRevis m_exports[exportIndex].setMetaObjectRevision(metaObjectRevision); } +void ScopeTree::updateParentProperty(const ScopeTree *scope) +{ + auto it = m_properties.find(QLatin1String("parent")); + if (it != m_properties.end() + && scope->name() != QLatin1String("Component") + && scope->name() != QLatin1String("program")) + it->setType(scope); +} + ScopeTree::Export::Export(QString package, QString type, const ComponentVersion &version, int metaObjectRevision) : m_package(std::move(package)), diff --git a/tools/qmllint/scopetree.h b/tools/qmllint/scopetree.h index 00cb466eb9..eb5f384477 100644 --- a/tools/qmllint/scopetree.h +++ b/tools/qmllint/scopetree.h @@ -153,6 +153,7 @@ public: void addProperty(const MetaProperty &prop) { m_properties.insert(prop.propertyName(), prop); } QHash<QString, MetaProperty> properties() const { return m_properties; } + void updateParentProperty(const ScopeTree *scope); QString defaultPropertyName() const { return m_defaultPropertyName; } void setDefaultPropertyName(const QString &name) { m_defaultPropertyName = name; } |