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
15#include <optional>
16
18
20{
21public:
23
24 QmlMarkupVisitor(const QString &code, const QList<QQmlJS::SourceLocation> &pragmas,
25 QQmlJS::Engine *engine);
27
29 [[nodiscard]] bool hasError() const;
30
31 bool visit(QQmlJS::AST::UiImport *) override;
32 void endVisit(QQmlJS::AST::UiImport *) override;
33
34 bool visit(QQmlJS::AST::UiPublicMember *) override;
35 bool visit(QQmlJS::AST::UiObjectDefinition *) override;
36
37 bool visit(QQmlJS::AST::UiObjectInitializer *) override;
38 void endVisit(QQmlJS::AST::UiObjectInitializer *) override;
39
40 bool visit(QQmlJS::AST::UiObjectBinding *) override;
41 bool visit(QQmlJS::AST::UiScriptBinding *) override;
42 bool visit(QQmlJS::AST::UiArrayBinding *) override;
43 bool visit(QQmlJS::AST::UiArrayMemberList *) override;
44 bool visit(QQmlJS::AST::UiQualifiedId *) override;
45
46 bool visit(QQmlJS::AST::ThisExpression *) override;
47 bool visit(QQmlJS::AST::IdentifierExpression *) override;
48 bool visit(QQmlJS::AST::NullExpression *) override;
49 bool visit(QQmlJS::AST::TrueLiteral *) override;
50 bool visit(QQmlJS::AST::FalseLiteral *) override;
51 bool visit(QQmlJS::AST::NumericLiteral *) override;
52 bool visit(QQmlJS::AST::StringLiteral *) override;
53 bool visit(QQmlJS::AST::RegExpLiteral *) override;
54 bool visit(QQmlJS::AST::ArrayPattern *) override;
55
56 bool visit(QQmlJS::AST::ObjectPattern *) override;
57 void endVisit(QQmlJS::AST::ObjectPattern *) override;
58
59 bool visit(QQmlJS::AST::PatternElementList *) override;
60 bool visit(QQmlJS::AST::Elision *) override;
61 bool visit(QQmlJS::AST::PatternProperty *) override;
62 bool visit(QQmlJS::AST::ArrayMemberExpression *) override;
63 bool visit(QQmlJS::AST::FieldMemberExpression *) override;
64 bool visit(QQmlJS::AST::NewMemberExpression *) override;
65 bool visit(QQmlJS::AST::NewExpression *) override;
66 bool visit(QQmlJS::AST::ArgumentList *) override;
67 bool visit(QQmlJS::AST::PostIncrementExpression *) override;
68 bool visit(QQmlJS::AST::PostDecrementExpression *) override;
69 bool visit(QQmlJS::AST::DeleteExpression *) override;
70 bool visit(QQmlJS::AST::VoidExpression *) override;
71 bool visit(QQmlJS::AST::TypeOfExpression *) override;
72 bool visit(QQmlJS::AST::PreIncrementExpression *) override;
73 bool visit(QQmlJS::AST::PreDecrementExpression *) override;
74 bool visit(QQmlJS::AST::UnaryPlusExpression *) override;
75 bool visit(QQmlJS::AST::UnaryMinusExpression *) override;
76 bool visit(QQmlJS::AST::TildeExpression *) override;
77 bool visit(QQmlJS::AST::NotExpression *) override;
78 bool visit(QQmlJS::AST::BinaryExpression *) override;
79 bool visit(QQmlJS::AST::ConditionalExpression *) override;
80 bool visit(QQmlJS::AST::CommaExpression *) override;
81
82 bool visit(QQmlJS::AST::Block *) override;
83 void endVisit(QQmlJS::AST::Block *) override;
84
85 bool visit(QQmlJS::AST::VariableStatement *) override;
86 bool visit(QQmlJS::AST::VariableDeclarationList *) override;
87 bool visit(QQmlJS::AST::EmptyStatement *) override;
88 bool visit(QQmlJS::AST::ExpressionStatement *) override;
89 bool visit(QQmlJS::AST::IfStatement *) override;
90 bool visit(QQmlJS::AST::DoWhileStatement *) override;
91 bool visit(QQmlJS::AST::WhileStatement *) override;
92 bool visit(QQmlJS::AST::ForStatement *) override;
93 bool visit(QQmlJS::AST::ForEachStatement *) override;
94 bool visit(QQmlJS::AST::ContinueStatement *) override;
95 bool visit(QQmlJS::AST::BreakStatement *) override;
96 bool visit(QQmlJS::AST::ReturnStatement *) override;
97 bool visit(QQmlJS::AST::WithStatement *) override;
98
99 bool visit(QQmlJS::AST::CaseBlock *) override;
100 void endVisit(QQmlJS::AST::CaseBlock *) override;
101
102 bool visit(QQmlJS::AST::SwitchStatement *) override;
103 bool visit(QQmlJS::AST::CaseClause *) override;
104 bool visit(QQmlJS::AST::DefaultClause *) override;
105 bool visit(QQmlJS::AST::LabelledStatement *) override;
106 bool visit(QQmlJS::AST::ThrowStatement *) override;
107 bool visit(QQmlJS::AST::TryStatement *) override;
108 bool visit(QQmlJS::AST::Catch *) override;
109 bool visit(QQmlJS::AST::Finally *) override;
110 bool visit(QQmlJS::AST::FunctionDeclaration *) override;
111 bool visit(QQmlJS::AST::FunctionExpression *) override;
112 bool visit(QQmlJS::AST::FormalParameterList *) override;
113 bool visit(QQmlJS::AST::DebuggerStatement *) override;
114
115private:
116 typedef QHash<QString, QString> StringHash;
117 void addExtra(quint32 start, quint32 finish);
118 void addMarkedUpToken(const QQmlJS::SourceLocation &location, const QString &text,
119 const StringHash &attributes = StringHash());
120 void addVerbatim(QQmlJS::SourceLocation first,
121 QQmlJS::SourceLocation last = QQmlJS::SourceLocation());
122 QString sourceText(const QQmlJS::SourceLocation &location);
124 std::optional<QQmlJS::SourceLocation>
125 getFullyQualifiedLocation(QQmlJS::AST::UiQualifiedId *id);
126 QQmlJS::SourceLocation getLocationForMarkup(QQmlJS::AST::UiQualifiedId *id);
127 QQmlJS::Engine *m_engine { nullptr };
128 QList<ExtraType> m_extraTypes {};
129 QList<QQmlJS::SourceLocation> m_extraLocations {};
130 QString m_source {};
131 QString m_output {};
132 quint32 m_cursor {};
133 int m_extraIndex {};
134 bool m_hasRecursionDepthError { false };
135};
137
138QT_END_NAMESPACE
139
140#endif
The Atom class is the fundamental unit for representing documents internally.
Definition atom.h:19
AtomType
\value AnnotatedList \value AutoLink \value BaseName \value BriefLeft \value BriefRight \value C \val...
Definition atom.h:21
@ Qml
Definition atom.h:79
The Location class provides a way to mark a location in a file.
Definition location.h:20
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.
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)
The Node class is the base class for all the nodes in QDoc's parse tree.
bool isFunction(Genus g=Genus::DontCare) const
Returns true if this is a FunctionNode and its Genus is set to g.
Definition node.h:100