aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsimportvisitor.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-10-21 16:06:20 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-10-27 09:23:30 +0100
commited8127cf41951a9ff1d6032c2158e49fdebe51c3 (patch)
tree12e74c92f9c9a9ee940e4bde91ba4132454c1dd8 /src/qmlcompiler/qqmljsimportvisitor.cpp
parent23813a319898e8951645a9f9bec5813090fd3a85 (diff)
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 <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor.cpp')
-rw-r--r--src/qmlcompiler/qqmljsimportvisitor.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp
index 04bb27dc84..bb789a1c66 100644
--- a/src/qmlcompiler/qqmljsimportvisitor.cpp
+++ b/src/qmlcompiler/qqmljsimportvisitor.cpp
@@ -51,7 +51,10 @@ void QQmlJSImportVisitor::enterEnvironment(QQmlJSScope::ScopeType type, const QS
const QQmlJS::SourceLocation &location)
{
m_currentScope = QQmlJSScope::create(type, m_currentScope);
- m_currentScope->setBaseTypeName(name);
+ if (type == QQmlJSScope::GroupedPropertyScope)
+ m_currentScope->setInternalName(name);
+ else
+ m_currentScope->setBaseTypeName(name);
m_currentScope->setIsComposite(true);
m_currentScope->setSourceLocation(location);
}
@@ -126,6 +129,7 @@ bool QQmlJSImportVisitor::visit(UiObjectDefinition *definition)
void QQmlJSImportVisitor::endVisit(UiObjectDefinition *)
{
+ m_currentScope->resolveGroupedScopes();
leaveEnvironment();
}
@@ -235,11 +239,27 @@ void QQmlJSImportVisitor::endVisit(QQmlJS::AST::ClassExpression *)
bool QQmlJSImportVisitor::visit(UiScriptBinding *scriptBinding)
{
- if (scriptBinding->qualifiedId->name == QLatin1String("id")) {
+ const auto id = scriptBinding->qualifiedId;
+ if (!id->next && id->name == QLatin1String("id")) {
const auto *statement = cast<ExpressionStatement *>(scriptBinding->statement);
const auto *idExprension = cast<IdentifierExpression *>(statement->expression);
m_scopesById.insert(idExprension->name.toString(), m_currentScope);
+ } else {
+ for (auto group = id; group->next; group = group->next) {
+ const QString name = group->name.toString();
+
+ if (name.isEmpty() || name.front().isUpper())
+ break; // TODO: uppercase grouped scopes are attached properties. Handle them.
+
+ enterEnvironment(QQmlJSScope::GroupedPropertyScope, name, group->firstSourceLocation());
+ }
+
+ // TODO: remember the actual binding, once we can process it.
+
+ while (m_currentScope->scopeType() == QQmlJSScope::GroupedPropertyScope)
+ leaveEnvironment();
}
+
return true;
}
@@ -448,6 +468,7 @@ bool QQmlJSImportVisitor::visit(QQmlJS::AST::UiObjectBinding *uiob)
void QQmlJSImportVisitor::endVisit(QQmlJS::AST::UiObjectBinding *uiob)
{
+ m_currentScope->resolveGroupedScopes();
const QQmlJSScope::ConstPtr childScope = m_currentScope;
leaveEnvironment();