diff options
Diffstat (limited to 'src/qdoc/node.h')
-rw-r--r-- | src/qdoc/node.h | 285 |
1 files changed, 131 insertions, 154 deletions
diff --git a/src/qdoc/node.h b/src/qdoc/node.h index 76c1eee18..f882ec565 100644 --- a/src/qdoc/node.h +++ b/src/qdoc/node.h @@ -34,7 +34,7 @@ #include <qpair.h> #include <qstringlist.h> #include <qvector.h> -#include "codechunk.h" +#include "parameters.h" #include "doc.h" QT_BEGIN_NAMESPACE @@ -55,13 +55,17 @@ class CollectionNode; class QmlPropertyNode; class SharedCommentNode; +typedef QMap<QString, FunctionNode*> FunctionMap; typedef QList<Node*> NodeList; +typedef QList<ClassNode*> ClassList; typedef QVector<Node*> NodeVector; -typedef QList<PropertyNode*> PropNodeList; typedef QMap<QString, Node*> NodeMap; +typedef QMap<QString, NodeMap> NodeMapMap; typedef QMultiMap<QString, Node*> NodeMultiMap; +typedef QMap<QString, NodeMultiMap> NodeMultiMapMap; typedef QMap<QString, CollectionNode*> CNMap; typedef QMultiMap<QString, CollectionNode*> CNMultiMap; +typedef QList<CollectionNode*> CollectionList; class Node { @@ -95,6 +99,7 @@ public: JsBasicType, SharedComment, Collection, + Proxy, LastType }; @@ -144,6 +149,9 @@ public: }; virtual ~Node(); + virtual Node *clone(Aggregate *) { return nullptr; } // currently only FunctionNode + virtual Tree *tree() const; + Aggregate *root() const; NodeType nodeType() const { return (NodeType) nodeType_; } QString nodeTypeString() const; @@ -159,6 +167,7 @@ public: void setPageType(const QString& t); static PageType getPageType(NodeType t); + bool isActive() const { return (status_ == (unsigned char) Active); } bool isClass() const { return nodeType_ == Class; } bool isCppNode() const { return genus() == CPP; } bool isEnumType() const { return nodeType_ == Enum; } @@ -179,19 +188,24 @@ public: bool isModule() const { return nodeType_ == Module; } bool isNamespace() const { return nodeType_ == Namespace; } bool isObsolete() const { return (status_ == (unsigned char) Obsolete); } + bool isPreliminary() const { return (status_ == (unsigned char) Preliminary); } bool isPrivate() const { return (Access) access_ == Private; } bool isProperty() const { return nodeType_ == Property; } + bool isProxyNode() const { return nodeType_ == Proxy; } bool isPublic() const { return (Access) access_ == Public; } + bool isProtected() const { return (Access) access_ == Protected; } bool isQmlBasicType() const { return nodeType_ == QmlBasicType; } bool isQmlModule() const { return nodeType_ == QmlModule; } bool isQmlNode() const { return genus() == QML; } bool isQmlProperty() const { return nodeType_ == QmlProperty; } bool isQmlPropertyGroup() const { return nodeType_ == QmlPropertyGroup; } bool isQmlType() const { return nodeType_ == QmlType; } + bool isRelatedNonmember() const { return relatedNonmember_; } bool isSharedCommentNode() const { return nodeType_ == SharedComment; } bool isTypeAlias() const { return nodeType_ == Typedef; } bool isTypedef() const { return nodeType_ == Typedef; } bool isVariable() const { return nodeType_ == Variable; } + bool isGenericCollection() const { return (nodeType_ == Node::Collection); } virtual bool isAbstract() const { return false; } virtual bool isAggregate() const { return false; } // means "can have children" @@ -199,13 +213,12 @@ public: virtual bool isAttached() const { return false; } virtual bool isCollectionNode() const { return false; } virtual bool isDefault() const { return false; } - virtual bool isImplicit() const { return false; } virtual bool isInternal() const; virtual bool isMacro() const { return false; } virtual bool isPageNode() const { return false; } // means "generates a doc page" virtual bool isQtQuickNode() const { return false; } virtual bool isReadOnly() const { return false; } - virtual bool isReimplemented() const { return false; } + virtual bool isMarkedReimp() const { return false; } virtual bool isStatic() const { return false; } virtual bool isTextPageNode() const { return false; } // means PageNode but not Aggregate virtual bool isWrapper() const; @@ -236,9 +249,8 @@ public: void setReconstitutedBrief(const QString &t) { reconstitutedBrief_ = t; } void setParent(Aggregate* n) { parent_ = n; } void setIndexNodeFlag(bool isIndexNode = true) { indexNodeFlag_ = isIndexNode; } + virtual void setRelatedNonmember(bool b) { relatedNonmember_ = b; } virtual void setOutputFileName(const QString& ) { } - - virtual void addMember(Node* ) { } virtual bool hasMembers() const { return false; } virtual bool hasNamespaces() const { return false; } @@ -248,12 +260,9 @@ public: virtual void getMemberNamespaces(NodeMap& ) { } virtual void getMemberClasses(NodeMap& ) const { } virtual void setDataType(const QString& ) { } - virtual void setReadOnly(bool ) { } virtual bool wasSeen() const { return false; } virtual void appendGroupName(const QString& ) { } virtual QString element() const { return QString(); } - virtual Tree* tree() const; - virtual void findChildren(const QString& , NodeList& nodes) const { nodes.clear(); } virtual void setNoAutoList(bool ) { } virtual bool docMustBeGenerated() const { return false; } @@ -263,9 +272,12 @@ public: virtual bool setTitle(const QString& ) { return false; } virtual bool setSubtitle(const QString& ) { return false; } + virtual void markInternal() { setAccess(Private); setStatus(Internal); } + virtual void markDefault() { } + virtual void markReadOnly(bool ) { } + bool match(const QList<int>& types) const; Aggregate* parent() const { return parent_; } - const Node* root() const; const QString& name() const { return name_; } QString physicalModuleName() const; QString url() const { return url_; } @@ -276,7 +288,6 @@ public: virtual void setQtVariable(const QString& ) { } virtual QString qtVariable() const { return QString(); } virtual bool hasTag(const QString& ) const { return false; } - virtual void setOverloadFlag(bool ) { } const QMap<LinkType, QPair<QString,QString> >& links() const { return linkMap_; } void setLink(LinkType linkType, const QString &link, const QString &desc); @@ -298,11 +309,6 @@ public: QString nodeSubtypeString() const; virtual void addPageKeywords(const QString& ) { } - void clearRelated() { relatesTo_ = 0; } - PageNode* relates() const { return relatesTo_; } - virtual void setRelates(PageNode* pseudoParent); - virtual void setRelates(const QString &name); - bool isSharingComment() const { return (sharedCommentNode_ != 0); } bool hasSharedDoc() const; void setSharedCommentNode(SharedCommentNode* t); @@ -327,11 +333,14 @@ public: const QString& outputSubdirectory() const { return outSubDir_; } virtual void setOutputSubdirectory(const QString& t) { outSubDir_ = t; } QString fullDocumentName() const; - static QString cleanId(const QString &str); + QString qualifyCppName(); + QString qualifyQmlName(); + QString unqualifyQmlName(); + QString qualifyWithParentName(); + static QString cleanId(const QString &str); static FlagValue toFlagValue(bool b); static bool fromFlagValue(FlagValue fv, bool defaultValue); - static QString pageTypeString(unsigned char t); static QString nodeTypeString(unsigned char t); static QString nodeSubtypeString(unsigned char t); @@ -343,20 +352,18 @@ public: protected: Node(NodeType type, Aggregate* parent, const QString& name); - void removeRelates(); private: - unsigned char nodeType_; unsigned char genus_; unsigned char access_; unsigned char safeness_; unsigned char pageType_; unsigned char status_; - bool indexNodeFlag_; + bool indexNodeFlag_ : 1; + bool relatedNonmember_ : 1; Aggregate* parent_; - PageNode* relatesTo_; SharedCommentNode *sharedCommentNode_; QString name_; Location declLocation_; @@ -389,7 +396,6 @@ public: bool isPageNode() const override { return true; } bool isTextPageNode() const override { return !isAggregate(); } // PageNode but not Aggregate - virtual bool isDummyNode() const { return false; } QString title() const override { return title_; } QString subtitle() const override { return subtitle_; } @@ -411,15 +417,8 @@ public: void setOutputFileName(const QString& f) override { outputFileName_ = f; } QString outputFileName() const override { return outputFileName_; } - void removeFromRelated(); - const NodeList & relatedNodes() const { return related_; } - protected: friend class Node; - void removeRelated(Node* pseudoChild); - void addRelated(Node* pseudoChild); - virtual void removePseudoChild(Node *) { } - virtual void addPseudoChild(Node *) { } protected: bool noAutoList_; @@ -428,14 +427,6 @@ public: QString outputFileName_; QStringList groupNames_; QStringList pageKeywds_; - NodeList related_; -}; - -class DummyNode : public PageNode -{ -public: - DummyNode(Aggregate* parent, const QString& name) : PageNode(parent, name) { } - bool isDummyNode() const override { return true; } }; class ExternalPageNode : public PageNode @@ -450,59 +441,81 @@ public: class Aggregate : public PageNode { public: - virtual ~Aggregate(); - Node* findChildNode(const QString& name, Node::Genus genus, int findFlags = 0) const; Node* findChildNode(const QString& name, NodeType type); - void findChildren(const QString& name, NodeList& nodes) const override; - FunctionNode* findFunctionNode(const QString& name, const QString& params) const; - FunctionNode* findFunctionNode(const FunctionNode* clone) const; + void findChildren(const QString &name, NodeVector &nodes) const; + FunctionNode *findFunctionChild(const QString &name, const Parameters ¶meters); + FunctionNode *findFunctionChild(const FunctionNode *clone); void normalizeOverloads(); - void makeUndocumentedChildrenInternal(); - void deleteChildren(); + void markUndocumentedChildrenInternal(); bool isAggregate() const override { return true; } const EnumNode* findEnumNodeForValue(const QString &enumValue) const; int count() const { return children_.size(); } - const NodeList & childNodes() const { return children_; } + const NodeList &childNodes() const { return children_; } + const NodeList &nonfunctionList(); + NodeList::ConstIterator constBegin() const { return children_.constBegin(); } + NodeList::ConstIterator constEnd() const { return children_.constEnd(); } - NodeList overloads(const QString &funcName) const; - void addInclude(const QString &include); - void setIncludes(const QStringList &includes); - const QStringList& includes() const { return includes_; } + void addIncludeFile(const QString &includeFile); + void setIncludeFiles(const QStringList &includeFiles); + const QStringList &includeFiles() const { return includeFiles_; } QStringList primaryKeys(); - QStringList secondaryKeys(); QmlPropertyNode* hasQmlProperty(const QString& ) const; QmlPropertyNode* hasQmlProperty(const QString&, bool attached) const; virtual QmlTypeNode* qmlBaseNode() const { return 0; } void addChildByTitle(Node* child, const QString& title); void printChildren(const QString& title); void addChild(Node* child); - void removeChild(Node* child); + void adoptChild(Node *child); void setOutputSubdirectory(const QString& t) override; - const NodeMap& primaryFunctionMap() { return primaryFunctionMap_; } - const QMap<QString, NodeList>& secondaryFunctionMap() { return secondaryFunctionMap_; } -protected: - Aggregate(NodeType type, Aggregate* parent, const QString& name) : PageNode(type, parent, name) { } + FunctionMap &functionMap() { return functionMap_; } + void findAllFunctions(NodeMapMap &functionIndex); + void findAllNamespaces(NodeMultiMap &namespaces); + void findAllAttributions(NodeMultiMap &attributions); + bool hasObsoleteMembers(); + void findAllObsoleteThings(); + void findAllClasses(); + void findAllSince(); + void resolveQmlInheritance(); + bool hasOverloads(const FunctionNode *fn) const; + void appendToRelatedByProxy(const NodeList &t) { relatedByProxy_.append(t); } + NodeList &relatedByProxy() { return relatedByProxy_; } - void removePseudoChild(Node *pseudoChild) override; - void addPseudoChild(Node *pseudoChild) override; +protected: + Aggregate(NodeType type, Aggregate *parent, const QString &name) + : PageNode(type, parent, name), functionCount_(0) { } + virtual ~Aggregate(); + void removeFunctionNode(FunctionNode *fn); private: friend class Node; + void addFunction(FunctionNode *fn); + void adoptFunction(FunctionNode *fn); static bool isSameSignature(const FunctionNode* f1, const FunctionNode* f2); -private: - QStringList includes_; + protected: NodeList children_; + NodeList relatedByProxy_; + +private: + QStringList includeFiles_; NodeList enumChildren_; - NodeMap childMap_; - NodeMap primaryFunctionMap_; - QMap<QString, NodeList> secondaryFunctionMap_; + NodeMap nonfunctionMap_; + NodeList nonfunctionList_; + int functionCount_; + FunctionMap functionMap_; +}; + +class ProxyNode : public Aggregate +{ + public: + ProxyNode(Aggregate *parent, const QString &name); + bool docMustBeGenerated() const override { return true; } }; class NamespaceNode : public Aggregate @@ -510,15 +523,15 @@ class NamespaceNode : public Aggregate public: NamespaceNode(Aggregate* parent, const QString& name) : Aggregate(Namespace, parent, name), seen_(false), documented_(false), tree_(0), docNode_(0) { } - virtual ~NamespaceNode() { } + virtual ~NamespaceNode(); Tree* tree() const override { return (parent() ? parent()->tree() : tree_); } bool wasSeen() const override { return seen_; } void markSeen() { seen_ = true; } void markNotSeen() { seen_ = false; } void setTree(Tree* t) { tree_ = t; } - const NodeList& orphans() const { return orphans_; } - void addOrphan(Node* child) { orphans_.append(child); } + const NodeList &includedChildren() const; + void includeChild(Node *child); QString whereDocumented() const { return whereDocumented_; } void setWhereDocumented(const QString &t) { whereDocumented_ = t; } bool isDocumentedHere() const; @@ -536,7 +549,7 @@ private: Tree* tree_; QString whereDocumented_; NamespaceNode* docNode_; - NodeList orphans_; + NodeList includedChildren_; }; struct RelatedClass @@ -754,6 +767,10 @@ public: QString idNumber() override; QString element() const override { return parent()->name(); } + void markInternal() override; + void markDefault() override; + void markReadOnly(bool flag) override; + private: int idNumber_; }; @@ -772,8 +789,6 @@ public: void setDataType(const QString& dataType) override { type_ = dataType; } void setStored(bool stored) { stored_ = toFlagValue(stored); } void setDesignable(bool designable) { designable_ = toFlagValue(designable); } - void setReadOnly(bool ro) override { readOnly_ = toFlagValue(ro); } - void setDefault() { isdefault_ = true; } const QString &dataType() const { return type_; } QString qualifiedDataType() const { return type_; } @@ -798,6 +813,9 @@ public: } QString element() const override; + void markDefault() override { isdefault_ = true; } + void markReadOnly(bool flag) override { readOnly_ = toFlagValue(flag); } + private: PropertyNode* findCorrespondingCppProperty(); @@ -840,6 +858,7 @@ public: Access itemAccess(const QString& name) const; const TypedefNode* flagsType() const { return flagsType_; } QString itemValue(const QString &name) const; + Node *clone(Aggregate *parent) override; private: QList<EnumItem> items_; @@ -854,7 +873,9 @@ public: associatedEnum_(0) { } virtual ~TypedefNode() { } + bool hasAssociatedEnum() const { return associatedEnum_ != nullptr; } const EnumNode* associatedEnum() const { return associatedEnum_; } + Node *clone(Aggregate *parent) override; private: void setAssociatedEnum(const EnumNode* t); @@ -872,6 +893,7 @@ public: virtual ~TypeAliasNode() { } QString aliasedType() { return aliasedType_; } + Node *clone(Aggregate *parent) override; private: QString aliasedType_; @@ -883,33 +905,6 @@ inline void EnumNode::setFlagsType(TypedefNode* t) t->setAssociatedEnum(this); } -class Parameter -{ -public: - Parameter() {} - Parameter(const QString& dataType, - const QString& name = QString(), - const QString& defaultValue = QString()); - Parameter(const Parameter& p); - - Parameter& operator=(const Parameter& p); - - void setName(const QString& name) { name_ = name; } - - bool hasType() const { return dataType_.length() > 0; } - const QString& dataType() const { return dataType_; } - const QString& name() const { return name_; } - const QString& defaultValue() const { return defaultValue_; } - void setDefaultValue(const QString& defaultValue) { defaultValue_ = defaultValue; } - - QString reconstruct(bool value = false) const; - -public: - QString dataType_; - QString name_; - QString defaultValue_; -}; - class SharedCommentNode : public Node { public: @@ -921,17 +916,14 @@ public: void append(Node* n) { collective_.append(n); } const QVector<Node*>& collective() const { return collective_; } - void setOverloadFlag(bool b) override; - void setRelates(PageNode* pseudoParent) override; - void setRelates(const QString &name) override; + void setOverloadFlags(); + void setRelatedNonmember(bool b) override; + Node *clone(Aggregate *parent) override; private: QVector<Node*> collective_; }; -//friend class QTypeInfo<Parameter>; -//Q_DECLARE_TYPEINFO(Parameter, Q_MOVABLE_TYPE); - class FunctionNode : public Node { public: @@ -962,6 +954,7 @@ public: FunctionNode(Metaness type, Aggregate* parent, const QString &name, bool attached = false); virtual ~FunctionNode() { } + Node *clone(Aggregate *parent) override; Metaness metaness() const { return metaness_; } QString metanessString() const; bool changeMetaness(Metaness from, Metaness to); @@ -979,22 +972,15 @@ public: void setVirtual() { virtualness_ = NormalVirtual; } void setConst(bool b) { const_ = b; } void setStatic(bool b) { static_ = b; } - unsigned char overloadNumber() const { return overloadNumber_; } - void setOverloadFlag(bool b) override { overload_ = b; } - void setOverloadNumber(unsigned char n) { overloadNumber_ = n; } - void setReimplemented(bool b); - void addParameter(const Parameter& parameter); - inline void setParameters(const QVector<Parameter>& parameters); - void setParameters(const QString &t); - void borrowParameterNames(const FunctionNode* source); - void setReimplementedFrom(const QString &path) { reimplementedFrom_ = path; } + void setReimpFlag() { reimpFlag_ = true; }; + void setOverridesThis(const QString &path) { overridesThis_ = path; } const QString& returnType() const { return returnType_; } QString virtualness() const; bool isConst() const { return const_; } bool isStatic() const override { return static_; } - bool isOverload() const { return overload_; } - bool isReimplemented() const override { return reimplemented_; } + bool isOverload() const { return overloadFlag_; } + bool isMarkedReimp() const override { return reimpFlag_; } bool isSomeCtor() const { return isCtor() || isCCtor() || isMCtor(); } bool isMacroWithParams() const { return (metaness_ == MacroWithParams); } bool isMacroWithoutParams() const { return (metaness_ == MacroWithoutParams); } @@ -1024,22 +1010,22 @@ public: bool isNonvirtual() const { return (virtualness_ == NonVirtual); } bool isVirtual() const { return (virtualness_ == NormalVirtual); } bool isPureVirtual() const { return (virtualness_ == PureVirtual); } + bool returnsBool() const { return (returnType_ == QLatin1String("bool")); } + + Parameters ¶meters() { return parameters_; } + const Parameters ¶meters() const { return parameters_; } + bool isPrivateSignal() const { return parameters_.isPrivateSignal(); } + void setParameters(const QString &signature) { parameters_.set(signature); } + QString signature(bool values, bool noReturnType) const override; - QVector<Parameter> ¶meters() { return parameters_; } - const QVector<Parameter>& parameters() const { return parameters_; } - void clearParams() { parameters_.clear(); } - QStringList parameterNames() const; - QString rawParameters(bool names = false, bool values = false) const; - const QString& reimplementedFrom() const { return reimplementedFrom_; } - const PropNodeList& associatedProperties() const { return associatedProperties_; } + const QString &overridesThis() const { return overridesThis_; } + NodeList &associatedProperties() { return associatedProperties_; } const QStringList& parentPath() const { return parentPath_; } bool hasAssociatedProperties() const { return !associatedProperties_.isEmpty(); } bool hasOneAssociatedProperty() const { return (associatedProperties_.size() == 1); } - PropertyNode* firstAssociatedProperty() const { return associatedProperties_[0]; } + Node *firstAssociatedProperty() const { return associatedProperties_[0]; } bool hasActiveAssociatedProperty() const; - QStringList reconstructParameters(bool values = false) const; - QString signature(bool values, bool noReturnType = false) const override; QString element() const override { return parent()->name(); } bool isAttached() const override { return attached_; } bool isQtQuickNode() const override { return parent()->isQtQuickNode(); } @@ -1047,26 +1033,15 @@ public: QString logicalModuleName() const override { return parent()->logicalModuleName(); } QString logicalModuleVersion() const override { return parent()->logicalModuleVersion(); } QString logicalModuleIdentifier() const override { return parent()->logicalModuleIdentifier(); } - bool isPrivateSignal() const { return privateSignal_; } - void setPrivateSignal() { privateSignal_ = true; } void debug() const; - bool isDeleted() const { return isDeleted_; } - void setIsDeleted(bool b) { isDeleted_ = b; } - - bool isDefaulted() const { return isDefaulted_; } - void setIsDefaulted(bool b) { isDefaulted_ = b; } - void setFinal(bool b) { isFinal_ = b; } bool isFinal() const { return isFinal_; } void setOverride(bool b) { isOverride_ = b; } bool isOverride() const { return isOverride_; } - void setImplicit(bool b) { isImplicit_ = b; } - bool isImplicit() const override { return isImplicit_; } - void setRef(bool b) { isRef_ = b; } bool isRef() const { return isRef_; } @@ -1081,6 +1056,15 @@ public: const QString &tag() const { return tag_; } bool compare(const FunctionNode *fn) const; bool isIgnored() const; + bool hasOverloads() const; + void clearOverloadFlag() { overloadFlag_ = false; } + void setOverloadFlag() { overloadFlag_ = true; } + void setOverloadNumber(signed short n); + void appendOverload(FunctionNode *fn); + signed short overloadNumber() const { return overloadNumber_; } + FunctionNode *nextOverload() { return nextOverload_; } + void setNextOverload(FunctionNode *fn) { nextOverload_ = fn; } + FunctionNode *findPrimaryFunction(); private: void addAssociatedProperty(PropertyNode* property); @@ -1088,29 +1072,26 @@ private: friend class Aggregate; friend class PropertyNode; - QString returnType_; - QStringList parentPath_; - Metaness metaness_; - Virtualness virtualness_; bool const_ : 1; bool static_ : 1; - bool reimplemented_: 1; + bool reimpFlag_: 1; bool attached_: 1; - bool privateSignal_: 1; - bool overload_ : 1; - bool isDeleted_ : 1; - bool isDefaulted_ : 1; + bool overloadFlag_ : 1; bool isFinal_ : 1; bool isOverride_ : 1; - bool isImplicit_ : 1; bool isRef_ : 1; bool isRefRef_ : 1; bool isInvokable_ : 1; - unsigned char overloadNumber_; - QVector<Parameter> parameters_; - QString reimplementedFrom_; - PropNodeList associatedProperties_; - QString tag_; + Metaness metaness_; + Virtualness virtualness_; + signed short overloadNumber_; + FunctionNode *nextOverload_; + QString returnType_; + QStringList parentPath_; + QString overridesThis_; + QString tag_; + NodeList associatedProperties_; + Parameters parameters_; }; class PropertyNode : public Node @@ -1179,11 +1160,6 @@ private: const PropertyNode* overrides_; }; -inline void FunctionNode::setParameters(const QVector<Parameter> &p) -{ - parameters_ = p; -} - inline void PropertyNode::addFunction(FunctionNode* function, FunctionRole role) { functions_[(int)role].append(function); @@ -1218,6 +1194,7 @@ public: const QString &rightType() const { return rightType_; } QString dataType() const { return leftType_ + rightType_; } bool isStatic() const override { return static_; } + Node *clone(Aggregate *parent) override; private: QString leftType_; |