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>
This commit is contained in:
Martin Smith 2012-05-09 14:04:22 +02:00 committed by Qt by Nokia
parent 66ca9382c9
commit 81c68fe029
4 changed files with 29 additions and 20 deletions

View File

@ -964,11 +964,14 @@ Node *CppCodeParser::processTopicCommandGroup(const Doc& doc,
QmlClassNode* qmlClass = tree_->findQmlClassNode(module,element); QmlClassNode* qmlClass = tree_->findQmlClassNode(module,element);
if (qmlClass) { if (qmlClass) {
qmlPropGroup = new QmlPropGroupNode(qmlClass,property); //,attached); qmlPropGroup = new QmlPropGroupNode(qmlClass,property); //,attached);
qmlPropGroup->setLocation(location());
} }
} }
if (qmlPropGroup) { if (qmlPropGroup) {
ClassNode *correspondingClass = static_cast<QmlClassNode*>(qmlPropGroup->parent())->classNode(); ClassNode *correspondingClass = static_cast<QmlClassNode*>(qmlPropGroup->parent())->classNode();
QmlPropertyNode *qmlPropNode = new QmlPropertyNode(qmlPropGroup,property,type,attached); QmlPropertyNode *qmlPropNode = new QmlPropertyNode(qmlPropGroup,property,type,attached);
qmlPropNode->setLocation(location());
qmlPropNode->setQPropertyFlag();
const PropertyNode *correspondingProperty = 0; const PropertyNode *correspondingProperty = 0;
if (correspondingClass) { if (correspondingClass) {
@ -986,6 +989,8 @@ Node *CppCodeParser::processTopicCommandGroup(const Doc& doc,
property, property,
type, type,
attached); attached);
qmlPropNode->setLocation(location());
qmlPropNode->setQPropertyFlag();
if (correspondingProperty) { if (correspondingProperty) {
bool writableList = type.startsWith("list") && correspondingProperty->dataType().endsWith('*'); bool writableList = type.startsWith("list") && correspondingProperty->dataType().endsWith('*');
qmlPropNode->setReadOnly(!(writableList || correspondingProperty->isWritable())); qmlPropNode->setReadOnly(!(writableList || correspondingProperty->isWritable()));

View File

@ -2294,6 +2294,7 @@ QmlPropertyNode::QmlPropertyNode(QmlPropGroupNode *parent,
designable_(FlagValueDefault), designable_(FlagValueDefault),
isdefault_(false), isdefault_(false),
attached_(attached), attached_(attached),
qproperty_(false),
readOnly_(FlagValueDefault) readOnly_(FlagValueDefault)
{ {
setPageType(ApiPage); setPageType(ApiPage);
@ -2313,6 +2314,7 @@ QmlPropertyNode::QmlPropertyNode(QmlClassNode *parent,
designable_(FlagValueDefault), designable_(FlagValueDefault),
isdefault_(false), isdefault_(false),
attached_(attached), attached_(attached),
qproperty_(false),
readOnly_(FlagValueDefault) readOnly_(FlagValueDefault)
{ {
setPageType(ApiPage); setPageType(ApiPage);
@ -2339,6 +2341,7 @@ QmlPropertyNode::QmlPropertyNode(QmlPropertyNode* parent,
designable_(FlagValueDefault), designable_(FlagValueDefault),
isdefault_(false), isdefault_(false),
attached_(attached), attached_(attached),
qproperty_(false),
readOnly_(FlagValueDefault) readOnly_(FlagValueDefault)
{ {
setPageType(ApiPage); setPageType(ApiPage);
@ -2353,18 +2356,19 @@ QmlPropertyNode::QmlPropertyNode(QmlPropertyNode* parent,
*/ */
bool QmlPropertyNode::isWritable(Tree* tree) bool QmlPropertyNode::isWritable(Tree* tree)
{ {
if (readOnly_ != FlagValueDefault) { if (readOnly_ != FlagValueDefault)
return !fromFlagValue(readOnly_, false); return !fromFlagValue(readOnly_, false);
}
PropertyNode* pn = correspondingProperty(tree); if (qproperty_) {
if (pn) { PropertyNode* pn = correspondingProperty(tree);
return pn->isWritable(); if (pn)
} return pn->isWritable();
else {
location().warning(tr("Can't detect if QML property %1 is read-only; writable assumed.").arg(name())); location().warning(tr("Can't detect if QML property %1::%2::%3 is read-only; "
return true; "writable assumed.")
.arg(qmlModuleIdentifier()).arg(qmlTypeName()).arg(name()));
} }
return true;
} }
PropertyNode* QmlPropertyNode::correspondingProperty(Tree *tree) PropertyNode* QmlPropertyNode::correspondingProperty(Tree *tree)

View File

@ -230,6 +230,7 @@ public:
QString guid() const; QString guid() const;
QString ditaXmlHref(); QString ditaXmlHref();
QString extractClassName(const QString &string) const; QString extractClassName(const QString &string) const;
virtual QString qmlTypeName() const { return name_; }
virtual QString qmlModuleName() const { return qmlModuleName_; } virtual QString qmlModuleName() const { return qmlModuleName_; }
virtual QString qmlModuleVersion() const { return qmlModuleVersionMajor_ + "." + qmlModuleVersionMinor_; } virtual QString qmlModuleVersion() const { return qmlModuleVersionMajor_ + "." + qmlModuleVersionMinor_; }
virtual QString qmlModuleIdentifier() const { return qmlModuleName_ + qmlModuleVersionMajor_; } virtual QString qmlModuleIdentifier() const { return qmlModuleName_ + qmlModuleVersionMajor_; }
@ -579,6 +580,7 @@ public:
virtual ~QmlPropGroupNode() { } virtual ~QmlPropGroupNode() { }
virtual bool isQmlNode() const { return true; } virtual bool isQmlNode() const { return true; }
virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); } virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); }
virtual QString qmlTypeName() const { return parent()->qmlTypeName(); }
virtual QString qmlModuleName() const { return parent()->qmlModuleName(); } virtual QString qmlModuleName() const { return parent()->qmlModuleName(); }
virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); } virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); }
virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); } virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); }
@ -626,6 +628,7 @@ public:
virtual bool isAttached() const { return attached_; } virtual bool isAttached() const { return attached_; }
virtual bool isQmlNode() const { return true; } virtual bool isQmlNode() const { return true; }
virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); } virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); }
virtual QString qmlTypeName() const { return parent()->qmlTypeName(); }
virtual QString qmlModuleName() const { return parent()->qmlModuleName(); } virtual QString qmlModuleName() const { return parent()->qmlModuleName(); }
virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); } virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); }
virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); } virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); }
@ -635,6 +638,7 @@ public:
const QString& element() const { return static_cast<QmlPropGroupNode*>(parent())->element(); } const QString& element() const { return static_cast<QmlPropGroupNode*>(parent())->element(); }
void appendQmlPropNode(QmlPropertyNode* p) { qmlPropNodes_.append(p); } void appendQmlPropNode(QmlPropertyNode* p) { qmlPropNodes_.append(p); }
const NodeList& qmlPropNodes() const { return qmlPropNodes_; } const NodeList& qmlPropNodes() const { return qmlPropNodes_; }
void setQPropertyFlag() { qproperty_ = true; }
private: private:
QString type_; QString type_;
@ -642,6 +646,7 @@ private:
FlagValue designable_; FlagValue designable_;
bool isdefault_; bool isdefault_;
bool attached_; bool attached_;
bool qproperty_;
FlagValue readOnly_; FlagValue readOnly_;
NodeList qmlPropNodes_; NodeList qmlPropNodes_;
}; };
@ -803,6 +808,7 @@ public:
(type() == QmlSignalHandler)); (type() == QmlSignalHandler));
} }
virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); } virtual bool isQtQuickNode() const { return parent()->isQtQuickNode(); }
virtual QString qmlTypeName() const { return parent()->qmlTypeName(); }
virtual QString qmlModuleName() const { return parent()->qmlModuleName(); } virtual QString qmlModuleName() const { return parent()->qmlModuleName(); }
virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); } virtual QString qmlModuleVersion() const { return parent()->qmlModuleVersion(); }
virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); } virtual QString qmlModuleIdentifier() const { return parent()->qmlModuleIdentifier(); }

