diff options
Diffstat (limited to 'tools/qmlformat/dumpastvisitor.h')
-rw-r--r-- | tools/qmlformat/dumpastvisitor.h | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/tools/qmlformat/dumpastvisitor.h b/tools/qmlformat/dumpastvisitor.h index 2001f4366e..faf067d400 100644 --- a/tools/qmlformat/dumpastvisitor.h +++ b/tools/qmlformat/dumpastvisitor.h @@ -32,9 +32,13 @@ #include <QtQml/private/qqmljsastvisitor_p.h> #include <QtQml/private/qqmljsast_p.h> +#include <QHash> +#include <QStack> + #include "commentastvisitor.h" using namespace QQmlJS::AST; +using namespace QQmlJS; class DumpAstVisitor : protected Visitor { @@ -43,6 +47,8 @@ public: QString toString() const { return m_result; } + bool preVisit(Node *) override; + bool visit(UiScriptBinding *node) override; bool visit(UiArrayBinding *node) override; @@ -62,11 +68,28 @@ public: bool visit(UiEnumMemberList *node) override; bool visit(UiPublicMember *node) override; bool visit(UiImport *node) override; + bool visit(UiPragma *node) override; + + bool visit(UiAnnotation *node) override; + void endVisit(UiAnnotation *node) override; void throwRecursionDepthError() override {} bool error() const { return m_error; } private: + struct ScopeProperties { + bool m_firstOfAll = true; + bool m_firstSignal = true; + bool m_firstProperty = true; + bool m_firstBinding = true; + bool m_firstObject = true; + bool m_inArrayBinding = false; + bool m_pendingBinding = false; + + UiObjectMember* m_lastInArrayBinding = nullptr; + QHash<QString, UiObjectMember*> m_bindings; + }; + QString generateIndent() const; QString formatLine(QString line, bool newline = true) const; @@ -106,19 +129,19 @@ private: QString parseFormalParameterList(FormalParameterList *list); + QString parseType(Type *type); + + QString parseFunctionExpression(FunctionExpression *expression, bool omitFunction = false); + + ScopeProperties& scope() { return m_scope_properties.top(); } + int m_indentLevel = 0; bool m_error = false; bool m_blockNeededBraces = false; - bool m_inArrayBinding = false; - bool m_firstOfAll = false; - bool m_firstSignal = false; - bool m_firstProperty = false; - bool m_firstBinding = false; - bool m_firstObject = true; + QStack<ScopeProperties> m_scope_properties; - UiObjectMember* m_lastInArrayBinding = nullptr; QString m_result = ""; CommentAstVisitor *m_comment; }; |