aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser/qqmljs.g
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-01-21 14:39:48 +0100
committerUlf Hermann <ulf.hermann@qt.io>2022-01-31 13:41:39 +0100
commite7db279c2854856c819a970391b3566c730b68f7 (patch)
tree8b5777924449af22c43f0bfa463d2003906137fb /src/qml/parser/qqmljs.g
parentf22d884faff5f68230981fc191527c67aeb8a18f (diff)
QML: Allow declaring and binding list<foo> properties in one step
We apply the same trick we already use for the UiObjectMember rules: We add an ExpressionStatementLookahead before the T_LBRACKET starting the UiArrayMemberList. Task-number: QTBUG-82443 Change-Id: Ibdb3111b7721d2af087c14b79538dee131b8e301 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljs.g')
-rw-r--r--src/qml/parser/qqmljs.g25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g
index e20e861f8b..306f3d40f9 100644
--- a/src/qml/parser/qqmljs.g
+++ b/src/qml/parser/qqmljs.g
@@ -1421,9 +1421,26 @@ UiObjectMemberWithScriptStatement: UiPropertyAttributes UiPropertyType QmlIdenti
} break;
./
+UiObjectMemberWithScriptStatement: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON UiScriptStatement OptionalSemicolon;
+/.
+ case $rule_number: {
+ AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6), sym(8).Statement);
+ node->typeModifier = stringRef(2);
+ auto attributes = sym(1).UiPropertyAttributes;
+ if (attributes->isRequired())
+ diagnostic_messages.append(compileError(attributes->requiredToken(), QLatin1String("Required properties with initializer do not make sense."), QtCriticalMsg));
+ node->setAttributes(attributes);
+ node->typeModifierToken = loc(2);
+ node->typeToken = loc(4);
+ node->identifierToken = loc(6);
+ node->colonToken = loc(7);
+ sym(1).Node = node;
+ } break;
+./
+
UiObjectMember: UiObjectMemberWithScriptStatement;
-UiObjectMemberWithArray: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON T_LBRACKET UiArrayMemberList T_RBRACKET Semicolon;
+UiObjectMemberWithArray: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T_GT QmlIdentifier T_COLON ExpressionStatementLookahead T_LBRACKET UiArrayMemberList T_RBRACKET Semicolon;
/.
case $rule_number: {
AST::UiPublicMember *node = new (pool) AST::UiPublicMember(sym(4).UiQualifiedId->finish(), stringRef(6));
@@ -1441,10 +1458,10 @@ UiObjectMemberWithArray: UiPropertyAttributes T_IDENTIFIER T_LT UiPropertyType T
propertyName->identifierToken = loc(6);
propertyName->next = nullptr;
- AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(propertyName, sym(9).UiArrayMemberList->finish());
+ AST::UiArrayBinding *binding = new (pool) AST::UiArrayBinding(propertyName, sym(10).UiArrayMemberList->finish());
binding->colonToken = loc(7);
- binding->lbracketToken = loc(8);
- binding->rbracketToken = loc(10);
+ binding->lbracketToken = loc(9);
+ binding->rbracketToken = loc(11);
node->binding = binding;