From 87f5cc385b670a63c2f2ba0ef90cba95ab215200 Mon Sep 17 00:00:00 2001 From: Fawzi Mohamed Date: Thu, 6 Feb 2020 14:15:09 +0100 Subject: Add annotations to AST Annotations are added to UiObjectMember. This makes it easy to find the annotations of any UiObjectMember through the annotations attribute. The clean AST approach would add an UiAnnotatedObjectMember that contains both the annotation list and an UiObjectMember, but that makes finding the annotation more difficult. The annotations are not visited by default, if one wants to dump them before the current object the simplest way is to use the preVisit and use .uiObjectMemberCast(). Depending on how we use annotation we could change the current approach. Task-number: QTBUG-81714 Change-Id: I543a2cfe5157bcc86de6de9faebde9aea22974eb Reviewed-by: Ulf Hermann --- src/qml/parser/qqmljsast.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/qml/parser/qqmljsast.cpp') diff --git a/src/qml/parser/qqmljsast.cpp b/src/qml/parser/qqmljsast.cpp index 416916c547..19b03d3cd1 100644 --- a/src/qml/parser/qqmljsast.cpp +++ b/src/qml/parser/qqmljsast.cpp @@ -1562,6 +1562,15 @@ void UiRequired::accept0(Visitor *visitor) visitor->endVisit(this); } +void UiAnnotationList::accept0(Visitor *visitor) +{ + if (visitor->visit(this)) { + accept(annotation, visitor); + } + + visitor->endVisit(this); +} + } } // namespace QQmlJS::AST QT_END_NAMESPACE -- cgit v1.2.3