From 3b6b8a0f749bb20d8e83762060ac87d2ec207562 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 10 May 2012 10:38:42 +0200 Subject: [PATCH] qdoc: Fixed a qdoc error problem When a page exists in more than one file, qdoc was reporting this sometimes without reference to the locations of the files. This has now been fixed. Change-Id: I0697acc170b94a74b15fb384556dd76f764f7792 Reviewed-by: Casper van Donderen --- src/tools/qdoc/cppcodeparser.cpp | 97 +++++++++++++++++++++------------------- src/tools/qdoc/cppcodeparser.h | 13 ++---- src/tools/qdoc/tree.cpp | 14 +++--- 3 files changed, 61 insertions(+), 63 deletions(-) diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp index 965455a..3d2cc60 100644 --- a/src/tools/qdoc/cppcodeparser.cpp +++ b/src/tools/qdoc/cppcodeparser.cpp @@ -695,22 +695,34 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc, } } else if (command == COMMAND_EXTERNALPAGE) { - return new FakeNode(tree_->root(), arg.first, Node::ExternalPage, Node::ArticlePage); + FakeNode* fn = new FakeNode(tree_->root(), arg.first, Node::ExternalPage, Node::ArticlePage); + fn->setLocation(arg.second); + return fn; } else if (command == COMMAND_FILE) { - return new FakeNode(tree_->root(), arg.first, Node::File, Node::NoPageType); + FakeNode* fn = new FakeNode(tree_->root(), arg.first, Node::File, Node::NoPageType); + fn->setLocation(arg.second); + return fn; } else if (command == COMMAND_GROUP) { - return new FakeNode(tree_->root(), arg.first, Node::Group, Node::OverviewPage); + FakeNode* fn = new FakeNode(tree_->root(), arg.first, Node::Group, Node::OverviewPage); + fn->setLocation(arg.second); + return fn; } else if (command == COMMAND_HEADERFILE) { - return new FakeNode(tree_->root(), arg.first, Node::HeaderFile, Node::ApiPage); + FakeNode* fn = new FakeNode(tree_->root(), arg.first, Node::HeaderFile, Node::ApiPage); + fn->setLocation(arg.second); + return fn; } else if (command == COMMAND_MODULE) { - return new FakeNode(tree_->root(), arg.first, Node::Module, Node::OverviewPage); + FakeNode* fn = new FakeNode(tree_->root(), arg.first, Node::Module, Node::OverviewPage); + fn->setLocation(arg.second); + return fn; } else if (command == COMMAND_QMLMODULE) { - return FakeNode::lookupQmlModuleNode(tree_, arg); + FakeNode* fn = FakeNode::lookupQmlModuleNode(tree_, arg); + fn->setLocation(arg.second); + return fn; } else if (command == COMMAND_PAGE) { Node::PageType ptype = Node::ArticlePage; @@ -758,6 +770,7 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc, } else if (command == COMMAND_DITAMAP) { FakeNode* fn = new DitaMapNode(tree_->root(), arg.first); + fn->setLocation(arg.second); return fn; } else if (command == COMMAND_QMLCLASS) { @@ -785,7 +798,9 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc, return qcn; } else if (command == COMMAND_QMLBASICTYPE) { - return new QmlBasicTypeNode(tree_->root(), arg.first); + QmlBasicTypeNode* n = new QmlBasicTypeNode(tree_->root(), arg.first); + n->setLocation(arg.second); + return n; } else if ((command == COMMAND_QMLSIGNAL) || (command == COMMAND_QMLMETHOD) || @@ -794,41 +809,33 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc, QString module; QString element; QString type; - if (splitQmlMethodArg(doc,arg.first,type,module,element)) { + if (splitQmlMethodArg(arg.first,type,module,element)) { QmlClassNode* qmlClass = tree_->findQmlClassNode(module,element); if (qmlClass) { + bool attached = false; + Node::Type nodeType = Node::QmlMethod; if (command == COMMAND_QMLSIGNAL) - return makeFunctionNode(doc, - arg.first, - qmlClass, - Node::QmlSignal, - false, - COMMAND_QMLSIGNAL); - else if (command == COMMAND_QMLATTACHEDSIGNAL) - return makeFunctionNode(doc, - arg.first, - qmlClass, - Node::QmlSignal, - true, - COMMAND_QMLATTACHEDSIGNAL); + nodeType = Node::QmlSignal; + else if (command == COMMAND_QMLATTACHEDSIGNAL) { + nodeType = Node::QmlSignal; + attached = true; + } else if (command == COMMAND_QMLMETHOD) { - return makeFunctionNode(doc, - arg.first, - qmlClass, - Node::QmlMethod, - false, - COMMAND_QMLMETHOD); + // do nothing } else if (command == COMMAND_QMLATTACHEDMETHOD) - return makeFunctionNode(doc, - arg. - first, - qmlClass, - Node::QmlMethod, - true, - COMMAND_QMLATTACHEDMETHOD); + attached = true; else return 0; // never get here. + FunctionNode* fn = makeFunctionNode(doc, + arg.first, + qmlClass, + nodeType, + attached, + command); + if (fn) + fn->setLocation(arg.second); + return fn; } } } @@ -854,8 +861,7 @@ Node* CppCodeParser::processTopicCommand(const Doc& doc, \note The two elements \e{Component} and \e{QtObject} never have a module qualifier. */ -bool CppCodeParser::splitQmlPropertyArg(const Doc& doc, - const QString& arg, +bool CppCodeParser::splitQmlPropertyArg(const QString& arg, QString& type, QString& module, QString& element, @@ -878,11 +884,11 @@ bool CppCodeParser::splitQmlPropertyArg(const Doc& doc, return true; } QString msg = "Unrecognizable QML module/component qualifier for " + arg; - doc.location().warning(tr(msg.toLatin1().data())); + location().warning(tr(msg.toLatin1().data())); } else { QString msg = "Missing property type for " + arg; - doc.location().warning(tr(msg.toLatin1().data())); + location().warning(tr(msg.toLatin1().data())); } return false; } @@ -901,8 +907,7 @@ bool CppCodeParser::splitQmlPropertyArg(const Doc& doc, \note The two elements \e{Component} and \e{QtObject} never have a module qualifier. */ -bool CppCodeParser::splitQmlMethodArg(const Doc& doc, - const QString& arg, +bool CppCodeParser::splitQmlMethodArg(const QString& arg, QString& type, QString& module, QString& element) @@ -935,7 +940,7 @@ bool CppCodeParser::splitQmlMethodArg(const Doc& doc, return true; } QString msg = "Unrecognizable QML module/component qualifier for " + arg; - doc.location().warning(tr(msg.toLatin1().data())); + location().warning(tr(msg.toLatin1().data())); return false; } @@ -945,9 +950,7 @@ bool CppCodeParser::splitQmlMethodArg(const Doc& doc, Currently, this function is called only for \e{qmlproperty} and \e{qmlattachedproperty}. */ -Node *CppCodeParser::processTopicCommandGroup(const Doc& doc, - const QString& command, - const ArgList& args) +Node *CppCodeParser::processTopicCommandGroup(const QString& command, const ArgList& args) { QmlPropGroupNode* qmlPropGroup = 0; if ((command == COMMAND_QMLPROPERTY) || @@ -960,7 +963,7 @@ Node *CppCodeParser::processTopicCommandGroup(const Doc& doc, bool attached = (command == COMMAND_QMLATTACHEDPROPERTY); ArgList::ConstIterator argsIter = args.begin(); arg = argsIter->first; - if (splitQmlPropertyArg(doc,arg,type,module,element,property)) { + if (splitQmlPropertyArg(arg,type,module,element,property)) { QmlClassNode* qmlClass = tree_->findQmlClassNode(module,element); if (qmlClass) { qmlPropGroup = new QmlPropGroupNode(qmlClass,property); //,attached); @@ -984,7 +987,7 @@ Node *CppCodeParser::processTopicCommandGroup(const Doc& doc, ++argsIter; while (argsIter != args.end()) { arg = argsIter->first; - if (splitQmlPropertyArg(doc,arg,type,module,element,property)) { + if (splitQmlPropertyArg(arg,type,module,element,property)) { QmlPropertyNode* qmlPropNode = new QmlPropertyNode(qmlPropGroup, property, type, @@ -2296,7 +2299,7 @@ bool CppCodeParser::matchDocsAndStuff() if ((topic == COMMAND_QMLPROPERTY) || (topic == COMMAND_QMLATTACHEDPROPERTY)) { Doc nodeDoc = doc; - Node *node = processTopicCommandGroup(nodeDoc,topic,args); + Node *node = processTopicCommandGroup(topic,args); if (node != 0) { nodes.append(node); docs.append(nodeDoc); diff --git a/src/tools/qdoc/cppcodeparser.h b/src/tools/qdoc/cppcodeparser.h index 0f4b511..6ae7116 100644 --- a/src/tools/qdoc/cppcodeparser.h +++ b/src/tools/qdoc/cppcodeparser.h @@ -89,23 +89,16 @@ protected: virtual Node *processTopicCommand(const Doc& doc, const QString& command, const ArgLocPair& arg); -#ifdef QDOC_QML - // might need to implement this in QsCodeParser as well. - virtual Node *processTopicCommandGroup(const Doc& doc, - const QString& command, - const ArgList& args); - bool splitQmlPropertyArg(const Doc& doc, - const QString& arg, + virtual Node *processTopicCommandGroup(const QString& command, const ArgList& args); + bool splitQmlPropertyArg(const QString& arg, QString& type, QString& module, QString& element, QString& name); - bool splitQmlMethodArg(const Doc& doc, - const QString& arg, + bool splitQmlMethodArg(const QString& arg, QString& type, QString& module, QString& element); -#endif virtual QSet otherMetaCommands(); virtual void processOtherMetaCommand(const Doc& doc, const QString& command, diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp index c4cc78a..d0a2123 100644 --- a/src/tools/qdoc/tree.cpp +++ b/src/tools/qdoc/tree.cpp @@ -430,8 +430,8 @@ static const char* const suffixes[NumSuffixes] = { "", "s", "es" }; /*! This function searches for a node with the specified \a title. - If \a relative is provided, use it to disambiguate if it has a - QML module identifier. + If \a relative node is provided, it is used to disambiguate if + it has a QML module identifier. */ const FakeNode* Tree::findFakeNodeByTitle(const QString& title, const Node* relative ) const { @@ -470,14 +470,13 @@ const FakeNode* Tree::findFakeNodeByTitle(const QString& title, const Node* rela QList internalLocations; while (j != priv->fakeNodesByTitle.constEnd()) { if (j.key() == i.key() && j.value()->url().isEmpty()) - internalLocations.append(j.value()->doc().location()); + internalLocations.append(j.value()->location()); ++j; } if (internalLocations.size() > 0) { - i.value()->doc().location().warning( - tr("Page '%1' defined in more than one location:").arg(title)); + i.value()->location().warning(tr("This page exists in more than one file: \"%1\"").arg(title)); foreach (const Location &location, internalLocations) - location.warning(tr("(defined here)")); + location.warning(tr("[It also exists here]")); } } return i.value(); @@ -601,6 +600,8 @@ NodeMultiMap Tree::groups() const } /*! + This function adds the \a group name to the list of groups + for the \a node name. It also adds the \a node to the \a group. */ void Tree::addToPublicGroup(Node* node, const QString& group) { @@ -609,6 +610,7 @@ void Tree::addToPublicGroup(Node* node, const QString& group) } /*! + Returns the public group map. */ QMultiMap Tree::publicGroups() const { -- 2.7.4