Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qmlmarkupvisitor.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QMLMARKUPVISITOR_H
5#define QMLMARKUPVISITOR_H
6
7#include "node.h"
8#include "tree.h"
9
10#include <QtCore/qstring.h>
11
12#include <private/qqmljsastvisitor_p.h>
13#include <private/qqmljsengine_p.h>
14
16
18{
19public:
21
22 QmlMarkupVisitor(const QString &code, const QList<QQmlJS::SourceLocation> &pragmas,
23 QQmlJS::Engine *engine);
25
27 [[nodiscard]] bool hasError() const;
28
29 bool visit(QQmlJS::AST::UiImport *) override;
30 void endVisit(QQmlJS::AST::UiImport *) override;
31
32 bool visit(QQmlJS::AST::UiPublicMember *) override;
33 bool visit(QQmlJS::AST::UiObjectDefinition *) override;
34
35 bool visit(QQmlJS::AST::UiObjectInitializer *) override;
36 void endVisit(QQmlJS::AST::UiObjectInitializer *) override;
37
38 bool visit(QQmlJS::AST::UiObjectBinding *) override;
39 bool visit(QQmlJS::AST::UiScriptBinding *) override;
40 bool visit(QQmlJS::AST::UiArrayBinding *) override;
41 bool visit(QQmlJS::AST::UiArrayMemberList *) override;
42 bool visit(QQmlJS::AST::UiQualifiedId *) override;
43
44 bool visit(QQmlJS::AST::ThisExpression *) override;
45 bool visit(QQmlJS::AST::IdentifierExpression *) override;
46 bool visit(QQmlJS::AST::NullExpression *) override;
47 bool visit(QQmlJS::AST::TrueLiteral *) override;
48 bool visit(QQmlJS::AST::FalseLiteral *) override;
49 bool visit(QQmlJS::AST::NumericLiteral *) override;
50 bool visit(QQmlJS::AST::StringLiteral *) override;
51 bool visit(QQmlJS::AST::RegExpLiteral *) override;
52 bool visit(QQmlJS::AST::ArrayPattern *) override;
53
54 bool visit(QQmlJS::AST::ObjectPattern *) override;
55 void endVisit(QQmlJS::AST::ObjectPattern *) override;
56
57 bool visit(QQmlJS::AST::PatternElementList *) override;
58 bool visit(QQmlJS::AST::Elision *) override;
59 bool visit(QQmlJS::AST::PatternProperty *) override;
60 bool visit(QQmlJS::AST::ArrayMemberExpression *) override;
61 bool visit(QQmlJS::AST::FieldMemberExpression *) override;
62 bool visit(QQmlJS::AST::NewMemberExpression *) override;
63 bool visit(QQmlJS::AST::NewExpression *) override;
64 bool visit(QQmlJS::AST::ArgumentList *) override;
65 bool visit(QQmlJS::AST::PostIncrementExpression *) override;
66 bool visit(QQmlJS::AST::PostDecrementExpression *) override;
67 bool visit(QQmlJS::AST::DeleteExpression *) override;
68 bool visit(QQmlJS::AST::VoidExpression *) override;
69 bool visit(QQmlJS::AST::TypeOfExpression *) override;
70 bool visit(QQmlJS::AST::PreIncrementExpression *) override;
71 bool visit(QQmlJS::AST::PreDecrementExpression *) override;
72 bool visit(QQmlJS::AST::UnaryPlusExpression *) override;
73 bool visit(QQmlJS::AST::UnaryMinusExpression *) override;
74 bool visit(QQmlJS::AST::TildeExpression *) override;
75 bool visit(QQmlJS::AST::NotExpression *) override;
76 bool visit(QQmlJS::AST::BinaryExpression *) override;
77 bool visit(QQmlJS::AST::ConditionalExpression *) override;
78 bool visit(QQmlJS::AST::Expression *) override;
79
80 bool visit(QQmlJS::AST::Block *) override;
81 void endVisit(QQmlJS::AST::Block *) override;
82
83 bool visit(QQmlJS::AST::VariableStatement *) override;
84 bool visit(QQmlJS::AST::VariableDeclarationList *) override;
85 bool visit(QQmlJS::AST::EmptyStatement *) override;
86 bool visit(QQmlJS::AST::ExpressionStatement *) override;
87 bool visit(QQmlJS::AST::IfStatement *) override;
88 bool visit(QQmlJS::AST::DoWhileStatement *) override;
89 bool visit(QQmlJS::AST::WhileStatement *) override;
90 bool visit(QQmlJS::AST::ForStatement *) override;
91 bool visit(QQmlJS::AST::ForEachStatement *) override;
92 bool visit(QQmlJS::AST::ContinueStatement *) override;
93 bool visit(QQmlJS::AST::BreakStatement *) override;
94 bool visit(QQmlJS::AST::ReturnStatement *) override;
95 bool visit(QQmlJS::AST::WithStatement *) override;
96
97 bool visit(QQmlJS::AST::CaseBlock *) override;
98 void endVisit(QQmlJS::AST::CaseBlock *) override;
99
100 bool visit(QQmlJS::AST::SwitchStatement *) override;
101 bool visit(QQmlJS::AST::CaseClause *) override;
102 bool visit(QQmlJS::AST::DefaultClause *) override;
103 bool visit(QQmlJS::AST::LabelledStatement *) override;
104 bool visit(QQmlJS::AST::ThrowStatement *) override;
105 bool visit(QQmlJS::AST::TryStatement *) override;
106 bool visit(QQmlJS::AST::Catch *) override;
107 bool visit(QQmlJS::AST::Finally *) override;
108 bool visit(QQmlJS::AST::FunctionDeclaration *) override;
109 bool visit(QQmlJS::AST::FunctionExpression *) override;
110 bool visit(QQmlJS::AST::FormalParameterList *) override;
111 bool visit(QQmlJS::AST::DebuggerStatement *) override;
112
113protected:
114 QString protect(const QString &string);
115
116private:
117 typedef QHash<QString, QString> StringHash;
118 void addExtra(quint32 start, quint32 finish);
119 void addMarkedUpToken(QQmlJS::SourceLocation &location, const QString &text,
120 const StringHash &attributes = StringHash());
121 void addVerbatim(QQmlJS::SourceLocation first,
122 QQmlJS::SourceLocation last = QQmlJS::SourceLocation());
123 QString sourceText(QQmlJS::SourceLocation &location);
125
126 QQmlJS::Engine *m_engine { nullptr };
127 QList<ExtraType> m_extraTypes {};
128 QList<QQmlJS::SourceLocation> m_extraLocations {};
129 QString m_source {};
130 QString m_output {};
131 quint32 m_cursor {};
132 int m_extraIndex {};
133 bool m_hasRecursionDepthError { false };
134};
136
137QT_END_NAMESPACE
138
139#endif
The Atom class is the fundamental unit for representing documents internally.
Definition atom.h:18
AtomType
\value AnnotatedList \value AutoLink \value BaseName \value BriefLeft \value BriefRight \value C \val...
Definition atom.h:20
@ Qml
Definition atom.h:76
The Location class provides a way to mark a location in a file.
Definition location.h:15
bool isFunction(Genus g=DontCare) const
Returns true if this is a FunctionNode and its Genus is set to g.
Definition node.h:135
LinkType
An unsigned char value that probably should be moved out of the Node base class.
Definition node.h:112
QString markedUpName(const Node *node) override
Constructs and returns the marked up name for the node.
Atom::AtomType atomType() const override
Returns the type of atom used to represent QML code in the documentation.
QString protect(const QString &string)
QmlMarkupVisitor(const QString &code, const QList< QQmlJS::SourceLocation > &pragmas, QQmlJS::Engine *engine)
void throwRecursionDepthError() final
~QmlMarkupVisitor() override=default
void endVisit(QQmlJS::AST::UiImport *) override
bool visit(QQmlJS::AST::UiImport *) override
Combined button and popup list for selecting options.
void replaceWithSpace(QString &str, int idx, int n)
Copy and paste from src/declarative/qml/qdeclarativescriptparser.cpp.
Q_DECLARE_TYPEINFO(QmlMarkupVisitor::ExtraType, Q_PRIMITIVE_TYPE)