1 /****************************************************************************
2 **
3 ** Copyright (C) 2019 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #ifndef NODE_H
30 #define NODE_H
31 
32 #include "doc.h"
33 #include "parameters.h"
34 
35 #include <QtCore/qdir.h>
36 #include <QtCore/qmap.h>
37 #include <QtCore/qpair.h>
38 #include <QtCore/qstringlist.h>
39 #include <QtCore/qvector.h>
40 
41 QT_BEGIN_NAMESPACE
42 
43 class Node;
44 class Tree;
45 class EnumNode;
46 class PageNode;
47 class ClassNode;
48 class Aggregate;
49 class ExampleNode;
50 class TypedefNode;
51 class QmlTypeNode;
52 class QDocDatabase;
53 class FunctionNode;
54 class PropertyNode;
55 class CollectionNode;
56 class QmlPropertyNode;
57 class SharedCommentNode;
58 
59 typedef QMap<QString, FunctionNode *> FunctionMap;
60 typedef QList<Node *> NodeList;
61 typedef QVector<ClassNode *> ClassList;
62 typedef QVector<Node *> NodeVector;
63 typedef QMap<QString, Node *> NodeMap;
64 typedef QMap<QString, NodeMap> NodeMapMap;
65 typedef QMultiMap<QString, Node *> NodeMultiMap;
66 typedef QMap<QString, NodeMultiMap> NodeMultiMapMap;
67 typedef QMap<QString, CollectionNode *> CNMap;
68 typedef QMultiMap<QString, CollectionNode *> CNMultiMap;
69 typedef QVector<CollectionNode *> CollectionList;
70 
71 class Node
72 {
73     Q_DECLARE_TR_FUNCTIONS(QDoc::Node)
74 
75 public:
76     enum NodeType : unsigned char {
77         NoType,
78         Namespace,
79         Class,
80         Struct,
81         Union,
82         HeaderFile,
83         Page,
84         Enum,
85         Example,
86         ExternalPage,
87         Function,
88         Typedef,
89         TypeAlias,
90         Property,
91         Variable,
92         Group,
93         Module,
94         QmlType,
95         QmlModule,
96         QmlProperty,
97         QmlBasicType,
98         JsType,
99         JsModule,
100         JsProperty,
101         JsBasicType,
102         SharedComment,
103         Collection,
104         Proxy,
105         LastType
106     };
107 
108     enum Genus : unsigned char { DontCare, CPP, JS, QML, DOC };
109 
110     enum Access : unsigned char { Public, Protected, Private };
111 
112     enum Status : unsigned char {
113         Obsolete,
114         Deprecated,
115         Preliminary,
116         Active,
117         Internal,
118         DontDocument
119     }; // don't reorder this enum
120 
121     enum ThreadSafeness : unsigned char {
122         UnspecifiedSafeness,
123         NonReentrant,
124         Reentrant,
125         ThreadSafe
126     };
127 
128     enum LinkType : unsigned char { StartLink, NextLink, PreviousLink, ContentsLink };
129 
130     enum PageType : unsigned char {
131         NoPageType,
132         AttributionPage,
133         ApiPage,
134         ArticlePage,
135         ExamplePage,
136         HowToPage,
137         OverviewPage,
138         TutorialPage,
139         FAQPage,
140         OnBeyondZebra
141     };
142 
143     enum FlagValue { FlagValueDefault = -1, FlagValueFalse = 0, FlagValueTrue = 1 };
144 
~Node()145     virtual ~Node() {}
clone(Aggregate *)146     virtual Node *clone(Aggregate *) { return nullptr; } // currently only FunctionNode
147     virtual Tree *tree() const;
148     Aggregate *root() const;
149 
nodeType()150     NodeType nodeType() const { return nodeType_; }
151     QString nodeTypeString() const;
152     bool changeType(NodeType from, NodeType to);
153 
genus()154     Genus genus() const { return genus_; }
setGenus(Genus t)155     void setGenus(Genus t) { genus_ = t; }
156     static Genus getGenus(NodeType t);
157 
pageType()158     PageType pageType() const { return pageType_; }
159     QString pageTypeString() const;
setPageType(PageType t)160     void setPageType(PageType t) { pageType_ = t; }
161     void setPageType(const QString &t);
162     static PageType getPageType(NodeType t);
163 
isActive()164     bool isActive() const { return status_ == Active; }
isAnyType()165     bool isAnyType() const { return true; }
isClass()166     bool isClass() const { return nodeType_ == Class; }
isCppNode()167     bool isCppNode() const { return genus() == CPP; }
isDeprecated()168     bool isDeprecated() const { return (status_ == Deprecated); }
isDontDocument()169     bool isDontDocument() const { return (status_ == DontDocument); }
isEnumType()170     bool isEnumType() const { return nodeType_ == Enum; }
isExample()171     bool isExample() const { return nodeType_ == Example; }
isExternalPage()172     bool isExternalPage() const { return nodeType_ == ExternalPage; }
173     bool isFunction(Genus g = DontCare) const
174     {
175         return (nodeType_ != Function ? false : (genus() == g ? true : g == DontCare));
176     }
isGroup()177     bool isGroup() const { return nodeType_ == Group; }
isHeader()178     bool isHeader() const { return nodeType_ == HeaderFile; }
isIndexNode()179     bool isIndexNode() const { return indexNodeFlag_; }
isJsBasicType()180     bool isJsBasicType() const { return nodeType_ == JsBasicType; }
isJsModule()181     bool isJsModule() const { return nodeType_ == JsModule; }
isJsNode()182     bool isJsNode() const { return genus() == JS; }
isJsProperty()183     bool isJsProperty() const { return nodeType_ == JsProperty; }
isJsType()184     bool isJsType() const { return nodeType_ == JsType; }
isModule()185     bool isModule() const { return nodeType_ == Module; }
isNamespace()186     bool isNamespace() const { return nodeType_ == Namespace; }
isPage()187     bool isPage() const { return nodeType_ == Page; }
isPreliminary()188     bool isPreliminary() const { return (status_ == Preliminary); }
isPrivate()189     bool isPrivate() const { return access_ == Private; }
isProperty()190     bool isProperty() const { return nodeType_ == Property; }
isProxyNode()191     bool isProxyNode() const { return nodeType_ == Proxy; }
isPublic()192     bool isPublic() const { return access_ == Public; }
isProtected()193     bool isProtected() const { return access_ == Protected; }
isQmlBasicType()194     bool isQmlBasicType() const { return nodeType_ == QmlBasicType; }
isQmlModule()195     bool isQmlModule() const { return nodeType_ == QmlModule; }
isQmlNode()196     bool isQmlNode() const { return genus() == QML; }
isQmlProperty()197     bool isQmlProperty() const { return nodeType_ == QmlProperty; }
isQmlType()198     bool isQmlType() const { return nodeType_ == QmlType; }
isRelatedNonmember()199     bool isRelatedNonmember() const { return relatedNonmember_; }
isStruct()200     bool isStruct() const { return nodeType_ == Struct; }
isSharedCommentNode()201     bool isSharedCommentNode() const { return nodeType_ == SharedComment; }
isTypeAlias()202     bool isTypeAlias() const { return nodeType_ == TypeAlias; }
isTypedef()203     bool isTypedef() const { return nodeType_ == Typedef || nodeType_ == TypeAlias; }
isUnion()204     bool isUnion() const { return nodeType_ == Union; }
isVariable()205     bool isVariable() const { return nodeType_ == Variable; }
isGenericCollection()206     bool isGenericCollection() const { return (nodeType_ == Node::Collection); }
207 
isObsolete()208     virtual bool isObsolete() const { return (status_ == Obsolete); }
isAbstract()209     virtual bool isAbstract() const { return false; }
isAggregate()210     virtual bool isAggregate() const { return false; } // means "can have children"
isFirstClassAggregate()211     virtual bool isFirstClassAggregate() const
212     {
213         return false;
214     } // Aggregate but not proxy or prop group"
isAlias()215     virtual bool isAlias() const { return false; }
isAttached()216     virtual bool isAttached() const { return false; }
isClassNode()217     virtual bool isClassNode() const { return false; }
isCollectionNode()218     virtual bool isCollectionNode() const { return false; }
isDefault()219     virtual bool isDefault() const { return false; }
220     virtual bool isInternal() const;
isMacro()221     virtual bool isMacro() const { return false; }
isPageNode()222     virtual bool isPageNode() const { return false; } // means "generates a doc page"
isQtQuickNode()223     virtual bool isQtQuickNode() const { return false; }
isReadOnly()224     virtual bool isReadOnly() const { return false; }
isRelatableType()225     virtual bool isRelatableType() const { return false; }
isMarkedReimp()226     virtual bool isMarkedReimp() const { return false; }
isPropertyGroup()227     virtual bool isPropertyGroup() const { return false; }
isStatic()228     virtual bool isStatic() const { return false; }
isTextPageNode()229     virtual bool isTextPageNode() const { return false; } // means PageNode but not Aggregate
230     virtual bool isWrapper() const;
231 
232     QString plainName() const;
233     QString plainFullName(const Node *relative = nullptr) const;
234     QString plainSignature() const;
235     QString fullName(const Node *relative = nullptr) const;
236     virtual QString signature(bool, bool, bool = false) const { return plainName(); }
237 
fileNameBase()238     const QString &fileNameBase() const { return fileNameBase_; }
hasFileNameBase()239     bool hasFileNameBase() const { return !fileNameBase_.isEmpty(); }
setFileNameBase(const QString & t)240     void setFileNameBase(const QString &t) { fileNameBase_ = t; }
241 
setAccess(Access t)242     void setAccess(Access t) { access_ = t; }
243     void setLocation(const Location &t);
244     void setDoc(const Doc &doc, bool replace = false);
setStatus(Status t)245     void setStatus(Status t)
246     {
247         if (status_ == Obsolete && t == Deprecated)
248             return;
249         status_ = t;
250     }
setThreadSafeness(ThreadSafeness t)251     void setThreadSafeness(ThreadSafeness t) { safeness_ = t; }
252     void setSince(const QString &since);
setPhysicalModuleName(const QString & name)253     void setPhysicalModuleName(const QString &name) { physicalModuleName_ = name; }
setUrl(const QString & url)254     void setUrl(const QString &url) { url_ = url; }
setTemplateDecl(const QString & t)255     void setTemplateDecl(const QString &t) { templateDecl_ = t; }
setReconstitutedBrief(const QString & t)256     void setReconstitutedBrief(const QString &t) { reconstitutedBrief_ = t; }
setParent(Aggregate * n)257     void setParent(Aggregate *n) { parent_ = n; }
258     void setIndexNodeFlag(bool isIndexNode = true) { indexNodeFlag_ = isIndexNode; }
setHadDoc()259     void setHadDoc() { hadDoc_ = true; }
setRelatedNonmember(bool b)260     virtual void setRelatedNonmember(bool b) { relatedNonmember_ = b; }
setOutputFileName(const QString &)261     virtual void setOutputFileName(const QString &) {}
addMember(Node *)262     virtual void addMember(Node *) {}
hasMembers()263     virtual bool hasMembers() const { return false; }
hasNamespaces()264     virtual bool hasNamespaces() const { return false; }
hasClasses()265     virtual bool hasClasses() const { return false; }
setAbstract(bool)266     virtual void setAbstract(bool) {}
setWrapper()267     virtual void setWrapper() {}
getMemberNamespaces(NodeMap &)268     virtual void getMemberNamespaces(NodeMap &) {}
getMemberClasses(NodeMap &)269     virtual void getMemberClasses(NodeMap &) const {}
setDataType(const QString &)270     virtual void setDataType(const QString &) {}
wasSeen()271     virtual bool wasSeen() const { return false; }
appendGroupName(const QString &)272     virtual void appendGroupName(const QString &) {}
element()273     virtual QString element() const { return QString(); }
setNoAutoList(bool)274     virtual void setNoAutoList(bool) {}
docMustBeGenerated()275     virtual bool docMustBeGenerated() const { return false; }
276 
title()277     virtual QString title() const { return name(); }
subtitle()278     virtual QString subtitle() const { return QString(); }
fullTitle()279     virtual QString fullTitle() const { return name(); }
setTitle(const QString &)280     virtual bool setTitle(const QString &) { return false; }
setSubtitle(const QString &)281     virtual bool setSubtitle(const QString &) { return false; }
282 
markInternal()283     void markInternal()
284     {
285         setAccess(Private);
286         setStatus(Internal);
287     }
markDefault()288     virtual void markDefault() {}
markReadOnly(bool)289     virtual void markReadOnly(bool) {}
290 
291     bool match(const QVector<int> &types) const;
parent()292     Aggregate *parent() const { return parent_; }
name()293     const QString &name() const { return name_; }
294     QString physicalModuleName() const;
url()295     QString url() const { return url_; }
nameForLists()296     virtual QString nameForLists() const { return name_; }
outputFileName()297     virtual QString outputFileName() const { return QString(); }
obsoleteLink()298     virtual QString obsoleteLink() const { return QString(); }
setObsoleteLink(const QString &)299     virtual void setObsoleteLink(const QString &) {}
setQtVariable(const QString &)300     virtual void setQtVariable(const QString &) {}
qtVariable()301     virtual QString qtVariable() const { return QString(); }
hasTag(const QString &)302     virtual bool hasTag(const QString &) const { return false; }
303 
links()304     const QMap<LinkType, QPair<QString, QString>> &links() const { return linkMap_; }
305     void setLink(LinkType linkType, const QString &link, const QString &desc);
306 
access()307     Access access() const { return access_; }
308     QString accessString() const;
declLocation()309     const Location &declLocation() const { return declLocation_; }
defLocation()310     const Location &defLocation() const { return defLocation_; }
location()311     const Location &location() const
312     {
313         return (defLocation_.isEmpty() ? declLocation_ : defLocation_);
314     }
doc()315     const Doc &doc() const { return doc_; }
isInAPI()316     bool isInAPI() const { return !isPrivate() && !isInternal() && hasDoc(); }
hasDoc()317     bool hasDoc() const { return (hadDoc_ || !doc_.isEmpty()); }
hadDoc()318     bool hadDoc() const { return hadDoc_; }
status()319     Status status() const { return status_; }
320     ThreadSafeness threadSafeness() const;
321     ThreadSafeness inheritedThreadSafeness() const;
since()322     QString since() const { return since_; }
templateDecl()323     const QString &templateDecl() const { return templateDecl_; }
reconstitutedBrief()324     const QString &reconstitutedBrief() const { return reconstitutedBrief_; }
325     QString nodeSubtypeString() const;
326 
isSharingComment()327     bool isSharingComment() const { return (sharedCommentNode_ != nullptr); }
328     bool hasSharedDoc() const;
setSharedCommentNode(SharedCommentNode * t)329     void setSharedCommentNode(SharedCommentNode *t) { sharedCommentNode_ = t; }
sharedCommentNode()330     SharedCommentNode *sharedCommentNode() { return sharedCommentNode_; }
331 
332     // QString guid() const;
333     QString extractClassName(const QString &string) const;
qmlTypeName()334     virtual QString qmlTypeName() const { return name_; }
qmlFullBaseName()335     virtual QString qmlFullBaseName() const { return QString(); }
logicalModuleName()336     virtual QString logicalModuleName() const { return QString(); }
logicalModuleVersion()337     virtual QString logicalModuleVersion() const { return QString(); }
logicalModuleIdentifier()338     virtual QString logicalModuleIdentifier() const { return QString(); }
setLogicalModuleInfo(const QString &)339     virtual void setLogicalModuleInfo(const QString &) {}
setLogicalModuleInfo(const QStringList &)340     virtual void setLogicalModuleInfo(const QStringList &) {}
logicalModule()341     virtual CollectionNode *logicalModule() const { return nullptr; }
setQmlModule(CollectionNode *)342     virtual void setQmlModule(CollectionNode *) {}
classNode()343     virtual ClassNode *classNode() { return nullptr; }
setClassNode(ClassNode *)344     virtual void setClassNode(ClassNode *) {}
345     QmlTypeNode *qmlTypeNode();
346     ClassNode *declarativeCppNode();
outputSubdirectory()347     const QString &outputSubdirectory() const { return outSubDir_; }
setOutputSubdirectory(const QString & t)348     virtual void setOutputSubdirectory(const QString &t) { outSubDir_ = t; }
349     QString fullDocumentName() const;
350     QString qualifyCppName();
351     QString qualifyQmlName();
352     QString unqualifyQmlName();
353     QString qualifyWithParentName();
354 
355     static QString cleanId(const QString &str);
356     static FlagValue toFlagValue(bool b);
357     static bool fromFlagValue(FlagValue fv, bool defaultValue);
358     static QString pageTypeString(PageType t);
359     static QString nodeTypeString(NodeType t);
360     static QString nodeSubtypeString(unsigned char t);
361     static void initialize();
goal(const QString & t)362     static NodeType goal(const QString &t) { return goals_.value(t); }
363     static bool nodeNameLessThan(const Node *first, const Node *second);
364 
365 protected:
366     Node(NodeType type, Aggregate *parent, const QString &name);
367 
368 private:
369     NodeType nodeType_;
370     Genus genus_;
371     Access access_;
372     ThreadSafeness safeness_;
373     PageType pageType_;
374     Status status_;
375     bool indexNodeFlag_ : 1;
376     bool relatedNonmember_ : 1;
377     bool hadDoc_ : 1;
378 
379     Aggregate *parent_;
380     SharedCommentNode *sharedCommentNode_;
381     QString name_;
382     Location declLocation_;
383     Location defLocation_;
384     Doc doc_;
385     QMap<LinkType, QPair<QString, QString>> linkMap_;
386     QString fileNameBase_;
387     QString physicalModuleName_;
388     QString url_;
389     QString since_;
390     QString templateDecl_;
391     QString reconstitutedBrief_;
392     // mutable QString uuid_;
393     QString outSubDir_;
394     static QStringMap operators_;
395     static int propertyGroupCount_;
396     static QMap<QString, Node::NodeType> goals_;
397 };
398 
399 class PageNode : public Node
400 {
401 public:
PageNode(Aggregate * parent,const QString & name)402     PageNode(Aggregate *parent, const QString &name) : Node(Page, parent, name), noAutoList_(false)
403     {
404     }
PageNode(NodeType type,Aggregate * parent,const QString & name)405     PageNode(NodeType type, Aggregate *parent, const QString &name)
406         : Node(type, parent, name), noAutoList_(false)
407     {
408     }
PageNode(Aggregate * parent,const QString & name,PageType ptype)409     PageNode(Aggregate *parent, const QString &name, PageType ptype)
410         : Node(Page, parent, name), noAutoList_(false)
411     {
412         setPageType(ptype);
413     }
414 
isPageNode()415     bool isPageNode() const override { return true; }
isTextPageNode()416     bool isTextPageNode() const override { return !isAggregate(); } // PageNode but not Aggregate
417 
title()418     QString title() const override { return title_; }
subtitle()419     QString subtitle() const override { return subtitle_; }
420     QString fullTitle() const override;
421     bool setTitle(const QString &title) override;
setSubtitle(const QString & subtitle)422     bool setSubtitle(const QString &subtitle) override
423     {
424         subtitle_ = subtitle;
425         return true;
426     }
nameForLists()427     QString nameForLists() const override { return title(); }
428 
imageFileName()429     virtual QString imageFileName() const { return QString(); }
setImageFileName(const QString &)430     virtual void setImageFileName(const QString &) {}
431 
noAutoList()432     bool noAutoList() const { return noAutoList_; }
setNoAutoList(bool b)433     void setNoAutoList(bool b) override { noAutoList_ = b; }
groupNames()434     const QStringList &groupNames() const { return groupNames_; }
appendGroupName(const QString & t)435     void appendGroupName(const QString &t) override { groupNames_.append(t); }
436 
setOutputFileName(const QString & f)437     void setOutputFileName(const QString &f) override { outputFileName_ = f; }
outputFileName()438     QString outputFileName() const override { return outputFileName_; }
439 
440 protected:
441     friend class Node;
442 
443 protected:
444     bool noAutoList_;
445     QString title_;
446     QString subtitle_;
447     QString outputFileName_;
448     QStringList groupNames_;
449 };
450 
451 class ExternalPageNode : public PageNode
452 {
453 public:
ExternalPageNode(Aggregate * parent,const QString & url)454     ExternalPageNode(Aggregate *parent, const QString &url)
455         : PageNode(Node::ExternalPage, parent, url)
456     {
457         setPageType(Node::ArticlePage);
458         setUrl(url);
459     }
460 };
461 
462 class Aggregate : public PageNode
463 {
464 public:
465     Node *findChildNode(const QString &name, Node::Genus genus, int findFlags = 0) const;
466     Node *findNonfunctionChild(const QString &name, bool (Node::*)() const);
467     void findChildren(const QString &name, NodeVector &nodes) const;
468     FunctionNode *findFunctionChild(const QString &name, const Parameters &parameters);
469     FunctionNode *findFunctionChild(const FunctionNode *clone);
470 
471     void normalizeOverloads();
472     void markUndocumentedChildrenInternal();
473 
isAggregate()474     bool isAggregate() const override { return true; }
475     const EnumNode *findEnumNodeForValue(const QString &enumValue) const;
476 
count()477     int count() const { return children_.size(); }
childNodes()478     const NodeList &childNodes() const { return children_; }
479     const NodeList &nonfunctionList();
constBegin()480     NodeList::ConstIterator constBegin() const { return children_.constBegin(); }
constEnd()481     NodeList::ConstIterator constEnd() const { return children_.constEnd(); }
482 
483     void addIncludeFile(const QString &includeFile);
484     void setIncludeFiles(const QStringList &includeFiles);
includeFiles()485     const QStringList &includeFiles() const { return includeFiles_; }
486 
487     QStringList primaryKeys();
488     QmlPropertyNode *hasQmlProperty(const QString &) const;
489     QmlPropertyNode *hasQmlProperty(const QString &, bool attached) const;
qmlBaseNode()490     virtual QmlTypeNode *qmlBaseNode() const { return nullptr; }
491     void addChildByTitle(Node *child, const QString &title);
492     void printChildren(const QString &title);
493     void addChild(Node *child);
494     void adoptChild(Node *child);
495     void setOutputSubdirectory(const QString &t) override;
496 
functionMap()497     FunctionMap &functionMap() { return functionMap_; }
498     void findAllFunctions(NodeMapMap &functionIndex);
499     void findAllNamespaces(NodeMultiMap &namespaces);
500     void findAllAttributions(NodeMultiMap &attributions);
501     bool hasObsoleteMembers() const;
502     void findAllObsoleteThings();
503     void findAllClasses();
504     void findAllSince();
505     void resolveQmlInheritance();
506     bool hasOverloads(const FunctionNode *fn) const;
appendToRelatedByProxy(const NodeList & t)507     void appendToRelatedByProxy(const NodeList &t) { relatedByProxy_.append(t); }
relatedByProxy()508     NodeList &relatedByProxy() { return relatedByProxy_; }
509     QString typeWord(bool cap) const;
510 
511 protected:
Aggregate(NodeType type,Aggregate * parent,const QString & name)512     Aggregate(NodeType type, Aggregate *parent, const QString &name)
513         : PageNode(type, parent, name), functionCount_(0)
514     {
515     }
516     ~Aggregate() override;
517     void removeFunctionNode(FunctionNode *fn);
518 
519 private:
520     friend class Node;
521     void addFunction(FunctionNode *fn);
522     void adoptFunction(FunctionNode *fn);
523     static bool isSameSignature(const FunctionNode *f1, const FunctionNode *f2);
524 
525 protected:
526     NodeList children_;
527     NodeList relatedByProxy_;
528 
529 private:
530     QStringList includeFiles_;
531     NodeList enumChildren_;
532     NodeMultiMap nonfunctionMap_;
533     NodeList nonfunctionList_;
534 
535 protected:
536     int functionCount_;
537     FunctionMap functionMap_;
538 };
539 
540 class ProxyNode : public Aggregate
541 {
542 public:
543     ProxyNode(Aggregate *parent, const QString &name);
docMustBeGenerated()544     bool docMustBeGenerated() const override { return true; }
isRelatableType()545     bool isRelatableType() const override { return true; }
546 };
547 
548 class NamespaceNode : public Aggregate
549 {
550 public:
NamespaceNode(Aggregate * parent,const QString & name)551     NamespaceNode(Aggregate *parent, const QString &name)
552         : Aggregate(Namespace, parent, name), seen_(false), tree_(nullptr), docNode_(nullptr)
553     {
554     }
555     ~NamespaceNode() override;
tree()556     Tree *tree() const override { return (parent() ? parent()->tree() : tree_); }
557 
isFirstClassAggregate()558     bool isFirstClassAggregate() const override { return true; }
isRelatableType()559     bool isRelatableType() const override { return true; }
wasSeen()560     bool wasSeen() const override { return seen_; }
markSeen()561     void markSeen() { seen_ = true; }
markNotSeen()562     void markNotSeen() { seen_ = false; }
setTree(Tree * t)563     void setTree(Tree *t) { tree_ = t; }
564     const NodeList &includedChildren() const;
565     void includeChild(Node *child);
whereDocumented()566     QString whereDocumented() const { return whereDocumented_; }
setWhereDocumented(const QString & t)567     void setWhereDocumented(const QString &t) { whereDocumented_ = t; }
568     bool isDocumentedHere() const;
569     bool hasDocumentedChildren() const;
570     void reportDocumentedChildrenInUndocumentedNamespace() const;
571     bool docMustBeGenerated() const override;
setDocNode(NamespaceNode * ns)572     void setDocNode(NamespaceNode *ns) { docNode_ = ns; }
docNode()573     NamespaceNode *docNode() const { return docNode_; }
574 
575 private:
576     bool seen_;
577     Tree *tree_;
578     QString whereDocumented_;
579     NamespaceNode *docNode_;
580     NodeList includedChildren_;
581 };
582 
583 struct RelatedClass
584 {
RelatedClassRelatedClass585     RelatedClass() {}
586     // constructor for resolved base class
RelatedClassRelatedClass587     RelatedClass(Node::Access access, ClassNode *node) : access_(access), node_(node) {}
588     // constructor for unresolved base class
RelatedClassRelatedClass589     RelatedClass(Node::Access access, const QStringList &path, const QString &signature)
590         : access_(access), node_(nullptr), path_(path), signature_(signature)
591     {
592     }
593     QString accessString() const;
isPrivateRelatedClass594     bool isPrivate() const { return (access_ == Node::Private); }
595 
596     Node::Access access_;
597     ClassNode *node_;
598     QStringList path_;
599     QString signature_;
600 };
601 
602 struct UsingClause
603 {
UsingClauseUsingClause604     UsingClause() {}
UsingClauseUsingClause605     UsingClause(const QString &signature) : node_(nullptr), signature_(signature) {}
signatureUsingClause606     const QString &signature() const { return signature_; }
nodeUsingClause607     const Node *node() { return node_; }
setNodeUsingClause608     void setNode(const Node *n) { node_ = n; }
609 
610     const Node *node_;
611     QString signature_;
612 };
613 
614 class ClassNode : public Aggregate
615 {
616 public:
ClassNode(NodeType type,Aggregate * parent,const QString & name)617     ClassNode(NodeType type, Aggregate *parent, const QString &name)
618         : Aggregate(type, parent, name), abstract_(false), wrapper_(false), qmlelement(nullptr)
619     {
620     }
isFirstClassAggregate()621     bool isFirstClassAggregate() const override { return true; }
isClassNode()622     bool isClassNode() const override { return true; }
isRelatableType()623     bool isRelatableType() const override { return true; }
isWrapper()624     bool isWrapper() const override { return wrapper_; }
obsoleteLink()625     QString obsoleteLink() const override { return obsoleteLink_; }
setObsoleteLink(const QString & t)626     void setObsoleteLink(const QString &t) override { obsoleteLink_ = t; }
setWrapper()627     void setWrapper() override { wrapper_ = true; }
628 
629     void addResolvedBaseClass(Access access, ClassNode *node);
630     void addDerivedClass(Access access, ClassNode *node);
631     void addUnresolvedBaseClass(Access access, const QStringList &path, const QString &signature);
632     void addUnresolvedUsingClause(const QString &signature);
633     void removePrivateAndInternalBases();
634     void resolvePropertyOverriddenFromPtrs(PropertyNode *pn);
635 
baseClasses()636     QVector<RelatedClass> &baseClasses() { return bases_; }
derivedClasses()637     QVector<RelatedClass> &derivedClasses() { return derived_; }
ignoredBaseClasses()638     QVector<RelatedClass> &ignoredBaseClasses() { return ignoredBases_; }
usingClauses()639     QVector<UsingClause> &usingClauses() { return usingClauses_; }
640 
baseClasses()641     const QVector<RelatedClass> &baseClasses() const { return bases_; }
derivedClasses()642     const QVector<RelatedClass> &derivedClasses() const { return derived_; }
ignoredBaseClasses()643     const QVector<RelatedClass> &ignoredBaseClasses() const { return ignoredBases_; }
usingClauses()644     const QVector<UsingClause> &usingClauses() const { return usingClauses_; }
645 
qmlElement()646     QmlTypeNode *qmlElement() { return qmlelement; }
setQmlElement(QmlTypeNode * qcn)647     void setQmlElement(QmlTypeNode *qcn) { qmlelement = qcn; }
isAbstract()648     bool isAbstract() const override { return abstract_; }
setAbstract(bool b)649     void setAbstract(bool b) override { abstract_ = b; }
650     PropertyNode *findPropertyNode(const QString &name);
651     QmlTypeNode *findQmlBaseNode();
652     FunctionNode *findOverriddenFunction(const FunctionNode *fn);
653     PropertyNode *findOverriddenProperty(const FunctionNode *fn);
654     bool docMustBeGenerated() const override;
655 
656 private:
657     void promotePublicBases(const QVector<RelatedClass> &bases);
658 
659 private:
660     QVector<RelatedClass> bases_;
661     QVector<RelatedClass> derived_;
662     QVector<RelatedClass> ignoredBases_;
663     QVector<UsingClause> usingClauses_;
664     bool abstract_;
665     bool wrapper_;
666     QString obsoleteLink_;
667     QmlTypeNode *qmlelement;
668 };
669 
670 class HeaderNode : public Aggregate
671 {
672 public:
673     HeaderNode(Aggregate *parent, const QString &name);
674     bool docMustBeGenerated() const override;
isFirstClassAggregate()675     bool isFirstClassAggregate() const override { return true; }
isRelatableType()676     bool isRelatableType() const override { return true; }
title()677     QString title() const override { return (title_.isEmpty() ? name() : title_); }
subtitle()678     QString subtitle() const override { return subtitle_; }
fullTitle()679     QString fullTitle() const override
680     {
681         return (title_.isEmpty() ? name() : name() + " - " + title_);
682     }
setTitle(const QString & title)683     bool setTitle(const QString &title) override
684     {
685         title_ = title;
686         return true;
687     }
setSubtitle(const QString & subtitle)688     bool setSubtitle(const QString &subtitle) override
689     {
690         subtitle_ = subtitle;
691         return true;
692     }
nameForLists()693     QString nameForLists() const override { return title(); }
694     bool hasDocumentedChildren() const;
695 
696 private:
697     QString title_;
698     QString subtitle_;
699 };
700 
701 class ExampleNode : public PageNode
702 {
703 public:
ExampleNode(Aggregate * parent,const QString & name)704     ExampleNode(Aggregate *parent, const QString &name) : PageNode(Node::Example, parent, name) {}
imageFileName()705     QString imageFileName() const override { return imageFileName_; }
setImageFileName(const QString & ifn)706     void setImageFileName(const QString &ifn) override { imageFileName_ = ifn; }
files()707     const QStringList &files() const { return files_; }
images()708     const QStringList &images() const { return images_; }
projectFile()709     const QString &projectFile() const { return projectFile_; }
setFiles(const QStringList files,const QString & projectFile)710     void setFiles(const QStringList files, const QString &projectFile)
711     {
712         files_ = files;
713         projectFile_ = projectFile;
714     }
setImages(const QStringList images)715     void setImages(const QStringList images) { images_ = images; }
appendFile(QString & file)716     void appendFile(QString &file) { files_.append(file); }
appendImage(QString & image)717     void appendImage(QString &image) { images_.append(image); }
718 
719 private:
720     QString imageFileName_;
721     QString projectFile_;
722     QStringList files_;
723     QStringList images_;
724 };
725 
726 struct ImportRec
727 {
728     QString name_; // module name
729     QString version_; // <major> . <minor>
730     QString importId_; // "as" name
731     QString importUri_; // subdirectory of module directory
732 
ImportRecImportRec733     ImportRec(const QString &name, const QString &version, const QString &importId,
734               const QString &importUri)
735         : name_(name), version_(version), importId_(importId), importUri_(importUri)
736     {
737     }
nameImportRec738     QString &name() { return name_; }
versionImportRec739     QString &version() { return version_; }
importIdImportRec740     QString &importId() { return importId_; }
importUriImportRec741     QString &importUri() { return importUri_; }
isEmptyImportRec742     bool isEmpty() const { return name_.isEmpty(); }
743 };
744 
745 typedef QVector<ImportRec> ImportList;
746 
747 class QmlTypeNode : public Aggregate
748 {
749 public:
750     QmlTypeNode(Aggregate *parent, const QString &name, NodeType type = QmlType);
isFirstClassAggregate()751     bool isFirstClassAggregate() const override { return true; }
isQtQuickNode()752     bool isQtQuickNode() const override
753     {
754         return (logicalModuleName() == QLatin1String("QtQuick"));
755     }
classNode()756     ClassNode *classNode() override { return cnode_; }
setClassNode(ClassNode * cn)757     void setClassNode(ClassNode *cn) override { cnode_ = cn; }
isAbstract()758     bool isAbstract() const override { return abstract_; }
isWrapper()759     bool isWrapper() const override { return wrapper_; }
setAbstract(bool b)760     void setAbstract(bool b) override { abstract_ = b; }
setWrapper()761     void setWrapper() override { wrapper_ = true; }
isInternal()762     bool isInternal() const override { return (status() == Internal); }
763     QString qmlFullBaseName() const override;
obsoleteLink()764     QString obsoleteLink() const override { return obsoleteLink_; }
setObsoleteLink(const QString & t)765     void setObsoleteLink(const QString &t) override { obsoleteLink_ = t; }
766     QString logicalModuleName() const override;
767     QString logicalModuleVersion() const override;
768     QString logicalModuleIdentifier() const override;
logicalModule()769     CollectionNode *logicalModule() const override { return logicalModule_; }
setQmlModule(CollectionNode * t)770     void setQmlModule(CollectionNode *t) override { logicalModule_ = t; }
771 
importList()772     const ImportList &importList() const { return importList_; }
setImportList(const ImportList & il)773     void setImportList(const ImportList &il) { importList_ = il; }
qmlBaseName()774     const QString &qmlBaseName() const { return qmlBaseName_; }
setQmlBaseName(const QString & name)775     void setQmlBaseName(const QString &name) { qmlBaseName_ = name; }
qmlBaseNodeNotSet()776     bool qmlBaseNodeNotSet() const { return (qmlBaseNode_ == nullptr); }
qmlBaseNode()777     QmlTypeNode *qmlBaseNode() const override { return qmlBaseNode_; }
setQmlBaseNode(QmlTypeNode * b)778     void setQmlBaseNode(QmlTypeNode *b) { qmlBaseNode_ = b; }
requireCppClass()779     void requireCppClass() { cnodeRequired_ = true; }
cppClassRequired()780     bool cppClassRequired() const { return cnodeRequired_; }
781     static void addInheritedBy(const Node *base, Node *sub);
782     static void subclasses(const Node *base, NodeList &subs);
783     static void terminate();
784     bool inherits(Aggregate *type);
785 
786 public:
787     static bool qmlOnly;
788     static QMultiMap<const Node *, Node *> inheritedBy;
789 
790 private:
791     bool abstract_;
792     bool cnodeRequired_;
793     bool wrapper_;
794     ClassNode *cnode_;
795     QString qmlBaseName_;
796     QString obsoleteLink_;
797     CollectionNode *logicalModule_;
798     QmlTypeNode *qmlBaseNode_;
799     ImportList importList_;
800 };
801 
802 class QmlBasicTypeNode : public Aggregate
803 {
804 public:
805     QmlBasicTypeNode(Aggregate *parent, const QString &name, NodeType type = QmlBasicType);
isFirstClassAggregate()806     bool isFirstClassAggregate() const override { return true; }
807 };
808 
809 class QmlPropertyNode : public Node
810 {
811     Q_DECLARE_TR_FUNCTIONS(QDoc::QmlPropertyNode)
812 
813 public:
814     QmlPropertyNode(Aggregate *parent, const QString &name, const QString &type, bool attached);
815 
setDataType(const QString & dataType)816     void setDataType(const QString &dataType) override { type_ = dataType; }
setStored(bool stored)817     void setStored(bool stored) { stored_ = toFlagValue(stored); }
setDesignable(bool designable)818     void setDesignable(bool designable) { designable_ = toFlagValue(designable); }
819 
dataType()820     const QString &dataType() const { return type_; }
qualifiedDataType()821     QString qualifiedDataType() const { return type_; }
isReadOnlySet()822     bool isReadOnlySet() const { return (readOnly_ != FlagValueDefault); }
isStored()823     bool isStored() const { return fromFlagValue(stored_, true); }
isDesignable()824     bool isDesignable() const { return fromFlagValue(designable_, false); }
825     bool isWritable();
isDefault()826     bool isDefault() const override { return isdefault_; }
isReadOnly()827     bool isReadOnly() const override { return fromFlagValue(readOnly_, false); }
isAlias()828     bool isAlias() const override { return isAlias_; }
isAttached()829     bool isAttached() const override { return attached_; }
isQtQuickNode()830     bool isQtQuickNode() const override { return parent()->isQtQuickNode(); }
qmlTypeName()831     QString qmlTypeName() const override { return parent()->qmlTypeName(); }
logicalModuleName()832     QString logicalModuleName() const override { return parent()->logicalModuleName(); }
logicalModuleVersion()833     QString logicalModuleVersion() const override { return parent()->logicalModuleVersion(); }
logicalModuleIdentifier()834     QString logicalModuleIdentifier() const override { return parent()->logicalModuleIdentifier(); }
element()835     QString element() const override { return parent()->name(); }
836 
markDefault()837     void markDefault() override { isdefault_ = true; }
markReadOnly(bool flag)838     void markReadOnly(bool flag) override { readOnly_ = toFlagValue(flag); }
839 
840 private:
841     PropertyNode *findCorrespondingCppProperty();
842 
843 private:
844     QString type_;
845     FlagValue stored_;
846     FlagValue designable_;
847     bool isAlias_;
848     bool isdefault_;
849     bool attached_;
850     FlagValue readOnly_;
851 };
852 
853 class EnumItem
854 {
855 public:
EnumItem()856     EnumItem() {}
EnumItem(const QString & name,const QString & value)857     EnumItem(const QString &name, const QString &value) : name_(name), value_(value) {}
858 
name()859     const QString &name() const { return name_; }
value()860     const QString &value() const { return value_; }
861 
862 private:
863     QString name_;
864     QString value_;
865 };
866 
867 class EnumNode : public Node
868 {
869 public:
870     EnumNode(Aggregate *parent, const QString &name, bool isScoped = false)
Node(Enum,parent,name)871         : Node(Enum, parent, name), flagsType_(nullptr), isScoped_(isScoped)
872     {
873     }
874 
875     void addItem(const EnumItem &item);
876     void setFlagsType(TypedefNode *typedeff);
hasItem(const QString & name)877     bool hasItem(const QString &name) const { return names_.contains(name); }
isScoped()878     bool isScoped() const { return isScoped_; }
879 
items()880     const QVector<EnumItem> &items() const { return items_; }
881     Access itemAccess(const QString &name) const;
flagsType()882     const TypedefNode *flagsType() const { return flagsType_; }
883     QString itemValue(const QString &name) const;
884     Node *clone(Aggregate *parent) override;
885 
886 private:
887     QVector<EnumItem> items_;
888     QSet<QString> names_;
889     const TypedefNode *flagsType_;
890     bool isScoped_;
891 };
892 
893 class TypedefNode : public Node
894 {
895 public:
896     TypedefNode(Aggregate *parent, const QString &name, NodeType type = Typedef)
Node(type,parent,name)897         : Node(type, parent, name), associatedEnum_(nullptr)
898     {
899     }
900 
hasAssociatedEnum()901     bool hasAssociatedEnum() const { return associatedEnum_ != nullptr; }
associatedEnum()902     const EnumNode *associatedEnum() const { return associatedEnum_; }
903     Node *clone(Aggregate *parent) override;
904 
905 private:
906     void setAssociatedEnum(const EnumNode *t);
907 
908     friend class EnumNode;
909 
910     const EnumNode *associatedEnum_;
911 };
912 
913 class TypeAliasNode : public TypedefNode
914 {
915 public:
TypeAliasNode(Aggregate * parent,const QString & name,const QString & aliasedType)916     TypeAliasNode(Aggregate *parent,
917                   const QString &name,
918                   const QString &aliasedType)
919         : TypedefNode(parent, name, NodeType::TypeAlias), aliasedType_(aliasedType)
920     {
921     }
922 
aliasedType()923     const QString &aliasedType() const { return aliasedType_; }
aliasedNode()924     const Node *aliasedNode() const { return aliasedNode_; }
setAliasedNode(const Node * node)925     void setAliasedNode(const Node *node) { aliasedNode_ = node; }
926     Node *clone(Aggregate *parent) override;
927 
928 private:
929     QString aliasedType_;
930     const Node *aliasedNode_ {};
931 };
932 
setFlagsType(TypedefNode * t)933 inline void EnumNode::setFlagsType(TypedefNode *t)
934 {
935     flagsType_ = t;
936     t->setAssociatedEnum(this);
937 }
938 
939 class SharedCommentNode : public Node
940 {
941 public:
SharedCommentNode(Node * n)942     SharedCommentNode(Node *n) : Node(Node::SharedComment, n->parent(), QString())
943     {
944         collective_.reserve(1);
945         append(n);
946     }
SharedCommentNode(QmlTypeNode * parent,int count,QString & group)947     SharedCommentNode(QmlTypeNode *parent, int count, QString &group)
948         : Node(Node::SharedComment, parent, group)
949     {
950         collective_.reserve(count);
951     }
~SharedCommentNode()952     ~SharedCommentNode() override { collective_.clear(); }
953 
isPropertyGroup()954     bool isPropertyGroup() const override
955     {
956         return !name().isEmpty() && !collective_.isEmpty()
957                 && (collective_.at(0)->isQmlProperty() || collective_.at(0)->isJsProperty());
958     }
count()959     int count() const { return collective_.size(); }
append(Node * n)960     void append(Node *n)
961     {
962         collective_.append(n);
963         n->setSharedCommentNode(this);
964         setGenus(n->genus());
965     }
sort()966     void sort() { std::sort(collective_.begin(), collective_.end(), Node::nodeNameLessThan); }
collective()967     const QVector<Node *> &collective() const { return collective_; }
968     void setOverloadFlags();
969     void setRelatedNonmember(bool b) override;
970     Node *clone(Aggregate *parent) override;
971 
972 private:
973     QVector<Node *> collective_;
974 };
975 
976 class FunctionNode : public Node
977 {
978 public:
979     enum Virtualness { NonVirtual, NormalVirtual, PureVirtual };
980 
981     enum Metaness {
982         Plain,
983         Signal,
984         Slot,
985         Ctor,
986         Dtor,
987         CCtor, // copy constructor
988         MCtor, // move-copy constructor
989         MacroWithParams,
990         MacroWithoutParams,
991         Native,
992         CAssign, // copy-assignment operator
993         MAssign, // move-assignment operator
994         QmlSignal,
995         QmlSignalHandler,
996         QmlMethod,
997         JsSignal,
998         JsSignalHandler,
999         JsMethod
1000     };
1001 
1002     FunctionNode(Aggregate *parent, const QString &name); // C++ function (Plain)
1003     FunctionNode(Metaness type, Aggregate *parent, const QString &name, bool attached = false);
1004 
1005     Node *clone(Aggregate *parent) override;
metaness()1006     Metaness metaness() const { return metaness_; }
1007     QString metanessString() const;
1008     bool changeMetaness(Metaness from, Metaness to);
setMetaness(Metaness t)1009     void setMetaness(Metaness t) { metaness_ = t; }
1010     Metaness setMetaness(const QString &t);
1011     QString kindString() const;
1012     static Metaness getMetaness(const QString &t);
1013     static Metaness getMetanessFromTopic(const QString &t);
1014     static Genus getGenus(Metaness t);
1015 
setReturnType(const QString & t)1016     void setReturnType(const QString &t) { returnType_ = t; }
setParentPath(const QStringList & p)1017     void setParentPath(const QStringList &p) { parentPath_ = p; }
1018     void setVirtualness(const QString &t);
setVirtualness(Virtualness v)1019     void setVirtualness(Virtualness v) { virtualness_ = v; }
setVirtual()1020     void setVirtual() { virtualness_ = NormalVirtual; }
setConst(bool b)1021     void setConst(bool b) { const_ = b; }
setStatic(bool b)1022     void setStatic(bool b) { static_ = b; }
setReimpFlag()1023     void setReimpFlag() { reimpFlag_ = true; }
setOverridesThis(const QString & path)1024     void setOverridesThis(const QString &path) { overridesThis_ = path; }
1025 
returnType()1026     const QString &returnType() const { return returnType_; }
1027     QString virtualness() const;
isConst()1028     bool isConst() const { return const_; }
isStatic()1029     bool isStatic() const override { return static_; }
isOverload()1030     bool isOverload() const { return overloadFlag_; }
isMarkedReimp()1031     bool isMarkedReimp() const override { return reimpFlag_; }
isSomeCtor()1032     bool isSomeCtor() const { return isCtor() || isCCtor() || isMCtor(); }
isMacroWithParams()1033     bool isMacroWithParams() const { return (metaness_ == MacroWithParams); }
isMacroWithoutParams()1034     bool isMacroWithoutParams() const { return (metaness_ == MacroWithoutParams); }
isMacro()1035     bool isMacro() const override { return (isMacroWithParams() || isMacroWithoutParams()); }
1036     bool isObsolete() const override;
1037 
isCppFunction()1038     bool isCppFunction() const { return metaness_ == Plain; } // Is this correct?
isSignal()1039     bool isSignal() const { return (metaness_ == Signal); }
isSlot()1040     bool isSlot() const { return (metaness_ == Slot); }
isCtor()1041     bool isCtor() const { return (metaness_ == Ctor); }
isDtor()1042     bool isDtor() const { return (metaness_ == Dtor); }
isCCtor()1043     bool isCCtor() const { return (metaness_ == CCtor); }
isMCtor()1044     bool isMCtor() const { return (metaness_ == MCtor); }
isCAssign()1045     bool isCAssign() const { return (metaness_ == CAssign); }
isMAssign()1046     bool isMAssign() const { return (metaness_ == MAssign); }
1047 
isJsMethod()1048     bool isJsMethod() const { return (metaness_ == JsMethod); }
isJsSignal()1049     bool isJsSignal() const { return (metaness_ == JsSignal); }
isJsSignalHandler()1050     bool isJsSignalHandler() const { return (metaness_ == JsSignalHandler); }
1051 
isQmlMethod()1052     bool isQmlMethod() const { return (metaness_ == QmlMethod); }
isQmlSignal()1053     bool isQmlSignal() const { return (metaness_ == QmlSignal); }
isQmlSignalHandler()1054     bool isQmlSignalHandler() const { return (metaness_ == QmlSignalHandler); }
1055 
isSpecialMemberFunction()1056     bool isSpecialMemberFunction() const
1057     {
1058         return (isDtor() || isCCtor() || isMCtor() || isCAssign() || isMAssign());
1059     }
isNonvirtual()1060     bool isNonvirtual() const { return (virtualness_ == NonVirtual); }
isVirtual()1061     bool isVirtual() const { return (virtualness_ == NormalVirtual); }
isPureVirtual()1062     bool isPureVirtual() const { return (virtualness_ == PureVirtual); }
returnsBool()1063     bool returnsBool() const { return (returnType_ == QLatin1String("bool")); }
1064 
parameters()1065     Parameters &parameters() { return parameters_; }
parameters()1066     const Parameters &parameters() const { return parameters_; }
isPrivateSignal()1067     bool isPrivateSignal() const { return parameters_.isPrivateSignal(); }
setParameters(const QString & signature)1068     void setParameters(const QString &signature) { parameters_.set(signature); }
1069     QString signature(bool values, bool noReturnType, bool templateParams = false) const override;
1070 
overridesThis()1071     const QString &overridesThis() const { return overridesThis_; }
associatedProperties()1072     const NodeList &associatedProperties() const { return associatedProperties_; }
parentPath()1073     const QStringList &parentPath() const { return parentPath_; }
hasAssociatedProperties()1074     bool hasAssociatedProperties() const { return !associatedProperties_.isEmpty(); }
hasOneAssociatedProperty()1075     bool hasOneAssociatedProperty() const { return (associatedProperties_.size() == 1); }
firstAssociatedProperty()1076     Node *firstAssociatedProperty() const { return associatedProperties_[0]; }
1077 
element()1078     QString element() const override { return parent()->name(); }
isAttached()1079     bool isAttached() const override { return attached_; }
isQtQuickNode()1080     bool isQtQuickNode() const override { return parent()->isQtQuickNode(); }
qmlTypeName()1081     QString qmlTypeName() const override { return parent()->qmlTypeName(); }
logicalModuleName()1082     QString logicalModuleName() const override { return parent()->logicalModuleName(); }
logicalModuleVersion()1083     QString logicalModuleVersion() const override { return parent()->logicalModuleVersion(); }
logicalModuleIdentifier()1084     QString logicalModuleIdentifier() const override { return parent()->logicalModuleIdentifier(); }
1085 
1086     void debug() const;
1087 
setFinal(bool b)1088     void setFinal(bool b) { isFinal_ = b; }
isFinal()1089     bool isFinal() const { return isFinal_; }
1090 
setOverride(bool b)1091     void setOverride(bool b) { isOverride_ = b; }
isOverride()1092     bool isOverride() const { return isOverride_; }
1093 
setRef(bool b)1094     void setRef(bool b) { isRef_ = b; }
isRef()1095     bool isRef() const { return isRef_; }
1096 
setRefRef(bool b)1097     void setRefRef(bool b) { isRefRef_ = b; }
isRefRef()1098     bool isRefRef() const { return isRefRef_; }
1099 
setInvokable(bool b)1100     void setInvokable(bool b) { isInvokable_ = b; }
isInvokable()1101     bool isInvokable() const { return isInvokable_; }
1102 
hasTag(const QString & t)1103     bool hasTag(const QString &t) const override { return (tag_ == t); }
setTag(const QString & t)1104     void setTag(const QString &t) { tag_ = t; }
tag()1105     const QString &tag() const { return tag_; }
1106     bool compare(const FunctionNode *fn) const;
1107     bool isIgnored() const;
1108     bool hasOverloads() const;
clearOverloadFlag()1109     void clearOverloadFlag() { overloadFlag_ = false; }
setOverloadFlag()1110     void setOverloadFlag() { overloadFlag_ = true; }
1111     void setOverloadNumber(signed short n);
1112     void appendOverload(FunctionNode *fn);
overloadNumber()1113     signed short overloadNumber() const { return overloadNumber_; }
nextOverload()1114     FunctionNode *nextOverload() { return nextOverload_; }
setNextOverload(FunctionNode * fn)1115     void setNextOverload(FunctionNode *fn) { nextOverload_ = fn; }
1116     FunctionNode *findPrimaryFunction();
1117 
1118 private:
1119     void addAssociatedProperty(PropertyNode *property);
1120 
1121     friend class Aggregate;
1122     friend class PropertyNode;
1123 
1124     bool const_ : 1;
1125     bool static_ : 1;
1126     bool reimpFlag_ : 1;
1127     bool attached_ : 1;
1128     bool overloadFlag_ : 1;
1129     bool isFinal_ : 1;
1130     bool isOverride_ : 1;
1131     bool isRef_ : 1;
1132     bool isRefRef_ : 1;
1133     bool isInvokable_ : 1;
1134     Metaness metaness_;
1135     Virtualness virtualness_;
1136     signed short overloadNumber_;
1137     FunctionNode *nextOverload_;
1138     QString returnType_;
1139     QStringList parentPath_;
1140     QString overridesThis_;
1141     QString tag_;
1142     NodeList associatedProperties_;
1143     Parameters parameters_;
1144 };
1145 
1146 class PropertyNode : public Node
1147 {
1148 public:
1149     enum FunctionRole { Getter, Setter, Resetter, Notifier };
1150     enum { NumFunctionRoles = Notifier + 1 };
1151 
1152     PropertyNode(Aggregate *parent, const QString &name);
1153 
setDataType(const QString & dataType)1154     void setDataType(const QString &dataType) override { type_ = dataType; }
1155     void addFunction(FunctionNode *function, FunctionRole role);
1156     void addSignal(FunctionNode *function, FunctionRole role);
setStored(bool stored)1157     void setStored(bool stored) { stored_ = toFlagValue(stored); }
setDesignable(bool designable)1158     void setDesignable(bool designable) { designable_ = toFlagValue(designable); }
setScriptable(bool scriptable)1159     void setScriptable(bool scriptable) { scriptable_ = toFlagValue(scriptable); }
setWritable(bool writable)1160     void setWritable(bool writable) { writable_ = toFlagValue(writable); }
setUser(bool user)1161     void setUser(bool user) { user_ = toFlagValue(user); }
1162     void setOverriddenFrom(const PropertyNode *baseProperty);
setRuntimeDesFunc(const QString & rdf)1163     void setRuntimeDesFunc(const QString &rdf) { runtimeDesFunc_ = rdf; }
setRuntimeScrFunc(const QString & scrf)1164     void setRuntimeScrFunc(const QString &scrf) { runtimeScrFunc_ = scrf; }
setConstant()1165     void setConstant() { const_ = true; }
setFinal()1166     void setFinal() { final_ = true; }
setRevision(int revision)1167     void setRevision(int revision) { revision_ = revision; }
1168 
dataType()1169     const QString &dataType() const { return type_; }
1170     QString qualifiedDataType() const;
1171     NodeList functions() const;
functions(FunctionRole role)1172     const NodeList &functions(FunctionRole role) const { return functions_[(int)role]; }
getters()1173     const NodeList &getters() const { return functions(Getter); }
setters()1174     const NodeList &setters() const { return functions(Setter); }
resetters()1175     const NodeList &resetters() const { return functions(Resetter); }
notifiers()1176     const NodeList &notifiers() const { return functions(Notifier); }
1177     bool hasAccessFunction(const QString &name) const;
1178     FunctionRole role(const FunctionNode *fn) const;
isStored()1179     bool isStored() const { return fromFlagValue(stored_, storedDefault()); }
isDesignable()1180     bool isDesignable() const { return fromFlagValue(designable_, designableDefault()); }
isScriptable()1181     bool isScriptable() const { return fromFlagValue(scriptable_, scriptableDefault()); }
runtimeDesignabilityFunction()1182     const QString &runtimeDesignabilityFunction() const { return runtimeDesFunc_; }
runtimeScriptabilityFunction()1183     const QString &runtimeScriptabilityFunction() const { return runtimeScrFunc_; }
isWritable()1184     bool isWritable() const { return fromFlagValue(writable_, writableDefault()); }
isUser()1185     bool isUser() const { return fromFlagValue(user_, userDefault()); }
isConstant()1186     bool isConstant() const { return const_; }
isFinal()1187     bool isFinal() const { return final_; }
overriddenFrom()1188     const PropertyNode *overriddenFrom() const { return overrides_; }
1189 
storedDefault()1190     bool storedDefault() const { return true; }
userDefault()1191     bool userDefault() const { return false; }
designableDefault()1192     bool designableDefault() const { return !setters().isEmpty(); }
scriptableDefault()1193     bool scriptableDefault() const { return true; }
writableDefault()1194     bool writableDefault() const { return !setters().isEmpty(); }
1195 
1196 private:
1197     QString type_;
1198     QString runtimeDesFunc_;
1199     QString runtimeScrFunc_;
1200     NodeList functions_[NumFunctionRoles];
1201     FlagValue stored_;
1202     FlagValue designable_;
1203     FlagValue scriptable_;
1204     FlagValue writable_;
1205     FlagValue user_;
1206     bool const_;
1207     bool final_;
1208     int revision_;
1209     const PropertyNode *overrides_;
1210 };
1211 
addFunction(FunctionNode * function,FunctionRole role)1212 inline void PropertyNode::addFunction(FunctionNode *function, FunctionRole role)
1213 {
1214     functions_[(int)role].append(function);
1215     function->addAssociatedProperty(this);
1216 }
1217 
addSignal(FunctionNode * function,FunctionRole role)1218 inline void PropertyNode::addSignal(FunctionNode *function, FunctionRole role)
1219 {
1220     functions_[(int)role].append(function);
1221     function->addAssociatedProperty(this);
1222 }
1223 
functions()1224 inline NodeList PropertyNode::functions() const
1225 {
1226     NodeList list;
1227     for (int i = 0; i < NumFunctionRoles; ++i)
1228         list += functions_[i];
1229     return list;
1230 }
1231 
1232 class VariableNode : public Node
1233 {
1234 public:
1235     VariableNode(Aggregate *parent, const QString &name);
1236 
setLeftType(const QString & leftType)1237     void setLeftType(const QString &leftType) { leftType_ = leftType; }
setRightType(const QString & rightType)1238     void setRightType(const QString &rightType) { rightType_ = rightType; }
setStatic(bool b)1239     void setStatic(bool b) { static_ = b; }
1240 
leftType()1241     const QString &leftType() const { return leftType_; }
rightType()1242     const QString &rightType() const { return rightType_; }
dataType()1243     QString dataType() const { return leftType_ + rightType_; }
isStatic()1244     bool isStatic() const override { return static_; }
1245     Node *clone(Aggregate *parent) override;
1246 
1247 private:
1248     QString leftType_;
1249     QString rightType_;
1250     bool static_;
1251 };
1252 
VariableNode(Aggregate * parent,const QString & name)1253 inline VariableNode::VariableNode(Aggregate *parent, const QString &name)
1254     : Node(Variable, parent, name), static_(false)
1255 {
1256     setGenus(Node::CPP);
1257 }
1258 
1259 class CollectionNode : public PageNode
1260 {
1261 public:
CollectionNode(NodeType type,Aggregate * parent,const QString & name)1262     CollectionNode(NodeType type, Aggregate *parent, const QString &name)
1263         : PageNode(type, parent, name), seen_(false)
1264     {
1265     }
1266 
isCollectionNode()1267     bool isCollectionNode() const override { return true; }
qtVariable()1268     QString qtVariable() const override { return qtVariable_; }
setQtVariable(const QString & v)1269     void setQtVariable(const QString &v) override { qtVariable_ = v; }
1270     void addMember(Node *node) override;
1271     bool hasMembers() const override;
1272     bool hasNamespaces() const override;
1273     bool hasClasses() const override;
1274     void getMemberNamespaces(NodeMap &out) override;
1275     void getMemberClasses(NodeMap &out) const override;
wasSeen()1276     bool wasSeen() const override { return seen_; }
1277 
fullTitle()1278     QString fullTitle() const override { return title(); }
logicalModuleName()1279     QString logicalModuleName() const override { return logicalModuleName_; }
logicalModuleVersion()1280     QString logicalModuleVersion() const override
1281     {
1282         return logicalModuleVersionMajor_ + QLatin1Char('.') + logicalModuleVersionMinor_;
1283     }
logicalModuleIdentifier()1284     QString logicalModuleIdentifier() const override
1285     {
1286         return logicalModuleName_ + logicalModuleVersionMajor_;
1287     }
1288     void setLogicalModuleInfo(const QString &arg) override;
1289     void setLogicalModuleInfo(const QStringList &info) override;
1290 
members()1291     const NodeList &members() const { return members_; }
1292     void printMembers(const QString &title);
1293 
markSeen()1294     void markSeen() { seen_ = true; }
markNotSeen()1295     void markNotSeen() { seen_ = false; }
1296 
1297 private:
1298     bool seen_;
1299     NodeList members_;
1300     QString logicalModuleName_;
1301     QString logicalModuleVersionMajor_;
1302     QString logicalModuleVersionMinor_;
1303     QString qtVariable_;
1304 };
1305 
1306 QT_END_NAMESPACE
1307 
1308 #endif
1309