diff options
author | Sami Shalayel <sami.shalayel@qt.io> | 2023-12-15 11:48:13 +0100 |
---|---|---|
committer | Sami Shalayel <sami.shalayel@qt.io> | 2023-12-29 09:48:18 +0100 |
commit | 2b008f242150017415bc427d87e84ac81b95e877 (patch) | |
tree | 01629d633db786027d77af779174e121fcf83900 /src/qml/parser | |
parent | ff4c2c311f1957ebacb66f0d35406a51da2a544e (diff) |
qmlls: adapt parser for attached/grouped properties completion
Add a recovery mode to the parser to accept bindings that are not
completely written out, and create an empty statement for that. This
mode is called enableIncompleteBindings and is only enabled for qmlls.
Also adapt qqmldomastcreator to those empty statements, and qmllsutils.
Pick-to: 6.7
Fixes: QTBUG-120169
Task-number: QTBUG-92876
Change-Id: Ic24cbb61e3be08368027371e377bf75ce87fafb1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/parser')
-rw-r--r-- | src/qml/parser/qqmljs.g | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/qml/parser/qqmljs.g b/src/qml/parser/qqmljs.g index bc5955245a..bb27ccc96f 100644 --- a/src/qml/parser/qqmljs.g +++ b/src/qml/parser/qqmljs.g @@ -308,6 +308,12 @@ public: inline void enableIdentifierInsertion() { m_enableIdentifierInsertion = true; } + inline bool incompleteBindings() const + { return m_enableIncompleteBindings; } + + inline void enableIncompleteBindings() + { m_enableIncompleteBindings = true; } + protected: bool parse(int startToken); @@ -399,6 +405,7 @@ protected: QList<DiagnosticMessage> diagnostic_messages; bool m_enableIdentifierInsertion = false; + bool m_enableIncompleteBindings = false; }; } // end of namespace QQmlJS @@ -1142,6 +1149,20 @@ case $rule_number: } break; ./ +UiObjectMember: UiQualifiedId Semicolon; +/. + case $rule_number: { + if (!m_enableIncompleteBindings) { + diagnostic_messages.append(compileError(loc(1), QLatin1String("Incomplete binding, expected token `:` or `{`"))); + return false; + } + AST::EmptyStatement *statement = new (pool) AST::EmptyStatement; + statement->semicolonToken = loc(2); + AST::UiScriptBinding *node = new (pool) AST::UiScriptBinding(sym(1).UiQualifiedId, statement); + sym(1).Node = node; + } break; +./ + UiPropertyType: T_VAR; /. case $rule_number: Q_FALLTHROUGH(); ./ UiPropertyType: T_RESERVED_WORD; |