8#include <QtCore/qdebug.h>
12QMultiMap<
const Node *, Node *> QmlTypeNode::s_inheritedBy;
15
16
17
18
19
28
29
30
33 s_inheritedBy.clear();
37
38
39
44 if (!s_inheritedBy.contains(base, sub))
45 s_inheritedBy.insert(base, sub);
49
50
54 if (s_inheritedBy.count(base) > 0) {
55 subs = s_inheritedBy.values(base);
60
61
62
63
68 result = m_qmlBaseNode->logicalModuleName() +
"::" + m_qmlBaseNode->name();
74
75
76
77
80 return (m_logicalModule ? m_logicalModule->logicalModuleName() : QString());
84
85
86
87
90 return (m_logicalModule ? m_logicalModule->logicalModuleVersion() : QString());
94
95
96
97
100 return (m_logicalModule ? m_logicalModule->logicalModuleIdentifier() : QString());
104
105
109 while (qtn !=
nullptr) {
118
119
120
121
122
125 if (m_qmlBaseNode || m_qmlBaseName.isEmpty())
128 auto *base =
static_cast<QmlTypeNode *>(previousSearches.value(m_qmlBaseName));
129 if (!previousSearches.contains(m_qmlBaseName)) {
130 for (
const auto &imp : std::as_const(m_importList)) {
131 base = QDocDatabase::qdocDB()->findQmlType(imp, m_qmlBaseName);
136 if (m_qmlBaseName.contains(
':'))
137 base = QDocDatabase::qdocDB()->findQmlType(m_qmlBaseName);
139 base = QDocDatabase::qdocDB()->findQmlType(QString(), m_qmlBaseName);
141 previousSearches.insert(m_qmlBaseName, base);
146 m_qmlBaseNode = base;
149 if (base->isIndexNode())
150 base->resolveInheritance(previousSearches);
152 location().warning(QStringLiteral(
"Type is its own base type: '%1'").arg(name()));
156 location().report(QStringLiteral(
"Unknown base '%1' for QML type '%2'").arg(qmlBaseName(), name()));
160
161
165
172 while (qtn && hare) {
177
178
179 for (
int i = 0; i < 2; i++)
186 if (previous && qtn && hare && qtn == hare) {
187 location().warning(QStringLiteral(
"Cyclic type inheritance: '%1'").arg(previous->name()));
188 previous->m_qmlBaseNode =
nullptr;
static void terminate()
Clear the static maps so that subsequent runs don't try to use contents from a previous run.
QmlTypeNode(Aggregate *parent, const QString &name, NodeType type)
Constructs a Qml type.
QString qmlFullBaseName() const override
If this QML type node has a base type node, return the fully qualified name of that QML type,...
QString logicalModuleIdentifier() const override
If the QML type's QML module pointer is set, return the QML module identifier from the QML module nod...
bool inherits(Aggregate *type)
Returns true if this QML type inherits type.
QString logicalModuleVersion() const override
If the QML type's QML module pointer is set, return the QML module version from the QML module node.
void resolveInheritance(NodeMap &previousSearches)
Recursively resolves the base node for this QML type when only the name of the base type is known.
static void addInheritedBy(const Node *base, Node *sub)
Record the fact that QML class base is inherited by QML class sub.
void checkInheritance()
Checks and warns about problems with the inheritance of this QML type.
QString logicalModuleName() const override
If the QML type's QML module pointer is set, return the QML module name from the QML module node.
static void subclasses(const Node *base, NodeList &subs)
Loads the list subs with the nodes of all the subclasses of base.
QmlTypeNode * qmlBaseNode() const override
If this Aggregate is a QmlTypeNode, this function returns a pointer to the QmlTypeNode that is its ba...
QMap< QString, Node * > NodeMap
The Node class is the base class for all the nodes in QDoc's parse tree.
virtual bool isInternal() const
Returns true if the node's status is Internal, or if its parent is a class with Internal status.
const Location & location() const
If this node's definition location is empty, this function returns this node's declaration location.