qdoc: Fixed linking for overloaded functions

qdoc was failing to create links when a \l command referred
to a function that has an undocumented overload with no
parameters. qdoc would choose that internal function to be
the target, but the link construction would fail.

qdoc now checks the status of the overload that is matched.
If the matching function is marked internal, qdoc keeps
looking for one that is not marked internal.

Change-Id: Iebf296e79dc2554e54f00ef72b6f6c1ba7074f06
Task-number: QTBUG-47991
Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
This commit is contained in:
Martin Smith 2015-08-31 12:52:26 +02:00
parent e979ca5eda
commit d3f0bee885
2 changed files with 26 additions and 19 deletions

View File

@ -817,7 +817,7 @@ FunctionNode *Aggregate::findFunctionNode(const QString& name, const QString& pa
FunctionNode* fn = pfn;
if (fn) {
const QVector<Parameter>* funcParams = &(fn->parameters());
if (params.isEmpty() && funcParams->isEmpty())
if (params.isEmpty() && funcParams->isEmpty() && !fn->isInternal())
return fn;
bool isQPrivateSignal = false; // Not used in the search
QVector<Parameter> testParams;
@ -829,7 +829,7 @@ FunctionNode *Aggregate::findFunctionNode(const QString& name, const QString& pa
int i = -1;
while (fn) {
if (testParams.size() == funcParams->size()) {
if (testParams.isEmpty())
if (testParams.isEmpty() && !fn->isInternal())
return fn;
bool different = false;
for (int j=0; j<testParams.size(); j++) {
@ -838,7 +838,7 @@ FunctionNode *Aggregate::findFunctionNode(const QString& name, const QString& pa
break;
}
}
if (!different)
if (!different && !fn->isInternal())
return fn;
}
if (++i < funcs.size()) {
@ -848,19 +848,30 @@ FunctionNode *Aggregate::findFunctionNode(const QString& name, const QString& pa
else
fn = 0;
}
if (!fn && !testParams.empty())
return 0;
/*
Most \l commands that link to functions don't include
the parameter declarations in the function signature,
so if the \l is meant to go to a function that does
have parameters, the algorithm above won't find it.
Therefore we must return the pointer to the function
in the primary function map in the cases where the
parameters should have been specified in the \l command.
But if the primary function is marked internal, search
the secondary list to find one that is not marked internal.
*/
if (!fn) {
if (!testParams.empty())
return 0;
if (pfn && !pfn->isInternal())
return pfn;
foreach (Node* n, funcs) {
fn = static_cast<FunctionNode*>(n);
if (!fn->isInternal())
return fn;
}
}
}
/*
Most \l commands that link to functions don't include
the parameter declarations in the function signature,
so if the \l is meant to go to a function that does
have parameters, the algorithm above won't find it.
Therefore we must return the pointer to the function
in the primary function map in the cases where the
parameters should have been specified in the \l command.
*/
return (fn ? fn : pfn);
return fn;
}
/*!

View File

@ -1673,8 +1673,6 @@ const Node* QDocDatabase::findNodeForAtom(const Atom* a, const Node* relative, Q
Atom* atom = const_cast<Atom*>(a);
QStringList targetPath = atom->string().split("#");
QString first = targetPath.first().trimmed();
if (Generator::debugging())
qDebug() << " first:" << first;
Tree* domain = 0;
Node::Genus genus = Node::DontCare;
@ -1725,8 +1723,6 @@ const Node* QDocDatabase::findNodeForAtom(const Atom* a, const Node* relative, Q
}
else if (first.endsWith(QChar(')'))) {
node = findFunctionNode(first, relative, genus);
if (Generator::debugging())
qDebug() << " node:" << node;
}
else {
node = findNodeForTarget(targetPath, relative, genus, ref);