diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2020-06-18 14:36:37 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2020-07-03 10:44:45 +0200 |
commit | 8cf45b19d5c5c65053a1c41f6293df37947e685d (patch) | |
tree | bba7cc0a6088c90abc4eba1f47af5c807f755aba /tools/qmlformat/dumpastvisitor.cpp | |
parent | f9925dba66a839614fdf1f3e735265f03258f526 (diff) |
qmlformat: Fix nested functions
Fixes: QTBUG-85035
Change-Id: I5e1cb003b7b84547e3408a086eebf3be740e6860
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit eb90e8ee3313bee547e6721a2649bf9ba84e3e5c)
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmlformat/dumpastvisitor.cpp')
-rw-r--r-- | tools/qmlformat/dumpastvisitor.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/qmlformat/dumpastvisitor.cpp b/tools/qmlformat/dumpastvisitor.cpp index 06a6f6335f..3b23ddf128 100644 --- a/tools/qmlformat/dumpastvisitor.cpp +++ b/tools/qmlformat/dumpastvisitor.cpp @@ -1232,8 +1232,14 @@ void DumpAstVisitor::endVisit(UiArrayBinding *) { } bool DumpAstVisitor::visit(FunctionDeclaration *node) { + if (scope().m_firstFunction) { + if (scope().m_firstOfAll) + scope().m_firstOfAll = false; + else + addNewLine(); - addNewLine(); + scope().m_firstFunction = false; + } addLine(getComment(node, Comment::Location::Front)); @@ -1251,13 +1257,16 @@ bool DumpAstVisitor::visit(FunctionDeclaration *node) { addLine(head); m_indentLevel++; + + return true; +} + +void DumpAstVisitor::endVisit(FunctionDeclaration *node) +{ m_result += parseStatementList(node->body); m_indentLevel--; addLine("}"); - addNewLine(); - - return true; } bool DumpAstVisitor::visit(UiObjectBinding *node) { |