diff options
author | Martin Smith <martin.smith@nokia.com> | 2012-05-09 14:04:22 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-09 20:10:44 +0200 |
commit | 81c68fe029adb857eb6ea6ed4c910bf97fc0755f (patch) | |
tree | 82ea1248f87750f3a3f0bf95814e1c46bdf9c5b6 /src | |
parent | 66ca9382c978bba137219df86b677c9fdc0d4d1c (diff) |
qdoc: Fixed three qdoc error problems
1. For QML properties documented in a .qml file,
qdoc no longer prints the error message that it
can't detect whether the property is read-only.
2. For QML properties documented in .cpp files,
qdoc now includes the file path and line number,
when it prints the error that it can't detect
whether the property is read-only.
3. qdoc also includes the completely qualified
property name in the error messages described
in 2.
Change-Id: If88381783fd0f29271f579ae170a0a6f4b1a7344
Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/qdoc/cppcodeparser.cpp | 5 | ||||
-rw-r--r-- | src/tools/qdoc/node.cpp | 22 | ||||
-rw-r--r-- | src/tools/qdoc/node.h | 6 | ||||
-rw-r--r-- | src/tools/qdoc/qmlvisitor.cpp | 16 |
4 files changed, 29 insertions, 20 deletions
diff --git a/src/tools/qdoc/cppcodeparser.cpp b/src/tools/qdoc/cppcodeparser.cpp index 3518881a87..965455a3d5 100644 --- a/src/tools/qdoc/cppcodeparser.cpp +++ b/src/tools/qdoc/cppcodeparser.cpp @@ -964,11 +964,14 @@ Node *CppCodeParser::processTopicCommandGroup(const Doc& doc, QmlClassNode* qmlClass = tree_->findQmlClassNode(module,element); if (qmlClass) { qmlPropGroup = new QmlPropGroupNode(qmlClass,property); //,attached); + qmlPropGroup->setLocation(location()); } } if (qmlPropGroup) { ClassNode *correspondingClass = static_cast<QmlClassNode*>(qmlPropGroup->parent())->classNode(); QmlPropertyNode *qmlPropNode = new QmlPropertyNode(qmlPropGroup,property,type,attached); + qmlPropNode->setLocation(location()); + qmlPropNode->setQPropertyFlag(); const PropertyNode *correspondingProperty = 0; if (correspondingClass) { @@ -986,6 +989,8 @@ Node *CppCodeParser::processTopicCommandGroup(const Doc& doc, property, type, attached); + qmlPropNode->setLocation(location()); + qmlPropNode->setQPropertyFlag(); if (correspondingProperty) { bool writableList = type.startsWith("list") && correspondingProperty->dataType().endsWith('*'); qmlPropNode->setReadOnly(!(writableList || correspondingProperty->isWritable())); diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index bb593ae466..f235753ccd 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -2294,6 +2294,7 @@ QmlPropertyNode::QmlPropertyNode(QmlPropGroupNode *parent, designable_(FlagValueDefault), isdefault_(false), attached_(attached), + qproperty_(false), readOnly_(FlagValueDefault) { setPageType(ApiPage); @@ -2313,6 +2314,7 @@ QmlPropertyNode::QmlPropertyNode(QmlClassNode *parent, designable_(FlagValueDefault), isdefault_(false), attached_(attached), + qproperty_(false), readOnly_(FlagValueDefault) { setPageType(ApiPage); @@ -2339,6 +2341,7 @@ QmlPropertyNode::QmlPropertyNode(QmlPropertyNode* parent, designable_(FlagValueDefault), isdefault_(false), attached_(attached), + qproperty_(false), readOnly_(FlagValueDefault) { setPageType(ApiPage); @@ -2353,18 +2356,19 @@ QmlPropertyNode::QmlPropertyNode(QmlPropertyNode* parent, */ bool QmlPropertyNode::isWritable(Tree* tree) { - if (readOnly_ != FlagValueDefault) { + if (readOnly_ != FlagValueDefault) return !fromFlagValue(readOnly_, false); - } - PropertyNode* pn = correspondingProperty(tree); - if (pn) { - return pn->isWritable(); - } - else { - location().warning(tr("Can't detect if QML property %1 is read-only; writable assumed.").arg(name())); - return true; + if (qproperty_) { + PropertyNode* pn = correspondingProperty(tree); + if (pn) + return pn->isWritable(); + + location().warning(tr("Can't detect if QML property %1::%2::%3 is read-only; " + "writable assumed.") + .arg(qmlModuleIdentifier()).arg(qmlTypeName()).arg(name())); } + return true; } PropertyNode* QmlPropertyNode::correspondingProperty(Tree *tree) diff --git a/src/tools/qdoc/node.h b/src/tools/qdoc/node.h index 8218b22fc3..0b8758d92f 100644 --- a/src/tools/qdoc/node.h +++ b/src/tools/qdoc/node.h @@ -230,6 +230,7 @@ public: QString guid() const; QString ditaXmlHref(); QString extractClassName(const QString &string) const; + virtual QString qmlTypeName() const { return name_; } virtual QString qmlModuleName() const { return qmlModuleName_; } virtual QString qmlModuleVersion() const { return qmlModuleVersionMajor_ + "." + qmlModuleVersionMinor_; } virtual QString qmlModuleIdentifier() const { return qmlModuleName_ + qmlModuleVersionMajor_; } @@ -579,6 +580,7 @@ public: virtual ~QmlPropGroupNode() { } virtual bool isQmlNode() const { return true; } virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); } + virtual QString qmlTypeName() const { return parent()->qmlTypeName(); } virtual QString qmlModuleName() const { return parent()->qmlModuleName(); } virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); } virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); } @@ -626,6 +628,7 @@ public: virtual bool isAttached() const { return attached_; } virtual bool isQmlNode() const { return true; } virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); } + virtual QString qmlTypeName() const { return parent()->qmlTypeName(); } virtual QString qmlModuleName() const { return parent()->qmlModuleName(); } virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); } virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); } @@ -635,6 +638,7 @@ public: const QString& element() const { return static_cast<QmlPropGroupNode*>(parent())->element(); } void appendQmlPropNode(QmlPropertyNode* p) { qmlPropNodes_.append(p); } const NodeList& qmlPropNodes() const { return qmlPropNodes_; } + void setQPropertyFlag() { qproperty_ = true; } private: QString type_; @@ -642,6 +646,7 @@ private: FlagValue designable_; bool isdefault_; bool attached_; + bool qproperty_; FlagValue readOnly_; NodeList qmlPropNodes_; }; @@ -803,6 +808,7 @@ public: (type() == QmlSignalHandler)); } virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); } + virtual QString qmlTypeName() const { return parent()->qmlTypeName(); } virtual QString qmlModuleName() const { return parent()->qmlModuleName(); } virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); } virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); } diff --git a/src/tools/qdoc/qmlvisitor.cpp b/src/tools/qdoc/qmlvisitor.cpp index abbea236e4..a1031f2e83 100644 --- a/src/tools/qdoc/qmlvisitor.cpp +++ b/src/tools/qdoc/qmlvisitor.cpp @@ -242,7 +242,11 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::AST::SourceLocation, QmlPropArgs qpa; if (splitQmlPropertyArg(doc, topicsUsed.at(i).args, qpa)) { QmlPropertyNode* n = new QmlPropertyNode(qpn, qpa.name_, qpa.type_, false); + n->setLocation(doc.location()); qpn->appendQmlPropNode(n); + n->setReadOnly(qpn->isReadOnly()); + if (qpn->isDefault()) + n->setDefault(); } else qDebug() << " FAILED TO PARSE QML PROPERTY:" @@ -484,22 +488,12 @@ bool QmlDocVisitor::visit(QQmlJS::AST::UiPublicMember *member) if (qmlClass) { QString name = member->name.toString(); QmlPropertyNode *qmlPropNode = new QmlPropertyNode(qmlClass, name, type, false); + //qmlPropNode->setLocation(doc.location()); qmlPropNode->setReadOnly(member->isReadonlyMember); if (member->isDefaultMember) qmlPropNode->setDefault(); applyDocumentation(member->firstSourceLocation(), qmlPropNode); } -#if 0 - if (qmlClass) { - QString name = member->name->asString(); - QmlPropGroupNode *qmlPropGroup = new QmlPropGroupNode(qmlClass, name, false); - if (member->isDefaultMember) - qmlPropGroup->setDefault(); - QmlPropertyNode *qmlPropNode = new QmlPropertyNode(qmlPropGroup, name, type, false); - qmlPropNode->setWritable(!member->isReadonlyMember); - applyDocumentation(member->firstSourceLocation(), qmlPropGroup); - } -#endif } break; } |