aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFawzi Mohamed <fawzi.mohamed@qt.io>2022-10-17 14:24:35 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-11-02 09:51:08 +0100
commitb2ec1c8ae1b07c517ece9ad8123ee31237f8c6ca (patch)
treeec0cb47c48964fb8976f4767a1dfdaa9ac382c9d /src
parent27448beb8f4fe38404101146880ab4bc38cd921d (diff)
qml: fix TypeArgumentList
All type annotations in qml did drop any typeArgument due to a bug in TypeArgumentList: instead of keeping a circular list that is inverted while building, and finally transformed in the inverse in the finish() method, it kept a singly linked list and the finish method would return a nullptr. Fix the formatting and indenting of type annotations now that they work. Task-number: QTBUG-107171 Change-Id: I9deff83d328c5c0784a4104e406036a435278945 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> (cherry picked from commit 0f08e3e673ece32fc9ada041115a0df631b447f3)
Diffstat (limited to 'src')
-rw-r--r--src/qml/parser/qqmljsast_p.h2
-rw-r--r--src/qmldom/qqmldomastcreator.cpp38
2 files changed, 25 insertions, 15 deletions
diff --git a/src/qml/parser/qqmljsast_p.h b/src/qml/parser/qqmljsast_p.h
index e764ebfb06..c2aa8f2aaa 100644
--- a/src/qml/parser/qqmljsast_p.h
+++ b/src/qml/parser/qqmljsast_p.h
@@ -367,7 +367,7 @@ public:
TypeArgumentList(Type *typeId)
: typeId(typeId)
- , next(nullptr)
+ , next(this)
{ kind = K; }
TypeArgumentList(TypeArgumentList *previous, Type *typeId)
diff --git a/src/qmldom/qqmldomastcreator.cpp b/src/qmldom/qqmldomastcreator.cpp
index 81d2d5d750..2559a6febf 100644
--- a/src/qmldom/qqmldomastcreator.cpp
+++ b/src/qmldom/qqmldomastcreator.cpp
@@ -67,6 +67,26 @@ static QString toString(const UiQualifiedId *qualifiedId, QChar delimiter = QLat
return result;
}
+static QString typeToString(AST::Type *t)
+{
+ Q_ASSERT(t);
+ QString res = toString(t->typeId);
+ if (!t->typeArguments)
+ return res;
+ res += u"<";
+ bool first = true;
+ for (TypeArgumentList *tt = static_cast<TypeArgumentList *>(t->typeArguments);
+ tt; tt = tt->next) {
+ if (first)
+ first = false;
+ else
+ res += u",";
+ res += typeToString(tt->typeId);
+ }
+ res += u">";
+ return res;
+}
+
SourceLocation combineLocations(SourceLocation s1, SourceLocation s2)
{
return combine(s1, s2);
@@ -487,13 +507,8 @@ public:
MethodInfo m;
m.name = fDef->name.toString();
if (AST::TypeAnnotation *tAnn = fDef->typeAnnotation) {
- if (AST::Type *t = tAnn->type) {
- m.typeName = toString(t->typeId);
- if (t->typeArguments) {
- Q_ASSERT_X(false, className,
- "todo: type argument should be added to the typeName");
- }
- }
+ if (AST::Type *t = tAnn->type)
+ m.typeName = typeToString(t);
}
m.access = MethodInfo::Public;
m.methodType = MethodInfo::Method;
@@ -528,13 +543,8 @@ public:
MethodParameter param;
param.name = args->element->bindingIdentifier.toString();
if (AST::TypeAnnotation *tAnn = args->element->typeAnnotation) {
- if (AST::Type *t = tAnn->type) {
- param.typeName = toString(t->typeId);
- if (t->typeArguments) {
- Q_ASSERT_X(false, className,
- "todo: type argument should be added to the typeName");
- }
- }
+ if (AST::Type *t = tAnn->type)
+ param.typeName = typeToString(t);
}
if (args->element->initializer) {
SourceLocation loc = combineLocations(args->element->initializer);