From 8c5ce68fcf09d128072c31d74878fcb0fd9b9c7a Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 6 Aug 2015 13:47:44 +0200 Subject: qdoc: Allow formal parameters in link targets This update allows qdoc to handle \l commands for linking to functions, where the formal parameters are included in the link target. For example, \l {QWidget::find(QString name)} will only match a member function of QWidget that has a single parameter of type QString. The parameter name is not used in the search. Change-Id: I8a31c9a7ed632f12a0e6d8a33cbb5cd361098317 Task-number: QTBUG-47286 Reviewed-by: Martin Smith --- src/tools/qdoc/tree.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/tools/qdoc/tree.cpp') diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp index e0fd68d2e70..d64903e61ed 100644 --- a/src/tools/qdoc/tree.cpp +++ b/src/tools/qdoc/tree.cpp @@ -220,6 +220,7 @@ QmlTypeNode* Tree::findQmlTypeNode(const QStringList& path) used as the starting point. */ const FunctionNode* Tree::findFunctionNode(const QStringList& path, + const QString& params, const Node* relative, int findFlags, Node::Genus genus) const @@ -234,7 +235,7 @@ const FunctionNode* Tree::findFunctionNode(const QStringList& path, qcn = static_cast(n); } if (qcn) - return static_cast(qcn->findFunctionNode(path[2])); + return static_cast(qcn->findFunctionNode(path[2], params)); } if (!relative) @@ -254,7 +255,7 @@ const FunctionNode* Tree::findFunctionNode(const QStringList& path, const Node* next; if (i == path.size() - 1) - next = ((const Aggregate*) node)->findFunctionNode(path.at(i)); + next = ((const Aggregate*) node)->findFunctionNode(path.at(i), params); else next = ((const Aggregate*) node)->findChildNode(path.at(i), genus); @@ -262,7 +263,7 @@ const FunctionNode* Tree::findFunctionNode(const QStringList& path, NodeList baseClasses = allBaseClasses(static_cast(node)); foreach (const Node* baseClass, baseClasses) { if (i == path.size() - 1) - next = static_cast(baseClass)->findFunctionNode(path.at(i)); + next = static_cast(baseClass)->findFunctionNode(path.at(i), params); else next = static_cast(baseClass)->findChildNode(path.at(i), genus); @@ -1452,13 +1453,17 @@ void Tree::insertQmlType(const QString& key, QmlTypeNode* n) Split \a target on "::" and find the function node with that path. */ -const Node* Tree::findFunctionNode(const QString& target, const Node* relative, Node::Genus genus) +const Node* Tree::findFunctionNode(const QString& target, + const QString& params, + const Node* relative, + Node::Genus genus) const { QString t = target; - if (t.endsWith("()")) + if (t.endsWith("()")) { t.chop(2); + } QStringList path = t.split("::"); - const FunctionNode* fn = findFunctionNode(path, relative, SearchBaseClasses, genus); + const FunctionNode* fn = findFunctionNode(path, params, relative, SearchBaseClasses, genus); if (fn && fn->metaness() != FunctionNode::MacroWithoutParams) return fn; return 0; -- cgit v1.2.3