aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser/qqmljsast_p.h
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2023-05-30 16:04:01 +0200
committerSami Shalayel <sami.shalayel@qt.io>2023-06-02 14:39:24 +0200
commit81f3dca10979cdfb80685d77f034350f2907c5e4 (patch)
tree02a7e4a4ae9b6118d7e3ee26236bff035b6b8416 /src/qml/parser/qqmljsast_p.h
parent8a8a99d888f37c3377f27aa10935f337252be429 (diff)
QmlDom: support function parameters and co
Implement function parameters for function definitions in the Dom, as otherwise the unused scriptelements in the stack will make the following script element construction fail. Also implement all the dom elements required by function parameters. Instead of filling in only the script element for the defaultValues, (and failing when encountering more complex expressions), add a ScriptExpression that can model more complex expressions in the argument (including default value, deconstruction, type annotations, etc.) in the Dom::MethodParameter class and leave the pre-existing defaultValue as is for now. Requirements for successful function parameter construction: * Add support for JS arrays and JS objects literals in the Dom. These ones are required to model parameter deconstruction, e.g. to pick certain list elements or object properties from the argument object/array * Fix the iteration order for PatternElementLists and PatternPropertyLists, as both are required for the JS arrays and objects * Add all kind of property names (used in JS object literals and JS object deconstruction) as literals in qqmldomastcreator. * JS array and object deconstruction happened to reveal a bug for VariableDeclarations, fix it (because you can use deconstruction in variable declarations) + add tests for that. * Support Type annotations in the Dom: this means that type annotations for methods are also created and also needs to be collected. Add a field returnType in Dom::MethodInfo for this. * Make sure that all QQmlJSScope's in the Dom are wrapped in optionals (because they are null when the semantic analysis option is not passed) and adapt the getters to it. Task-number: QTBUG-92876 Change-Id: I81df66989e833c9acd75f854b49dcc15b0729e99 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/parser/qqmljsast_p.h')
-rw-r--r--src/qml/parser/qqmljsast_p.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index e7052f324e..0511d8db91 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -328,7 +328,11 @@ public:
{ return identifierToken; }
SourceLocation lastSourceLocation() const override
- { return lastListElement(this)->identifierToken; }
+ {
+ return lastListElement(this)->lastOwnSourceLocation();
+ }
+
+ SourceLocation lastOwnSourceLocation() const { return identifierToken; }
QString toString() const
{
@@ -3330,7 +3334,12 @@ public:
SourceLocation lastSourceLocation() const override
{
auto last = lastListElement(this);
- return (last->colonToken.isValid() ? last->propertyTypeToken : last->identifierToken);
+ return last->lastOwnSourceLocation();
+ }
+
+ SourceLocation lastOwnSourceLocation() const
+ {
+ return (colonToken.isValid() ? propertyTypeToken : identifierToken);
}
inline UiParameterList *finish ()