qdoc: Fixed three qdoc error problems
authorMartin Smith <martin.smith@nokia.com>
Wed, 9 May 2012 12:04:22 +0000 (14:04 +0200)
committerQt by Nokia <qt-info@nokia.com>
Wed, 9 May 2012 18:10:44 +0000 (20:10 +0200)
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>
src/tools/qdoc/cppcodeparser.cpp
src/tools/qdoc/node.cpp
src/tools/qdoc/node.h
src/tools/qdoc/qmlvisitor.cpp

index 3518881..965455a 100644 (file)
@@ -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()));
index bb593ae..f235753 100644 (file)
@@ -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)
index 8218b22..0b8758d 100644 (file)
@@ -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(); }
index abbea23..a1031f2 100644 (file)
@@ -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;
     }