From 8b10e8c198baa53f892c65d2e41c56df751ff7b8 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 5 Mar 2013 10:52:16 +0100 Subject: [PATCH] qdoc: Maintain correct nesting level for QML parsing qdoc was not incrementing the nesting level when parsing a UiObjectBinding, which can contain a component definition. qdoc now increments the nesting level when starting to vidit a UiObjectBinding and decrements it when ending the visit. Note this fix does not stop qdoc from reporting that public signal handlers have not been documented. If that is to be changed, it will be done separately. Task-number: QTBUG-29993 Change-Id: Ibd5ef81082e989652b3a15dcc95080a2757e0077 Reviewed-by: J-P Nurmi --- src/tools/qdoc/qmlvisitor.cpp | 32 ++++++++++++++++++++++++++++---- src/tools/qdoc/qmlvisitor.h | 5 +++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/tools/qdoc/qmlvisitor.cpp b/src/tools/qdoc/qmlvisitor.cpp index 8b6f81de3e..058ab9a725 100644 --- a/src/tools/qdoc/qmlvisitor.cpp +++ b/src/tools/qdoc/qmlvisitor.cpp @@ -424,8 +424,9 @@ bool QmlDocVisitor::visit(QQmlJS::AST::UiObjectDefinition *definition) */ void QmlDocVisitor::endVisit(QQmlJS::AST::UiObjectDefinition *definition) { - if (nestingLevel > 0) + if (nestingLevel > 0) { --nestingLevel; + } lastEndOffset = definition->lastSourceLocation().end(); } @@ -461,6 +462,26 @@ void QmlDocVisitor::endVisit(QQmlJS::AST::UiImportList *definition) lastEndOffset = definition->lastSourceLocation().end(); } +bool QmlDocVisitor::visit(QQmlJS::AST::UiObjectBinding *) +{ + ++nestingLevel; + return true; +} + +void QmlDocVisitor::endVisit(QQmlJS::AST::UiObjectBinding *) +{ + --nestingLevel; +} + +bool QmlDocVisitor::visit(QQmlJS::AST::UiArrayBinding *) +{ + return true; +} + +void QmlDocVisitor::endVisit(QQmlJS::AST::UiArrayBinding *) +{ +} + /*! Visits the public \a member declaration, which can be a signal or a property. It is a custom signal or property. @@ -468,8 +489,9 @@ void QmlDocVisitor::endVisit(QQmlJS::AST::UiImportList *definition) */ bool QmlDocVisitor::visit(QQmlJS::AST::UiPublicMember *member) { - if (nestingLevel > 1) + if (nestingLevel > 1) { return true; + } switch (member->type) { case QQmlJS::AST::UiPublicMember::Signal: { @@ -535,8 +557,9 @@ bool QmlDocVisitor::visit(QQmlJS::AST::IdentifierPropertyName *) */ bool QmlDocVisitor::visit(QQmlJS::AST::FunctionDeclaration* fd) { - if (nestingLevel > 1) + if (nestingLevel > 1) { return true; + } if (current->type() == Node::Document) { QmlClassNode* qmlClass = static_cast(current); if (qmlClass) { @@ -581,8 +604,9 @@ void QmlDocVisitor::endVisit(QQmlJS::AST::FunctionDeclaration* fd) */ bool QmlDocVisitor::visit(QQmlJS::AST::UiScriptBinding* sb) { - if (nestingLevel > 1) + if (nestingLevel > 1) { return true; + } if (current->type() == Node::Document) { QString handler = sb->qualifiedId->name.toString(); if (handler.length() > 2 && handler.startsWith("on") && handler.at(2).isUpper()) { diff --git a/src/tools/qdoc/qmlvisitor.h b/src/tools/qdoc/qmlvisitor.h index bfec61eb34..cc00ccbe6c 100644 --- a/src/tools/qdoc/qmlvisitor.h +++ b/src/tools/qdoc/qmlvisitor.h @@ -85,6 +85,11 @@ public: bool visit(QQmlJS::AST::UiPublicMember *member); void endVisit(QQmlJS::AST::UiPublicMember *definition); + virtual bool visit(QQmlJS::AST::UiObjectBinding *); + virtual void endVisit(QQmlJS::AST::UiObjectBinding *); + virtual void endVisit(QQmlJS::AST::UiArrayBinding *); + virtual bool visit(QQmlJS::AST::UiArrayBinding *); + bool visit(QQmlJS::AST::IdentifierPropertyName *idproperty); bool visit(QQmlJS::AST::FunctionDeclaration *);