summaryrefslogtreecommitdiff
path: root/src/qdoc/node.cpp
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@qt.io>2019-07-18 13:38:35 +0200
committerMartin Smith <martin.smith@qt.io>2019-07-22 14:43:40 +0200
commit466d87a7c92436e0da98005475065dc212cac71c (patch)
treee9ba90a816153c7b742109b7cdee2ebba23c94c2 /src/qdoc/node.cpp
parent1b9972cde24a8d8bb7f24ddbb196666456a1ce6b (diff)
downloadqttools-466d87a7c92436e0da98005475065dc212cac71c.tar.gz
qdoc: Fix the \reimp command output
When qdoc finds \reimp in a function node comment, it searches the parent class node's base classes to find the function node for the function that is overridden. When it finds this node it prints the "Reimpliments: Yyy::Xxx()" line in the current function node's documentation. This was not working correctly when the reimplemented function was in a different module. The problem was that the fact that the function in the base class had been documented was not recorded in the index file. This update fixes that problem. Now every element that was documented is given the "documented" attribute in the index file set to true. Sometimes, \reimp is used to say that a function reimplements an access function for a property in a base class. This update handles that case as well. See QToolButton::sizeHint(), for example. This change introduces a 6 new qdoc errors in QtBase about \reimp functions for which a documented base class function was not found. Change-Id: Idd444958c3118ade97642bf84781166e6ca8f036 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc/node.cpp')
-rw-r--r--src/qdoc/node.cpp75
1 files changed, 73 insertions, 2 deletions
diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp
index c664aea63..2ec58dc3a 100644
--- a/src/qdoc/node.cpp
+++ b/src/qdoc/node.cpp
@@ -307,6 +307,7 @@ Node::Node(NodeType type, Aggregate *parent, const QString& name)
status_(Active),
indexNodeFlag_(false),
relatedNonmember_(false),
+ hadDoc_(false),
parent_(parent),
sharedCommentNode_(nullptr),
name_(name)
@@ -1084,7 +1085,7 @@ FunctionNode *Aggregate::findFunctionChild(const QString &name, const Parameters
/*!
Find the function node that is a child of this node, such
that the function described has the same name and signature
- as the function described by the \a clone node.
+ as the function described by the function node \a clone.
*/
FunctionNode *Aggregate::findFunctionChild(const FunctionNode *clone)
{
@@ -1856,7 +1857,7 @@ FunctionNode* ClassNode::findOverriddenFunction(const FunctionNode* fn)
}
if (cn != nullptr) {
FunctionNode *result = cn->findFunctionChild(fn);
- if (result != nullptr && !result->isNonvirtual() && result->hasDoc())
+ if (result != nullptr && !result->isInternal() && !result->isNonvirtual() && result->hasDoc())
return result;
result = cn->findOverriddenFunction(fn);
if (result != nullptr && !result->isNonvirtual())
@@ -1868,6 +1869,44 @@ FunctionNode* ClassNode::findOverriddenFunction(const FunctionNode* fn)
}
/*!
+ \a fn is an overriding function in this class or in a class
+ derived from this class. Find the node for the property that
+ \a fn overrides in this class's children or in one of this
+ class's base classes. Return a pointer to the overridden
+ property or return 0.
+ */
+PropertyNode* ClassNode::findOverriddenProperty(const FunctionNode* fn)
+{
+ QList<RelatedClass>::Iterator bc = bases_.begin();
+ while (bc != bases_.end()) {
+ ClassNode *cn = bc->node_;
+ if (cn == nullptr) {
+ cn = QDocDatabase::qdocDB()->findClassNode(bc->path_);
+ bc->node_ = cn;
+ }
+ if (cn != nullptr) {
+ const NodeList &children = cn->childNodes();
+ NodeList::const_iterator i = children.begin();
+ while (i != children.end()) {
+ if ((*i)->isProperty()) {
+ PropertyNode *pn = static_cast<PropertyNode*>(*i);
+ if (pn->name() == fn->name() || pn->hasAccessFunction(fn->name())) {
+ if (pn->hasDoc())
+ return pn;
+ }
+ }
+ i++;
+ }
+ PropertyNode *result = cn->findOverriddenProperty(fn);
+ if (result != nullptr)
+ return result;
+ }
+ ++bc;
+ }
+ return nullptr;
+}
+
+/*!
Returns true if the class or struct represented by this class
node must be documented. If this function returns true, then
qdoc must find a qdoc comment for this class. If it returns
@@ -2732,6 +2771,38 @@ QString PropertyNode::qualifiedDataType() const
}
}
+/*!
+ Returns true if this property has an access function named \a name.
+ */
+bool PropertyNode::hasAccessFunction(const QString &name) const
+{
+ NodeList::const_iterator i = getters().begin();
+ while (i != getters().end()) {
+ if ((*i)->name() == name)
+ return true;
+ ++i;
+ }
+ i = setters().begin();
+ while (i != setters().end()) {
+ if ((*i)->name() == name)
+ return true;
+ ++i;
+ }
+ i = resetters().begin();
+ while (i != resetters().end()) {
+ if ((*i)->name() == name)
+ return true;
+ ++i;
+ }
+ i = notifiers().begin();
+ while (i != notifiers().end()) {
+ if ((*i)->name() == name)
+ return true;
+ ++i;
+ }
+ return false;
+}
+
bool QmlTypeNode::qmlOnly = false;
QMultiMap<const Node*, Node*> QmlTypeNode::inheritedBy;