From ed8127cf41951a9ff1d6032c2158e49fdebe51c3 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 21 Oct 2020 16:06:20 +0200 Subject: QmlCompiler: Introduce grouped scopes This way we can analyze the left hand part of things like "anchors.fill: parent" in qmllint. Change-Id: I0f58312566c3d5062e0fb301c2bad908ab8b8cbb Reviewed-by: Fabian Kosmale --- src/qmlcompiler/qqmljsscope.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/qmlcompiler/qqmljsscope.cpp') diff --git a/src/qmlcompiler/qqmljsscope.cpp b/src/qmlcompiler/qqmljsscope.cpp index bea6c29932..0787e1062e 100644 --- a/src/qmlcompiler/qqmljsscope.cpp +++ b/src/qmlcompiler/qqmljsscope.cpp @@ -168,6 +168,27 @@ void QQmlJSScope::resolveTypes(const QHash &cont } } +void QQmlJSScope::resolveGroupedScopes() +{ + for (auto it = m_childScopes.begin(), end = m_childScopes.end(); it != end; ++it) { + QQmlJSScope::Ptr childScope = *it; + if (childScope->scopeType() != QQmlJSScope::GroupedPropertyScope) + continue; + + const QString propertyName = childScope->internalName(); + for (const QQmlJSScope *type = this; type; type = type->baseType().data()) { + auto propertyIt = type->m_properties.find(propertyName); + if (propertyIt != type->m_properties.end()) { + childScope->m_baseType = QQmlJSScope::ConstPtr(propertyIt->type()); + childScope->m_baseTypeName = propertyIt->typeName(); + break; + } + } + + childScope->resolveGroupedScopes(); + } +} + QQmlJSScope::ConstPtr QQmlJSScope::findCurrentQMLScope(const QQmlJSScope::ConstPtr &scope) { auto qmlScope = scope; -- cgit v1.2.3