View File

@ -242,7 +242,11 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::AST::SourceLocation,
QmlPropArgs qpa; QmlPropArgs qpa;
if (splitQmlPropertyArg(doc, topicsUsed.at(i).args, qpa)) { if (splitQmlPropertyArg(doc, topicsUsed.at(i).args, qpa)) {
QmlPropertyNode* n = new QmlPropertyNode(qpn, qpa.name_, qpa.type_, false); QmlPropertyNode* n = new QmlPropertyNode(qpn, qpa.name_, qpa.type_, false);
n->setLocation(doc.location());
qpn->appendQmlPropNode(n); qpn->appendQmlPropNode(n);
n->setReadOnly(qpn->isReadOnly());
if (qpn->isDefault())
n->setDefault();
} }
else else
qDebug() << " FAILED TO PARSE QML PROPERTY:" qDebug() << " FAILED TO PARSE QML PROPERTY:"
@ -484,22 +488,12 @@ bool QmlDocVisitor::visit(QQmlJS::AST::UiPublicMember *member)
if (qmlClass) { if (qmlClass) {
QString name = member->name.toString(); QString name = member->name.toString();
QmlPropertyNode *qmlPropNode = new QmlPropertyNode(qmlClass, name, type, false); QmlPropertyNode *qmlPropNode = new QmlPropertyNode(qmlClass, name, type, false);
//qmlPropNode->setLocation(doc.location());
qmlPropNode->setReadOnly(member->isReadonlyMember); qmlPropNode->setReadOnly(member->isReadonlyMember);
if (member->isDefaultMember) if (member->isDefaultMember)
qmlPropNode->setDefault(); qmlPropNode->setDefault();
applyDocumentation(member->firstSourceLocation(), qmlPropNode); 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; break;
} }