diff options
author | Topi Reinio <topi.reinio@qt.io> | 2020-01-29 13:14:32 +0100 |
---|---|---|
committer | Topi Reinio <topi.reinio@qt.io> | 2020-01-29 21:44:49 +0100 |
commit | 653884ab6988ea72fc0d5cc21675efcef67d0455 (patch) | |
tree | 15e9679c1ebf96b8c4bda6dd7dd678d8352f6c2b | |
parent | cd50765264adac52dc7ace48b0f339c0b13f76fc (diff) | |
download | qttools-653884ab6988ea72fc0d5cc21675efcef67d0455.tar.gz |
qdoc: Override isObsolete() for a FunctionNode
Make Node::isObsolete() virtual and override it for FunctionNode.
This is needed to treat access functions of obsolete properties
also as obsolete.
Remove FunctionNode::hasActiveAssociatedProperty() as it was a
workaround for isObsolete() not being complete for function nodes.
Fixes: QTBUG-79386
Change-Id: If7597ca19f35b4582979bed36f628874c5beac07
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r-- | src/qdoc/node.cpp | 28 | ||||
-rw-r--r-- | src/qdoc/node.h | 4 | ||||
-rw-r--r-- | src/qdoc/sections.cpp | 4 |
3 files changed, 19 insertions, 17 deletions
diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp index 65c75e743..5415f14cd 100644 --- a/src/qdoc/node.cpp +++ b/src/qdoc/node.cpp @@ -4204,19 +4204,23 @@ void FunctionNode::addAssociatedProperty(PropertyNode *p) } /*! - Returns true if this function has at least one property - that is active, i.e. at least one property that is not - obsolete. - */ -bool FunctionNode::hasActiveAssociatedProperty() const + \reimp + + Returns \c true if this is an access function for an obsolete property, + otherwise calls the base implementation of isObsolete(). +*/ +bool FunctionNode::isObsolete() const { - if (associatedProperties_.isEmpty()) - return false; - for (const auto *property : qAsConst(associatedProperties_)) { - if (!property->isObsolete()) - return true; - } - return false; + auto it = std::find_if_not(associatedProperties_.begin(), + associatedProperties_.end(), + [](const Node *p)->bool { + return p->isObsolete(); + }); + + if (!associatedProperties_.isEmpty() && it == associatedProperties_.end()) + return true; + + return Node::isObsolete(); } /*! \fn unsigned char FunctionNode::overloadNumber() const diff --git a/src/qdoc/node.h b/src/qdoc/node.h index 739c262b4..345a20033 100644 --- a/src/qdoc/node.h +++ b/src/qdoc/node.h @@ -183,7 +183,6 @@ public: bool isJsType() const { return nodeType_ == JsType; } bool isModule() const { return nodeType_ == Module; } bool isNamespace() const { return nodeType_ == Namespace; } - bool isObsolete() const { return (status_ == Obsolete); } bool isPage() const { return nodeType_ == Page; } bool isPreliminary() const { return (status_ == Preliminary); } bool isPrivate() const { return access_ == Private; } @@ -205,6 +204,7 @@ public: bool isVariable() const { return nodeType_ == Variable; } bool isGenericCollection() const { return (nodeType_ == Node::Collection); } + virtual bool isObsolete() const { return (status_ == Obsolete); } virtual bool isAbstract() const { return false; } virtual bool isAggregate() const { return false; } // means "can have children" virtual bool isFirstClassAggregate() const @@ -1025,6 +1025,7 @@ public: bool isMacroWithParams() const { return (metaness_ == MacroWithParams); } bool isMacroWithoutParams() const { return (metaness_ == MacroWithoutParams); } bool isMacro() const override { return (isMacroWithParams() || isMacroWithoutParams()); } + bool isObsolete() const override; bool isCppFunction() const { return metaness_ == Plain; } // Is this correct? bool isSignal() const { return (metaness_ == Signal); } @@ -1065,7 +1066,6 @@ public: bool hasAssociatedProperties() const { return !associatedProperties_.isEmpty(); } bool hasOneAssociatedProperty() const { return (associatedProperties_.size() == 1); } Node *firstAssociatedProperty() const { return associatedProperties_[0]; } - bool hasActiveAssociatedProperty() const; QString element() const override { return parent()->name(); } bool isAttached() const override { return attached_; } diff --git a/src/qdoc/sections.cpp b/src/qdoc/sections.cpp index 64bef16b4..6cad782de 100644 --- a/src/qdoc/sections.cpp +++ b/src/qdoc/sections.cpp @@ -728,9 +728,7 @@ void Sections::distributeNodeInSummaryVector(SectionVector &sv, Node *n) sv[RelatedNonmembers].insert(n); return; } - if (fn->hasAssociatedProperties() && !fn->hasActiveAssociatedProperty()) - return; - else if (fn->isIgnored()) + if (fn->isIgnored()) return; if (fn->isSlot()) { if (fn->isPublic()) |