diff --git a/src/tools/qdoc/qmlvisitor.cpp b/src/tools/qdoc/qmlvisitor.cpp index 6d44b99af7..ffe1afe28b 100644 --- a/src/tools/qdoc/qmlvisitor.cpp +++ b/src/tools/qdoc/qmlvisitor.cpp @@ -88,6 +88,7 @@ QmlDocVisitor::QmlDocVisitor(const QString &filePath, QSet &topics) : nestingLevel(0) { + lastEndOffset = 0; this->filePath = filePath; this->name = QFileInfo(filePath).baseName(); document = code; @@ -117,21 +118,21 @@ QQmlJS::AST::SourceLocation QmlDocVisitor::precedingComment(quint32 offset) cons QQmlJS::AST::SourceLocation loc = it.previous(); - if (loc.begin() <= lastEndOffset) + if (loc.begin() <= lastEndOffset) { // Return if we reach the end of the preceding structure. break; - - else if (usedComments.contains(loc.begin())) + } + else if (usedComments.contains(loc.begin())) { // Return if we encounter a previously used comment. break; - + } else if (loc.begin() > lastEndOffset && loc.end() < offset) { - // Only examine multiline comments in order to avoid snippet markers. if (document.at(loc.offset - 1) == QLatin1Char('*')) { QString comment = document.mid(loc.offset, loc.length); - if (comment.startsWith(QLatin1Char('!')) || comment.startsWith(QLatin1Char('*'))) + if (comment.startsWith(QLatin1Char('!')) || comment.startsWith(QLatin1Char('*'))) { return loc; + } } } } @@ -165,8 +166,9 @@ bool QmlDocVisitor::applyDocumentation(QQmlJS::AST::SourceLocation location, Nod node->setDoc(doc); applyMetacommands(loc, node, doc); usedComments.insert(loc.offset); - if (doc.isEmpty()) + if (doc.isEmpty()) { return false; + } return true; } Location codeLoc(filePath);