aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlformat
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2020-06-24 13:05:55 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2020-06-25 09:02:08 +0200
commit88b3d1fd26b6b566ef00ae728051bff29455eea5 (patch)
tree3c84fb5d9820f955051c6b3fcbce9065ce585e48 /tools/qmlformat
parentdd71c43b9718be3523ed6b307a3402f88de070e1 (diff)
qmlformat: Fix inline components
Fixes: QTBUG-85189 Change-Id: I2b30595b44d14b89406b126d3d148f51f8bfbca4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools/qmlformat')
-rw-r--r--tools/qmlformat/dumpastvisitor.cpp41
-rw-r--r--tools/qmlformat/dumpastvisitor.h3
2 files changed, 44 insertions, 0 deletions
diff --git a/tools/qmlformat/dumpastvisitor.cpp b/tools/qmlformat/dumpastvisitor.cpp
index c8fb0b511f..6868a3e21b 100644
--- a/tools/qmlformat/dumpastvisitor.cpp
+++ b/tools/qmlformat/dumpastvisitor.cpp
@@ -1030,6 +1030,47 @@ QHash<QString, UiObjectMember*> findBindings(UiObjectMemberList *list) {
return bindings;
}
+bool DumpAstVisitor::visit(UiInlineComponent *node)
+{
+ if (scope().m_firstObject) {
+ if (scope().m_firstOfAll)
+ scope().m_firstOfAll = false;
+ else
+ addNewLine();
+
+ scope().m_firstObject = false;
+ }
+
+ addLine(getComment(node, Comment::Location::Front));
+ addLine(getComment(node, Comment::Location::Front_Inline));
+ addLine("component " + node->name + ": "
+ + parseUiQualifiedId(node->component->qualifiedTypeNameId) + " {");
+
+ m_indentLevel++;
+
+ ScopeProperties props;
+ props.m_bindings = findBindings(node->component->initializer->members);
+ m_scope_properties.push(props);
+
+ m_result += getOrphanedComments(node);
+
+ return true;
+}
+
+void DumpAstVisitor::endVisit(UiInlineComponent *node)
+{
+ m_indentLevel--;
+
+ m_scope_properties.pop();
+
+ bool need_comma = scope().m_inArrayBinding && scope().m_lastInArrayBinding != node;
+
+ addLine(need_comma ? "}," : "}");
+ addLine(getComment(node, Comment::Location::Back));
+ if (!scope().m_inArrayBinding)
+ addNewLine();
+}
+
bool DumpAstVisitor::visit(UiObjectDefinition *node) {
if (scope().m_firstObject) {
if (scope().m_firstOfAll)
diff --git a/tools/qmlformat/dumpastvisitor.h b/tools/qmlformat/dumpastvisitor.h
index 01b7e418e2..9b908dd101 100644
--- a/tools/qmlformat/dumpastvisitor.h
+++ b/tools/qmlformat/dumpastvisitor.h
@@ -59,6 +59,9 @@ public:
bool visit(FunctionDeclaration *node) override;
+ bool visit(UiInlineComponent *node) override;
+ void endVisit(UiInlineComponent *node) override;
+
bool visit(UiObjectDefinition *node) override;
void endVisit(UiObjectDefinition *node) override;