qdoc: Correctly resolve non-function links that end in parentheses

If QDoc fails to find a function node for a link target that ends
in parentheses, it must retry to find another type of node, as
page/section titles can sometimes resemble function signatures.

This fixes a regression introduced by commit 8c5ce68f.

Change-Id: I675fe5b93ecc8a1823c0a5f817fb4b80b4e63320
Task-number: QTBUG-47919
Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Reviewed-by: Martin Smith <martin.smith@digia.com>
This commit is contained in:
Topi Reinio 2015-08-25 16:00:01 +02:00 committed by Topi Reiniö
parent 6313ff8a62
commit 72e5fda3bd

View File

@ -306,15 +306,12 @@ const Node* QDocForest::findNodeForTarget(QStringList& targetPath,
{ {
int flags = SearchBaseClasses | SearchEnumValues; int flags = SearchBaseClasses | SearchEnumValues;
QString entity = targetPath.at(0); QString entity = targetPath.takeFirst();
targetPath.removeFirst();
QStringList entityPath = entity.split("::"); QStringList entityPath = entity.split("::");
QString target; QString target;
if (!targetPath.isEmpty()) { if (!targetPath.isEmpty())
target = targetPath.at(0); target = targetPath.takeFirst();
targetPath.removeFirst();
}
foreach (Tree* t, searchOrder()) { foreach (Tree* t, searchOrder()) {
const Node* n = t->findNodeForTarget(entityPath, target, relative, flags, genus, ref); const Node* n = t->findNodeForTarget(entityPath, target, relative, flags, genus, ref);
@ -1703,37 +1700,28 @@ const Node* QDocDatabase::findNodeForAtom(const Atom* a, const Node* relative, Q
function = first.left(position); function = first.left(position);
node = domain->findFunctionNode(function, params, 0, genus); node = domain->findFunctionNode(function, params, 0, genus);
} }
else { if (!node) {
int flags = SearchBaseClasses | SearchEnumValues; int flags = SearchBaseClasses | SearchEnumValues;
QStringList nodePath = first.split("::"); QStringList nodePath = first.split("::");
QString target; QString target;
targetPath.removeFirst(); targetPath.removeFirst();
if (!targetPath.isEmpty()) { if (!targetPath.isEmpty())
target = targetPath.at(0); target = targetPath.takeFirst();
targetPath.removeFirst();
}
if (relative && relative->tree()->physicalModuleName() != domain->physicalModuleName()) if (relative && relative->tree()->physicalModuleName() != domain->physicalModuleName())
relative = 0; relative = 0;
node = domain->findNodeForTarget(nodePath, target, relative, flags, genus, ref); return domain->findNodeForTarget(nodePath, target, relative, flags, genus, ref);
return node;
} }
} }
else { else {
if (first.endsWith(".html")) { if (first.endsWith(".html"))
node = findNodeByNameAndType(QStringList(first), Node::Document); node = findNodeByNameAndType(QStringList(first), Node::Document);
// the path may also refer to an example file with .html extension
if (!node && first.contains("/"))
return findNodeForTarget(targetPath, relative, genus, ref);
}
else if (first.endsWith(QChar(')'))) { else if (first.endsWith(QChar(')'))) {
node = findFunctionNode(first, relative, genus); node = findFunctionNode(first, relative, genus);
if (Generator::debugging()) if (Generator::debugging())
qDebug() << " node:" << node; qDebug() << " node:" << node;
} }
else { if (!node)
node = findNodeForTarget(targetPath, relative, genus, ref); return findNodeForTarget(targetPath, relative, genus, ref);
return node;
}
} }
if (node && ref.isEmpty()) { if (node && ref.isEmpty()) {