From 0ec550c748748fcc94008bc2555482bd614251dc Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 27 May 2015 14:24:26 +0200 Subject: qdoc: Always try to use the declaration location MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qdoc now always tries to use an element's declaration location for the "location," "filepath," and "lineno" attributes in the index file, when it makes sense to use the declaration location. That's pretty much everything in C++. qdoc records both the declaration location and the definition location in the element's tree node. When it writes the element to the index file, it asks for the declaration location. Change-Id: I2d169a0f028bb0d46717e6f822dacc6dd20673b2 Task-number: QTBUG-46034 Reviewed-by: Venugopal Shivashankar Reviewed-by: Topi Reiniƶ --- src/tools/qdoc/node.cpp | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'src/tools/qdoc/node.cpp') diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index dbe397357ce..e58e65a633c 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -682,6 +682,24 @@ const Node* Node::root() const return (parent() ? parent()->root() : this); } +/*! + Sets the node's declaration location, its definition + location, or both, depending on the suffix of the file + name from the file path in location \a t. + */ +void Node::setLocation(const Location& t) +{ + QString suffix = t.fileSuffix(); + if (suffix == "h") + declLocation_ = t; + else if (suffix == "cpp") + defLocation_ = t; + else { + declLocation_ = t; + defLocation_ = t; + } +} + /*! \class Aggregate */ @@ -2278,16 +2296,16 @@ bool QmlPropertyNode::isWritable() if (pn) return pn->isWritable(); else - location().warning(tr("No Q_PROPERTY for QML property %1::%2::%3 " - "in C++ class documented as QML type: " - "(property not found in the C++ class or its base classes)") - .arg(logicalModuleName()).arg(qmlTypeName()).arg(name())); + defLocation().warning(tr("No Q_PROPERTY for QML property %1::%2::%3 " + "in C++ class documented as QML type: " + "(property not found in the C++ class or its base classes)") + .arg(logicalModuleName()).arg(qmlTypeName()).arg(name())); } else - location().warning(tr("No Q_PROPERTY for QML property %1::%2::%3 " - "in C++ class documented as QML type: " - "(C++ class not specified or not found).") - .arg(logicalModuleName()).arg(qmlTypeName()).arg(name())); + defLocation().warning(tr("No Q_PROPERTY for QML property %1::%2::%3 " + "in C++ class documented as QML type: " + "(C++ class not specified or not found).") + .arg(logicalModuleName()).arg(qmlTypeName()).arg(name())); } } return true; -- cgit v1.2.3