summaryrefslogtreecommitdiffstats
path: root/src/tools/qdoc/qdocdatabase.cpp
diff options
context:
space:
mode:
authorMartin Smith <[email protected]>2015-03-04 11:48:51 +0100
committerMartin Smith <[email protected]>2015-03-07 09:47:23 +0000
commit100ffb60ef07e026a054b9df9007ec1b25698c90 (patch)
tree9f13a82559149a25a3d6d511d6cb6ead56b32f1e /src/tools/qdoc/qdocdatabase.cpp
parent94bad40392ad89489744e4d59889fa0e920063b4 (diff)
qdoc: Teach qdoc to resolve namespaces
It turns out this bug was caused by modularization, which created the situation where members of the Qt namespace are in different modules. Most are in QtCore, but a few are in QtGui. qdoc was creating a namespace node for the Qt namespace in the node tree for QtCore, and another namespace node in the node tree for QtGui. This meant that there were two NamespaceNodes for the Qt namespace. Correctly, only one of these nodes contained the text for the \namespace command for the Qt namespace. This was the namespace node that was being used to create the HTML reference page for the Qt namespace. Unfortunately, the Qt namespace node in the tree for QtGui was not being merged into the Qt namespace node in QtCore, so some of the members of the Qt namespace were not being shown on the reference page. This update teches qdoc how to merge namespace nodes to ensure that all the members appear on the reference page for the namespace. There can be a namespace node for the namespace xxx in any number of modules, but they will all be merged into the namespace node for namespace xxx that contains the qdoc comment for \namespace xxx. Change-Id: I0f6a653ea6f920aacd5d8e13f9865488d95f6458 Task-number: QTBUG-44688 Reviewed-by: Topi Reiniƶ <[email protected]>
Diffstat (limited to 'src/tools/qdoc/qdocdatabase.cpp')
-rw-r--r--src/tools/qdoc/qdocdatabase.cpp71
1 files changed, 57 insertions, 14 deletions
diff --git a/src/tools/qdoc/qdocdatabase.cpp b/src/tools/qdoc/qdocdatabase.cpp
index 75295613f70..30d4d28a173 100644
--- a/src/tools/qdoc/qdocdatabase.cpp
+++ b/src/tools/qdoc/qdocdatabase.cpp
@@ -796,7 +796,6 @@ void QDocDatabase::processForest()
{
Tree* t = forest_.firstTree();
while (t) {
- findAllNamespaces(t->root());
findAllClasses(t->root());
findAllFunctions(t->root());
findAllObsoleteThings(t->root());
@@ -805,6 +804,7 @@ void QDocDatabase::processForest()
t->setTreeHasBeenAnalyzed();
t = forest_.nextTree();
}
+ resolveNamespaces();
}
/*!
@@ -872,16 +872,10 @@ NodeMap& QDocDatabase::getQmlTypesWithObsoleteMembers()
return qmlTypesWithObsoleteMembers_;
}
-/*!
- Constructs the C++ namespace data structure, if it has not
- already been constructed. Returns a reference to it.
+/*! \fn NodeMap& QDocDatabase::getNamespaces()
+ Returns a reference to the map of all namespace nodes.
+ This function must not be called in the -prepare phase.
*/
-NodeMap& QDocDatabase::getNamespaces()
-{
- if (namespaceIndex_.isEmpty())
- processForest(&QDocDatabase::findAllNamespaces);
- return namespaceIndex_;
-}
/*!
Construct the C++ class data structures, if they have not
@@ -1082,14 +1076,15 @@ void QDocDatabase::findAllNamespaces(InnerNode* node)
{
NodeList::ConstIterator c = node->childNodes().constBegin();
while (c != node->childNodes().constEnd()) {
- if ((*c)->access() != Node::Private) {
+ if ((*c)->access() != Node::Private || (*c)->isNamespace()) {
if ((*c)->isInnerNode()) {
findAllNamespaces(static_cast<InnerNode *>(*c));
- if ((*c)->type() == Node::Namespace) {
+ if ((*c)->isNamespace()) {
// Ensure that the namespace's name is not empty (the root
// namespace has no name).
- if (!(*c)->name().isEmpty())
- namespaceIndex_.insert((*c)->name(), *c);
+ if (!(*c)->name().isEmpty()) {
+ nmm_.insert((*c)->name(), *c);
+ }
}
}
}
@@ -1332,8 +1327,56 @@ void QDocDatabase::resolveStuff()
//primaryTree()->resolveTargets(primaryTreeRoot());
primaryTree()->resolveCppToQmlLinks();
primaryTree()->resolveUsingClauses();
+ resolveNamespaces();
+}
+
+/*!
+ */
+void QDocDatabase::resolveNamespaces()
+{
+ if (!namespaceIndex_.isEmpty())
+ return;
+ Tree* t = forest_.firstTree();
+ while (t) {
+ findAllNamespaces(t->root());
+ t = forest_.nextTree();
+ }
+ QList<QString> keys = nmm_.uniqueKeys();
+ foreach (QString s, keys) {
+ NamespaceNode* ns = 0;
+ QList<Node*> nodes = nmm_.values(s);
+ int count = nmm_.remove(s);
+ if (count > 1) {
+ foreach (Node* n, nodes) {
+ if (n->isNamespace() && n->wasSeen()) {
+ ns = static_cast<NamespaceNode*>(n);
+ break;
+ }
+ }
+ }
+ else if (count == 1)
+ ns = static_cast<NamespaceNode*>(nodes.at(0));
+ if (ns && ns->wasSeen()) {
+ if (count >1) {
+ foreach (Node* n, nodes) {
+ if (n->isNamespace()) {
+ NamespaceNode* NS = static_cast<NamespaceNode*>(n);
+ if (NS != ns) {
+ while (!NS->childNodes().isEmpty()) {
+ Node* child = NS->childNodes().first();
+ NS->removeChild(child);
+ ns->addChild(child);
+ }
+ }
+ }
+ }
+ }
+ namespaceIndex_.insert(ns->name(), ns);
+ }
+ }
}
+
/*!
This function is called for autolinking to a \a type,
which could be a function return type or a parameter