summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2021-04-28 13:36:28 +0200
committerPaul Wicking <paul.wicking@qt.io>2021-05-03 10:05:04 +0200
commit6f462ac37916d9fc3fae793e040690741845ef62 (patch)
tree66bc4b997e0b38cd3d2cd86e8787d54672ca38a6
parenta1ed48d0d073a8bdd7b5e608982a5bbd9af47af8 (diff)
QDoc: Code cleanup
* Use multiple arguments for QStrings instead of calling .arg() multiple times. * Define trivial constructor/destructor '= default' instead of adding empty implementations. * Remove unreachable code. * Prefer ranged-based for loops. * Initialize with auto from static_cast<>() and new. * Simplify expressions. * Prefer "QList::empty()" over "QList::size() > 0". * Remove unused method. * Return qsizetype instead of int to avoid narrowing conversion. * Remove unused include. * Remove unreachable return statement. * Prefer raw string literals over escaped regexes. * Initialize struct members. * Make variables used as const refs const refs. * Use std::move instead of passing const ref in ctor. * Drop redundant 'virtual' from methods marked 'override'. * Make local copies that arent ever modified const refs to avoid copying. * Turn for-loop into std::any_of. * Made single-argument constructor explicit. * Don't shadow variable names from outer scope if not necessary. * Remove const at top level that does not improve const correctness. * Update copyright notice for affected classes. Task-number: QTBUG-71176 Change-Id: Ia41e5b947b72f594b60d189b6b0ff68587c3afb9 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
-rw-r--r--src/qdoc/aggregate.cpp85
-rw-r--r--src/qdoc/aggregate.h7
-rw-r--r--src/qdoc/atom.cpp5
-rw-r--r--src/qdoc/atom.h16
-rw-r--r--src/qdoc/clangcodeparser.cpp75
-rw-r--r--src/qdoc/clangcodeparser.h4
-rw-r--r--src/qdoc/classnode.cpp38
-rw-r--r--src/qdoc/classnode.h8
-rw-r--r--src/qdoc/codechunk.cpp6
-rw-r--r--src/qdoc/codechunk.h4
-rw-r--r--src/qdoc/codemarker.cpp12
-rw-r--r--src/qdoc/codemarker.h6
-rw-r--r--src/qdoc/codeparser.cpp21
-rw-r--r--src/qdoc/codeparser.h2
-rw-r--r--src/qdoc/collectionnode.cpp16
-rw-r--r--src/qdoc/collectionnode.h3
-rw-r--r--src/qdoc/config.cpp69
-rw-r--r--src/qdoc/config.h11
-rw-r--r--src/qdoc/cppcodemarker.cpp30
-rw-r--r--src/qdoc/cppcodemarker.h3
-rw-r--r--src/qdoc/cppcodeparser.cpp28
-rw-r--r--src/qdoc/cppcodeparser.h2
-rw-r--r--src/qdoc/doc.cpp26
-rw-r--r--src/qdoc/doc.h3
-rw-r--r--src/qdoc/docbookgenerator.cpp30
-rw-r--r--src/qdoc/docbookgenerator.h4
-rw-r--r--src/qdoc/docparser.cpp83
-rw-r--r--src/qdoc/docparser.h16
-rw-r--r--src/qdoc/docprivate.cpp4
-rw-r--r--src/qdoc/docprivate.h9
-rw-r--r--src/qdoc/editdistance.cpp10
-rw-r--r--src/qdoc/editdistance.h6
-rw-r--r--src/qdoc/enumitem.h6
-rw-r--r--src/qdoc/examplenode.h6
-rw-r--r--src/qdoc/functionnode.cpp17
-rw-r--r--src/qdoc/functionnode.h5
-rw-r--r--src/qdoc/generator.cpp117
-rw-r--r--src/qdoc/generator.h10
-rw-r--r--src/qdoc/headernode.cpp4
-rw-r--r--src/qdoc/headernode.h2
-rw-r--r--src/qdoc/helpprojectwriter.cpp38
-rw-r--r--src/qdoc/helpprojectwriter.h7
-rw-r--r--src/qdoc/htmlgenerator.cpp46
-rw-r--r--src/qdoc/htmlgenerator.h5
-rw-r--r--src/qdoc/importrec.h17
-rw-r--r--src/qdoc/jscodemarker.cpp13
-rw-r--r--src/qdoc/jscodemarker.h14
-rw-r--r--src/qdoc/location.cpp21
-rw-r--r--src/qdoc/location.h7
-rw-r--r--src/qdoc/main.cpp5
-rw-r--r--src/qdoc/manifestwriter.cpp6
-rw-r--r--src/qdoc/manifestwriter.h2
-rw-r--r--src/qdoc/namespacenode.cpp18
-rw-r--r--src/qdoc/namespacenode.h4
-rw-r--r--src/qdoc/node.cpp26
-rw-r--r--src/qdoc/node.h4
-rw-r--r--src/qdoc/openedlist.cpp26
-rw-r--r--src/qdoc/openedlist.h7
-rw-r--r--src/qdoc/parameters.cpp13
-rw-r--r--src/qdoc/parameters.h6
-rw-r--r--src/qdoc/propertynode.cpp2
-rw-r--r--src/qdoc/propertynode.h19
-rw-r--r--src/qdoc/puredocparser.cpp10
-rw-r--r--src/qdoc/puredocparser.h2
-rw-r--r--src/qdoc/qdocdatabase.cpp45
-rw-r--r--src/qdoc/qdocdatabase.h15
-rw-r--r--src/qdoc/qdocindexfiles.cpp22
-rw-r--r--src/qdoc/qdocindexfiles.h2
-rw-r--r--src/qdoc/qmlcodemarker.cpp33
-rw-r--r--src/qdoc/qmlcodemarker.h15
-rw-r--r--src/qdoc/qmlcodeparser.cpp14
-rw-r--r--src/qdoc/qmlcodeparser.h8
-rw-r--r--src/qdoc/qmlmarkupvisitor.cpp10
-rw-r--r--src/qdoc/qmlmarkupvisitor.h4
-rw-r--r--src/qdoc/qmlpropertynode.cpp22
-rw-r--r--src/qdoc/qmlpropertynode.h6
-rw-r--r--src/qdoc/qmltypenode.cpp3
-rw-r--r--src/qdoc/qmltypenode.h6
-rw-r--r--src/qdoc/qmlvisitor.cpp41
-rw-r--r--src/qdoc/qmlvisitor.h4
-rw-r--r--src/qdoc/quoter.cpp17
-rw-r--r--src/qdoc/quoter.h6
-rw-r--r--src/qdoc/relatedclass.cpp18
-rw-r--r--src/qdoc/relatedclass.h11
-rw-r--r--src/qdoc/sections.cpp78
-rw-r--r--src/qdoc/sections.h10
-rw-r--r--src/qdoc/sharedcommentnode.cpp4
-rw-r--r--src/qdoc/sharedcommentnode.h4
-rw-r--r--src/qdoc/text.cpp8
-rw-r--r--src/qdoc/text.h6
-rw-r--r--src/qdoc/tokenizer.cpp5
-rw-r--r--src/qdoc/tokenizer.h73
-rw-r--r--src/qdoc/tree.cpp75
-rw-r--r--src/qdoc/tree.h38
-rw-r--r--src/qdoc/typedefnode.cpp2
-rw-r--r--src/qdoc/typedefnode.h5
-rw-r--r--src/qdoc/usingclause.cpp4
-rw-r--r--src/qdoc/usingclause.h6
-rw-r--r--src/qdoc/utilities.cpp6
-rw-r--r--src/qdoc/utilities.h6
-rw-r--r--src/qdoc/webxmlgenerator.cpp4
-rw-r--r--src/qdoc/webxmlgenerator.h4
-rw-r--r--src/qdoc/xmlgenerator.cpp3
-rw-r--r--src/qdoc/xmlgenerator.h1
104 files changed, 522 insertions, 1249 deletions
diff --git a/src/qdoc/aggregate.cpp b/src/qdoc/aggregate.cpp
index c824dc793..683c84583 100644
--- a/src/qdoc/aggregate.cpp
+++ b/src/qdoc/aggregate.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -77,10 +77,9 @@ Aggregate::~Aggregate()
m_enumChildren.clear();
m_nonfunctionMap.clear();
m_functionMap.clear();
- for (int i = 0; i < m_children.size(); ++i) {
- if ((m_children[i] != nullptr) && (m_children[i]->parent() == this))
- delete m_children[i];
- m_children[i] = nullptr;
+ for (const Node *child : m_children) {
+ if ((child != nullptr) && (child->parent() == this))
+ delete child;
}
m_children.clear();
}
@@ -231,14 +230,6 @@ FunctionNode *Aggregate::findFunctionChild(const FunctionNode *clone)
}
/*!
- Returns the list of keys from the primary function map.
- */
-QStringList Aggregate::primaryKeys()
-{
- return m_functionMap.keys();
-}
-
-/*!
Mark all child nodes that have no documentation as having
private access and internal status. qdoc will then ignore
them for documentation purposes.
@@ -345,7 +336,7 @@ const NodeList &Aggregate::nonfunctionList()
const EnumNode *Aggregate::findEnumNodeForValue(const QString &enumValue) const
{
for (const auto *node : m_enumChildren) {
- const EnumNode *en = static_cast<const EnumNode *>(node);
+ const auto *en = static_cast<const EnumNode *>(node);
if (en->hasItem(enumValue))
return en;
}
@@ -551,7 +542,7 @@ void Aggregate::adoptChild(Node *child)
m_enumChildren.append(child);
}
if (child->isSharedCommentNode()) {
- SharedCommentNode *scn = static_cast<SharedCommentNode *>(child);
+ auto *scn = static_cast<SharedCommentNode *>(child);
for (Node *n : scn->collective())
adoptChild(n);
}
@@ -624,63 +615,7 @@ QmlPropertyNode *Aggregate::hasQmlProperty(const QString &n, bool attached) cons
bool Aggregate::hasOverloads(const FunctionNode *fn) const
{
auto it = m_functionMap.find(fn->name());
- return (it == m_functionMap.end() ? false : (it.value()->nextOverload() != nullptr));
-}
-
-/*!
- Prints the inner node's list of children.
- For debugging only.
- */
-void Aggregate::printChildren(const QString &title)
-{
- qDebug() << title << name() << m_children.size();
- if (m_children.size() > 0) {
- for (int i = 0; i < m_children.size(); ++i) {
- Node *n = m_children.at(i);
- qDebug() << " CHILD:" << n->name() << n->nodeTypeString();
- }
- }
-}
-
-/*!
- Removes \a fn from this aggregate's function map. That's
- all it does. If \a fn is in the function map index and it
- has an overload, the value pointer in the function map
- index is set to the the overload pointer. If the function
- has no overload pointer, the function map entry is erased.
-
- \note When removing a function node from the function map,
- it is important to set the removed function node's next
- overload pointer to null because the function node might
- be added as a child to some other aggregate.
-
- \note This is a protected function.
- */
-void Aggregate::removeFunctionNode(FunctionNode *fn)
-{
- auto it = m_functionMap.find(fn->name());
- if (it != m_functionMap.end()) {
- if (it.value() == fn) {
- if (fn->nextOverload() != nullptr) {
- it.value() = fn->nextOverload();
- fn->setNextOverload(nullptr);
- fn->setOverloadNumber(0);
- } else {
- m_functionMap.erase(it);
- }
- } else {
- FunctionNode *current = it.value();
- while (current != nullptr) {
- if (current->nextOverload() == fn) {
- current->setNextOverload(fn->nextOverload());
- fn->setNextOverload(nullptr);
- fn->setOverloadNumber(0);
- break;
- }
- current = current->nextOverload();
- }
- }
- }
+ return !(it == m_functionMap.end()) && (it.value()->nextOverload() != nullptr);
}
/*
@@ -784,11 +719,11 @@ void Aggregate::findAllObsoleteThings()
else if (node->isQmlType() || node->isJsType())
QDocDatabase::obsoleteQmlTypes().insert(node->qualifyQmlName(), node);
} else if (node->isClassNode()) {
- Aggregate *a = static_cast<Aggregate *>(node);
+ auto *a = static_cast<Aggregate *>(node);
if (a->hasObsoleteMembers())
QDocDatabase::classesWithObsoleteMembers().insert(node->qualifyCppName(), node);
} else if (node->isQmlType() || node->isJsType()) {
- Aggregate *a = static_cast<Aggregate *>(node);
+ auto *a = static_cast<Aggregate *>(node);
if (a->hasObsoleteMembers())
QDocDatabase::qmlTypesWithObsoleteMembers().insert(node->qualifyQmlName(),
node);
@@ -876,7 +811,7 @@ void Aggregate::findAllSince()
if (node->isFunction()) {
// Insert functions into the general since map.
- FunctionNode *fn = static_cast<FunctionNode *>(node);
+ auto *fn = static_cast<FunctionNode *>(node);
if (!fn->isObsolete() && !fn->isSomeCtor() && !fn->isDtor())
nsmap.value().insert(fn->name(), fn);
} else if (node->isClassNode()) {
diff --git a/src/qdoc/aggregate.h b/src/qdoc/aggregate.h
index a8a8bb46c..3668f64e5 100644
--- a/src/qdoc/aggregate.h
+++ b/src/qdoc/aggregate.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -55,7 +55,7 @@ public:
bool isAggregate() const override { return true; }
const EnumNode *findEnumNodeForValue(const QString &enumValue) const;
- int count() const { return m_children.size(); }
+ qsizetype count() const { return m_children.size(); }
const NodeList &childNodes() const { return m_children; }
const NodeList &nonfunctionList();
NodeList::ConstIterator constBegin() const { return m_children.constBegin(); }
@@ -65,12 +65,10 @@ public:
void setIncludeFiles(const QStringList &includeFiles);
const QStringList &includeFiles() const { return m_includeFiles; }
- QStringList primaryKeys();
QmlPropertyNode *hasQmlProperty(const QString &) const;
QmlPropertyNode *hasQmlProperty(const QString &, bool attached) const;
virtual QmlTypeNode *qmlBaseNode() const { return nullptr; }
void addChildByTitle(Node *child, const QString &title);
- void printChildren(const QString &title);
void addChild(Node *child);
void adoptChild(Node *child);
void setOutputSubdirectory(const QString &t) override;
@@ -93,7 +91,6 @@ protected:
Aggregate(NodeType type, Aggregate *parent, const QString &name)
: PageNode(type, parent, name) {}
~Aggregate() override;
- void removeFunctionNode(FunctionNode *fn);
private:
friend class Node;
diff --git a/src/qdoc/atom.cpp b/src/qdoc/atom.cpp
index ee788ec2d..3aa5324f7 100644
--- a/src/qdoc/atom.cpp
+++ b/src/qdoc/atom.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -29,7 +29,6 @@
#include "atom.h"
#include "location.h"
-#include "proxynode.h"
#include "qdocdatabase.h"
#include <QtCore/qregularexpression.h>
@@ -362,7 +361,7 @@ void Atom::dump() const
str.replace(QLatin1String("\\"), QLatin1String("\\\\"));
str.replace(QLatin1String("\""), QLatin1String("\\\""));
str.replace(QLatin1String("\n"), QLatin1String("\\n"));
- str.replace(QRegularExpression(QLatin1String("[^\x20-\x7e]")), QLatin1String("?"));
+ str.replace(QRegularExpression(QLatin1String(R"([^ -~])")), QLatin1String("?"));
if (!str.isEmpty())
str = QLatin1String(" \"") + str + QLatin1Char('"');
fprintf(stderr, " %-15s%s\n", typeString().toLatin1().data(), str.toLatin1().data());
diff --git a/src/qdoc/atom.h b/src/qdoc/atom.h
index b6d1a8840..f030b774a 100644
--- a/src/qdoc/atom.h
+++ b/src/qdoc/atom.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -172,16 +172,14 @@ public:
QString typeString() const;
const QString &string() const { return strs[0]; }
const QString &string(int i) const { return strs[i]; }
- int count() const { return strs.size(); }
+ qsizetype count() const { return strs.size(); }
void dump() const;
QString linkText() const;
const QStringList &strings() const { return strs; }
virtual bool isLinkAtom() const { return false; }
virtual Node::Genus genus() { return Node::DontCare; }
- virtual bool specifiesDomain() { return false; }
virtual Tree *domain() { return nullptr; }
- virtual Node::NodeType goal() { return Node::NoType; }
virtual const QString &error() { return noError_; }
virtual void resolveSquareBracketParams() {}
@@ -206,21 +204,11 @@ public:
resolveSquareBracketParams();
return genus_;
}
- bool specifiesDomain() override
- {
- resolveSquareBracketParams();
- return (domain_ != nullptr);
- }
Tree *domain() override
{
resolveSquareBracketParams();
return domain_;
}
- Node::NodeType goal() override
- {
- resolveSquareBracketParams();
- return goal_;
- }
const QString &error() override { return error_; }
void resolveSquareBracketParams() override;
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp
index 866b8119d..16a632ec5 100644
--- a/src/qdoc/clangcodeparser.cpp
+++ b/src/qdoc/clangcodeparser.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -37,10 +37,6 @@
**
****************************************************************************/
-/*
- clangcodeparser.cpp
-*/
-
#include "clangcodeparser.h"
#include "access.h"
@@ -461,7 +457,7 @@ private:
*/
struct SimpleLoc
{
- unsigned int line, column;
+ unsigned int line {}, column {};
friend bool operator<(const SimpleLoc &a, const SimpleLoc &b)
{
return a.line != b.line ? a.line < b.line : a.column < b.column;
@@ -582,8 +578,8 @@ CXChildVisitResult ClangVisitor::visitFnSignature(CXCursor cursor, CXSourceLocat
*fnNode = findNodeForCursor(qdb_, cursor);
if (*fnNode) {
if ((*fnNode)->isFunction(Node::CPP)) {
- FunctionNode *fn = static_cast<FunctionNode *>(*fnNode);
- readParameterNamesAndAttributes(fn, cursor);
+ auto *fn = static_cast<FunctionNode *>(*fnNode);
+ readParameterNamesAndAttributes(fn, cursor);
}
} else { // Possibly an implicitly generated special member
QString name = functionName(cursor);
@@ -622,14 +618,14 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l
if (typeAlias.size() == 2) {
typeAlias[0] = typeAlias[0].trimmed();
const QLatin1String usingString("using ");
- int usingPos = typeAlias[0].indexOf(usingString);
+ qsizetype usingPos = typeAlias[0].indexOf(usingString);
if (usingPos != -1) {
if (kind == CXCursor_TypeAliasTemplateDecl)
templateString = typeAlias[0].left(usingPos).trimmed();
typeAlias[0].remove(0, usingPos + usingString.size());
typeAlias[0] = typeAlias[0].split(QLatin1Char(' ')).first();
typeAlias[1] = typeAlias[1].trimmed();
- TypeAliasNode *ta = new TypeAliasNode(parent_, typeAlias[0], typeAlias[1]);
+ auto *ta = new TypeAliasNode(parent_, typeAlias[0], typeAlias[1]);
ta->setAccess(fromCX_CXXAccessSpecifier(clang_getCXXAccessSpecifier(cursor)));
ta->setLocation(fromCXSourceLocation(clang_getCursorLocation(cursor)));
ta->setTemplateDecl(templateString);
@@ -668,7 +664,7 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l
else if (actualKind == CXCursor_UnionDecl)
type = Node::Union;
- ClassNode *classe = new ClassNode(type, semanticParent, className);
+ auto *classe = new ClassNode(type, semanticParent, className);
classe->setAccess(fromCX_CXXAccessSpecifier(clang_getCXXAccessSpecifier(cursor)));
classe->setLocation(fromCXSourceLocation(clang_getCursorLocation(cursor)));
@@ -688,8 +684,8 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l
auto classe = static_cast<ClassNode *>(parent_);
if (baseNode == nullptr || !baseNode->isClassNode()) {
QString bcName = reconstructQualifiedPathForCursor(baseCursor);
- classe->addUnresolvedBaseClass(
- access, bcName.split(QLatin1String("::"), Qt::SkipEmptyParts), bcName);
+ classe->addUnresolvedBaseClass(access,
+ bcName.split(QLatin1String("::"), Qt::SkipEmptyParts));
return CXChildVisit_Continue;
}
auto baseClasse = static_cast<ClassNode *>(baseNode);
@@ -724,14 +720,14 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l
if (ignoredSymbol(name))
return CXChildVisit_Continue;
- FunctionNode *fn = new FunctionNode(parent_, name);
+ auto *fn = new FunctionNode(parent_, name);
CXSourceRange range = clang_Cursor_getCommentRange(cursor);
if (!clang_Range_isNull(range)) {
QString comment = getSpelling(range);
if (comment.startsWith("//!")) {
- int tag = comment.indexOf(QChar('['));
+ qsizetype tag = comment.indexOf(QChar('['));
if (tag > 0) {
- int end = comment.indexOf(QChar(']'), tag);
+ qsizetype end = comment.indexOf(QChar(']'), tag);
if (end > 0)
fn->setTag(comment.mid(tag, 1 + end - tag));
}
@@ -749,7 +745,7 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l
}
#endif
case CXCursor_EnumDecl: {
- EnumNode *en = static_cast<EnumNode *>(findNodeForCursor(qdb_, cursor));
+ auto *en = static_cast<EnumNode *>(findNodeForCursor(qdb_, cursor));
if (en && en->items().count())
return CXChildVisit_Continue; // Was already parsed, probably in another TU
QString enumTypeName = fromCXString(clang_getCursorSpelling(cursor));
@@ -810,7 +806,7 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l
case CXCursor_TypedefDecl: {
if (findNodeForCursor(qdb_, cursor)) // Was already parsed, probably in another TU
return CXChildVisit_Continue;
- TypedefNode *td = new TypedefNode(parent_, fromCXString(clang_getCursorSpelling(cursor)));
+ auto *td = new TypedefNode(parent_, fromCXString(clang_getCursorSpelling(cursor)));
td->setAccess(fromCX_CXXAccessSpecifier(clang_getCXXAccessSpecifier(cursor)));
td->setLocation(fromCXSourceLocation(clang_getCursorLocation(cursor)));
// Search to see if this is a Q_DECLARE_FLAGS (if the type is QFlags<ENUM>)
@@ -966,8 +962,8 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc)
&& !spelling.startsWith(QLatin1String("Q_OVERRIDE")))
return false;
- int lpIdx = spelling.indexOf(QChar('('));
- int rpIdx = spelling.lastIndexOf(QChar(')'));
+ qsizetype lpIdx = spelling.indexOf(QChar('('));
+ qsizetype rpIdx = spelling.lastIndexOf(QChar(')'));
if (lpIdx <= 0 || rpIdx <= lpIdx)
return false;
@@ -983,10 +979,10 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc)
parts.removeFirst(); // QTBUG-80027
type = parts.takeFirst();
- if (type == QLatin1String("const") && parts.size() > 0)
+ if (type == QLatin1String("const") && !parts.empty())
type += " " + parts.takeFirst();
- if (parts.size() > 0)
+ if (!parts.empty())
name = parts.takeFirst();
else
return false;
@@ -1006,8 +1002,6 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc)
// Keywords with no associated values
if (key == "CONSTANT") {
property->setConstant();
- } else if (key == "FINAL") {
- property->setFinal();
} else if (key == "REQUIRED") {
property->setRequired();
}
@@ -1028,7 +1022,6 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc)
property->setDesignable(false);
else {
property->setDesignable(false);
- property->setRuntimeDesFunc(value);
}
} else if (key == "BINDABLE") {
property->setPropertyType(PropertyNode::Bindable);
@@ -1036,14 +1029,6 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc)
qdb_->addPropertyFunction(property, value, PropertyNode::Resetter);
} else if (key == "NOTIFY") {
qdb_->addPropertyFunction(property, value, PropertyNode::Notifier);
- } else if (key == "REVISION") {
- int revision;
- bool ok;
- revision = value.toInt(&ok);
- if (ok)
- property->setRevision(revision);
- else
- loc.warning(QStringLiteral("Invalid revision number: %1").arg(value));
} else if (key == "SCRIPTABLE") {
QString v = value.toLower();
if (v == "true")
@@ -1052,7 +1037,6 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc)
property->setScriptable(false);
else {
property->setScriptable(false);
- property->setRuntimeScrFunc(value);
}
}
}
@@ -1101,14 +1085,6 @@ Node *ClangVisitor::nodeForCommentAtLocation(CXSourceLocation loc, CXSourceLocat
}
/*!
- The destructor is trivial.
- */
-ClangCodeParser::~ClangCodeParser()
-{
- // nothing.
-}
-
-/*!
Get the include paths from the qdoc configuration database
\a config. Call the initializeParser() in the base class.
Get the defines list from the qdocconf database.
@@ -1290,9 +1266,7 @@ void ClangCodeParser::getMoreArgs()
that list instead.
*/
qCWarning(lcQdoc) << "No include paths passed to qdoc; guessing reasonable include paths";
- auto forest = qdb_->searchOrder();
- QByteArray version = qdb_->version().toUtf8();
QString basicIncludeDir = QDir::cleanPath(QString(Config::installDir + "/../include"));
m_moreArgs += "-I" + basicIncludeDir.toLatin1();
m_moreArgs += includePathsFromHeaders(m_allHeaders);
@@ -1567,8 +1541,7 @@ void ClangCodeParser::parseSourceFile(const Location & /*location*/, const QStri
"topic command (e.g., '\\%1', '\\%2') in the "
"comment and no function definition following "
"the comment.")
- .arg(COMMAND_FN)
- .arg(COMMAND_PAGE));
+ .arg(COMMAND_FN, COMMAND_PAGE));
}
}
} else {
@@ -1625,11 +1598,11 @@ Node *ClangCodeParser::parseFnArg(const Location &location, const QString &fnArg
they will be the names used in the documentation.
*/
QString fnSignature = fnArg.mid(tagEnd);
- FunctionNode *fn = static_cast<FunctionNode *>(fnNode);
+ auto *fn = static_cast<FunctionNode *>(fnNode);
QStringList leftParenSplit = fnSignature.mid(fnSignature.indexOf(fn->name())).split('(');
if (leftParenSplit.size() > 1) {
QStringList rightParenSplit = leftParenSplit[1].split(')');
- if (rightParenSplit.size() > 0) {
+ if (!rightParenSplit.empty()) {
QString params = rightParenSplit[0];
if (!params.isEmpty()) {
QStringList commaSplit = params.split(',');
@@ -1654,9 +1627,9 @@ Node *ClangCodeParser::parseFnArg(const Location &location, const QString &fnArg
}
return fnNode;
}
- CXTranslationUnit_Flags flags = static_cast<CXTranslationUnit_Flags>(
- CXTranslationUnit_Incomplete | CXTranslationUnit_SkipFunctionBodies
- | CXTranslationUnit_KeepGoing);
+ auto flags = static_cast<CXTranslationUnit_Flags>(CXTranslationUnit_Incomplete
+ | CXTranslationUnit_SkipFunctionBodies
+ | CXTranslationUnit_KeepGoing);
CXIndex index = clang_createIndex(1, kClangDontDisplayDiagnostics);
diff --git a/src/qdoc/clangcodeparser.h b/src/qdoc/clangcodeparser.h
index 9c09365d4..2e2db4565 100644
--- a/src/qdoc/clangcodeparser.h
+++ b/src/qdoc/clangcodeparser.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
class ClangCodeParser : public CppCodeParser
{
public:
- ~ClangCodeParser() override;
+ ~ClangCodeParser() override = default;
void initializeParser() override;
void terminateParser() override;
diff --git a/src/qdoc/classnode.cpp b/src/qdoc/classnode.cpp
index 28d733a72..f4ab72144 100644
--- a/src/qdoc/classnode.cpp
+++ b/src/qdoc/classnode.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -70,21 +70,9 @@ void ClassNode::addDerivedClass(Access access, ClassNode *node)
before the generate phase of qdoc. In an unresolved base
class, the pointer to the base class node is 0.
*/
-void ClassNode::addUnresolvedBaseClass(Access access, const QStringList &path,
- const QString &signature)
+void ClassNode::addUnresolvedBaseClass(Access access, const QStringList &path)
{
- m_bases.append(RelatedClass(access, path, signature));
-}
-
-/*!
- Add an unresolved \c using clause to this class node's list
- of \c using clauses. The unresolved \c using clause will be
- resolved before the generate phase of qdoc. In an unresolved
- \c using clause, the pointer to the function node is 0.
- */
-void ClassNode::addUnresolvedUsingClause(const QString &signature)
-{
- m_usingClauses.append(UsingClause(signature));
+ m_bases.append(RelatedClass(access, path));
}
/*!
@@ -102,8 +90,8 @@ PropertyNode *ClassNode::findPropertyNode(const QString &name)
const QList<RelatedClass> &bases = baseClasses();
if (!bases.isEmpty()) {
- for (int i = 0; i < bases.size(); ++i) {
- ClassNode *cn = bases[i].m_node;
+ for (const RelatedClass &base : bases) {
+ ClassNode *cn = base.m_node;
if (cn) {
pn = cn->findPropertyNode(name);
if (pn)
@@ -113,8 +101,8 @@ PropertyNode *ClassNode::findPropertyNode(const QString &name)
}
const QList<RelatedClass> &ignoredBases = ignoredBaseClasses();
if (!ignoredBases.isEmpty()) {
- for (int i = 0; i < ignoredBases.size(); ++i) {
- ClassNode *cn = ignoredBases[i].m_node;
+ for (const RelatedClass &base : ignoredBases) {
+ ClassNode *cn = base.m_node;
if (cn) {
pn = cn->findPropertyNode(name);
if (pn)
@@ -138,14 +126,14 @@ QmlTypeNode *ClassNode::findQmlBaseNode()
const QList<RelatedClass> &bases = baseClasses();
if (!bases.isEmpty()) {
- for (int i = 0; i < bases.size(); ++i) {
- ClassNode *cn = bases[i].m_node;
+ for (const RelatedClass &base : bases) {
+ ClassNode *cn = base.m_node;
if (cn && cn->qmlElement()) {
return cn->qmlElement();
}
}
- for (int i = 0; i < bases.size(); ++i) {
- ClassNode *cn = bases[i].m_node;
+ for (const RelatedClass &base : bases) {
+ ClassNode *cn = base.m_node;
if (cn) {
result = cn->findQmlBaseNode();
if (result != nullptr) {
@@ -250,7 +238,7 @@ bool ClassNode::docMustBeGenerated() const
void ClassNode::promotePublicBases(const QList<RelatedClass> &bases)
{
if (!bases.isEmpty()) {
- for (int i = bases.size() - 1; i >= 0; --i) {
+ for (qsizetype i = bases.size() - 1; i >= 0; --i) {
ClassNode *bc = bases.at(i).m_node;
if (bc == nullptr)
bc = QDocDatabase::qdocDB()->findClassNode(bases.at(i).m_path);
@@ -299,7 +287,7 @@ void ClassNode::removePrivateAndInternalBases()
if (dc != nullptr && (dc->isPrivate() || dc->isInternal() || dc->isDontDocument())) {
m_derived.removeAt(i);
const QList<RelatedClass> &dd = dc->derivedClasses();
- for (int j = dd.size() - 1; j >= 0; --j)
+ for (qsizetype j = dd.size() - 1; j >= 0; --j)
m_derived.insert(i, dd.at(j));
} else {
++i;
diff --git a/src/qdoc/classnode.h b/src/qdoc/classnode.h
index c6bdc65c1..d0b2e881a 100644
--- a/src/qdoc/classnode.h
+++ b/src/qdoc/classnode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -59,8 +59,7 @@ public:
void addResolvedBaseClass(Access access, ClassNode *node);
void addDerivedClass(Access access, ClassNode *node);
- void addUnresolvedBaseClass(Access access, const QStringList &path, const QString &signature);
- void addUnresolvedUsingClause(const QString &signature);
+ void addUnresolvedBaseClass(Access access, const QStringList &path);
void removePrivateAndInternalBases();
void resolvePropertyOverriddenFromPtrs(PropertyNode *pn);
@@ -70,9 +69,6 @@ public:
QList<UsingClause> &usingClauses() { return m_usingClauses; }
const QList<RelatedClass> &baseClasses() const { return m_bases; }
- const QList<RelatedClass> &derivedClasses() const { return m_derived; }
- const QList<RelatedClass> &ignoredBaseClasses() const { return m_ignoredBases; }
- const QList<UsingClause> &usingClauses() const { return m_usingClauses; }
QmlTypeNode *qmlElement() { return m_qmlElement; }
void setQmlElement(QmlTypeNode *qcn) { m_qmlElement = qcn; }
diff --git a/src/qdoc/codechunk.cpp b/src/qdoc/codechunk.cpp
index b562aa937..7944d9791 100644
--- a/src/qdoc/codechunk.cpp
+++ b/src/qdoc/codechunk.cpp
@@ -26,14 +26,8 @@
**
****************************************************************************/
-/*
- codechunk.cpp
-*/
-
#include "codechunk.h"
-#include <QtCore/qstringlist.h>
-
QT_BEGIN_NAMESPACE
enum { Other, Alnum, Gizmo, Comma, LBrace, RBrace, RAngle, Colon, Paren };
diff --git a/src/qdoc/codechunk.h b/src/qdoc/codechunk.h
index 43d258c8f..0a7b0022e 100644
--- a/src/qdoc/codechunk.h
+++ b/src/qdoc/codechunk.h
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- codechunk.h
-*/
-
#ifndef CODECHUNK_H
#define CODECHUNK_H
diff --git a/src/qdoc/codemarker.cpp b/src/qdoc/codemarker.cpp
index e8509314b..7100ebeca 100644
--- a/src/qdoc/codemarker.cpp
+++ b/src/qdoc/codemarker.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -113,7 +113,7 @@ CodeMarker *CodeMarker::markerForCode(const QString &code)
CodeMarker *CodeMarker::markerForFileName(const QString &fileName)
{
CodeMarker *defaultMarker = markerForLanguage(defaultLang);
- int dot = -1;
+ qsizetype dot = -1;
while ((dot = fileName.lastIndexOf(QLatin1Char('.'), dot)) != -1) {
QString ext = fileName.mid(dot + 1);
if (defaultMarker != nullptr && defaultMarker->recognizeExtension(ext))
@@ -237,7 +237,7 @@ static const QString squot = QLatin1String("&quot;");
QString CodeMarker::protect(const QString &str)
{
- int n = str.length();
+ qsizetype n = str.length();
QString marked;
marked.reserve(n * 2 + 30);
const QChar *data = str.constData();
@@ -264,7 +264,7 @@ QString CodeMarker::protect(const QString &str)
void CodeMarker::appendProtectedString(QString *output, QStringView str)
{
- int n = str.length();
+ qsizetype n = str.length();
output->reserve(output->size() + n * 2 + 30);
const QChar *data = str.constData();
for (int i = 0; i != n; ++i) {
@@ -339,7 +339,7 @@ QString CodeMarker::typified(const QString &string, bool trailingSpace)
QString CodeMarker::taggedNode(const Node *node)
{
QString tag;
- QString name = node->name();
+ const QString &name = node->name();
switch (node->nodeType()) {
case Node::Namespace:
@@ -380,7 +380,7 @@ QString CodeMarker::taggedQmlNode(const Node *node)
{
QString tag;
if (node->isFunction()) {
- const FunctionNode *fn = static_cast<const FunctionNode *>(node);
+ const auto *fn = static_cast<const FunctionNode *>(node);
switch (fn->metaness()) {
case FunctionNode::JsSignal:
case FunctionNode::QmlSignal:
diff --git a/src/qdoc/codemarker.h b/src/qdoc/codemarker.h
index 73fdadbbd..a4662ed56 100644
--- a/src/qdoc/codemarker.h
+++ b/src/qdoc/codemarker.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -58,10 +58,6 @@ public:
}
virtual QString markedUpQmlItem(const Node *, bool) { return QString(); }
virtual QString markedUpName(const Node * /*node*/) { return QString(); }
- virtual QString markedUpFullName(const Node * /*node*/, const Node * /*relative*/)
- {
- return QString();
- }
virtual QString markedUpEnumValue(const QString & /*enumValue*/, const Node * /*relative*/)
{
return QString();
diff --git a/src/qdoc/codeparser.cpp b/src/qdoc/codeparser.cpp
index ccebff44a..8443f86dd 100644
--- a/src/qdoc/codeparser.cpp
+++ b/src/qdoc/codeparser.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,16 +26,11 @@
**
****************************************************************************/
-/*
- codeparser.cpp
-*/
-
#include "codeparser.h"
#include "config.h"
#include "generator.h"
#include "node.h"
-#include "proxynode.h"
#include "qdocdatabase.h"
#include <QtCore/qregularexpression.h>
@@ -173,7 +168,8 @@ const QSet<QString> &CodeParser::commonMetaCommands()
*/
void CodeParser::extractPageLinkAndDesc(QStringView arg, QString *link, QString *desc)
{
- QRegularExpression bracedRegExp(QRegularExpression::anchoredPattern(QLatin1String("\\{([^{}]*)\\}(?:\\{([^{}]*)\\})?")));
+ QRegularExpression bracedRegExp(
+ QRegularExpression::anchoredPattern(QLatin1String(R"(\{([^{}]*)\}(?:\{([^{}]*)\})?)")));
auto match = bracedRegExp.match(arg);
if (match.hasMatch()) {
*link = match.captured(1);
@@ -181,7 +177,7 @@ void CodeParser::extractPageLinkAndDesc(QStringView arg, QString *link, QString
if (desc->isEmpty())
*desc = *link;
} else {
- int spaceAt = arg.indexOf(QLatin1Char(' '));
+ qsizetype spaceAt = arg.indexOf(QLatin1Char(' '));
if (arg.contains(QLatin1String(".html")) && spaceAt != -1) {
*link = arg.left(spaceAt).trimmed().toString();
*desc = arg.mid(spaceAt).trimmed().toString();
@@ -265,11 +261,10 @@ void CodeParser::checkModuleInclusion(Node *n)
}
qdb_->addToModule(Generator::defaultModuleName(), n);
- n->doc().location().warning(QStringLiteral("%1 %2 has no \\inmodule command; "
- "using project name by default: %3")
- .arg(word)
- .arg(n->name())
- .arg(Generator::defaultModuleName()));
+ n->doc().location().warning(
+ QStringLiteral("%1 %2 has no \\inmodule command; "
+ "using project name by default: %3")
+ .arg(word, n->name(), Generator::defaultModuleName()));
}
}
}
diff --git a/src/qdoc/codeparser.h b/src/qdoc/codeparser.h
index 767cec86a..1a721ffd9 100644
--- a/src/qdoc/codeparser.h
+++ b/src/qdoc/codeparser.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
diff --git a/src/qdoc/collectionnode.cpp b/src/qdoc/collectionnode.cpp
index 47c714bfb..9db4092df 100644
--- a/src/qdoc/collectionnode.cpp
+++ b/src/qdoc/collectionnode.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -28,7 +28,6 @@
#include "collectionnode.h"
-#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
@@ -105,19 +104,6 @@ void CollectionNode::getMemberClasses(NodeMap &out) const
}
/*!
- Prints the collection node's list of members.
- For debugging only.
- */
-void CollectionNode::printMembers(const QString &title)
-{
- qDebug() << title << name() << m_members.size();
- if (m_members.empty()) {
- for (const auto &member : qAsConst(m_members))
- qDebug() << " MEMBER:" << member->name() << member->nodeTypeString();
- }
-}
-
-/*!
This function splits \a arg on the blank character to get a
logical module name and version number. If the version number
is present, it splits the version number on the '.' character
diff --git a/src/qdoc/collectionnode.h b/src/qdoc/collectionnode.h
index c4e9cac24..71629f663 100644
--- a/src/qdoc/collectionnode.h
+++ b/src/qdoc/collectionnode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -70,7 +70,6 @@ public:
void setLogicalModuleInfo(const QStringList &info) override;
const NodeList &members() const { return m_members; }
- void printMembers(const QString &title);
void markSeen() { m_seen = true; }
void markNotSeen() { m_seen = false; }
diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp
index 7464eaa9a..c2beda80d 100644
--- a/src/qdoc/config.cpp
+++ b/src/qdoc/config.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- config.cpp
-*/
-
#include "config.h"
#include "utilities.h"
@@ -117,7 +113,6 @@ QString ConfigStrings::VERSION = QStringLiteral("version");
QString ConfigStrings::VERSIONSYM = QStringLiteral("versionsym");
QString ConfigStrings::FILEEXTENSIONS = QStringLiteral("fileextensions");
QString ConfigStrings::IMAGEEXTENSIONS = QStringLiteral("imageextensions");
-QString ConfigStrings::QMLONLY = QStringLiteral("qmlonly");
QString ConfigStrings::QMLTYPESPAGE = QStringLiteral("qmltypespage");
QString ConfigStrings::QMLTYPESTITLE = QStringLiteral("qmltypestitle");
QString ConfigStrings::WARNINGLIMIT = QStringLiteral("warninglimit");
@@ -208,11 +203,8 @@ void MetaStack::process(QChar ch, const Location &location)
top().close();
top().open();
} else {
- /*
- This is where all the processing is done.
- */
- for (auto it = top().next.begin(); it != top().next.end(); ++it)
- *it += ch;
+ for (QString &topNext : top().next)
+ topNext += ch;
}
}
@@ -355,11 +347,11 @@ void Config::expandVariables()
QStringLiteral("Environment or configuration variable '%1' undefined")
.arg(it->m_var));
} else if (!refVar.m_expandVars.empty()) {
- configVar.m_location.fatal(QStringLiteral("Nested variable expansion not allowed"),
- QStringLiteral("When expanding '%1' at %2:%3")
- .arg(refVar.m_name)
- .arg(refVar.m_location.filePath())
- .arg(refVar.m_location.lineNo()));
+ configVar.m_location.fatal(
+ QStringLiteral("Nested variable expansion not allowed"),
+ QStringLiteral("When expanding '%1' at %2:%3")
+ .arg(refVar.m_name, refVar.m_location.filePath(),
+ QString::number(refVar.m_location.lineNo())));
}
QString expanded;
if (it->m_delim.isNull())
@@ -585,8 +577,6 @@ QStringList Config::getStringList(const QString &var) const
are canonicalized. If \a validate is true, outputs a warning for invalid
paths. If \a var is defined, updates the internal location to the
location of \a var for the purposes of error reporting.
-
- \sa Location::canonicalRelativePath()
*/
QStringList Config::getCanonicalPathList(const QString &var, bool validate) const
{
@@ -676,25 +666,6 @@ QSet<QString> Config::subVars(const QString &var) const
}
/*!
- Same as subVars(), but returns a ConfigVarMap \a map with the
- matching keys (stripped of the prefix \a var and mapped to
- their values.
- */
-void Config::subVarsAndValues(const QString &var, ConfigVarMap &map) const
-{
- QString varDot = var + QLatin1Char('.');
- for (auto it = m_configVars.constBegin(); it != m_configVars.constEnd(); ++it) {
- if (it.key().startsWith(varDot)) {
- QString subVar = it.key().mid(varDot.length());
- int dot = subVar.indexOf(QLatin1Char('.'));
- if (dot != -1)
- subVar.truncate(dot);
- map.insert(subVar, it.value());
- }
- }
-}
-
-/*!
Searches for a path to \a fileName in 'sources', 'sourcedirs', and
'exampledirs' config variables and returns a full path to the first
match found. If the file is not found, returns an empty string.
@@ -893,13 +864,12 @@ QString Config::copyFile(const Location &location, const QString &sourceFilePath
QFile inFile(sourceFilePath);
if (!inFile.open(QFile::ReadOnly)) {
location.warning(QStringLiteral("Cannot open input file for copy: '%1': %2")
- .arg(sourceFilePath)
- .arg(inFile.errorString()));
+ .arg(sourceFilePath, inFile.errorString()));
return QString();
}
QString outFileName = userFriendlySourceFilePath;
- int slash = outFileName.lastIndexOf(QLatin1Char('/'));
+ qsizetype slash = outFileName.lastIndexOf(QLatin1Char('/'));
if (slash != -1)
outFileName = outFileName.mid(slash);
if ((outFileName.size()) > 0 && (outFileName[0] != '/'))
@@ -909,13 +879,12 @@ QString Config::copyFile(const Location &location, const QString &sourceFilePath
QFile outFile(outFileName);
if (!outFile.open(QFile::WriteOnly)) {
location.warning(QStringLiteral("Cannot open output file for copy: '%1': %2")
- .arg(outFileName)
- .arg(outFile.errorString()));
+ .arg(outFileName, outFile.errorString()));
return QString();
}
char buffer[1024];
- int len;
+ qsizetype len;
while ((len = inFile.read(buffer, sizeof(buffer))) > 0)
outFile.write(buffer, len);
return outFileName;
@@ -956,14 +925,13 @@ QStringList Config::loadMaster(const QString &fileName)
QFile fin(fileName);
if (!fin.open(QFile::ReadOnly | QFile::Text)) {
if (!Config::installDir.isEmpty()) {
- int prefix = location.filePath().length() - location.fileName().length();
+ qsizetype prefix = location.filePath().length() - location.fileName().length();
fin.setFileName(Config::installDir + QLatin1Char('/')
+ fileName.right(fileName.length() - prefix));
}
if (!fin.open(QFile::ReadOnly | QFile::Text))
location.fatal(QStringLiteral("Cannot open master qdocconf file '%1': %2")
- .arg(fileName)
- .arg(fin.errorString()));
+ .arg(fileName, fin.errorString()));
}
QTextStream stream(&fin);
QStringList qdocFiles;
@@ -1013,14 +981,13 @@ void Config::load(Location location, const QString &fileName)
QFile fin(fileInfo.fileName());
if (!fin.open(QFile::ReadOnly | QFile::Text)) {
if (!Config::installDir.isEmpty()) {
- int prefix = location.filePath().length() - location.fileName().length();
+ qsizetype prefix = location.filePath().length() - location.fileName().length();
fin.setFileName(Config::installDir + QLatin1Char('/')
+ fileName.right(fileName.length() - prefix));
}
if (!fin.open(QFile::ReadOnly | QFile::Text))
- location.fatal(QStringLiteral("Cannot open file '%1': %2")
- .arg(fileName)
- .arg(fin.errorString()));
+ location.fatal(
+ QStringLiteral("Cannot open file '%1': %2").arg(fileName, fin.errorString()));
}
QTextStream stream(&fin);
@@ -1121,7 +1088,7 @@ void Config::load(Location location, const QString &fileName)
for (;;) {
if (cc == '\\') {
- int metaCharPos;
+ qsizetype metaCharPos;
SKIP_CHAR();
if (cc == '\n') {
diff --git a/src/qdoc/config.h b/src/qdoc/config.h
index 44940dfa1..a7042e6b9 100644
--- a/src/qdoc/config.h
+++ b/src/qdoc/config.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- config.h
-*/
-
#ifndef CONFIG_H
#define CONFIG_H
@@ -147,7 +143,6 @@ public:
QRegularExpression getRegExp(const QString &var) const;
QList<QRegularExpression> getRegExpList(const QString &var) const;
QSet<QString> subVars(const QString &var) const;
- void subVarsAndValues(const QString &var, ConfigVarMap &map) const;
QStringList getAllFiles(const QString &filesVar, const QString &dirsVar,
const QSet<QString> &excludedDirs = QSet<QString>(),
const QSet<QString> &excludedFiles = QSet<QString>());
@@ -196,7 +191,6 @@ public:
QString previousCurrentDir() const { return m_previousCurrentDir; }
void setPreviousCurrentDir(const QString &path) { m_previousCurrentDir = path; }
- QDocPass qdocPass() const { return m_qdocPass; }
void setQDocPass(const QDocPass &pass) { m_qdocPass = pass; };
bool preparing() const { return (m_qdocPass == Prepare); }
bool generating() const { return (m_qdocPass == Generate); }
@@ -231,7 +225,6 @@ private:
Location m_lastLocation {};
ConfigVarMap m_configVars {};
- static QMap<QString, QString> m_uncompressedFiles;
static QMap<QString, QString> m_extractedDirs;
static QStack<QString> m_workingDirs;
static QMap<QString, QStringList> m_includeFilesMap;
@@ -316,7 +309,6 @@ struct ConfigStrings
static QString VERSIONSYM;
static QString FILEEXTENSIONS;
static QString IMAGEEXTENSIONS;
- static QString QMLONLY;
static QString QMLTYPESPAGE;
static QString QMLTYPESTITLE;
static QString WARNINGLIMIT;
@@ -396,7 +388,6 @@ struct ConfigStrings
#define CONFIG_VERSIONSYM ConfigStrings::VERSIONSYM
#define CONFIG_FILEEXTENSIONS ConfigStrings::FILEEXTENSIONS
#define CONFIG_IMAGEEXTENSIONS ConfigStrings::IMAGEEXTENSIONS
-#define CONFIG_QMLONLY ConfigStrings::QMLONLY
#define CONFIG_QMLTYPESPAGE ConfigStrings::QMLTYPESPAGE
#define CONFIG_QMLTYPESTITLE ConfigStrings::QMLTYPESTITLE
#define CONFIG_WARNINGLIMIT ConfigStrings::WARNINGLIMIT
diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp
index 9846a0dd8..0b6b9ab07 100644
--- a/src/qdoc/cppcodemarker.cpp
+++ b/src/qdoc/cppcodemarker.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- cppcodemarker.cpp
-*/
-
#include "cppcodemarker.h"
#include "access.h"
@@ -213,7 +209,7 @@ QString CppCodeMarker::markedUpSynopsis(const Node *node, const Node * /* relati
break;
case Node::TypeAlias:
if (style == Section::Details) {
- QString templateDecl = node->templateDecl();
+ const QString &templateDecl = node->templateDecl();
if (!templateDecl.isEmpty())
synopsis += templateDecl + QLatin1Char(' ');
}
@@ -257,17 +253,17 @@ QString CppCodeMarker::markedUpQmlItem(const Node *node, bool summary)
if (summary) {
name = linkTag(node, name);
} else if (node->isQmlProperty() || node->isJsProperty()) {
- const QmlPropertyNode *pn = static_cast<const QmlPropertyNode *>(node);
+ const auto *pn = static_cast<const QmlPropertyNode *>(node);
if (pn->isAttached())
name.prepend(pn->element() + QLatin1Char('.'));
}
name = "<@name>" + name + "</@name>";
QString synopsis;
if (node->isQmlProperty() || node->isJsProperty()) {
- const QmlPropertyNode *pn = static_cast<const QmlPropertyNode *>(node);
+ const auto *pn = static_cast<const QmlPropertyNode *>(node);
synopsis = name + " : " + typified(pn->dataType());
} else if (node->isFunction(Node::QML) || node->isFunction(Node::JS)) {
- const FunctionNode *func = static_cast<const FunctionNode *>(node);
+ const auto *func = static_cast<const FunctionNode *>(node);
if (!func->returnType().isEmpty())
synopsis = typified(func->returnType(), true) + name;
else
@@ -320,22 +316,6 @@ QString CppCodeMarker::markedUpName(const Node *node)
return name;
}
-QString CppCodeMarker::markedUpFullName(const Node *node, const Node *relative)
-{
- if (node->name().isEmpty())
- return "global";
-
- QString fullName;
- for (;;) {
- fullName.prepend(markedUpName(node));
- if (node->parent() == relative || node->parent()->name().isEmpty())
- break;
- fullName.prepend("<@op>::</@op>");
- node = node->parent();
- }
- return fullName;
-}
-
QString CppCodeMarker::markedUpEnumValue(const QString &enumValue, const Node *relative)
{
if (!relative->isEnumType())
diff --git a/src/qdoc/cppcodemarker.h b/src/qdoc/cppcodemarker.h
index 6a7515134..a645d1a36 100644
--- a/src/qdoc/cppcodemarker.h
+++ b/src/qdoc/cppcodemarker.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2018 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -48,7 +48,6 @@ public:
QString markedUpSynopsis(const Node *node, const Node *relative, Section::Style style) override;
QString markedUpQmlItem(const Node *node, bool summary) override;
QString markedUpName(const Node *node) override;
- QString markedUpFullName(const Node *node, const Node *relative) override;
QString markedUpEnumValue(const QString &enumValue, const Node *relative) override;
QString markedUpIncludes(const QStringList &includes) override;
QString functionBeginRegExp(const QString &funcName) override;
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp
index 106e5f75d..cdb3041d4 100644
--- a/src/qdoc/cppcodeparser.cpp
+++ b/src/qdoc/cppcodeparser.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -44,7 +44,6 @@
#include "sharedcommentnode.h"
#include <QtCore/qdebug.h>
-#include <QtCore/qfile.h>
#include <algorithm>
@@ -204,7 +203,7 @@ Node *CppCodeParser::processTopicCommand(const Doc &doc, const QString &command,
Node::NodeType type = m_nodeTypeMap[command];
QStringList words = arg.first.split(QLatin1Char(' '));
QStringList path;
- int idx = 0;
+ qsizetype idx = 0;
Node *node = nullptr;
if (type == Node::Variable && words.size() > 1)
@@ -231,8 +230,7 @@ Node *CppCodeParser::processTopicCommand(const Doc &doc, const QString &command,
if (isWorthWarningAbout(doc)) {
doc.location().warning(
QStringLiteral("Cannot find '%1' specified with '\\%2' in any header file")
- .arg(arg.first)
- .arg(command));
+ .arg(arg.first, command));
}
} else if (node->isAggregate()) {
if (type == Node::Namespace) {
@@ -416,7 +414,7 @@ void CppCodeParser::processQmlProperties(const Doc &doc, NodeList &nodes, DocLis
bool jsProps = isJSPropertyTopic(topic.topic);
arg = topic.args;
if (splitQmlPropertyArg(arg, type, module, qmlTypeName, property, doc.location())) {
- int i = property.indexOf('.');
+ qsizetype i = property.indexOf('.');
if (i != -1)
group = property.left(i);
}
@@ -528,17 +526,15 @@ void CppCodeParser::processMetaCommand(const Doc &doc, const QString &command,
if (fn->overridesThis().isEmpty() && isWorthWarningAbout(doc)) {
doc.location().warning(
QStringLiteral("Cannot find base function for '\\%1' in %2()")
- .arg(COMMAND_REIMP)
- .arg(node->name()),
+ .arg(COMMAND_REIMP, node->name()),
QStringLiteral("The function either doesn't exist in any "
"base class with the same signature or it "
"exists but isn't virtual."));
}
fn->setReimpFlag();
} else {
- doc.location().warning(QStringLiteral("Ignored '\\%1' in %2")
- .arg(COMMAND_REIMP)
- .arg(node->name()));
+ doc.location().warning(
+ QStringLiteral("Ignored '\\%1' in %2").arg(COMMAND_REIMP, node->name()));
}
}
} else if (command == COMMAND_RELATES) {
@@ -705,12 +701,12 @@ FunctionNode *CppCodeParser::parseOtherFuncArg(const QString &topic, const Locat
QString funcName;
QString returnType;
- int leftParen = funcArg.indexOf(QChar('('));
+ qsizetype leftParen = funcArg.indexOf(QChar('('));
if (leftParen > 0)
funcName = funcArg.left(leftParen);
else
funcName = funcArg;
- int firstBlank = funcName.indexOf(QChar(' '));
+ qsizetype firstBlank = funcName.indexOf(QChar(' '));
if (firstBlank > 0) {
returnType = funcName.left(firstBlank);
funcName = funcName.right(funcName.length() - firstBlank - 1);
@@ -782,7 +778,7 @@ FunctionNode *CppCodeParser::parseMacroArg(const Location &location, const QStri
QString params;
if (leftParenSplit.size() > 1) {
const QString &afterParen = leftParenSplit.at(1);
- int rightParen = afterParen.indexOf(')');
+ qsizetype rightParen = afterParen.indexOf(')');
if (rightParen >= 0)
params = afterParen.left(rightParen);
}
@@ -856,7 +852,7 @@ void CppCodeParser::setExampleFileLists(ExampleNode *en)
QLatin1String("*.qrc *.pro *.qmlproject *.pyproject CMakeLists.txt qmldir"));
}
- const int pathLen = exampleDir.path().size() - en->name().size();
+ const qsizetype pathLen = exampleDir.path().size() - en->name().size();
for (auto &file : exampleFiles)
file = file.mid(pathLen);
for (auto &file : imageFiles)
@@ -1006,7 +1002,7 @@ bool CppCodeParser::hasTooManyTopics(const Doc &doc) const
for (const auto &t : topicCommandsUsed)
topicList += QLatin1String(" \\") + t + QLatin1Char(',');
topicList[topicList.lastIndexOf(',')] = '.';
- int i = topicList.lastIndexOf(',');
+ qsizetype i = topicList.lastIndexOf(',');
Q_ASSERT(i >= 0); // we had at least two commas
topicList[i] = ' ';
topicList.insert(i + 1, "and");
diff --git a/src/qdoc/cppcodeparser.h b/src/qdoc/cppcodeparser.h
index f438a0082..897912d6e 100644
--- a/src/qdoc/cppcodeparser.h
+++ b/src/qdoc/cppcodeparser.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp
index 742dbffe9..cfe063303 100644
--- a/src/qdoc/doc.cpp
+++ b/src/qdoc/doc.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -294,7 +294,6 @@ void Doc::initialize()
Config &config = Config::instance();
DocParser::initialize(config);
- QmlTypeNode::qmlOnly = config.getBool(CONFIG_QMLONLY);
QStringMap reverseAliasMap;
for (const auto &a : config.subVars(CONFIG_ALIAS)) {
@@ -302,9 +301,7 @@ void Doc::initialize()
if (reverseAliasMap.contains(alias)) {
config.lastLocation().warning(QStringLiteral("Command name '\\%1' cannot stand"
" for both '\\%2' and '\\%3'")
- .arg(alias)
- .arg(reverseAliasMap[alias])
- .arg(a));
+ .arg(alias, reverseAliasMap[alias], a));
} else {
reverseAliasMap.insert(alias, a);
}
@@ -334,15 +331,11 @@ void Doc::initialize()
QString other = QStringLiteral("default");
if (macro.defaultDef.isEmpty())
other = macro.otherDefs.constBegin().key();
- config.lastLocation().warning(QStringLiteral("Macro '\\%1' takes"
- " inconsistent number"
- " of arguments (%2"
- " %3, %4 %5)")
- .arg(macroName)
- .arg(f)
- .arg(m)
- .arg(other)
- .arg(macro.numParams));
+ config.lastLocation().warning(
+ QStringLiteral("Macro '\\%1' takes inconsistent number of "
+ "arguments (%2 %3, %4 %5)")
+ .arg(macroName, f, QString::number(m), other,
+ QString::number(macro.numParams)));
silent = true;
}
if (macro.numParams < m)
@@ -445,7 +438,6 @@ CodeMarker *Doc::quoteFromFile(const Location &location, Quoter &quoter, const Q
}
}
- QString dirPath = QFileInfo(filePath).path();
CodeMarker *marker = CodeMarker::markerForFileName(fileName);
quoter.quoteFromFile(userFriendlyFilePath, code, marker->markedUpCode(code, nullptr, location));
return marker;
@@ -467,7 +459,7 @@ QString Doc::canonicalTitle(const QString &title)
bool dashAppended = false;
bool begun = false;
- int lastAlnum = 0;
+ qsizetype lastAlnum = 0;
for (int i = 0; i != title.size(); ++i) {
uint c = title.at(i).unicode();
if (c >= 'A' && c <= 'Z')
@@ -499,7 +491,7 @@ void Doc::detach()
--priv->count;
- DocPrivate *newPriv = new DocPrivate(*priv);
+ auto *newPriv = new DocPrivate(*priv);
newPriv->count = 1;
if (priv->extra)
newPriv->extra = new DocPrivateExtra(*priv->extra);
diff --git a/src/qdoc/doc.h b/src/qdoc/doc.h
index 6832743f0..b64f9261a 100644
--- a/src/qdoc/doc.h
+++ b/src/qdoc/doc.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -61,7 +61,6 @@ public:
enum Sections {
NoSection = -2,
Part = -1,
- Chapter = 1,
Section1 = 1,
Section2 = 2,
Section3 = 3,
diff --git a/src/qdoc/docbookgenerator.cpp b/src/qdoc/docbookgenerator.cpp
index 6919de47f..71857f53b 100644
--- a/src/qdoc/docbookgenerator.cpp
+++ b/src/qdoc/docbookgenerator.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2019 Thibaut Cuvelier
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -192,8 +193,7 @@ const Atom *DocBookGenerator::generateAtomList(const Atom *atom, const Node *rel
if (atom->type() == Atom::FormatEndif) {
if (generate && numAtoms0 == numAtoms) {
relative->location().warning(QStringLiteral("Output format %1 not handled %2")
- .arg(format())
- .arg(outFileName()));
+ .arg(format(), outFileName()));
Atom unhandledFormatAtom(Atom::UnhandledFormat, format());
generateAtomList(&unhandledFormatAtom, relative, generate, numAtoms);
}
@@ -219,7 +219,7 @@ const Atom *DocBookGenerator::generateAtomList(const Atom *atom, const Node *rel
/*!
Generate DocBook from an instance of Atom.
*/
-int DocBookGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker)
+qsizetype DocBookGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker)
{
Q_ASSERT(writer);
Q_UNUSED(marker);
@@ -913,7 +913,7 @@ void DocBookGenerator::generateClassHierarchy(const Node *relative, NodeMultiMap
writer->writeEndElement(); // itemizedlist
newLine();
} else {
- ClassNode *child = static_cast<ClassNode *>(*stack.top().begin());
+ auto *child = static_cast<ClassNode *>(*stack.top().begin());
writer->writeStartElement(dbNamespace, "listitem");
newLine();
writer->writeStartElement(dbNamespace, "para");
@@ -944,7 +944,7 @@ void DocBookGenerator::generateLink(const Atom *atom)
auto match = funcLeftParen.match(atom->string());
if (match.hasMatch()) {
// hack for C++: move () outside of link
- int k = match.capturedStart(1);
+ qsizetype k = match.capturedStart(1);
writer->writeCharacters(atom->string().left(k));
writer->writeEndElement(); // link
inLink = false;
@@ -1097,7 +1097,7 @@ void DocBookGenerator::generateCompactList(ListType listType, const Node *relati
return;
const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_'
- int commonPrefixLen = commonPrefix.length();
+ qsizetype commonPrefixLen = commonPrefix.length();
/*
Divide the data into 37 paragraphs: 0, ..., 9, A, ..., Z,
@@ -1575,12 +1575,12 @@ void DocBookGenerator::generateObsoleteMembers(const Sections &sections)
writer->writeEndElement(); // para
newLine();
- for (int i = 0; i < details_spv.size(); ++i) {
- QString title = details_spv.at(i)->title();
+ for (const Section *section : details_spv) {
+ const QString &title = section->title();
QString ref = registerRef(title.toLower());
startSection(ref, title);
- const NodeVector &members = details_spv.at(i)->obsoleteMembers();
+ const NodeVector &members = section->obsoleteMembers();
NodeVector::ConstIterator m = members.constBegin();
while (m != members.constEnd()) {
if ((*m)->access() != Access::Private)
@@ -1611,7 +1611,6 @@ void DocBookGenerator::generateObsoleteQmlMembers(const Sections &sections)
return;
Aggregate *aggregate = sections.aggregate();
- QString title = "Obsolete Members for " + aggregate->name();
QString fn = fileName(aggregate, fileExtension());
QString link;
if (useOutputSubdirs() && !Generator::outputSubdir().isEmpty())
@@ -1911,9 +1910,7 @@ void DocBookGenerator::generateQmlRequisites(const QmlTypeNode *qcn)
// Instantiates.
ClassNode *cn = (const_cast<QmlTypeNode *>(qcn))->classNode();
if (cn && (cn->status() != Node::Internal)) {
- const Node *otherNode = nullptr;
Atom a = Atom(Atom::LinkNode, CodeMarker::stringForNode(qcn));
- QString link = getAutoLink(&a, cn, &otherNode);
generateStartRequisite("Instantiates:");
generateSimpleLink(fullDocumentLocation(cn), cn->name());
@@ -2395,7 +2392,7 @@ void DocBookGenerator::generateMaintainerList(const Aggregate *node, CodeMarker
{
Q_UNUSED(marker);
// From Generator::generateMaintainerList.
- QStringList sl = getMetadataElements(node, "maintainer");
+ const QStringList sl = getMetadataElements(node, "maintainer");
if (!sl.isEmpty()) {
writer->writeStartElement(dbNamespace, "para");
@@ -2407,9 +2404,9 @@ void DocBookGenerator::generateMaintainerList(const Aggregate *node, CodeMarker
writer->writeStartElement(dbNamespace, "simplelist");
writer->writeAttribute("type", "vert");
writer->writeAttribute("role", "maintainer");
- for (int i = 0; i < sl.size(); ++i) {
+ for (const QString &maintainer : sl) {
writer->writeStartElement(dbNamespace, "member");
- writer->writeCharacters(sl.at(i));
+ writer->writeCharacters(maintainer);
writer->writeEndElement(); // member
newLine();
}
@@ -3454,7 +3451,7 @@ void DocBookGenerator::generateAddendum(const Node *node, Addendum type, CodeMar
{
if (!node->isFunction())
return;
- const FunctionNode *fn = static_cast<const FunctionNode *>(node);
+ const auto *fn = static_cast<const FunctionNode *>(node);
NodeList nodes = fn->associatedProperties();
if (nodes.isEmpty())
return;
@@ -3967,7 +3964,6 @@ void DocBookGenerator::generateDetailedQmlMember(Node *node, const Aggregate *re
writer->writeAttribute("renderas", "sect2");
// Write the title.
- QString title;
if (node->isFunction(Node::QML) || node->isFunction(Node::JS))
generateQmlMethodTitle(node);
else if (node->isQmlProperty() || node->isJsProperty())
diff --git a/src/qdoc/docbookgenerator.h b/src/qdoc/docbookgenerator.h
index 8de9160cf..33bbdb5c7 100644
--- a/src/qdoc/docbookgenerator.h
+++ b/src/qdoc/docbookgenerator.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2019 Thibaut Cuvelier
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -89,7 +90,8 @@ protected:
CodeMarker *marker = nullptr) override;
const Atom *generateAtomList(const Atom *atom, const Node *relative, bool generate,
int &numAtoms);
- int generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker = nullptr) override;
+ qsizetype generateAtom(const Atom *atom, const Node *relative,
+ CodeMarker *marker = nullptr) override;
private:
QXmlStreamWriter *startDocument(const Node *node);
diff --git a/src/qdoc/docparser.cpp b/src/qdoc/docparser.cpp
index 14e4aff9e..0147ce043 100644
--- a/src/qdoc/docparser.cpp
+++ b/src/qdoc/docparser.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -269,7 +269,7 @@ bool DocParser::quoting = false;
static QString cleanLink(const QString &link)
{
- int colonPos = link.indexOf(':');
+ qsizetype colonPos = link.indexOf(':');
if ((colonPos == -1) || (!link.startsWith("file:") && !link.startsWith("mailto:")))
return link;
return link.mid(colonPos + 1).simplified();
@@ -487,7 +487,7 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate,
break;
}
case CMD_ELSE:
- if (preprocessorSkipping.size() > 0) {
+ if (!preprocessorSkipping.empty()) {
if (preprocessorSkipping.top()) {
--numPreprocessorSkipping;
} else {
@@ -624,12 +624,12 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate,
} else {
if (m_openedCommands.contains(CMD_TABLE))
location().warning(QStringLiteral("Cannot use '\\%1' within '\\%2'")
- .arg(cmdName(CMD_HEADER))
- .arg(cmdName(m_openedCommands.top())));
+ .arg(cmdName(CMD_HEADER),
+ cmdName(m_openedCommands.top())));
else
- location().warning(QStringLiteral("Cannot use '\\%1' outside of '\\%2'")
- .arg(cmdName(CMD_HEADER))
- .arg(cmdName(CMD_TABLE)));
+ location().warning(
+ QStringLiteral("Cannot use '\\%1' outside of '\\%2'")
+ .arg(cmdName(CMD_HEADER), cmdName(CMD_TABLE)));
}
break;
case CMD_I:
@@ -784,9 +784,8 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate,
if (!m_inTableHeader && !m_inTableRow) {
location().warning(
QStringLiteral("Missing '\\%1' or '\\%2' before '\\%3'")
- .arg(cmdName(CMD_HEADER))
- .arg(cmdName(CMD_ROW))
- .arg(cmdName(CMD_LI)));
+ .arg(cmdName(CMD_HEADER), cmdName(CMD_ROW),
+ cmdName(CMD_LI)));
append(Atom::TableRowLeft);
m_inTableRow = true;
} else if (m_inTableItem) {
@@ -799,9 +798,7 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate,
} else
location().warning(
QStringLiteral("Command '\\%1' outside of '\\%2' and '\\%3'")
- .arg(cmdName(cmd))
- .arg(cmdName(CMD_LIST))
- .arg(cmdName(CMD_TABLE)));
+ .arg(cmdName(cmd), cmdName(CMD_LIST), cmdName(CMD_TABLE)));
break;
case CMD_OLDCODE:
leavePara();
@@ -915,12 +912,11 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate,
} else {
if (m_openedCommands.contains(CMD_TABLE))
location().warning(QStringLiteral("Cannot use '\\%1' within '\\%2'")
- .arg(cmdName(CMD_ROW))
- .arg(cmdName(m_openedCommands.top())));
+ .arg(cmdName(CMD_ROW),
+ cmdName(m_openedCommands.top())));
else
location().warning(QStringLiteral("Cannot use '\\%1' outside of '\\%2'")
- .arg(cmdName(CMD_ROW))
- .arg(cmdName(CMD_TABLE)));
+ .arg(cmdName(CMD_ROW), cmdName(CMD_TABLE)));
}
break;
case CMD_SA:
@@ -1248,7 +1244,7 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate,
}
if (newWord) {
- int startPos = m_position;
+ qsizetype startPos = m_position;
bool autolink = isAutoLinkString(m_input, m_position);
if (m_position == startPos) {
if (!ch.isSpace()) {
@@ -1321,8 +1317,7 @@ QString DocParser::detailsUnknownCommand(const QSet<QString> &metaCommandSet, co
if (m_utilities.aliasMap.contains(str))
return QStringLiteral("The command '\\%1' was renamed '\\%2' by the configuration"
" file. Use the new name.")
- .arg(str)
- .arg(m_utilities.aliasMap[str]);
+ .arg(str, m_utilities.aliasMap[str]);
QString best = nearestName(str, commandSet);
if (best.isEmpty())
@@ -1384,9 +1379,8 @@ void DocParser::include(const QString &fileName, const QString &identifier)
++i;
}
if (startLine < 0) {
- location().warning(QStringLiteral("Cannot find '%1' in '%2'")
- .arg(identifier)
- .arg(filePath));
+ location().warning(
+ QStringLiteral("Cannot find '%1' in '%2'").arg(identifier, filePath));
return;
}
QString result;
@@ -1404,8 +1398,7 @@ void DocParser::include(const QString &fileName, const QString &identifier)
} while (i < lineBuffer.size());
if (result.isEmpty()) {
location().warning(QStringLiteral("Empty qdoc snippet '%1' in '%2'")
- .arg(identifier)
- .arg(filePath));
+ .arg(identifier, filePath));
} else {
m_input.insert(m_position, result);
m_inputLength = m_input.length();
@@ -1467,7 +1460,7 @@ bool DocParser::openCommand(int cmd)
m_openedCommands.push(cmd);
} else {
location().warning(
- QStringLiteral("Can't use '\\%1' in '\\%2'").arg(cmdName(cmd)).arg(cmdName(outer)));
+ QStringLiteral("Can't use '\\%1' in '\\%2'").arg(cmdName(cmd), cmdName(outer)));
}
return ok;
}
@@ -1477,14 +1470,14 @@ bool DocParser::openCommand(int cmd)
*/
inline bool DocParser::isAutoLinkString(const QString &word)
{
- int start = 0;
+ qsizetype start = 0;
return isAutoLinkString(word, start);
}
-bool DocParser::isAutoLinkString(const QString &word, int &curPos)
+bool DocParser::isAutoLinkString(const QString &word, qsizetype &curPos)
{
- int len = word.size();
- int startPos = curPos;
+ qsizetype len = word.size();
+ qsizetype startPos = curPos;
int numUppercase = 0;
int numLowercase = 0;
int numStrangeSymbols = 0;
@@ -1547,9 +1540,9 @@ bool DocParser::closeCommand(int endCmd)
if (contains) {
while (endCmdFor(m_openedCommands.top()) != endCmd && m_openedCommands.size() > 1) {
- location().warning(QStringLiteral("Missing '\\%1' before '\\%2'")
- .arg(endCmdName(m_openedCommands.top()))
- .arg(cmdName(endCmd)));
+ location().warning(
+ QStringLiteral("Missing '\\%1' before '\\%2'")
+ .arg(endCmdName(m_openedCommands.top()), cmdName(endCmd)));
m_openedCommands.pop();
}
} else {
@@ -1819,7 +1812,7 @@ bool DocParser::expandMacro()
Q_ASSERT(m_input[m_position].unicode() == '\\');
QString cmdStr;
- int backslashPos = m_position++;
+ qsizetype backslashPos = m_position++;
while (m_position < m_input.length() && m_input[m_position].isLetterOrNumber())
cmdStr += m_input[m_position++];
@@ -1933,7 +1926,7 @@ QString DocParser::expandMacroToString(const QString &name, const QString &def,
QString result;
QRegularExpression re(matchExpr);
int capStart = (re.captureCount() > 0) ? 1 : 0;
- int i = 0;
+ qsizetype i = 0;
QRegularExpressionMatch match;
while ((match = re.match(rawString, i)).hasMatch()) {
for (int c = capStart; c <= re.captureCount(); ++c)
@@ -2029,7 +2022,7 @@ QString DocParser::getArgument(bool verbatim)
skipSpacesOrOneEndl();
int delimDepth = 0;
- int startPos = m_position;
+ qsizetype startPos = m_position;
QString arg = getBracedArgument(verbatim);
if (arg.isEmpty()) {
while ((m_position < m_input.length())
@@ -2135,7 +2128,7 @@ QString DocParser::getRestOfLine()
bool trailingSlash = false;
do {
- int begin = m_position;
+ qsizetype begin = m_position;
while (m_position < m_input.size() && m_input[m_position] != '\n') {
if (m_input[m_position] == '\\' && !trailingSlash) {
@@ -2174,7 +2167,7 @@ QString DocParser::getMetaCommandArgument(const QString &cmdStr)
{
skipSpacesOnLine();
- int begin = m_position;
+ qsizetype begin = m_position;
int parenDepth = 0;
while (m_position < m_input.size() && (m_input[m_position] != '\n' || parenDepth > 0)) {
@@ -2207,7 +2200,7 @@ QString DocParser::getUntilEnd(int cmd)
location().warning(QStringLiteral("Missing '\\%1'").arg(cmdName(endCmd)));
m_position = m_input.length();
} else {
- int end = match.capturedStart();
+ qsizetype end = match.capturedStart();
t = m_input.mid(m_position, end - m_position);
m_position = match.capturedEnd();
}
@@ -2220,7 +2213,7 @@ QString DocParser::getCode(int cmd, CodeMarker *marker, const QString &argStr)
if (!argStr.isEmpty()) {
QStringList args = argStr.split(" ", Qt::SkipEmptyParts);
- int paramNo, j = 0;
+ qsizetype paramNo, j = 0;
while (j < code.size()) {
if (code[j] == '\\' && j < code.size() - 1 && (paramNo = code[j + 1].digitValue()) >= 1
&& paramNo <= args.size()) {
@@ -2242,7 +2235,7 @@ QString DocParser::getCode(int cmd, CodeMarker *marker, const QString &argStr)
bool DocParser::isBlankLine()
{
- int i = m_position;
+ qsizetype i = m_position;
while (i < m_inputLength && m_input[i].isSpace()) {
if (m_input[i] == '\n')
@@ -2255,7 +2248,7 @@ bool DocParser::isBlankLine()
bool DocParser::isLeftBraceAhead()
{
int numEndl = 0;
- int i = m_position;
+ qsizetype i = m_position;
while (i < m_inputLength && m_input[i].isSpace() && numEndl < 2) {
// ### bug with '\\'
@@ -2269,7 +2262,7 @@ bool DocParser::isLeftBraceAhead()
bool DocParser::isLeftBracketAhead()
{
int numEndl = 0;
- int i = m_position;
+ qsizetype i = m_position;
while (i < m_inputLength && m_input[i].isSpace() && numEndl < 2) {
// ### bug with '\\'
@@ -2295,7 +2288,7 @@ void DocParser::skipSpacesOnLine()
*/
void DocParser::skipSpacesOrOneEndl()
{
- int firstEndl = -1;
+ qsizetype firstEndl = -1;
while (m_position < m_input.length() && m_input[m_position].isSpace()) {
QChar ch = m_input[m_position];
if (ch == '\n') {
diff --git a/src/qdoc/docparser.h b/src/qdoc/docparser.h
index f5f9d3607..83f5441b0 100644
--- a/src/qdoc/docparser.h
+++ b/src/qdoc/docparser.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -112,7 +112,7 @@ private:
QString getCode(int cmd, CodeMarker *marker, const QString &argStr = QString());
inline bool isAutoLinkString(const QString &word);
- bool isAutoLinkString(const QString &word, int &curPos);
+ bool isAutoLinkString(const QString &word, qsizetype &curPos);
bool isBlankLine();
bool isLeftBraceAhead();
bool isLeftBracketAhead();
@@ -123,15 +123,15 @@ private:
static bool isCode(const Atom *atom);
static bool isQuote(const Atom *atom);
- QStack<int> m_openedInputs;
+ QStack<qsizetype> m_openedInputs;
QString m_input;
- int m_position {};
- int m_backslashPosition {};
- int m_endPosition {};
- int m_inputLength {};
+ qsizetype m_position {};
+ qsizetype m_backslashPosition {};
+ qsizetype m_endPosition {};
+ qsizetype m_inputLength {};
Location m_cachedLocation;
- int m_cachedPosition {};
+ qsizetype m_cachedPosition {};
DocPrivate *m_private { nullptr };
enum ParagraphState { OutsideParagraph, InSingleLineParagraph, InMultiLineParagraph };
diff --git a/src/qdoc/docprivate.cpp b/src/qdoc/docprivate.cpp
index 14ece93da..609f58b9d 100644
--- a/src/qdoc/docprivate.cpp
+++ b/src/qdoc/docprivate.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -27,8 +27,6 @@
****************************************************************************/
#include "docprivate.h"
-#include "atom.h"
-#include "openedlist.h"
#include "text.h"
#include <QtCore/qhash.h>
diff --git a/src/qdoc/docprivate.h b/src/qdoc/docprivate.h
index 1c7969f1a..8463e538d 100644
--- a/src/qdoc/docprivate.h
+++ b/src/qdoc/docprivate.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -73,11 +73,7 @@ class DocPrivate
public:
explicit DocPrivate(const Location &start = Location(), const Location &end = Location(),
const QString &source = QString())
- : start_loc(start),
- end_loc(end),
- src(source),
- hasLegalese(false),
- hasSectioningUnits(false) {};
+ : start_loc(start), end_loc(end), src(source), hasLegalese(false) {};
~DocPrivate();
void addAlso(const Text &also);
@@ -101,7 +97,6 @@ public:
TopicList topics_;
bool hasLegalese : 1;
- bool hasSectioningUnits : 1;
};
QT_END_NAMESPACE
diff --git a/src/qdoc/editdistance.cpp b/src/qdoc/editdistance.cpp
index 841f5f48d..64b18604b 100644
--- a/src/qdoc/editdistance.cpp
+++ b/src/qdoc/editdistance.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- editdistance.cpp
-*/
-
#include "editdistance.h"
QT_BEGIN_NAMESPACE
@@ -39,8 +35,8 @@ int editDistance(const QString &s, const QString &t)
#define D(i, j) d[(i)*n + (j)]
int i;
int j;
- int m = s.length() + 1;
- int n = t.length() + 1;
+ qsizetype m = s.length() + 1;
+ qsizetype n = t.length() + 1;
int *d = new int[m * n];
int result;
diff --git a/src/qdoc/editdistance.h b/src/qdoc/editdistance.h
index c7ea080cd..9727b6ddd 100644
--- a/src/qdoc/editdistance.h
+++ b/src/qdoc/editdistance.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- editdistance.h
-*/
-
#ifndef EDITDISTANCE_H
#define EDITDISTANCE_H
diff --git a/src/qdoc/enumitem.h b/src/qdoc/enumitem.h
index 6755d7c40..5ce3f79e2 100644
--- a/src/qdoc/enumitem.h
+++ b/src/qdoc/enumitem.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -32,13 +32,15 @@
#include <QtCore/qglobal.h>
#include <QtCore/qstring.h>
+#include <utility>
+
QT_BEGIN_NAMESPACE
class EnumItem
{
public:
EnumItem() = default;
- EnumItem(const QString &name, const QString &value) : m_name(name), m_value(value) {}
+ EnumItem(QString name, QString value) : m_name(std::move(name)), m_value(std::move(value)) { }
const QString &name() const { return m_name; }
const QString &value() const { return m_value; }
diff --git a/src/qdoc/examplenode.h b/src/qdoc/examplenode.h
index 22fb364d9..598f8e535 100644
--- a/src/qdoc/examplenode.h
+++ b/src/qdoc/examplenode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -46,12 +46,12 @@ public:
const QStringList &files() const { return m_files; }
const QStringList &images() const { return m_images; }
const QString &projectFile() const { return m_projectFile; }
- void setFiles(const QStringList files, const QString &projectFile)
+ void setFiles(const QStringList &files, const QString &projectFile)
{
m_files = files;
m_projectFile = projectFile;
}
- void setImages(const QStringList images) { m_images = images; }
+ void setImages(const QStringList &images) { m_images = images; }
void appendFile(QString &file) { m_files.append(file); }
void appendImage(QString &image) { m_images.append(image); }
diff --git a/src/qdoc/functionnode.cpp b/src/qdoc/functionnode.cpp
index 53694e5b5..d68233313 100644
--- a/src/qdoc/functionnode.cpp
+++ b/src/qdoc/functionnode.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -132,7 +132,7 @@ FunctionNode::FunctionNode(Metaness kind, Aggregate *parent, const QString &name
*/
Node *FunctionNode::clone(Aggregate *parent)
{
- FunctionNode *fn = new FunctionNode(*this); // shallow copy
+ auto *fn = new FunctionNode(*this); // shallow copy
fn->setParent(nullptr);
fn->setNextOverload(nullptr);
parent->addChild(fn);
@@ -272,17 +272,6 @@ FunctionNode::Metaness FunctionNode::getMetanessFromTopic(const QString &topic)
}
/*!
- Sets the function node's Metaness value based on the value
- of string \a metaness, which is the value of the function's "meta"
- attribute in an index file. Returns the Metaness value
- */
-FunctionNode::Metaness FunctionNode::setMetaness(const QString &metaness)
-{
- m_metaness = getMetaness(metaness);
- return m_metaness;
-}
-
-/*!
If this function node's metaness is \a from, change the
metaness to \a to and return \c true. Otherwise return
false. This function is used to change Qml function node
@@ -330,7 +319,7 @@ bool FunctionNode::changeMetaness(Metaness from, Metaness to)
void FunctionNode::setOverloadNumber(signed short number)
{
m_overloadNumber = number;
- m_overloadFlag = (number > 0) ? true : false;
+ m_overloadFlag = (number > 0);
}
/*!
diff --git a/src/qdoc/functionnode.h b/src/qdoc/functionnode.h
index 55870b1cc..fed895876 100644
--- a/src/qdoc/functionnode.h
+++ b/src/qdoc/functionnode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -72,7 +72,6 @@ public:
QString metanessString() const;
bool changeMetaness(Metaness from, Metaness to);
void setMetaness(Metaness metaness) { m_metaness = metaness; }
- Metaness setMetaness(const QString &metaness);
QString kindString() const;
static Metaness getMetaness(const QString &value);
static Metaness getMetanessFromTopic(const QString &topic);
@@ -137,7 +136,6 @@ public:
const QString &overridesThis() const { return m_overridesThis; }
const NodeList &associatedProperties() const { return m_associatedProperties; }
- const QStringList &parentPath() const { return m_parentPath; }
bool hasAssociatedProperties() const { return !m_associatedProperties.isEmpty(); }
bool hasOneAssociatedProperty() const { return (m_associatedProperties.size() == 1); }
Node *firstAssociatedProperty() const { return m_associatedProperties[0]; }
@@ -173,7 +171,6 @@ public:
bool compare(const Node *node, bool sameParent = true) const;
bool isIgnored() const;
bool hasOverloads() const;
- void clearOverloadFlag() { m_overloadFlag = false; }
void setOverloadFlag() { m_overloadFlag = true; }
void setOverloadNumber(signed short number);
void appendOverload(FunctionNode *functionNode);
diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp
index 5eaa7fbe9..ecb539e6e 100644
--- a/src/qdoc/generator.cpp
+++ b/src/qdoc/generator.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,9 +26,6 @@
**
****************************************************************************/
-/*
- generator.cpp
-*/
#include "generator.h"
#include "access.h"
@@ -133,15 +130,6 @@ void Generator::appendFullName(Text &text, const Node *apparentNode, const QStri
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK);
}
-void Generator::appendFullNames(Text &text, const NodeList &nodes, const Node *relative)
-{
- int index = 0;
- for (const auto &node : nodes) {
- appendFullName(text, node, relative);
- text << Utilities::comma(index++, nodes.count());
- }
-}
-
/*!
Append the signature for the function named in \a node to
\a text, so that is is a link to the documentation for that
@@ -262,7 +250,7 @@ QFile *Generator::openSubPageFile(const Node *node, const QString &fileName)
void Generator::beginFilePage(const Node *node, const QString &fileName)
{
QFile *outFile = openSubPageFile(node, fileName);
- QTextStream *out = new QTextStream(outFile);
+ auto *out = new QTextStream(outFile);
outStreamStack.push(out);
}
@@ -390,7 +378,7 @@ QString Generator::fileBase(const Node *node) const
p = pp;
}
if (node->isNamespace() && !node->name().isEmpty()) {
- const NamespaceNode *ns = static_cast<const NamespaceNode *>(node);
+ const auto *ns = static_cast<const NamespaceNode *>(node);
if (!ns->isDocumentedHere()) {
base.append(QLatin1String("-sub-"));
base.append(ns->tree()->camelCaseModuleName());
@@ -589,7 +577,7 @@ QString Generator::fullDocumentLocation(const Node *node, bool useSubdir)
parentName = fileBase(node) + QLatin1Char('.') + currentGenerator()->fileExtension();
break;
case Node::Function: {
- const FunctionNode *fn = static_cast<const FunctionNode *>(node);
+ const auto *fn = static_cast<const FunctionNode *>(node);
switch (fn->metaness()) {
case FunctionNode::JsSignal:
case FunctionNode::QmlSignal:
@@ -717,8 +705,7 @@ const Atom *Generator::generateAtomList(const Atom *atom, const Node *relative,
if (atom->type() == Atom::FormatEndif) {
if (generate && numAtoms0 == numAtoms) {
relative->location().warning(QStringLiteral("Output format %1 not handled %2")
- .arg(format())
- .arg(outFileName()));
+ .arg(format(), outFileName()));
Atom unhandledFormatAtom(Atom::UnhandledFormat, format());
generateAtomList(&unhandledFormatAtom, relative, marker, generate, numAtoms);
}
@@ -830,7 +817,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
// Generate warnings
if (node->isEnumType()) {
- const EnumNode *enume = static_cast<const EnumNode *>(node);
+ const auto *enume = static_cast<const EnumNode *>(node);
QSet<QString> definedItems;
const QList<EnumItem> &items = enume->items();
@@ -851,14 +838,12 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
node->doc().location().warning(
QStringLiteral("No such enum item '%1' in %2")
- .arg(it)
- .arg(node->plainFullName()),
+ .arg(it, node->plainFullName()),
details);
} else if (!documentedItems.contains(it)) {
node->doc().location().warning(
QStringLiteral("Undocumented enum item '%1' in %2")
- .arg(it)
- .arg(node->plainFullName()));
+ .arg(it, node->plainFullName()));
}
}
}
@@ -872,8 +857,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
if (!fn->isMarkedReimp() && !fn->isOverload()) {
fn->doc().location().warning(
QStringLiteral("Undocumented parameter '%1' in %2")
- .arg(name)
- .arg(node->plainFullName()));
+ .arg(name, node->plainFullName()));
}
}
}
@@ -885,8 +869,7 @@ void Generator::generateBody(const Node *node, CodeMarker *marker)
if (!best.isEmpty())
details = QStringLiteral("Maybe you meant '%1'?").arg(best);
fn->doc().location().warning(QStringLiteral("No such parameter '%1' in %2")
- .arg(name)
- .arg(fn->plainFullName()),
+ .arg(name, fn->plainFullName()),
details);
}
}
@@ -919,7 +902,7 @@ void Generator::generateRequiredLinks(const Node *node, CodeMarker *marker)
if (!node->isExample())
return;
- const ExampleNode *en = static_cast<const ExampleNode *>(node);
+ const auto *en = static_cast<const ExampleNode *>(node);
QString exampleUrl = Config::instance().getString(CONFIG_URL + Config::dot + CONFIG_EXAMPLES);
if (exampleUrl.isEmpty()) {
@@ -1043,32 +1026,6 @@ void Generator::generateFileList(const ExampleNode *en, CodeMarker *marker, bool
generateText(text, en, marker);
}
-void Generator::generateInherits(const ClassNode *classe, CodeMarker *marker)
-{
- if (!classe->baseClasses().isEmpty()) {
- Text text;
- text << Atom::ParaLeft << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
- << "Inherits: " << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD);
-
- int index = 0;
- const QList<RelatedClass> &baseClasses = classe->baseClasses();
- for (const auto &cls : baseClasses) {
- if (cls.m_node) {
- appendFullName(text, cls.m_node, classe);
-
- if (cls.m_access == Access::Protected) {
- text << " (protected)";
- } else if (cls.m_access == Access::Private) {
- text << " (private)";
- }
- text << Utilities::separator(index++, classe->baseClasses().count());
- }
- }
- text << Atom::ParaRight;
- generateText(text, classe, marker);
- }
-}
-
/*!
Recursive writing of HTML files from the root \a node.
*/
@@ -1112,7 +1069,7 @@ void Generator::generateDocumentation(Node *node)
members of cn in the other modules and add them
to the members list.
*/
- CollectionNode *cn = static_cast<CollectionNode *>(node);
+ auto *cn = static_cast<CollectionNode *>(node);
if (cn->wasSeen()) {
m_qdb->mergeCollections(cn);
beginSubPage(node, fileName(node));
@@ -1142,12 +1099,12 @@ void Generator::generateDocumentation(Node *node)
endSubPage();
} else if (node->isQmlType() || node->isJsType()) {
beginSubPage(node, fileName(node));
- QmlTypeNode *qcn = static_cast<QmlTypeNode *>(node);
+ auto *qcn = static_cast<QmlTypeNode *>(node);
generateQmlTypePage(qcn, marker);
endSubPage();
} else if (node->isQmlBasicType() || node->isJsBasicType()) {
beginSubPage(node, fileName(node));
- QmlBasicTypeNode *qbtn = static_cast<QmlBasicTypeNode *>(node);
+ auto *qbtn = static_cast<QmlBasicTypeNode *>(node);
generateQmlBasicTypePage(qbtn, marker);
endSubPage();
} else if (node->isProxyNode()) {
@@ -1159,7 +1116,7 @@ void Generator::generateDocumentation(Node *node)
}
if (node->isAggregate()) {
- Aggregate *aggregate = static_cast<Aggregate *>(node);
+ auto *aggregate = static_cast<Aggregate *>(node);
const NodeList &children = aggregate->childNodes();
for (auto *node : children) {
if (node->isPageNode() && !node->isPrivate())
@@ -1189,25 +1146,6 @@ void Generator::generateMaintainerList(const Aggregate *node, CodeMarker *marker
}
/*!
- Output the "Inherit by" list for the QML element,
- if it is inherited by any other elements.
- */
-void Generator::generateQmlInheritedBy(const QmlTypeNode *qcn, CodeMarker *marker)
-{
- if (qcn) {
- NodeList subs;
- QmlTypeNode::subclasses(qcn, subs);
- if (!subs.isEmpty()) {
- Text text;
- text << Atom::ParaLeft << "Inherited by ";
- appendSortedQmlNames(text, qcn, subs);
- text << Atom::ParaRight;
- generateText(text, qcn, marker);
- }
- }
-}
-
-/*!
Extract sections of markup text surrounded by \e qmltext
and \e endqmltext and output them.
*/
@@ -1240,7 +1178,7 @@ void Generator::generateReimplementsClause(const FunctionNode *fn, CodeMarker *m
{
if (!fn->overridesThis().isEmpty()) {
if (fn->parent()->isClassNode()) {
- ClassNode *cn = static_cast<ClassNode *>(fn->parent());
+ auto *cn = static_cast<ClassNode *>(fn->parent());
const FunctionNode *overrides = cn->findOverriddenFunction(fn);
if (overrides && !overrides->isPrivate() && !overrides->parent()->isPrivate()) {
if (overrides->hasDoc()) {
@@ -1365,7 +1303,7 @@ void Generator::generateAddendum(const Node *node, Addendum type, CodeMarker *ma
case QmlSignalHandler:
{
QString handler(node->name());
- int prefixLocation = handler.lastIndexOf('.', -2) + 1;
+ qsizetype prefixLocation = handler.lastIndexOf('.', -2) + 1;
handler[prefixLocation] = handler[prefixLocation].toTitleCase();
handler.insert(prefixLocation, QLatin1String("on"));
text << "The corresponding handler is "
@@ -1377,14 +1315,14 @@ void Generator::generateAddendum(const Node *node, Addendum type, CodeMarker *ma
{
if (!node->isFunction())
return;
- const FunctionNode *fn = static_cast<const FunctionNode *>(node);
+ const auto *fn = static_cast<const FunctionNode *>(node);
NodeList nodes = fn->associatedProperties();
if (nodes.isEmpty())
return;
std::sort(nodes.begin(), nodes.end(), Node::nodeNameLessThan);
for (const auto *n : qAsConst(nodes)) {
QString msg;
- const PropertyNode *pn = static_cast<const PropertyNode *>(n);
+ const auto *pn = static_cast<const PropertyNode *>(n);
switch (pn->role(fn)) {
case PropertyNode::Getter:
msg = QStringLiteral("Getter function");
@@ -1684,7 +1622,7 @@ QString Generator::imageFileName(const Node *relative, const QString &fileBase)
QString path = Config::copyFile(relative->doc().location(), filePath, userFriendlyFilePath,
outputDir() + QLatin1String("/images"));
- int images_slash = path.lastIndexOf("images/");
+ qsizetype images_slash = path.lastIndexOf("images/");
QString relImagePath;
if (images_slash != -1)
relImagePath = path.mid(images_slash);
@@ -1945,8 +1883,8 @@ bool Generator::parseArg(const QString &src, const QString &tag, int *pos, int n
while (i < n && src[i] == ' ') \
++i;
- int i = *pos;
- int j = i;
+ qsizetype i = *pos;
+ qsizetype j = i;
// assume "<@" has been parsed outside
// SKIP_CHAR('<');
@@ -2034,14 +1972,6 @@ void Generator::setImageFileExtensions(const QStringList &extensions)
imgFileExts[format()] = extensions;
}
-void Generator::singularPlural(Text &text, const NodeList &nodes)
-{
- if (nodes.count() == 1)
- text << " is";
- else
- text << " are";
-}
-
int Generator::skipAtoms(const Atom *atom, Atom::AtomType type) const
{
int skipAhead = 0;
@@ -2208,8 +2138,7 @@ QString Generator::typeString(const Node *node)
void Generator::unknownAtom(const Atom *atom)
{
Location::internalError(QStringLiteral("unknown atom type '%1' in %2 generator")
- .arg(atom->typeString())
- .arg(format()));
+ .arg(atom->typeString(), format()));
}
QT_END_NAMESPACE
diff --git a/src/qdoc/generator.h b/src/qdoc/generator.h
index 3892617cf..d69845fef 100644
--- a/src/qdoc/generator.h
+++ b/src/qdoc/generator.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -108,7 +108,7 @@ protected:
virtual QString fileExtension() const = 0;
virtual void generateExampleFilePage(const Node *, const QString &, CodeMarker *) {}
virtual void generateAlsoList(const Node *node, CodeMarker *marker);
- virtual int generateAtom(const Atom *, const Node *, CodeMarker *) { return 0; }
+ virtual qsizetype generateAtom(const Atom *, const Node *, CodeMarker *) { return 0; }
virtual void generateBody(const Node *node, CodeMarker *marker);
virtual void generateCppReferencePage(Aggregate *, CodeMarker *) {}
virtual void generateProxyPage(Aggregate *, CodeMarker *) {}
@@ -117,11 +117,8 @@ protected:
virtual void generatePageNode(PageNode *, CodeMarker *) {}
virtual void generateCollectionNode(CollectionNode *, CodeMarker *) {}
virtual void generateGenericCollectionPage(CollectionNode *, CodeMarker *) {}
- virtual void generateInherits(const ClassNode *classe, CodeMarker *marker);
virtual void generateDocumentation(Node *node);
virtual void generateMaintainerList(const Aggregate *node, CodeMarker *marker);
- virtual void generateQmlInheritedBy(const QmlTypeNode *qcn, CodeMarker *marker);
- virtual void generateQmlInherits(QmlTypeNode *, CodeMarker *) {}
virtual bool generateQmlText(const Text &text, const Node *relative, CodeMarker *marker,
const QString &qmlName);
virtual bool generateText(const Text &text, const Node *relative, CodeMarker *marker);
@@ -131,7 +128,6 @@ protected:
static bool matchAhead(const Atom *atom, Atom::AtomType expectedAtomType);
static QString outputPrefix(const Node *node);
static QString outputSuffix(const Node *node);
- static void singularPlural(Text &text, const NodeList &nodes);
static void supplementAlsoList(const Node *node, QList<Text> &alsoList);
static QString trimmedTrailing(const QString &string, const QString &prefix,
const QString &suffix);
@@ -174,14 +170,12 @@ protected:
const Node *actualNode = nullptr);
void appendFullName(Text &text, const Node *apparentNode, const QString &fullName,
const Node *actualNode);
- void appendFullNames(Text &text, const NodeList &nodes, const Node *relative);
int appendSortedNames(Text &text, const ClassNode *classe,
const QList<RelatedClass> &classes);
void appendSignature(Text &text, const Node *node);
void signatureList(const NodeList &nodes, const Node *relative, CodeMarker *marker);
void addImageToCopy(const ExampleNode *en, const QString &file);
- static bool compareNodes(const Node *a, const Node *b) { return (a->name() < b->name()); }
static bool comparePaths(const QString &a, const QString &b) { return (a < b); }
private:
diff --git a/src/qdoc/headernode.cpp b/src/qdoc/headernode.cpp
index ada156e83..f28d37362 100644
--- a/src/qdoc/headernode.cpp
+++ b/src/qdoc/headernode.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -52,7 +52,7 @@ bool HeaderNode::docMustBeGenerated() const
{
if (isInAPI())
return true;
- return (hasDocumentedChildren() ? true : false);
+ return hasDocumentedChildren();
}
/*!
diff --git a/src/qdoc/headernode.h b/src/qdoc/headernode.h
index e50e23c55..bae57c8d5 100644
--- a/src/qdoc/headernode.h
+++ b/src/qdoc/headernode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
diff --git a/src/qdoc/helpprojectwriter.cpp b/src/qdoc/helpprojectwriter.cpp
index 64f76fb20..fa352bb23 100644
--- a/src/qdoc/helpprojectwriter.cpp
+++ b/src/qdoc/helpprojectwriter.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -44,7 +44,6 @@
#include <QtCore/qcryptographichash.h>
#include <QtCore/qdebug.h>
#include <QtCore/qhash.h>
-#include <QtCore/qmap.h>
QT_BEGIN_NAMESPACE
@@ -185,14 +184,8 @@ void HelpProjectWriter::readSelectors(SubProject &subproject, const QStringList
void HelpProjectWriter::addExtraFile(const QString &file)
{
- for (int i = 0; i < projects.size(); ++i)
- projects[i].extraFiles.insert(file);
-}
-
-void HelpProjectWriter::addExtraFiles(const QSet<QString> &files)
-{
- for (int i = 0; i < projects.size(); ++i)
- projects[i].extraFiles.unite(files);
+ for (HelpProject &project : projects)
+ project.extraFiles.insert(file);
}
Keyword HelpProjectWriter::keywordDetails(const Node *node) const
@@ -208,7 +201,7 @@ Keyword HelpProjectWriter::keywordDetails(const Node *node) const
: node->name();
return Keyword(name, id, ref);
} else if (node->isQmlType() || node->isQmlBasicType()) {
- QString name = node->name();
+ const QString &name = node->name();
QString moduleName = node->logicalModuleName();
QStringList ids("QML." + name);
if (!moduleName.isEmpty()) {
@@ -257,7 +250,7 @@ bool HelpProjectWriter::generateSection(HelpProject &project, QXmlStreamWriter &
// Add all group members for '[group|module|qmlmodule]:name' selector
if (node->isCollectionNode()) {
if (project.subprojects[i].groups.contains(node->name().toLower())) {
- const CollectionNode *cn = static_cast<const CollectionNode *>(node);
+ const auto *cn = static_cast<const CollectionNode *>(node);
const auto members = cn->members();
for (const Node *m : members) {
if (!m->isInAPI())
@@ -313,11 +306,9 @@ bool HelpProjectWriter::generateSection(HelpProject &project, QXmlStreamWriter &
case Node::Enum:
project.keywords.append(keywordDetails(node));
{
- const EnumNode *enumNode = static_cast<const EnumNode *>(node);
+ const auto *enumNode = static_cast<const EnumNode *>(node);
const auto items = enumNode->items();
for (const auto &item : items) {
- QStringList details;
-
if (enumNode->itemAccess(item.name()) == Access::Private)
continue;
@@ -364,7 +355,7 @@ bool HelpProjectWriter::generateSection(HelpProject &project, QXmlStreamWriter &
break;
case Node::Function: {
- const FunctionNode *funcNode = static_cast<const FunctionNode *>(node);
+ const auto *funcNode = static_cast<const FunctionNode *>(node);
/*
QML and JS methods, signals, and signal handlers used to be node types,
@@ -394,7 +385,7 @@ bool HelpProjectWriter::generateSection(HelpProject &project, QXmlStreamWriter &
} break;
case Node::TypeAlias:
case Node::Typedef: {
- const TypedefNode *typedefNode = static_cast<const TypedefNode *>(node);
+ const auto *typedefNode = static_cast<const TypedefNode *>(node);
Keyword typedefDetails = keywordDetails(node);
const EnumNode *enumNode = typedefNode->associatedEnum();
// Use the location of any associated enum node in preference
@@ -461,7 +452,7 @@ void HelpProjectWriter::generateSections(HelpProject &project, QXmlStreamWriter
return;
if (node->isAggregate()) {
- const Aggregate *aggregate = static_cast<const Aggregate *>(node);
+ const auto *aggregate = static_cast<const Aggregate *>(node);
// Ensure that we don't visit nodes more than once.
QSet<const Node *> childSet;
@@ -489,8 +480,8 @@ void HelpProjectWriter::generateSections(HelpProject &project, QXmlStreamWriter
void HelpProjectWriter::generate()
{
- for (int i = 0; i < projects.size(); ++i)
- generateProject(projects[i]);
+ for (HelpProject &project : projects)
+ generateProject(project);
}
void HelpProjectWriter::writeHashFile(QFile &file)
@@ -568,12 +559,9 @@ void HelpProjectWriter::writeNode(HelpProject &project, QXmlStreamWriter &writer
if (node->parent() && !node->parent()->name().isEmpty())
writer.writeAttribute("title",
QStringLiteral("%1::%2 %3 Reference")
- .arg(node->parent()->name())
- .arg(objName)
- .arg(typeStr));
+ .arg(node->parent()->name(), objName, typeStr));
else
- writer.writeAttribute("title",
- QStringLiteral("%1 %2 Reference").arg(objName).arg(typeStr));
+ writer.writeAttribute("title", QStringLiteral("%1 %2 Reference").arg(objName, typeStr));
addMembers(project, writer, node);
writer.writeEndElement(); // section
diff --git a/src/qdoc/helpprojectwriter.h b/src/qdoc/helpprojectwriter.h
index 1f465e8e2..691c21608 100644
--- a/src/qdoc/helpprojectwriter.h
+++ b/src/qdoc/helpprojectwriter.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -100,7 +100,6 @@ public:
HelpProjectWriter(const QString &defaultFileName, Generator *g);
void reset(const QString &defaultFileName, Generator *g);
void addExtraFile(const QString &file);
- void addExtraFiles(const QSet<QString> &files);
void generate();
private:
@@ -114,8 +113,8 @@ private:
void addMembers(HelpProject &project, QXmlStreamWriter &writer, const Node *node);
void writeSection(QXmlStreamWriter &writer, const QString &path, const QString &value);
- QDocDatabase *qdb_;
- Generator *gen_;
+ QDocDatabase *qdb_ {};
+ Generator *gen_ {};
QString outputDir;
QList<HelpProject> projects;
diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp
index 35d4dfc05..1521d8d7e 100644
--- a/src/qdoc/htmlgenerator.cpp
+++ b/src/qdoc/htmlgenerator.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -282,9 +282,9 @@ void HtmlGenerator::generateExampleFilePage(const Node *en, const QString &file,
/*!
Generate html from an instance of Atom.
*/
-int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker)
+qsizetype HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker)
{
- int idx, skipAhead = 0;
+ qsizetype idx, skipAhead = 0;
static bool in_para = false;
Node::Genus genus = Node::DontCare;
@@ -728,8 +728,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark
if (atom->next() != nullptr && atom->next()->string().toInt() > 1) {
out() << QString(R"(<ol class="%1" type="%1" start="%2">)")
- .arg(olType)
- .arg(atom->next()->string());
+ .arg(olType, atom->next()->string());
} else
out() << QString(R"(<ol class="%1" type="%1">)").arg(olType);
}
@@ -1096,9 +1095,7 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m
command = R"('\class' comment)";
if (!ns || ns->isDocumentedHere()) {
aggregate->location().warning(
- QStringLiteral("No %1 for '%2'")
- .arg(command)
- .arg(aggregate->plainSignature()));
+ QStringLiteral("No %1 for '%2'").arg(command, aggregate->plainSignature()));
}
} else {
generateExtractionMark(aggregate, DetailedDescriptionMark);
@@ -1492,7 +1489,6 @@ void HtmlGenerator::generateGenericCollectionPage(CollectionNode *cn, CodeMarker
{
SubTitleSize subTitleSize = LargeSubTitle;
QString fullTitle = cn->name();
- QString ref;
generateHeader(fullTitle, cn, marker);
generateTitle(fullTitle, Text() << cn->subtitle(), subTitleSize, cn, marker);
@@ -2575,7 +2571,7 @@ void HtmlGenerator::generateCompactList(ListType listType, const Node *relative,
return;
const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_'
- int commonPrefixLen = commonPrefix.length();
+ qsizetype commonPrefixLen = commonPrefix.length();
/*
Divide the data into 37 paragraphs: 0, ..., 9, A, ..., Z,
@@ -2616,7 +2612,7 @@ void HtmlGenerator::generateCompactList(ListType listType, const Node *relative,
We now want to compute the paragraph offset. Paragraphs 0 to 6
start at offsets 0, 3, 4, 8, 9, 14, 23.
*/
- int paragraphOffset[NumParagraphs + 1]; // 37 + 1
+ qsizetype paragraphOffset[NumParagraphs + 1]; // 37 + 1
paragraphOffset[0] = 0;
for (int i = 0; i < NumParagraphs; i++) // i = 0..36
paragraphOffset[i + 1] = paragraphOffset[i] + paragraph[i].count();
@@ -3220,7 +3216,7 @@ void HtmlGenerator::generateLink(const Atom *atom, CodeMarker *marker)
auto match = m_funcLeftParen.match(atom->string());
if (match.hasMatch() && marker->recognizeLanguage("Cpp")) {
// hack for C++: move () outside of link
- int k = match.capturedStart(1);
+ qsizetype k = match.capturedStart(1);
out() << protectEnc(atom->string().left(k));
if (m_link.isEmpty()) {
if (showBrokenLinks)
@@ -3250,7 +3246,7 @@ QString HtmlGenerator::protect(const QString &string)
html += (x);
QString html;
- int n = string.length();
+ qsizetype n = string.length();
for (int i = 0; i < n; ++i) {
QChar ch = string.at(i);
@@ -3570,30 +3566,6 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, const Aggregate *relat
generateExtractionMark(node, EndMark);
}
-/*!
- Output the "Inherits" line for the QML element,
- if there should be one.
- */
-void HtmlGenerator::generateQmlInherits(QmlTypeNode *qcn, CodeMarker *marker)
-{
- if (!qcn)
- return;
- QmlTypeNode *base = qcn->qmlBaseNode();
- while (base && base->isInternal()) {
- base = base->qmlBaseNode();
- }
- if (base) {
- Text text;
- text << Atom::ParaLeft << "Inherits ";
- text << Atom(Atom::LinkNode, CodeMarker::stringForNode(base));
- text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK);
- text << Atom(Atom::String, base->name());
- text << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK);
- text << Atom::ParaRight;
- generateText(text, qcn, marker);
- }
-}
-
void HtmlGenerator::generateExtractionMark(const Node *node, ExtractionMarkType markType)
{
if (markType != EndMark) {
diff --git a/src/qdoc/htmlgenerator.h b/src/qdoc/htmlgenerator.h
index d99a5fd3c..ca75a77b6 100644
--- a/src/qdoc/htmlgenerator.h
+++ b/src/qdoc/htmlgenerator.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -60,7 +60,7 @@ public:
protected:
void generateExampleFilePage(const Node *en, const QString &file, CodeMarker *marker) override;
- int generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker) override;
+ qsizetype generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker) override;
void generateCppReferencePage(Aggregate *aggregate, CodeMarker *marker) override;
void generateProxyPage(Aggregate *aggregate, CodeMarker *marker) override;
void generateQmlTypePage(QmlTypeNode *qcn, CodeMarker *marker) override;
@@ -107,7 +107,6 @@ private:
void generateQmlSummary(const NodeVector &members, const Node *relative, CodeMarker *marker);
void generateQmlItem(const Node *node, const Node *relative, CodeMarker *marker, bool summary);
void generateDetailedQmlMember(Node *node, const Aggregate *relative, CodeMarker *marker);
- void generateQmlInherits(QmlTypeNode *qcn, CodeMarker *marker) override;
void generateSection(const NodeVector &nv, const Node *relative, CodeMarker *marker);
void generateSynopsis(const Node *node, const Node *relative, CodeMarker *marker,
diff --git a/src/qdoc/importrec.h b/src/qdoc/importrec.h
index baab81452..e120ce41e 100644
--- a/src/qdoc/importrec.h
+++ b/src/qdoc/importrec.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -32,27 +32,24 @@
#include <QtCore/qglobal.h>
#include <QtCore/qstring.h>
+#include <utility>
+
QT_BEGIN_NAMESPACE
struct ImportRec
{
QString m_moduleName;
QString m_majorMinorVersion;
- QString m_importAsName;
QString m_importUri; // subdirectory of module directory
- ImportRec(const QString &name, const QString &version, const QString &importId,
- const QString &importUri)
- : m_moduleName(name),
- m_majorMinorVersion(version),
- m_importAsName(importId),
- m_importUri(importUri)
+ ImportRec(QString name, QString version, QString importUri)
+ : m_moduleName(std::move(name)),
+ m_majorMinorVersion(std::move(version)),
+ m_importUri(std::move(importUri))
{
}
QString &name() { return m_moduleName; }
QString &version() { return m_majorMinorVersion; }
- QString &importId() { return m_importAsName; }
- QString &importUri() { return m_importUri; }
bool isEmpty() const { return m_moduleName.isEmpty(); }
};
diff --git a/src/qdoc/jscodemarker.cpp b/src/qdoc/jscodemarker.cpp
index ee773f789..7acdd0a25 100644
--- a/src/qdoc/jscodemarker.cpp
+++ b/src/qdoc/jscodemarker.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- jscodemarker.cpp
-*/
-
#include "jscodemarker.h"
#include "atom.h"
@@ -46,10 +42,6 @@
QT_BEGIN_NAMESPACE
-JsCodeMarker::JsCodeMarker() {}
-
-JsCodeMarker::~JsCodeMarker() {}
-
/*!
Returns \c true if the \a code is recognized by the parser.
*/
@@ -60,8 +52,7 @@ bool JsCodeMarker::recognizeCode(const QString &code)
QQmlJS::Lexer lexer(&engine);
QQmlJS::Parser parser(&engine);
- QString newCode = code;
- QList<QQmlJS::SourceLocation> pragmas = extractPragmas(newCode);
+ const QString &newCode = code;
lexer.setCode(newCode, 1);
return parser.parseProgram();
diff --git a/src/qdoc/jscodemarker.h b/src/qdoc/jscodemarker.h
index ed0ec6b9b..dbf6523a7 100644
--- a/src/qdoc/jscodemarker.h
+++ b/src/qdoc/jscodemarker.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- jscodemarker.h
-*/
-
#ifndef JSCODEMARKER_H
#define JSCODEMARKER_H
@@ -40,16 +36,16 @@ QT_BEGIN_NAMESPACE
class JsCodeMarker : public QmlCodeMarker
{
public:
- JsCodeMarker();
- ~JsCodeMarker() override;
+ JsCodeMarker() = default;
+ ~JsCodeMarker() override = default;
bool recognizeCode(const QString &code) override;
bool recognizeExtension(const QString &ext) override;
bool recognizeLanguage(const QString &language) override;
Atom::AtomType atomType() const override;
- virtual QString markedUpCode(const QString &code, const Node *relative,
- const Location &location) override;
+ QString markedUpCode(const QString &code, const Node *relative,
+ const Location &location) override;
private:
QString addMarkUp(const QString &code, const Node *relative, const Location &location);
diff --git a/src/qdoc/location.cpp b/src/qdoc/location.cpp
index 736e56595..e9118cf08 100644
--- a/src/qdoc/location.cpp
+++ b/src/qdoc/location.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -33,7 +33,6 @@
#include <QtCore/qdebug.h>
#include <QtCore/qdir.h>
#include <QtCore/qregularexpression.h>
-#include <QtCore/QTime>
#include <climits>
#include <cstdio>
@@ -218,21 +217,6 @@ QString Location::fileSuffix() const
return (fp.isEmpty() ? fp : fp.mid(fp.lastIndexOf('.') + 1));
}
-/*!
- \brief Returns \a path which is canonicalized and relative to the config file.
-
- QDir::relativeFilePath does not canonicalize the paths, so
- if the config file is located at qtbase\src\widgets\doc\qtwidgets.qdocconf
- and it has a reference to any ancestor folder (e.g. ".." or even "../doc")
- */
-QString Location::canonicalRelativePath(const QString &path)
-{
- QDir configFileDir(QDir::current());
- QDir dir(path);
- const QString canon = dir.canonicalPath();
- return configFileDir.relativeFilePath(canon);
-}
-
/*! \fn int Location::lineNo() const
Returns the current line number.
Must not be called on an empty Location object.
@@ -367,8 +351,7 @@ void Location::internalError(const QString &hint)
Location().fatal(QStringLiteral("Internal error (%1)").arg(hint),
QStringLiteral("There is a bug in %1. Seek advice from your local"
" %2 guru.")
- .arg(programName)
- .arg(programName));
+ .arg(programName, programName));
}
/*!
diff --git a/src/qdoc/location.h b/src/qdoc/location.h
index f35160fa7..6c641eb96 100644
--- a/src/qdoc/location.h
+++ b/src/qdoc/location.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- location.h
-*/
-
#ifndef LOCATION_H
#define LOCATION_H
@@ -82,7 +78,6 @@ public:
static void terminate();
static void information(const QString &message);
static void internalError(const QString &hint);
- static QString canonicalRelativePath(const QString &path);
static int exitCode();
private:
diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp
index 2b57909a8..1f7a9810b 100644
--- a/src/qdoc/main.cpp
+++ b/src/qdoc/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -332,7 +332,6 @@ static void processQdocconfFile(const QString &fileName)
and the location in the configuration file where the
source language was set.
*/
- QString lang = config.getString(CONFIG_LANGUAGE);
Location langLocation = config.lastLocation();
/*
@@ -346,8 +345,6 @@ static void processQdocconfFile(const QString &fileName)
*/
QDocDatabase *qdb = QDocDatabase::qdocDB();
qdb->setVersion(config.getString(CONFIG_VERSION));
- qdb->setShowInternal(config.showInternal());
- qdb->setSingleExec(config.getBool(CONFIG_SINGLEEXEC));
/*
By default, the only output format is HTML.
*/
diff --git a/src/qdoc/manifestwriter.cpp b/src/qdoc/manifestwriter.cpp
index bb44158c1..4f969bedd 100644
--- a/src/qdoc/manifestwriter.cpp
+++ b/src/qdoc/manifestwriter.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -162,7 +162,7 @@ void ManifestWriter::processManifestMetaContent(const QString &fullName, F match
const auto &names = index.names;
for (const QString &name : names) {
bool match;
- int wildcard = name.indexOf(QChar('*'));
+ qsizetype wildcard = name.indexOf(QChar('*'));
switch (wildcard) {
case -1: // no wildcard used, exact match required
match = (fullName == name);
@@ -353,7 +353,7 @@ void ManifestWriter::addWordsFromModuleNamesAsTags()
{
// '?<=': positive lookbehind
QRegularExpression re("([A-Z]+[a-z0-9]*((?<=3)D|GL)?)");
- int pos = 0;
+ qsizetype pos = 0;
QRegularExpressionMatch match;
while ((match = re.match(m_project, pos)).hasMatch()) {
m_tags << match.captured(1).toLower();
diff --git a/src/qdoc/manifestwriter.h b/src/qdoc/manifestwriter.h
index abfbb1ba5..c9a6283b0 100644
--- a/src/qdoc/manifestwriter.h
+++ b/src/qdoc/manifestwriter.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
diff --git a/src/qdoc/namespacenode.cpp b/src/qdoc/namespacenode.cpp
index 27e342f49..536499b2a 100644
--- a/src/qdoc/namespacenode.cpp
+++ b/src/qdoc/namespacenode.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -59,9 +59,9 @@ QT_BEGIN_NAMESPACE
*/
NamespaceNode::~NamespaceNode()
{
- for (int i = 0; i < m_children.size(); ++i) {
- if (m_children[i]->parent() != this)
- m_children[i] = nullptr;
+ for (auto &child : m_children) {
+ if (child->parent() != this)
+ child = nullptr;
}
}
@@ -84,11 +84,8 @@ bool NamespaceNode::isDocumentedHere() const
*/
bool NamespaceNode::hasDocumentedChildren() const
{
- for (const auto *node : qAsConst(m_children)) {
- if (node->isInAPI())
- return true;
- }
- return false;
+ return std::any_of(m_children.cbegin(), m_children.cend(),
+ [](Node *child) { return child->isInAPI(); });
}
/*!
@@ -110,8 +107,7 @@ void NamespaceNode::reportDocumentedChildrenInUndocumentedNamespace() const
QStringLiteral(
"Add /*! '\\%1 %2' ... */ or remove the qdoc comment marker (!) at "
"that line number.")
- .arg(COMMAND_NAMESPACE)
- .arg(name());
+ .arg(COMMAND_NAMESPACE, name());
node->doc().location().warning(msg1, msg2);
}
diff --git a/src/qdoc/namespacenode.h b/src/qdoc/namespacenode.h
index 08e676339..d098937e8 100644
--- a/src/qdoc/namespacenode.h
+++ b/src/qdoc/namespacenode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -49,11 +49,9 @@ public:
bool isRelatableType() const override { return true; }
bool wasSeen() const override { return m_seen; }
void markSeen() { m_seen = true; }
- void markNotSeen() { m_seen = false; }
void setTree(Tree *t) { m_tree = t; }
const NodeList &includedChildren() const;
void includeChild(Node *child);
- QString whereDocumented() const { return m_whereDocumented; }
void setWhereDocumented(const QString &t) { m_whereDocumented = t; }
bool isDocumentedHere() const;
bool hasDocumentedChildren() const;
diff --git a/src/qdoc/node.cpp b/src/qdoc/node.cpp
index f09dd3a97..d31ecaab4 100644
--- a/src/qdoc/node.cpp
+++ b/src/qdoc/node.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -45,6 +45,8 @@
#include <QtCore/quuid.h>
#include <QtCore/qversionnumber.h>
+#include <utility>
+
QT_BEGIN_NAMESPACE
QStringMap Node::operators;
@@ -661,11 +663,8 @@ QString Node::fullName(const Node *relative) const
*/
bool Node::match(const QList<int> &types) const
{
- for (int i = 0; i < types.size(); ++i) {
- if (nodeType() == types.at(i))
- return true;
- }
- return false;
+ return std::any_of(types.cbegin(), types.cend(),
+ [this](const int type) { return nodeType() == type; });
}
/*!
@@ -690,13 +689,13 @@ void Node::setDoc(const Doc &doc, bool replace)
given \a parent and \a name. The new node is added to the
parent's child list.
*/
-Node::Node(NodeType type, Aggregate *parent, const QString &name)
+Node::Node(NodeType type, Aggregate *parent, QString name)
: m_nodeType(type),
m_indexNodeFlag(false),
m_relatedNonmember(false),
m_hadDoc(false),
m_parent(parent),
- m_name(name)
+ m_name(std::move(name))
{
if (m_parent)
m_parent->addChild(this);
@@ -974,11 +973,6 @@ Node::FlagValue Node::toFlagValue(bool b)
If \a fv is neither the true enum value nor the
false enum value, the boolean value returned is
\a defaultValue.
-
- Note that runtimeDesignabilityFunction() should be called
- first. If that function returns the name of a function, it
- means the function must be called at runtime to determine
- whether the property is Designable.
*/
bool Node::fromFlagValue(FlagValue fv, bool defaultValue)
{
@@ -1211,7 +1205,7 @@ QString Node::qualifyQmlName()
*/
bool Node::isWrapper() const
{
- return (m_parent ? m_parent->isWrapper() : false);
+ return m_parent != nullptr && m_parent->isWrapper();
}
/*!
@@ -1269,13 +1263,13 @@ QString Node::physicalModuleName() const
QString path = location().filePath();
QString pattern = QString("src") + QDir::separator();
- int start = path.lastIndexOf(pattern);
+ qsizetype start = path.lastIndexOf(pattern);
if (start == -1)
return QString();
QString moduleDir = path.mid(start + pattern.size());
- int finish = moduleDir.indexOf(QDir::separator());
+ qsizetype finish = moduleDir.indexOf(QDir::separator());
if (finish == -1)
return QString();
diff --git a/src/qdoc/node.h b/src/qdoc/node.h
index acf7c27af..e492387f0 100644
--- a/src/qdoc/node.h
+++ b/src/qdoc/node.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -362,7 +362,7 @@ public:
static bool nodeNameLessThan(const Node *first, const Node *second);
protected:
- Node(NodeType type, Aggregate *parent, const QString &name);
+ Node(NodeType type, Aggregate *parent, QString name);
private:
NodeType m_nodeType {};
diff --git a/src/qdoc/openedlist.cpp b/src/qdoc/openedlist.cpp
index 852effcb4..13dc4a307 100644
--- a/src/qdoc/openedlist.cpp
+++ b/src/qdoc/openedlist.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- openedlist.cpp
-*/
-
#include "openedlist.h"
#include "atom.h"
@@ -115,25 +111,13 @@ QString OpenedList::numberString() const
}*/
}
-QString OpenedList::toAlpha(int n)
-{
- QString str;
-
- while (n > 0) {
- n--;
- str.prepend(QChar((n % 26) + 'a'));
- n /= 26;
- }
- return str;
-}
-
int OpenedList::fromAlpha(const QString &str)
{
int n = 0;
int u;
- for (int i = 0; i < str.length(); i++) {
- u = str[i].toLower().unicode();
+ for (const QChar &character : str) {
+ u = character.toLower().unicode();
if (u >= 'a' && u <= 'z') {
n *= 26;
n += u - 'a' + 1;
@@ -188,10 +172,10 @@ int OpenedList::fromRoman(const QString &str)
int u;
int v = 0;
- for (int i = str.length() - 1; i >= 0; i--) {
+ for (const QChar &character : str) {
j = 0;
u = 1000;
- while (roman[j] != 'i' && roman[j] != str[i].toLower()) {
+ while (roman[j] != 'i' && roman[j] != character.toLower()) {
j += 2;
u /= roman[j - 1];
}
diff --git a/src/qdoc/openedlist.h b/src/qdoc/openedlist.h
index 113a79762..00476170a 100644
--- a/src/qdoc/openedlist.h
+++ b/src/qdoc/openedlist.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- openedlist.h
-*/
-
#ifndef OPENEDLIST_H
#define OPENEDLIST_H
@@ -59,7 +55,6 @@ public:
QString suffix() const { return suff; }
private:
- static QString toAlpha(int n);
static int fromAlpha(const QString &str);
static QString toRoman(int n);
static int fromRoman(const QString &str);
diff --git a/src/qdoc/parameters.cpp b/src/qdoc/parameters.cpp
index 2a5443100..638d99902 100644
--- a/src/qdoc/parameters.cpp
+++ b/src/qdoc/parameters.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -34,7 +34,7 @@
QT_BEGIN_NAMESPACE
-QRegularExpression Parameters::varComment_("^/\\*\\s*([a-zA-Z_0-9]+)\\s*\\*/$");
+QRegularExpression Parameters::varComment_(R"(^/\*\s*([a-zA-Z_0-9]+)\s*\*/$)");
/*!
\class Parameter
@@ -173,7 +173,7 @@ void Parameters::matchTemplateAngles(CodeChunk &type)
Uses the current tokenizer to parse the \a name and \a type
of the parameter.
*/
-bool Parameters::matchTypeAndName(CodeChunk &type, QString &name, bool qProp)
+bool Parameters::matchTypeAndName(CodeChunk &type, QString &name)
{
/*
This code is really hard to follow... sorry. The loop is there to match
@@ -331,9 +331,6 @@ bool Parameters::matchTypeAndName(CodeChunk &type, QString &name, bool qProp)
name.append("]");
readToken();
}
- } else if (qProp && (match(Tok_default) || match(Tok_final) || match(Tok_override))) {
- // Hack to make 'default', 'final' and 'override' work again in Q_PROPERTY
- name = previousLexeme();
}
if (tok_ == Tok_LeftBracket) {
@@ -427,7 +424,7 @@ void Parameters::append(const QString &type, const QString &name, const QString
QString Parameters::signature(bool includeValues) const
{
QString result;
- if (parameters_.size() > 0) {
+ if (!parameters_.empty()) {
for (int i = 0; i < parameters_.size(); i++) {
if (i > 0)
result += ", ";
@@ -476,7 +473,7 @@ void Parameters::set(const QString &signature)
for (const auto &item : qAsConst(commaSplit)) {
QStringList blankSplit = item.split(' ', Qt::SkipEmptyParts);
QString pDefault;
- int defaultIdx = blankSplit.indexOf(QStringLiteral("="));
+ qsizetype defaultIdx = blankSplit.indexOf(QStringLiteral("="));
if (defaultIdx != -1) {
if (++defaultIdx < blankSplit.size())
pDefault = blankSplit.mid(defaultIdx).join(' ');
diff --git a/src/qdoc/parameters.h b/src/qdoc/parameters.h
index effb49467..539418d62 100644
--- a/src/qdoc/parameters.h
+++ b/src/qdoc/parameters.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -81,7 +81,7 @@ class Parameters
{
public:
Parameters();
- Parameters(const QString &signature);
+ Parameters(const QString &signature); // TODO: Making this explicit breaks QDoc
void clear()
{
@@ -118,7 +118,7 @@ private:
QString previousLexeme();
bool match(int target);
void matchTemplateAngles(CodeChunk &type);
- bool matchTypeAndName(CodeChunk &type, QString &name, bool qProp = false);
+ bool matchTypeAndName(CodeChunk &type, QString &name);
bool matchParameter();
bool parse(const QString &signature);
diff --git a/src/qdoc/propertynode.cpp b/src/qdoc/propertynode.cpp
index aaa0aeb41..50de3459d 100644
--- a/src/qdoc/propertynode.cpp
+++ b/src/qdoc/propertynode.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
diff --git a/src/qdoc/propertynode.h b/src/qdoc/propertynode.h
index be1ccfa09..530834f51 100644
--- a/src/qdoc/propertynode.h
+++ b/src/qdoc/propertynode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -55,15 +55,10 @@ public:
void setDesignable(bool designable) { m_designable = toFlagValue(designable); }
void setScriptable(bool scriptable) { m_scriptable = toFlagValue(scriptable); }
void setWritable(bool writable) { m_writable = toFlagValue(writable); }
- void setUser(bool user) { m_user = toFlagValue(user); }
void setOverriddenFrom(const PropertyNode *baseProperty);
- void setRuntimeDesFunc(const QString &rdf) { m_runtimeDesFunc = rdf; }
- void setRuntimeScrFunc(const QString &scrf) { m_runtimeScrFunc = scrf; }
void setConstant() { m_const = true; }
- void setFinal() { m_final = true; }
void setRequired() { m_required = true; }
void setPropertyType(PropertyType type) { m_propertyType = type; }
- void setRevision(int revision) { m_revision = revision; }
const QString &dataType() const { return m_type; }
QString qualifiedDataType() const;
@@ -76,29 +71,19 @@ public:
bool hasAccessFunction(const QString &name) const;
FunctionRole role(const FunctionNode *functionNode) const;
bool isStored() const { return fromFlagValue(m_stored, storedDefault()); }
- bool isDesignable() const { return fromFlagValue(m_designable, designableDefault()); }
- bool isScriptable() const { return fromFlagValue(m_scriptable, scriptableDefault()); }
- const QString &runtimeDesignabilityFunction() const { return m_runtimeDesFunc; }
- const QString &runtimeScriptabilityFunction() const { return m_runtimeScrFunc; }
bool isWritable() const { return fromFlagValue(m_writable, writableDefault()); }
- bool isUser() const { return fromFlagValue(m_user, userDefault()); }
bool isConstant() const { return m_const; }
- bool isFinal() const { return m_final; }
bool isRequired() const { return m_required; }
PropertyType propertyType() const { return m_propertyType; }
const PropertyNode *overriddenFrom() const { return m_overrides; }
bool storedDefault() const { return true; }
- bool userDefault() const { return false; }
bool designableDefault() const { return !setters().isEmpty(); }
- bool scriptableDefault() const { return true; }
bool writableDefault() const { return !setters().isEmpty(); }
private:
QString m_type {};
PropertyType m_propertyType { Standard };
- QString m_runtimeDesFunc {};
- QString m_runtimeScrFunc {};
NodeList m_functions[NumFunctionRoles] {};
FlagValue m_stored { FlagValueDefault };
FlagValue m_designable { FlagValueDefault };
@@ -106,9 +91,7 @@ private:
FlagValue m_writable { FlagValueDefault };
FlagValue m_user { FlagValueDefault };
bool m_const { false };
- bool m_final { false };
bool m_required { false };
- int m_revision { -1 };
const PropertyNode *m_overrides { nullptr };
};
diff --git a/src/qdoc/puredocparser.cpp b/src/qdoc/puredocparser.cpp
index 1c8baf37d..5e2e31556 100644
--- a/src/qdoc/puredocparser.cpp
+++ b/src/qdoc/puredocparser.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -58,9 +58,8 @@ void PureDocParser::parseSourceFile(const Location &location, const QString &fil
QFile in(filePath);
currentFile_ = filePath;
if (!in.open(QIODevice::ReadOnly)) {
- location.error(QStringLiteral("Can't open source file '%1' (%2)")
- .arg(filePath)
- .arg(strerror(errno)));
+ location.error(
+ QStringLiteral("Can't open source file '%1' (%2)").arg(filePath, strerror(errno)));
currentFile_.clear();
return;
}
@@ -105,8 +104,7 @@ bool PureDocParser::processQdocComments()
if (topics.isEmpty()) {
doc.location().warning(QStringLiteral("This qdoc comment contains no topic command "
"(e.g., '\\%1', '\\%2').")
- .arg(COMMAND_MODULE)
- .arg(COMMAND_PAGE));
+ .arg(COMMAND_MODULE, COMMAND_PAGE));
continue;
}
if (hasTooManyTopics(doc))
diff --git a/src/qdoc/puredocparser.h b/src/qdoc/puredocparser.h
index f147a7755..7c9affb51 100644
--- a/src/qdoc/puredocparser.h
+++ b/src/qdoc/puredocparser.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
diff --git a/src/qdoc/qdocdatabase.cpp b/src/qdoc/qdocdatabase.cpp
index ec6fbecd4..86b3a2bdf 100644
--- a/src/qdoc/qdocdatabase.cpp
+++ b/src/qdoc/qdocdatabase.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -88,8 +88,8 @@ bool QDocDatabase::debug = false;
*/
QDocForest::~QDocForest()
{
- for (int i = 0; i < searchOrder_.size(); ++i)
- delete searchOrder_.at(i);
+ for (auto *entry : searchOrder_)
+ delete entry;
forest_.clear();
searchOrder_.clear();
indexSearchOrder_.clear();
@@ -98,17 +98,6 @@ QDocForest::~QDocForest()
}
/*!
- Initializes the forest prior to a traversal and
- returns a pointer to the root node of the primary
- tree. If the forest is empty, it return 0
- */
-NamespaceNode *QDocForest::firstRoot()
-{
- currentIndex_ = 0;
- return (!searchOrder().isEmpty() ? searchOrder()[0]->root() : nullptr);
-}
-
-/*!
Increments the forest's current tree index. If the current
tree index is still within the forest, the function returns
the root node of the current tree. Otherwise it returns \nullptr.
@@ -389,22 +378,12 @@ NodeMultiMapMap QDocDatabase::newSinceMaps_;
modules sequentially in a loop. Each source file for each module
is read exactly once.
*/
-QDocDatabase::QDocDatabase() : showInternal_(false), singleExec_(false), forest_(this)
+QDocDatabase::QDocDatabase() : forest_(this)
{
// nothing
}
/*!
- Destroys the qdoc database object. This requires destroying
- the forest object, which contains an array of tree pointers.
- Each tree is deleted.
- */
-QDocDatabase::~QDocDatabase()
-{
- // nothing.
-}
-
-/*!
Creates the singleton. Allows only one instance of the class
to be created. Returns a pointer to the singleton.
*/
@@ -778,8 +757,8 @@ QmlTypeNode *QDocDatabase::findQmlType(const ImportRec &import, const QString &n
qmName = import.m_moduleName;
else
qmName = import.m_importUri;
- for (int i = 0; i < dotSplit.size(); ++i) {
- QString qualifiedName = qmName + "::" + dotSplit[i];
+ for (const auto &namePart : dotSplit) {
+ QString qualifiedName = qmName + "::" + namePart;
QmlTypeNode *qcn = forest_.lookupQmlType(qualifiedName);
if (qcn)
return qcn;
@@ -1125,7 +1104,7 @@ void QDocDatabase::resolveNamespaces()
NamespaceNode *ns = nullptr;
NamespaceNode *somewhere = nullptr;
const NodeList namespaces = namespaceMultimap.values(key);
- int count = namespaceMultimap.remove(key);
+ qsizetype count = namespaceMultimap.remove(key);
if (count > 0) {
for (auto *node : namespaces) {
ns = static_cast<NamespaceNode *>(node);
@@ -1205,7 +1184,7 @@ void QDocDatabase::resolveProxies()
const NodeList &proxies = t->proxies();
if (!proxies.isEmpty()) {
for (auto *node : proxies) {
- ProxyNode *pn = static_cast<ProxyNode *>(node);
+ const auto *pn = static_cast<ProxyNode *>(node);
if (pn->count() > 0) {
Aggregate *aggregate = primaryTree()->findAggregate(pn->name());
if (aggregate != nullptr)
@@ -1235,11 +1214,11 @@ const FunctionNode *QDocDatabase::findFunctionNode(const QString &target, const
{
QString signature;
QString function = target;
- int length = target.length();
+ qsizetype length = target.length();
if (function.endsWith("()"))
function.chop(2);
if (function.endsWith(QChar(')'))) {
- int position = function.lastIndexOf(QChar('('));
+ qsizetype position = function.lastIndexOf(QChar('('));
signature = function.mid(position + 1, length - position - 2);
function = function.left(position);
}
@@ -1489,11 +1468,11 @@ const Node *QDocDatabase::findNodeForAtom(const Atom *a, const Node *relative, Q
else if (first.endsWith(QChar(')'))) {
QString signature;
QString function = first;
- int length = first.length();
+ qsizetype length = first.length();
if (function.endsWith("()"))
function.chop(2);
if (function.endsWith(QChar(')'))) {
- int position = function.lastIndexOf(QChar('('));
+ qsizetype position = function.lastIndexOf(QChar('('));
signature = function.mid(position + 1, length - position - 2);
function = function.left(position);
}
diff --git a/src/qdoc/qdocdatabase.h b/src/qdoc/qdocdatabase.h
index 3770e0f43..bbe14495c 100644
--- a/src/qdoc/qdocdatabase.h
+++ b/src/qdoc/qdocdatabase.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -59,10 +59,9 @@ class QDocForest
{
private:
friend class QDocDatabase;
- QDocForest(QDocDatabase *qdb) : qdb_(qdb), primaryTree_(nullptr), currentIndex_(0) {}
+ explicit QDocForest(QDocDatabase *qdb) : qdb_(qdb), primaryTree_(nullptr), currentIndex_(0) { }
~QDocForest();
- NamespaceNode *firstRoot();
NamespaceNode *nextRoot();
Tree *firstTree();
Tree *nextTree();
@@ -201,7 +200,7 @@ class QDocDatabase
public:
static QDocDatabase *qdocDB();
static void destroyQdocDB();
- ~QDocDatabase();
+ ~QDocDatabase() = default;
Tree *findTree(const QString &t) { return forest_.findTree(t); }
@@ -328,7 +327,7 @@ public:
{
return forest_.getCollectionNode(name, type);
}
- FunctionNode *findFunctionNodeForTag(QString tag)
+ FunctionNode *findFunctionNodeForTag(const QString &tag)
{
return primaryTree()->findFunctionNodeForTag(tag);
}
@@ -365,8 +364,6 @@ public:
void clearOpenNamespaces() { openNamespaces_.clear(); }
void insertOpenNamespace(const QString &path) { openNamespaces_.insert(path); }
- void setShowInternal(bool value) { showInternal_ = value; }
- void setSingleExec(bool value) { singleExec_ = value; }
void processForest();
// Try to make this function private.
@@ -402,7 +399,7 @@ private:
private:
QDocDatabase();
- QDocDatabase(QDocDatabase const &) : showInternal_(false), forest_(this) {}
+ QDocDatabase(QDocDatabase const &) : forest_(this) { }
QDocDatabase &operator=(QDocDatabase const &);
public:
@@ -424,8 +421,6 @@ private:
static NodeMultiMapMap newQmlTypeMaps_;
static NodeMultiMapMap newSinceMaps_;
- bool showInternal_;
- bool singleExec_;
QString version_;
QDocForest forest_;
diff --git a/src/qdoc/qdocindexfiles.cpp b/src/qdoc/qdocindexfiles.cpp
index b6169a997..42877a948 100644
--- a/src/qdoc/qdocindexfiles.cpp
+++ b/src/qdoc/qdocindexfiles.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -55,7 +55,6 @@ QT_BEGIN_NAMESPACE
enum QDocAttr {
QDocAttrNone,
- QDocAttrAttribution,
QDocAttrExample,
QDocAttrFile,
QDocAttrImage,
@@ -473,7 +472,7 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader &reader, Node *current,
else if (!indexUrl.isNull())
location = Location(parent->name().toLower() + ".html");
} else if (elementName == QLatin1String("property")) {
- PropertyNode *propNode = new PropertyNode(parent, name);
+ auto *propNode = new PropertyNode(parent, name);
node = propNode;
if (attributes.value(QLatin1String("bindable")) == QLatin1String("true"))
propNode->setPropertyType(PropertyNode::Bindable);
@@ -499,7 +498,7 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader &reader, Node *current,
fn->setStatic(attributes.value(QLatin1String("static")) == QLatin1String("true"));
fn->setFinal(attributes.value(QLatin1String("final")) == QLatin1String("true"));
fn->setOverride(attributes.value(QLatin1String("override")) == QLatin1String("true"));
- int refness = attributes.value(QLatin1String("refness")).toUInt();
+ qsizetype refness = attributes.value(QLatin1String("refness")).toUInt();
if (refness == 1)
fn->setRef(true);
else if (refness == 2)
@@ -632,8 +631,8 @@ void QDocIndexFiles::readIndexSection(QXmlStreamReader &reader, Node *current,
QString groupsAttr = attributes.value(QLatin1String("groups")).toString();
if (!groupsAttr.isEmpty()) {
const QStringList groupNames = groupsAttr.split(QLatin1Char(','));
- for (const auto &name : groupNames) {
- qdb_->addToGroup(name, node);
+ for (const auto &group : groupNames) {
+ qdb_->addToGroup(group, node);
}
}
@@ -712,7 +711,6 @@ void QDocIndexFiles::insertTarget(TargetRec::TargetType type,
*/
void QDocIndexFiles::resolveIndex()
{
- QPair<ClassNode *, QString> pair;
for (const auto &pair : qAsConst(basesList_)) {
const QStringList bases = pair.second.split(QLatin1Char(','));
for (const auto &base : bases) {
@@ -721,14 +719,14 @@ void QDocIndexFiles::resolveIndex()
if (n)
pair.first->addResolvedBaseClass(Access::Public, static_cast<ClassNode *>(n));
else
- pair.first->addUnresolvedBaseClass(Access::Public, basePath, QString());
+ pair.first->addUnresolvedBaseClass(Access::Public, basePath);
}
}
// No longer needed.
basesList_.clear();
}
-static const QString getAccessString(Access t)
+static QString getAccessString(Access t)
{
switch (t) {
@@ -744,7 +742,7 @@ static const QString getAccessString(Access t)
return QLatin1String("public");
}
-static const QString getStatusString(Node::Status t)
+static QString getStatusString(Node::Status t)
{
switch (t) {
case Node::Obsolete:
@@ -764,7 +762,7 @@ static const QString getStatusString(Node::Status t)
return QLatin1String("active");
}
-static const QString getThreadSafenessString(Node::ThreadSafeness t)
+static QString getThreadSafenessString(Node::ThreadSafeness t)
{
switch (t) {
case Node::NonReentrant:
@@ -785,7 +783,7 @@ static const QString getThreadSafenessString(Node::ThreadSafeness t)
*/
int QDocIndexFiles::indexForNode(Node *node)
{
- int i = relatedNodes_.indexOf(node);
+ qsizetype i = relatedNodes_.indexOf(node);
if (i == -1) {
i = relatedNodes_.size();
relatedNodes_ << node;
diff --git a/src/qdoc/qdocindexfiles.h b/src/qdoc/qdocindexfiles.h
index 56171fc1c..e161189ba 100644
--- a/src/qdoc/qdocindexfiles.h
+++ b/src/qdoc/qdocindexfiles.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
diff --git a/src/qdoc/qmlcodemarker.cpp b/src/qdoc/qmlcodemarker.cpp
index 62ed7db3b..75070e52a 100644
--- a/src/qdoc/qmlcodemarker.cpp
+++ b/src/qdoc/qmlcodemarker.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- qmlcodemarker.cpp
-*/
-
#include "qmlcodemarker.h"
#include <QtCore/qregularexpression.h>
@@ -49,10 +45,6 @@
QT_BEGIN_NAMESPACE
-QmlCodeMarker::QmlCodeMarker() {}
-
-QmlCodeMarker::~QmlCodeMarker() {}
-
/*!
Returns \c true if the \a code is recognized by the parser.
*/
@@ -119,23 +111,6 @@ QString QmlCodeMarker::markedUpName(const Node *node)
return name;
}
-QString QmlCodeMarker::markedUpFullName(const Node *node, const Node *relative)
-{
- if (node->name().isEmpty()) {
- return "global";
- } else {
- QString fullName;
- for (;;) {
- fullName.prepend(markedUpName(node));
- if (node->parent() == relative || node->parent()->name().isEmpty())
- break;
- fullName.prepend("<@op>::</@op>");
- node = node->parent();
- }
- return fullName;
- }
-}
-
QString QmlCodeMarker::markedUpIncludes(const QStringList &includes)
{
QString code;
@@ -222,8 +197,6 @@ static void replaceWithSpace(QString &str, int idx, int n)
*/
QList<QQmlJS::SourceLocation> QmlCodeMarker::extractPragmas(QString &script)
{
- const QString pragma(QLatin1String("pragma"));
- const QString library(QLatin1String("library"));
QList<QQmlJS::SourceLocation> removed;
QQmlJS::Lexer l(nullptr);
@@ -233,7 +206,7 @@ QList<QQmlJS::SourceLocation> QmlCodeMarker::extractPragmas(QString &script)
while (true) {
if (token != QQmlJSGrammar::T_DOT)
- return removed;
+ break;
int startOffset = l.tokenOffset();
int startLine = l.tokenStartLine();
@@ -242,7 +215,7 @@ QList<QQmlJS::SourceLocation> QmlCodeMarker::extractPragmas(QString &script)
token = l.lex();
if (token != QQmlJSGrammar::T_PRAGMA && token != QQmlJSGrammar::T_IMPORT)
- return removed;
+ break;
int endOffset = 0;
while (startLine == l.tokenStartLine()) {
endOffset = l.tokenLength() + l.tokenOffset();
diff --git a/src/qdoc/qmlcodemarker.h b/src/qdoc/qmlcodemarker.h
index 6eb6c28b7..ef409750c 100644
--- a/src/qdoc/qmlcodemarker.h
+++ b/src/qdoc/qmlcodemarker.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- qmlcodemarker.h
-*/
-
#ifndef QMLCODEMARKER_H
#define QMLCODEMARKER_H
@@ -44,18 +40,17 @@ QT_BEGIN_NAMESPACE
class QmlCodeMarker : public CppCodeMarker
{
public:
- QmlCodeMarker();
- ~QmlCodeMarker() override;
+ QmlCodeMarker() = default;
+ ~QmlCodeMarker() override = default;
bool recognizeCode(const QString &code) override;
bool recognizeExtension(const QString &ext) override;
bool recognizeLanguage(const QString &language) override;
Atom::AtomType atomType() const override;
- virtual QString markedUpCode(const QString &code, const Node *relative,
- const Location &location) override;
+ QString markedUpCode(const QString &code, const Node *relative,
+ const Location &location) override;
QString markedUpName(const Node *node) override;
- QString markedUpFullName(const Node *node, const Node *relative) override;
QString markedUpIncludes(const QStringList &includes) override;
QString functionBeginRegExp(const QString &funcName) override;
QString functionEndRegExp(const QString &funcName) override;
diff --git a/src/qdoc/qmlcodeparser.cpp b/src/qdoc/qmlcodeparser.cpp
index f4356d4cd..ad15b5628 100644
--- a/src/qdoc/qmlcodeparser.cpp
+++ b/src/qdoc/qmlcodeparser.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- qmlcodeparser.cpp
-*/
-
#include "qmlcodeparser.h"
#include "node.h"
@@ -37,7 +33,6 @@
#ifndef QT_NO_DECLARATIVE
# include <private/qqmljsast_p.h>
-# include <private/qqmljsastvisitor_p.h>
#endif
#include <qdebug.h>
@@ -54,11 +49,6 @@ QmlCodeParser::QmlCodeParser()
}
/*!
- Destroys the QML code parser.
- */
-QmlCodeParser::~QmlCodeParser() {}
-
-/*!
Initializes the code parser base class.
Also creates a lexer and parser from QQmlJS.
*/
@@ -194,7 +184,6 @@ static void replaceWithSpace(QString &str, int idx, int n)
void QmlCodeParser::extractPragmas(QString &script)
{
const QString pragma(QLatin1String("pragma"));
- const QString library(QLatin1String("library"));
QQmlJS::Lexer l(nullptr);
l.setCode(script, 0);
@@ -231,7 +220,6 @@ void QmlCodeParser::extractPragmas(QString &script)
else
return;
}
- return;
}
#endif
diff --git a/src/qdoc/qmlcodeparser.h b/src/qdoc/qmlcodeparser.h
index 67ba628f9..4a6dbe0ca 100644
--- a/src/qdoc/qmlcodeparser.h
+++ b/src/qdoc/qmlcodeparser.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- qmlcodeparser.h
-*/
-
#ifndef QMLCODEPARSER_H
#define QMLCODEPARSER_H
@@ -52,7 +48,7 @@ class QmlCodeParser : public CodeParser
{
public:
QmlCodeParser();
- ~QmlCodeParser() override;
+ ~QmlCodeParser() override = default;
void initializeParser() override;
void terminateParser() override;
diff --git a/src/qdoc/qmlmarkupvisitor.cpp b/src/qdoc/qmlmarkupvisitor.cpp
index fc7f3c784..24d60f3bc 100644
--- a/src/qdoc/qmlmarkupvisitor.cpp
+++ b/src/qdoc/qmlmarkupvisitor.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -33,7 +33,6 @@
#ifndef QT_NO_DECLARATIVE
# include <private/qqmljsast_p.h>
-# include <private/qqmljsastfwd_p.h>
# include <private/qqmljsengine_p.h>
#endif
@@ -79,8 +78,6 @@ QmlMarkupVisitor::QmlMarkupVisitor(const QString &source,
}
}
-QmlMarkupVisitor::~QmlMarkupVisitor() {}
-
// The protect() function is a copy of the one from CppCodeMarker.
static const QString samp = QLatin1String("&amp;");
@@ -90,7 +87,7 @@ static const QString squot = QLatin1String("&quot;");
QString QmlMarkupVisitor::protect(const QString &str)
{
- int n = str.length();
+ qsizetype n = str.length();
QString marked;
marked.reserve(n * 2 + 30);
const QChar *data = str.constData();
@@ -200,7 +197,7 @@ void QmlMarkupVisitor::addMarkedUpToken(QQmlJS::SourceLocation &location,
output += QString(QLatin1String("<@%1")).arg(tagName);
for (const auto &key : attributes)
- output += QString(QLatin1String(" %1=\"%2\"")).arg(key).arg(attributes[key]);
+ output += QString(QLatin1String(" %1=\"%2\"")).arg(key, attributes[key]);
output += QString(QLatin1String(">%2</@%3>")).arg(protect(sourceText(location)), tagName);
cursor += location.length;
}
@@ -812,7 +809,6 @@ bool QmlMarkupVisitor::visit(QQmlJS::AST::DebuggerStatement *statement)
bool QmlMarkupVisitor::visit(QQmlJS::AST::UiObjectDefinition *definition)
{
- QHash<QString, QString> attributes;
addMarkedUpToken(definition->qualifiedTypeNameId->identifierToken, QLatin1String("type"));
QQmlJS::AST::Node::accept(definition->initializer, this);
return false;
diff --git a/src/qdoc/qmlmarkupvisitor.h b/src/qdoc/qmlmarkupvisitor.h
index 58299c125..efc3e36f7 100644
--- a/src/qdoc/qmlmarkupvisitor.h
+++ b/src/qdoc/qmlmarkupvisitor.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -47,7 +47,7 @@ public:
QmlMarkupVisitor(const QString &code, const QList<QQmlJS::SourceLocation> &pragmas,
QQmlJS::Engine *engine);
- virtual ~QmlMarkupVisitor();
+ ~QmlMarkupVisitor() override = default;
QString markedUpCode();
bool hasError() const;
diff --git a/src/qdoc/qmlpropertynode.cpp b/src/qdoc/qmlpropertynode.cpp
index d83aa5160..681b878b3 100644
--- a/src/qdoc/qmlpropertynode.cpp
+++ b/src/qdoc/qmlpropertynode.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -30,6 +30,8 @@
#include "classnode.h"
#include "propertynode.h"
+
+#include <utility>
#include "qdocdatabase.h"
QT_BEGIN_NAMESPACE
@@ -37,10 +39,10 @@ QT_BEGIN_NAMESPACE
/*!
Constructor for the QML property node.
*/
-QmlPropertyNode::QmlPropertyNode(Aggregate *parent, const QString &name, const QString &type,
+QmlPropertyNode::QmlPropertyNode(Aggregate *parent, const QString &name, QString type,
bool attached)
: Node(parent->isJsType() ? JsProperty : QmlProperty, parent, name),
- m_type(type),
+ m_type(std::move(type)),
m_attached(attached)
{
if (m_type == "alias")
@@ -79,16 +81,12 @@ bool QmlPropertyNode::isWritable()
"No Q_PROPERTY for QML property %1::%2::%3 "
"in C++ class documented as QML type: "
"(property not found in the C++ class or its base classes)")
- .arg(logicalModuleName())
- .arg(qmlTypeName())
- .arg(name()));
+ .arg(logicalModuleName(), qmlTypeName(), name()));
} else
defLocation().warning(QStringLiteral("No Q_PROPERTY for QML property %1::%2::%3 "
"in C++ class documented as QML type: "
"(C++ class not specified or not found).")
- .arg(logicalModuleName())
- .arg(qmlTypeName())
- .arg(name()));
+ .arg(logicalModuleName(), qmlTypeName(), name()));
}
}
return true;
@@ -104,7 +102,7 @@ bool QmlPropertyNode::isRequired()
return fromFlagValue(m_required, false);
PropertyNode *pn = findCorrespondingCppProperty();
- return pn ? pn->isRequired() : false;
+ return pn != nullptr && pn->isRequired();
}
/*!
@@ -118,7 +116,7 @@ PropertyNode *QmlPropertyNode::findCorrespondingCppProperty()
while (n && !(n->isQmlType() || n->isJsType()))
n = n->parent();
if (n) {
- QmlTypeNode *qcn = static_cast<QmlTypeNode *>(n);
+ auto *qcn = static_cast<QmlTypeNode *>(n);
ClassNode *cn = qcn->classNode();
if (cn) {
/*
@@ -138,7 +136,7 @@ PropertyNode *QmlPropertyNode::findCorrespondingCppProperty()
QStringList path(extractClassName(pn->qualifiedDataType()));
Node *nn = QDocDatabase::qdocDB()->findClassNode(path);
if (nn) {
- ClassNode *cn = static_cast<ClassNode *>(nn);
+ auto *cn = static_cast<ClassNode *>(nn);
PropertyNode *pn2 = cn->findPropertyNode(dotSplit[1]);
/*
If found, return the C++ property
diff --git a/src/qdoc/qmlpropertynode.h b/src/qdoc/qmlpropertynode.h
index 6d22ae55d..7665f9a2b 100644
--- a/src/qdoc/qmlpropertynode.h
+++ b/src/qdoc/qmlpropertynode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -40,7 +40,7 @@ QT_BEGIN_NAMESPACE
class QmlPropertyNode : public Node
{
public:
- QmlPropertyNode(Aggregate *parent, const QString &name, const QString &type, bool attached);
+ QmlPropertyNode(Aggregate *parent, const QString &name, QString type, bool attached);
void setDataType(const QString &dataType) override { m_type = dataType; }
void setStored(bool stored) { m_stored = toFlagValue(stored); }
@@ -50,10 +50,8 @@ public:
const QString &dataType() const { return m_type; }
const QString &defaultValue() const { return m_defaultValue; }
- QString qualifiedDataType() const { return m_type; }
bool isReadOnlySet() const { return (readOnly_ != FlagValueDefault); }
bool isStored() const { return fromFlagValue(m_stored, true); }
- bool isDesignable() const { return fromFlagValue(m_designable, false); }
bool isWritable();
bool isRequired();
bool isDefault() const override { return m_isDefault; }
diff --git a/src/qdoc/qmltypenode.cpp b/src/qdoc/qmltypenode.cpp
index 839c84320..bc58d964a 100644
--- a/src/qdoc/qmltypenode.cpp
+++ b/src/qdoc/qmltypenode.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -34,7 +34,6 @@
QT_BEGIN_NAMESPACE
-bool QmlTypeNode::qmlOnly = false;
QMultiMap<const Node *, Node *> QmlTypeNode::inheritedBy;
/*!
diff --git a/src/qdoc/qmltypenode.h b/src/qdoc/qmltypenode.h
index 82b1448b4..81067d6f6 100644
--- a/src/qdoc/qmltypenode.h
+++ b/src/qdoc/qmltypenode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -68,14 +68,11 @@ public:
CollectionNode *logicalModule() const override { return m_logicalModule; }
void setQmlModule(CollectionNode *t) override { m_logicalModule = t; }
- const ImportList &importList() const { return m_importList; }
void setImportList(const ImportList &il) { m_importList = il; }
const QString &qmlBaseName() const { return m_qmlBaseName; }
void setQmlBaseName(const QString &name) { m_qmlBaseName = name; }
QmlTypeNode *qmlBaseNode() const override { return m_qmlBaseNode; }
- void setQmlBaseNode(QmlTypeNode *b) { m_qmlBaseNode = b; }
void resolveInheritance(NodeMap &previousSearches);
- void requireCppClass() { m_classNodeRequired = true; }
bool cppClassRequired() const { return m_classNodeRequired; }
static void addInheritedBy(const Node *base, Node *sub);
static void subclasses(const Node *base, NodeList &subs);
@@ -83,7 +80,6 @@ public:
bool inherits(Aggregate *type);
public:
- static bool qmlOnly;
static QMultiMap<const Node *, Node *> inheritedBy;
private:
diff --git a/src/qdoc/qmlvisitor.cpp b/src/qdoc/qmlvisitor.cpp
index fb2c15c2d..cdb3c8967 100644
--- a/src/qdoc/qmlvisitor.cpp
+++ b/src/qdoc/qmlvisitor.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -40,11 +40,9 @@
#include <QtCore/qdebug.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qglobal.h>
-#include <QtCore/qstringlist.h>
#ifndef QT_NO_DECLARATIVE
# include <private/qqmljsast_p.h>
-# include <private/qqmljsastfwd_p.h>
# include <private/qqmljsengine_p.h>
#endif
@@ -69,14 +67,6 @@ QmlDocVisitor::QmlDocVisitor(const QString &filePath, const QString &code, QQmlJ
}
/*!
- The destructor does nothing.
- */
-QmlDocVisitor::~QmlDocVisitor()
-{
- // nothing.
-}
-
-/*!
Returns the location of the nearest comment above the \a offset.
*/
QQmlJS::SourceLocation QmlDocVisitor::precedingComment(quint32 offset) const
@@ -121,7 +111,6 @@ public:
private:
QString signature_;
QStringList names_;
- QString funcName_;
Tokenizer *tokenizer_;
int tok_;
FunctionNode *func_;
@@ -157,7 +146,7 @@ bool QmlDocVisitor::applyDocumentation(QQmlJS::SourceLocation location, Node *no
Aggregate *parent = nodePassedIn->parent();
node->setDoc(doc);
nodes.append(node);
- if (topicsUsed.size() > 0) {
+ if (!topicsUsed.empty()) {
for (int i = 0; i < topicsUsed.size(); ++i) {
QString topic = topicsUsed.at(i).topic;
if (!topic.startsWith(QLatin1String("qml"))
@@ -193,7 +182,7 @@ bool QmlDocVisitor::applyDocumentation(QQmlJS::SourceLocation location, Node *no
qDebug() << " FAILED TO PARSE QML OR JS PROPERTY:" << topic << args;
} else if (topic.endsWith(QLatin1String("method")) || topic == COMMAND_QMLSIGNAL) {
if (node->isFunction()) {
- FunctionNode *fn = static_cast<FunctionNode *>(node);
+ auto *fn = static_cast<FunctionNode *>(node);
QmlSignatureParser qsp(fn, args, doc.location());
if (topic == COMMAND_JSMETHOD || topic == COMMAND_JSATTACHEDMETHOD)
fn->changeMetaness(FunctionNode::QmlMethod, FunctionNode::JsMethod);
@@ -201,8 +190,8 @@ bool QmlDocVisitor::applyDocumentation(QQmlJS::SourceLocation location, Node *no
}
}
}
- for (int i = 0; i < nodes.size(); ++i)
- applyMetacommands(loc, nodes.at(i), doc);
+ for (const auto &node : nodes)
+ applyMetacommands(loc, node, doc);
usedComments.insert(loc.offset);
if (doc.isEmpty()) {
return false;
@@ -334,8 +323,8 @@ bool QmlSignatureParser::matchFunctionDecl()
{
CodeChunk returnType;
- int firstBlank = signature_.indexOf(QChar(' '));
- int leftParen = signature_.indexOf(QChar('('));
+ qsizetype firstBlank = signature_.indexOf(QChar(' '));
+ qsizetype leftParen = signature_.indexOf(QChar('('));
if ((firstBlank > 0) && (leftParen - firstBlank) > 1) {
if (!matchTypeAndName(&returnType, nullptr))
return false;
@@ -344,7 +333,7 @@ bool QmlSignatureParser::matchFunctionDecl()
while (match(Tok_Ident)) {
names_.append(previousLexeme());
if (!match(Tok_Gulbrandsen)) {
- funcName_ = previousLexeme();
+ previousLexeme();
names_.pop_back();
break;
}
@@ -442,7 +431,7 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::SourceLocation, Node *node, Doc &d
doc.location().warning(
QStringLiteral("%1 tries to inherit itself").arg(args[0].first));
else if (node->isQmlType() || node->isJsType()) {
- QmlTypeNode *qmlType = static_cast<QmlTypeNode *>(node);
+ auto *qmlType = static_cast<QmlTypeNode *>(node);
qmlType->setQmlBaseName(args[0].first);
}
} else if (command == COMMAND_DEFAULT) {
@@ -561,9 +550,8 @@ bool QmlDocVisitor::visit(QQmlJS::AST::UiImport *import)
const auto end = import->version->lastSourceLocation().end();
version = document.mid(start, end - start);
}
- QString importId = document.mid(import->importIdToken.offset, import->importIdToken.length);
QString importUri = getFullyQualifiedId(import->importUri);
- importList.append(ImportRec(name, version, importId, importUri));
+ importList.append(ImportRec(name, version, importUri));
return true;
}
@@ -628,13 +616,13 @@ bool QmlDocVisitor::visit(QQmlJS::AST::UiPublicMember *member)
switch (member->type) {
case QQmlJS::AST::UiPublicMember::Signal: {
if (current->isQmlType() || current->isJsType()) {
- QmlTypeNode *qmlType = static_cast<QmlTypeNode *>(current);
+ auto *qmlType = static_cast<QmlTypeNode *>(current);
if (qmlType) {
FunctionNode::Metaness metaness = FunctionNode::QmlSignal;
if (qmlType->isJsType())
metaness = FunctionNode::JsSignal;
QString name = member->name.toString();
- FunctionNode *newSignal = new FunctionNode(metaness, current, name);
+ auto *newSignal = new FunctionNode(metaness, current, name);
Parameters &parameters = newSignal->parameters();
for (QQmlJS::AST::UiParameterList *it = member->parameters; it; it = it->next) {
const QString type = qualifiedIdToString(it->type);
@@ -648,9 +636,8 @@ bool QmlDocVisitor::visit(QQmlJS::AST::UiPublicMember *member)
}
case QQmlJS::AST::UiPublicMember::Property: {
QString type = qualifiedIdToString(member->memberType);
- QString name = member->name.toString();
if (current->isQmlType() || current->isJsType()) {
- QmlTypeNode *qmlType = static_cast<QmlTypeNode *>(current);
+ auto *qmlType = static_cast<QmlTypeNode *>(current);
if (qmlType) {
QString name = member->name.toString();
QmlPropertyNode *qmlPropNode = qmlType->hasQmlProperty(name);
@@ -699,7 +686,7 @@ bool QmlDocVisitor::visit(QQmlJS::AST::FunctionDeclaration *fd)
else if (!current->isQmlType())
return true;
QString name = fd->name.toString();
- FunctionNode *method = new FunctionNode(metaness, current, name);
+ auto *method = new FunctionNode(metaness, current, name);
Parameters &parameters = method->parameters();
QQmlJS::AST::FormalParameterList *formals = fd->formals;
if (formals) {
diff --git a/src/qdoc/qmlvisitor.h b/src/qdoc/qmlvisitor.h
index a717c7d0d..17cff7617 100644
--- a/src/qdoc/qmlvisitor.h
+++ b/src/qdoc/qmlvisitor.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -65,7 +65,7 @@ class QmlDocVisitor : public QQmlJS::AST::Visitor
public:
QmlDocVisitor(const QString &filePath, const QString &code, QQmlJS::Engine *engine,
const QSet<QString> &commands, const QSet<QString> &topics);
- ~QmlDocVisitor() override;
+ ~QmlDocVisitor() override = default;
bool visit(QQmlJS::AST::UiImport *import) override;
void endVisit(QQmlJS::AST::UiImport *definition) override;
diff --git a/src/qdoc/quoter.cpp b/src/qdoc/quoter.cpp
index bbe0c685d..c3302f107 100644
--- a/src/qdoc/quoter.cpp
+++ b/src/qdoc/quoter.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -38,7 +38,7 @@ QHash<QString, QString> Quoter::commentHash;
static void replaceMultipleNewlines(QString &s)
{
- const int n = s.size();
+ const qsizetype n = s.size();
bool slurping = false;
int j = -1;
const QChar newLine = QLatin1Char('\n');
@@ -58,9 +58,9 @@ static void replaceMultipleNewlines(QString &s)
QStringList Quoter::splitLines(const QString &line)
{
QStringList result;
- int i = line.size();
+ qsizetype i = line.size();
while (true) {
- int j = i - 1;
+ qsizetype j = i - 1;
while (j >= 0 && line.at(j) == QLatin1Char('\n'))
--j;
while (j >= 0 && line.at(j) != QLatin1Char('\n'))
@@ -80,7 +80,7 @@ QStringList Quoter::splitLines(const QString &line)
static void trimWhiteSpace(QString &str)
{
enum { Normal, MetAlnum, MetSpace } state = Normal;
- const int n = str.length();
+ const qsizetype n = str.length();
int j = -1;
QChar *d = str.data();
@@ -116,7 +116,7 @@ Quoter::Quoter() : silent(false)
* .html, .qrc, .ui, .xq, .xml files:
<!-- [<id>] -->
*/
- if (!commentHash.size()) {
+ if (commentHash.empty()) {
commentHash["pro"] = "#!";
commentHash["py"] = "#!";
commentHash["cmake"] = "#!";
@@ -224,7 +224,7 @@ QString Quoter::quoteSnippet(const Location &docLocation, const QString &identif
QString line = plainLines.first();
if (match(docLocation, delimiter, line)) {
QString lastLine = getLine(indent);
- int dIndex = lastLine.indexOf(delimiter);
+ qsizetype dIndex = lastLine.indexOf(delimiter);
if (dIndex > 0) {
// The delimiter might be preceded on the line by other
// delimeters, so look for the first comment on the line.
@@ -323,8 +323,7 @@ void Quoter::failedAtEnd(const Location &docLocation, const QString &command)
docLocation.warning(QStringLiteral("Unexpected '\\%1'").arg(command));
} else {
docLocation.warning(QStringLiteral("Command '\\%1' failed at end of file '%2'")
- .arg(command)
- .arg(codeLocation.filePath()));
+ .arg(command, codeLocation.filePath()));
}
silent = true;
}
diff --git a/src/qdoc/quoter.h b/src/qdoc/quoter.h
index 44f3ee18a..743d5dcec 100644
--- a/src/qdoc/quoter.h
+++ b/src/qdoc/quoter.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- quoter.h
-*/
-
#ifndef QUOTER_H
#define QUOTER_H
diff --git a/src/qdoc/relatedclass.cpp b/src/qdoc/relatedclass.cpp
index e17668b2f..2ea3a038e 100644
--- a/src/qdoc/relatedclass.cpp
+++ b/src/qdoc/relatedclass.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -69,19 +69,3 @@ bool RelatedClass::isPrivate() const
return (m_access == Access::Private);
}
-/*!
- Returns a string representing the access specifier.
- */
-QString RelatedClass::accessString() const
-{
- switch (m_access) {
- case Access::Protected:
- return QLatin1String("protected");
- case Access::Private:
- return QLatin1String("private");
- case Access::Public:
- default:
- break;
- }
- return QLatin1String("public");
-}
diff --git a/src/qdoc/relatedclass.h b/src/qdoc/relatedclass.h
index e8884a097..74b9565ba 100644
--- a/src/qdoc/relatedclass.h
+++ b/src/qdoc/relatedclass.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -34,6 +34,8 @@
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
+#include <utility>
+
QT_BEGIN_NAMESPACE
class ClassNode;
@@ -44,17 +46,12 @@ struct RelatedClass
// constructor for resolved base class
RelatedClass(Access access, ClassNode *node) : m_access(access), m_node(node) {}
// constructor for unresolved base class
- RelatedClass(Access access, const QStringList &path, const QString &signature)
- : m_access(access), m_path(path), m_signature(signature)
- {
- }
- QString accessString() const;
+ RelatedClass(Access access, QStringList path) : m_access(access), m_path(std::move(path)) { }
bool isPrivate() const;
Access m_access {};
ClassNode *m_node { nullptr };
QStringList m_path {};
- QString m_signature {};
};
QT_END_NAMESPACE
diff --git a/src/qdoc/sections.cpp b/src/qdoc/sections.cpp
index 1b3d0ab76..08bcb6f99 100644
--- a/src/qdoc/sections.cpp
+++ b/src/qdoc/sections.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -63,15 +63,11 @@ QList<Section> Sections::stdQmlTypeDetailsSections_(7, Section(Section::Details,
*/
/*!
+ \fn Section::Section(Style style, Status status)
+
The constructor used when the \a style and \a status must
be provided.
*/
-Section::Section(Style style, Status status) : style_(style), status_(status), aggregate_(nullptr)
-{
- // members_.reserve(100);
- // obsoleteMembers_.reserve(50);
- // reimplementedMembers_.reserve(50);
-}
/*!
The destructor must delete the members of collections
@@ -94,10 +90,9 @@ void Section::clear()
obsoleteMemberMap_.clear();
reimplementedMemberMap_.clear();
if (!classMapList_.isEmpty()) {
- for (int i = 0; i < classMapList_.size(); i++) {
- ClassMap *cm = classMapList_[i];
- classMapList_[i] = nullptr;
- delete cm;
+ for (ClassMap *classMap : classMapList_) {
+ classMap = nullptr;
+ delete classMap;
}
classMapList_.clear();
}
@@ -108,10 +103,9 @@ void Section::clear()
reimplementedMembers_.clear();
inheritedMembers_.clear();
if (!classKeysNodesList_.isEmpty()) {
- for (int i = 0; i < classKeysNodesList_.size(); i++) {
- ClassKeysNodes *ckn = classKeysNodesList_[i];
- classKeysNodesList_[i] = nullptr;
- delete ckn;
+ for (ClassKeysNodes *classKeysNode : classKeysNodesList_) {
+ classKeysNode = nullptr;
+ delete classKeysNode;
}
classKeysNodesList_.clear();
}
@@ -131,7 +125,7 @@ QString Section::sortName(const Node *node, const QString *name)
else
nodeName = node->name();
int numDigits = 0;
- for (int i = nodeName.size() - 1; i > 0; --i) {
+ for (qsizetype i = nodeName.size() - 1; i > 0; --i) {
if (nodeName.at(i).digitValue() == -1)
break;
++numDigits;
@@ -144,7 +138,7 @@ QString Section::sortName(const Node *node, const QString *name)
}
if (node->isFunction()) {
- const FunctionNode *fn = static_cast<const FunctionNode *>(node);
+ const auto *fn = static_cast<const FunctionNode *>(node);
if (fn->isCppFunction()) {
QString sortNo;
if (fn->isSomeCtor())
@@ -192,13 +186,13 @@ void Section::insert(Node *node)
if (node->isPrivate() || node->isInternal()) {
irrelevant = true;
} else if (node->isFunction()) {
- FunctionNode *func = static_cast<FunctionNode *>(node);
+ auto *func = static_cast<FunctionNode *>(node);
irrelevant = (inherited && (func->isSomeCtor() || func->isDtor()));
} else if (node->isClassNode() || node->isEnumType() || node->isTypedef()
|| node->isVariable()) {
irrelevant = (inherited && style_ != AllMembers);
if (!irrelevant && style_ == Details && node->isTypedef()) {
- const TypedefNode *tdn = static_cast<const TypedefNode *>(node);
+ const auto *tdn = static_cast<const TypedefNode *>(node);
if (tdn->associatedEnum())
irrelevant = true;
}
@@ -239,7 +233,7 @@ void Section::insert(Node *node)
bool Section::insertReimplementedMember(Node *node)
{
if (!node->isPrivate() && !node->isRelatedNonmember()) {
- const FunctionNode *fn = static_cast<const FunctionNode *>(node);
+ const auto *fn = static_cast<const FunctionNode *>(node);
if (!fn->overridesThis().isEmpty() && (status_ == Active)) {
if (fn->parent() == aggregate_) {
QString key = sortName(fn);
@@ -260,7 +254,7 @@ bool Section::insertReimplementedMember(Node *node)
*/
ClassMap *Section::newClassMap(const Aggregate *aggregate)
{
- ClassMap *classMap = new ClassMap;
+ auto *classMap = new ClassMap;
classMap->first = static_cast<const QmlTypeNode *>(aggregate);
classMapList_.append(classMap);
return classMap;
@@ -289,7 +283,7 @@ void Section::reduce()
reimplementedMembers_ = reimplementedMemberMap_.values().toVector();
for (int i = 0; i < classMapList_.size(); i++) {
ClassMap *cm = classMapList_[i];
- ClassKeysNodes *ckn = new ClassKeysNodes;
+ auto *ckn = new ClassKeysNodes;
ckn->first = cm->first;
ckn->second.second = cm->second.values().toVector();
ckn->second.first = cm->second.keys();
@@ -381,7 +375,7 @@ Sections::Sections(const NodeMultiMap &nsmap) : aggregate_(nullptr)
sections[SinceTypeAliases].appendMember(node);
break;
case Node::Function: {
- const FunctionNode *fn = static_cast<const FunctionNode *>(node);
+ const auto *fn = static_cast<const FunctionNode *>(node);
switch (fn->metaness()) {
case FunctionNode::JsSignal:
case FunctionNode::QmlSignal:
@@ -475,8 +469,8 @@ Sections::~Sections()
*/
void Sections::initAggregate(SectionVector &v, Aggregate *aggregate)
{
- for (int i = 0; i < v.size(); ++i)
- v[i].setAggregate(aggregate);
+ for (Section &section : v)
+ section.setAggregate(aggregate);
}
/*!
@@ -597,8 +591,8 @@ void Sections::initSections()
*/
void Sections::clear(QList<Section> &v)
{
- for (int i = 0; i < v.size(); ++i)
- v[i].clear();
+ for (Section &section : v)
+ section.clear();
}
/*!
@@ -606,8 +600,8 @@ void Sections::clear(QList<Section> &v)
*/
void Sections::reduce(QList<Section> &v)
{
- for (int i = 0; i < v.size(); ++i)
- v[i].reduce();
+ for (Section &section : v)
+ section.reduce();
}
/*!
@@ -635,7 +629,7 @@ void Sections::stdRefPageSwitch(SectionVector &v, Node *n, Node *t)
v[StdTypes].insert(n);
return;
case Node::Function: {
- FunctionNode *func = static_cast<FunctionNode *>(t);
+ auto *func = static_cast<FunctionNode *>(t);
if (func->isMacro())
v[StdMacros].insert(n);
else
@@ -643,7 +637,7 @@ void Sections::stdRefPageSwitch(SectionVector &v, Node *n, Node *t)
}
return;
case Node::Variable: {
- const VariableNode *var = static_cast<const VariableNode *>(t);
+ const auto *var = static_cast<const VariableNode *>(t);
if (!var->doc().isEmpty()) {
if (var->isStatic())
v[StdStaticVariables].insert(n);
@@ -653,7 +647,7 @@ void Sections::stdRefPageSwitch(SectionVector &v, Node *n, Node *t)
}
return;
case Node::SharedComment: {
- SharedCommentNode *scn = static_cast<SharedCommentNode *>(t);
+ auto *scn = static_cast<SharedCommentNode *>(t);
if (!scn->doc().isEmpty() && scn->collective().count())
stdRefPageSwitch(
v, scn,
@@ -729,7 +723,7 @@ void Sections::distributeNodeInSummaryVector(SectionVector &sv, Node *n)
if (n->isSharedCommentNode())
return;
if (n->isFunction()) {
- FunctionNode *fn = static_cast<FunctionNode *>(n);
+ auto *fn = static_cast<FunctionNode *>(n);
if (fn->isRelatedNonmember()) {
if (fn->isMacro())
sv[Macros].insert(n);
@@ -818,13 +812,13 @@ void Sections::distributeNodeInDetailsVector(SectionVector &dv, Node *n)
Node *t = n;
if (n->isSharedCommentNode() && n->hasDoc()) {
- SharedCommentNode *scn = static_cast<SharedCommentNode *>(n);
+ auto *scn = static_cast<SharedCommentNode *>(n);
if (scn->collective().count())
t = scn->collective().first(); // TODO: warn about mixed node types in collective?
}
if (t->isFunction()) {
- FunctionNode *fn = static_cast<FunctionNode *>(t);
+ auto *fn = static_cast<FunctionNode *>(t);
if (fn->isRelatedNonmember()) {
if (fn->isMacro())
dv[DetailsMacros].insert(n);
@@ -867,19 +861,19 @@ void Sections::distributeQmlNodeInDetailsVector(SectionVector &dv, Node *n)
dv[QmlProperties].insert(n);
return;
}
- SharedCommentNode *scn = static_cast<SharedCommentNode *>(n);
+ auto *scn = static_cast<SharedCommentNode *>(n);
if (scn->collective().count())
t = scn->collective().first(); // TODO: warn about mixed node types in collective?
}
if (t->isQmlProperty() || t->isJsProperty()) {
- QmlPropertyNode *pn = static_cast<QmlPropertyNode *>(t);
+ auto *pn = static_cast<QmlPropertyNode *>(t);
if (pn->isAttached())
dv[QmlAttachedProperties].insert(n);
else
dv[QmlProperties].insert(n);
} else if (t->isFunction()) {
- FunctionNode *fn = static_cast<FunctionNode *>(t);
+ auto *fn = static_cast<FunctionNode *>(t);
if (fn->isQmlSignal() || fn->isJsSignal()) {
if (fn->isAttached())
dv[QmlAttachedSignals].insert(n);
@@ -906,13 +900,13 @@ void Sections::distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n, bool
if (n->isSharingComment() && !sharing)
return;
if (n->isQmlProperty() || n->isJsProperty()) {
- QmlPropertyNode *pn = static_cast<QmlPropertyNode *>(n);
+ auto *pn = static_cast<QmlPropertyNode *>(n);
if (pn->isAttached())
sv[QmlAttachedProperties].insert(pn);
else
sv[QmlProperties].insert(pn);
} else if (n->isFunction()) {
- FunctionNode *fn = static_cast<FunctionNode *>(n);
+ auto *fn = static_cast<FunctionNode *>(n);
if (fn->isQmlSignal() || fn->isJsSignal()) {
if (fn->isAttached())
sv[QmlAttachedSignals].insert(fn);
@@ -927,7 +921,7 @@ void Sections::distributeQmlNodeInSummaryVector(SectionVector &sv, Node *n, bool
sv[QmlMethods].insert(fn);
}
} else if (n->isSharedCommentNode()) {
- SharedCommentNode *scn = static_cast<SharedCommentNode *>(n);
+ auto *scn = static_cast<SharedCommentNode *>(n);
if (scn->isPropertyGroup()) {
sv[QmlProperties].insert(scn);
} else {
@@ -976,7 +970,7 @@ void Sections::buildStdCppClassRefPageSections()
}
QStack<ClassNode *> stack;
- ClassNode *cn = static_cast<ClassNode *>(aggregate_);
+ auto *cn = static_cast<ClassNode *>(aggregate_);
pushBaseClasses(stack, cn);
while (!stack.isEmpty()) {
ClassNode *cn = stack.pop();
diff --git a/src/qdoc/sections.h b/src/qdoc/sections.h
index b070c7380..3ad52d613 100644
--- a/src/qdoc/sections.h
+++ b/src/qdoc/sections.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -53,7 +53,7 @@ public:
public:
Section() : style_(Details), status_(Active), aggregate_(nullptr) {}
- Section(Style style, Status status);
+ Section(Style style, Status status) : style_(style), status_(status), aggregate_(nullptr) {};
~Section();
void init(const QString &title) { title_ = title; }
@@ -85,7 +85,6 @@ public:
ClassMap *newClassMap(const Aggregate *aggregate);
void add(ClassMap *classMap, Node *n);
void appendMember(Node *node) { members_.append(node); }
- void appendReimplementedMember(Node *node) { reimplementedMembers_.append(node); }
void clear();
void reduce();
@@ -145,7 +144,6 @@ class Sections
{
public:
enum VectorIndex {
- AllMembers = 0,
PublicTypes = 0,
DetailsMemberTypes = 0,
SinceNamespaces = 0,
@@ -202,8 +200,8 @@ public:
Macros = 17
};
- Sections(Aggregate *aggregate);
- Sections(const NodeMultiMap &nsmap);
+ explicit Sections(Aggregate *aggregate);
+ explicit Sections(const NodeMultiMap &nsmap);
~Sections();
void initSections();
diff --git a/src/qdoc/sharedcommentnode.cpp b/src/qdoc/sharedcommentnode.cpp
index e1190adaa..ad7ef4de3 100644
--- a/src/qdoc/sharedcommentnode.cpp
+++ b/src/qdoc/sharedcommentnode.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -60,7 +60,7 @@ void SharedCommentNode::setOverloadFlags()
*/
Node *SharedCommentNode::clone(Aggregate *parent)
{
- SharedCommentNode *scn = new SharedCommentNode(*this); // shallow copy
+ auto *scn = new SharedCommentNode(*this); // shallow copy
scn->setParent(nullptr);
parent->addChild(scn);
diff --git a/src/qdoc/sharedcommentnode.h b/src/qdoc/sharedcommentnode.h
index 67c3af810..af0dd69ab 100644
--- a/src/qdoc/sharedcommentnode.h
+++ b/src/qdoc/sharedcommentnode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -55,7 +55,7 @@ public:
return !name().isEmpty() && !m_collective.isEmpty()
&& (m_collective.at(0)->isQmlProperty() || m_collective.at(0)->isJsProperty());
}
- int count() const { return m_collective.size(); }
+ qsizetype count() const { return m_collective.size(); }
void append(Node *node)
{
m_collective.append(node);
diff --git a/src/qdoc/text.cpp b/src/qdoc/text.cpp
index ca5a7ed18..da0fb1dee 100644
--- a/src/qdoc/text.cpp
+++ b/src/qdoc/text.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- text.cpp
-*/
-
#include "text.h"
#include <QtCore/qregularexpression.h>
@@ -229,7 +225,7 @@ void Text::dump() const
str.replace("\\", "\\\\");
str.replace("\"", "\\\"");
str.replace("\n", "\\n");
- str.replace(QRegularExpression("[^\x20-\x7e]"), "?");
+ str.replace(QRegularExpression(R"([^ -~])"), "?");
if (!str.isEmpty())
str = " \"" + str + QLatin1Char('"');
fprintf(stderr, " %-15s%s\n", atom->typeString().toLatin1().data(),
diff --git a/src/qdoc/text.h b/src/qdoc/text.h
index 5bbbd51b1..64f54873e 100644
--- a/src/qdoc/text.h
+++ b/src/qdoc/text.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- text.h
-*/
-
#ifndef TEXT_H
#define TEXT_H
diff --git a/src/qdoc/tokenizer.cpp b/src/qdoc/tokenizer.cpp
index c9802ff87..08c8acb00 100644
--- a/src/qdoc/tokenizer.cpp
+++ b/src/qdoc/tokenizer.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -39,6 +39,7 @@
#include <cctype>
#include <cstring>
+#include <utility>
QT_BEGIN_NAMESPACE
@@ -148,7 +149,7 @@ Tokenizer::Tokenizer(const Location &loc, QFile &in)
start(loc);
}
-Tokenizer::Tokenizer(const Location &loc, const QByteArray &in) : yyIn(in)
+Tokenizer::Tokenizer(const Location &loc, QByteArray in) : yyIn(std::move(in))
{
init();
yyPos = 0;
diff --git a/src/qdoc/tokenizer.h b/src/qdoc/tokenizer.h
index 564079f91..d333b85dd 100644
--- a/src/qdoc/tokenizer.h
+++ b/src/qdoc/tokenizer.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- tokenizer.h
-*/
-
#ifndef TOKENIZER_H
#define TOKENIZER_H
@@ -81,57 +77,16 @@ enum {
Tok_class,
Tok_const,
Tok_double,
- Tok_enum,
- Tok_explicit,
- Tok_friend,
- Tok_inline,
Tok_int,
Tok_long,
- Tok_namespace,
Tok_operator,
- Tok_private,
- Tok_protected,
- Tok_public,
Tok_short,
- Tok_signals,
Tok_signed,
- Tok_slots,
- Tok_static,
- Tok_struct,
- Tok_template,
- Tok_typedef,
Tok_typename,
- Tok_union,
Tok_unsigned,
- Tok_using,
- Tok_virtual,
Tok_void,
Tok_volatile,
Tok_int64,
- Tok_default,
- Tok_delete,
- Tok_final,
- Tok_override,
- Tok_Q_OBJECT,
- Tok_Q_OVERRIDE,
- Tok_Q_PROPERTY,
- Tok_Q_PRIVATE_PROPERTY,
- Tok_Q_DECLARE_SEQUENTIAL_ITERATOR,
- Tok_Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR,
- Tok_Q_DECLARE_ASSOCIATIVE_ITERATOR,
- Tok_Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR,
- Tok_Q_DECLARE_FLAGS,
- Tok_Q_SIGNALS,
- Tok_Q_SLOTS,
- Tok_QT_COMPAT,
- Tok_QT_COMPAT_CONSTRUCTOR,
- Tok_QT_DEPRECATED,
- Tok_QT_MOC_COMPAT,
- Tok_QT_MODULE,
- Tok_QT3_SUPPORT,
- Tok_QT3_SUPPORT_CONSTRUCTOR,
- Tok_QT3_MOC_SUPPORT,
- Tok_QDOC_PROPERTY,
Tok_QPrivateSignal,
Tok_FirstKeyword = Tok_char,
Tok_LastKeyword = Tok_QPrivateSignal
@@ -149,7 +104,7 @@ enum {
class Tokenizer
{
public:
- Tokenizer(const Location &loc, const QByteArray &in);
+ Tokenizer(const Location &loc, QByteArray in);
Tokenizer(const Location &loc, QFile &file);
~Tokenizer();
@@ -161,10 +116,8 @@ public:
QString previousLexeme() const;
QString lexeme() const;
QString version() const { return yyVersion; }
- int braceDepth() const { return yyBraceDepth; }
int parenDepth() const { return yyParenDepth; }
int bracketDepth() const { return yyBracketDepth; }
- Location &tokenLocation() { return yyTokLoc; }
static void initialize();
static void terminate();
@@ -206,20 +159,20 @@ private:
Location yyTokLoc;
Location yyCurLoc;
- char *yyLexBuf1;
- char *yyLexBuf2;
- char *yyPrevLex;
- char *yyLex;
- size_t yyLexLen;
+ char *yyLexBuf1 {};
+ char *yyLexBuf2 {};
+ char *yyPrevLex {};
+ char *yyLex {};
+ size_t yyLexLen {};
QStack<bool> yyPreprocessorSkipping;
- int yyNumPreprocessorSkipping;
- int yyBraceDepth;
- int yyParenDepth;
- int yyBracketDepth;
- int yyCh;
+ int yyNumPreprocessorSkipping {};
+ int yyBraceDepth {};
+ int yyParenDepth {};
+ int yyBracketDepth {};
+ int yyCh {};
QString yyVersion;
- bool parsingMacro;
+ bool parsingMacro {};
protected:
QByteArray yyIn;
diff --git a/src/qdoc/tree.cpp b/src/qdoc/tree.cpp
index dac9a5dc8..0227dff84 100644
--- a/src/qdoc/tree.cpp
+++ b/src/qdoc/tree.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -70,7 +70,6 @@ QT_BEGIN_NAMESPACE
*/
Tree::Tree(const QString &camelCaseModuleName, QDocDatabase *qdb)
: treeHasBeenAnalyzed_(false),
- docsHaveBeenGenerated_(false),
camelCaseModuleName_(camelCaseModuleName),
physicalModuleName_(camelCaseModuleName.toLower()),
qdb_(qdb),
@@ -159,30 +158,6 @@ NamespaceNode *Tree::findNamespaceNode(const QStringList &path) const
}
/*!
- Find the Qml type node named \a path. Begin the search at the
- \a start node. If the \a start node is 0, begin the search
- at the root of the tree. Only a Qml type node named <\a path is
- acceptible. If one is not found, 0 is returned.
- */
-QmlTypeNode *Tree::findQmlTypeNode(const QStringList &path)
-{
- /*
- If the path contains one or two double colons ("::"),
- check first to see if the first two path strings refer
- to a QML element. If they do, path[0] will be the QML
- module identifier, and path[1] will be the QML type.
- If the anser is yes, the reference identifies a QML
- class node.
- */
- if (path.size() >= 2 && !path[0].isEmpty()) {
- QmlTypeNode *qcn = qdb_->findQmlType(path[0], path[1]);
- if (qcn != nullptr)
- return qcn;
- }
- return static_cast<QmlTypeNode *>(findNodeRecursive(path, 0, root(), &Node::isQmlType));
-}
-
-/*!
This function searches for the node specified by \a path.
The matching node can be one of several different types
including a C++ class, a C++ namespace, or a C++ header
@@ -222,7 +197,7 @@ void Tree::resolveBaseClasses(Aggregate *n)
{
for (auto it = n->constBegin(); it != n->constEnd(); ++it) {
if ((*it)->isClassNode()) {
- ClassNode *cn = static_cast<ClassNode *>(*it);
+ auto *cn = static_cast<ClassNode *>(*it);
QList<RelatedClass> &bases = cn->baseClasses();
for (auto &base : bases) {
if (base.m_node == nullptr) {
@@ -245,7 +220,7 @@ void Tree::resolveBaseClasses(Aggregate *n)
n = findClassNode(base.m_path, parent);
}
if (n != nullptr) {
- ClassNode *bcn = static_cast<ClassNode *>(n);
+ auto *bcn = static_cast<ClassNode *>(n);
base.m_node = bcn;
bcn->addDerivedClass(base.m_access, cn);
}
@@ -264,7 +239,7 @@ void Tree::resolvePropertyOverriddenFromPtrs(Aggregate *n)
{
for (auto node = n->constBegin(); node != n->constEnd(); ++node) {
if ((*node)->isClassNode()) {
- ClassNode *cn = static_cast<ClassNode *>(*node);
+ auto *cn = static_cast<ClassNode *>(*node);
for (auto property = cn->constBegin(); property != cn->constEnd(); ++property) {
if ((*property)->isProperty())
cn->resolvePropertyOverriddenFromPtrs(static_cast<PropertyNode *>(*property));
@@ -291,7 +266,7 @@ void Tree::resolveProperties()
for (auto it = parent->constBegin(); it != parent->constEnd(); ++it) {
if ((*it)->isFunction()) {
- FunctionNode *function = static_cast<FunctionNode *>(*it);
+ auto *function = static_cast<FunctionNode *>(*it);
if (function->access() == property->access()
&& (function->status() == property->status() || function->doc().isEmpty())) {
if (function->name() == getterName) {
@@ -330,8 +305,8 @@ void Tree::resolveCppToQmlLinks()
const NodeList &children = root_.childNodes();
for (auto *child : children) {
if (child->isQmlType() || child->isJsType()) {
- QmlTypeNode *qcn = static_cast<QmlTypeNode *>(child);
- ClassNode *cn = const_cast<ClassNode *>(qcn->classNode());
+ auto *qcn = static_cast<QmlTypeNode *>(child);
+ auto *cn = const_cast<ClassNode *>(qcn->classNode());
if (cn)
cn->setQmlElement(qcn);
}
@@ -350,7 +325,7 @@ void Tree::resolveUsingClauses(Aggregate *parent)
parent = &root_;
for (auto *child : parent->childNodes()) {
if (child->isClassNode()) {
- ClassNode *cn = static_cast<ClassNode *>(child);
+ auto *cn = static_cast<ClassNode *>(child);
QList<UsingClause> &usingClauses = cn->usingClauses();
for (auto &usingClause : usingClauses) {
if (usingClause.node() == nullptr) {
@@ -359,11 +334,7 @@ void Tree::resolveUsingClauses(Aggregate *parent)
usingClause.setNode(n);
}
}
- } else if (child->isTypeAlias()) {
- TypeAliasNode *ta = static_cast<TypeAliasNode *>(child);
- ta->setAliasedNode(qdb_->findNodeForTarget(ta->aliasedType(), child->parent()));
}
-
if (child->genus() == Node::CPP && child->isAggregate())
resolveUsingClauses(static_cast<Aggregate *>(child));
}
@@ -442,7 +413,7 @@ Node *Tree::findNodeRecursive(const QStringList &path, int pathIndex, const Node
Node *node = const_cast<Node *>(start);
if (!node->isAggregate())
return ((pathIndex >= path.size()) ? node : nullptr);
- Aggregate *current = static_cast<Aggregate *>(node);
+ auto *current = static_cast<Aggregate *>(node);
const NodeList &children = current->childNodes();
const QString &name = path.at(pathIndex);
for (auto *node : children) {
@@ -762,7 +733,7 @@ QString Tree::getRef(const QString &target, const Node *node) const
void Tree::insertTarget(const QString &name, const QString &title, TargetRec::TargetType type,
Node *node, int priority)
{
- TargetRec *target = new TargetRec(name, title, type, node, priority);
+ auto *target = new TargetRec(name, type, node, priority);
nodesByTargetRef_.insert(name, target);
nodesByTargetTitle_.insert(title, target);
}
@@ -773,7 +744,7 @@ void Tree::resolveTargets(Aggregate *root)
{
for (auto *child : root->childNodes()) {
if (child->isTextPageNode()) {
- PageNode *node = static_cast<PageNode *>(child);
+ auto *node = static_cast<PageNode *>(child);
QString key = node->title();
if (!key.isEmpty()) {
if (key.contains(QChar(' ')))
@@ -797,12 +768,12 @@ void Tree::resolveTargets(Aggregate *root)
if (child->doc().hasTableOfContents()) {
const QList<Atom *> &toc = child->doc().tableOfContents();
- for (int i = 0; i < toc.size(); ++i) {
- QString ref = refForAtom(toc.at(i));
- QString title = Text::sectionHeading(toc.at(i)).toString();
+ for (Atom *i : toc) {
+ QString ref = refForAtom(i);
+ QString title = Text::sectionHeading(i).toString();
if (!ref.isEmpty() && !title.isEmpty()) {
QString key = Doc::canonicalTitle(title);
- TargetRec *target = new TargetRec(ref, title, TargetRec::Contents, child, 3);
+ auto *target = new TargetRec(ref, TargetRec::Contents, child, 3);
nodesByTargetRef_.insert(key, target);
nodesByTargetTitle_.insert(title, target);
}
@@ -810,11 +781,11 @@ void Tree::resolveTargets(Aggregate *root)
}
if (child->doc().hasKeywords()) {
const QList<Atom *> &keywords = child->doc().keywords();
- for (int i = 0; i < keywords.size(); ++i) {
- QString ref = refForAtom(keywords.at(i));
- QString title = keywords.at(i)->string();
+ for (Atom *i : keywords) {
+ QString ref = refForAtom(i);
+ QString title = i->string();
if (!ref.isEmpty() && !title.isEmpty()) {
- TargetRec *target = new TargetRec(ref, title, TargetRec::Keyword, child, 1);
+ auto *target = new TargetRec(ref, TargetRec::Keyword, child, 1);
nodesByTargetRef_.insert(Doc::canonicalTitle(title), target);
nodesByTargetTitle_.insert(title, target);
}
@@ -822,12 +793,12 @@ void Tree::resolveTargets(Aggregate *root)
}
if (child->doc().hasTargets()) {
const QList<Atom *> &targets = child->doc().targets();
- for (int i = 0; i < targets.size(); ++i) {
- QString ref = refForAtom(targets.at(i));
- QString title = targets.at(i)->string();
+ for (Atom *i : targets) {
+ QString ref = refForAtom(i);
+ QString title = i->string();
if (!ref.isEmpty() && !title.isEmpty()) {
QString key = Doc::canonicalTitle(title);
- TargetRec *target = new TargetRec(ref, title, TargetRec::Target, child, 2);
+ auto *target = new TargetRec(ref, TargetRec::Target, child, 2);
nodesByTargetRef_.insert(key, target);
nodesByTargetTitle_.insert(title, target);
}
diff --git a/src/qdoc/tree.h b/src/qdoc/tree.h
index 7799eaeea..274551488 100644
--- a/src/qdoc/tree.h
+++ b/src/qdoc/tree.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -26,10 +26,6 @@
**
****************************************************************************/
-/*
- tree.h
-*/
-
#ifndef TREE_H
#define TREE_H
@@ -42,6 +38,8 @@
#include <QtCore/qstack.h>
+#include <utility>
+
QT_BEGIN_NAMESPACE
class CollectionNode;
@@ -53,9 +51,8 @@ struct TargetRec
public:
enum TargetType { Unknown, Target, Keyword, Contents, Class, Function, Page, Subtitle };
- TargetRec(const QString &name, const QString &title, TargetRec::TargetType type, Node *node,
- int priority)
- : node_(node), ref_(name), title_(title), priority_(priority), type_(type)
+ TargetRec(QString name, TargetRec::TargetType type, Node *node, int priority)
+ : node_(node), ref_(std::move(name)), priority_(priority)
{
// Discard the dedicated ref for keywords - they always
// link to the top of the QDoc comment they appear in
@@ -64,28 +61,17 @@ public:
}
bool isEmpty() const { return ref_.isEmpty(); }
- Node::Genus genus() { return (node_ ? node_->genus() : Node::DontCare); }
+ Node::Genus genus() const { return (node_ ? node_->genus() : Node::DontCare); }
Node *node_;
QString ref_;
- QString title_;
int priority_;
- TargetType type_;
};
struct TargetLoc
{
public:
- TargetLoc(const Node *loc, const QString &t, const QString &fileName, const QString &text,
- bool broken)
- : loc_(loc), target_(t), fileName_(fileName), text_(text), broken_(broken)
- {
- }
- const Node *loc_;
- QString target_;
- QString fileName_;
- QString text_;
- bool broken_;
+ TargetLoc() = default;
};
typedef QMultiMap<QString, TargetRec *> TargetMap;
@@ -93,7 +79,6 @@ typedef QMultiMap<QString, PageNode *> PageNodeMultiMap;
typedef QMap<QString, QmlTypeNode *> QmlTypeMap;
typedef QMultiMap<QString, const ExampleNode *> ExampleNodeMap;
typedef QList<TargetLoc *> TargetList;
-typedef QMap<QString, TargetList *> TargetListMap;
class Tree
{
@@ -136,8 +121,6 @@ private: // The rest of the class is private.
const Node *findNode(const QStringList &path, const Node *relative, int flags,
Node::Genus genus) const;
- QmlTypeNode *findQmlTypeNode(const QStringList &path);
-
Node *findNodeByNameAndType(const QStringList &path, bool (Node::*isMatch)() const) const;
Aggregate *findRelatesNode(const QStringList &path);
const Node *findEnumNode(const Node *node, const Node *aggregate, const QStringList &path, int offset) const;
@@ -151,7 +134,6 @@ private: // The rest of the class is private.
void addPropertyFunction(PropertyNode *property, const QString &funcName,
PropertyNode::FunctionRole funcRole);
void resolveBaseClasses(Aggregate *n);
- void resolveBaseClassesHelper(int pass, ClassNode *cn);
void resolvePropertyOverriddenFromPtrs(Aggregate *n);
void resolveProperties();
void resolveCppToQmlLinks();
@@ -201,18 +183,12 @@ private: // The rest of the class is private.
void setIndexFileName(const QString &t) { indexFileName_ = t; }
bool treeHasBeenAnalyzed() const { return treeHasBeenAnalyzed_; }
- bool docsHaveBeenGenerated() const { return docsHaveBeenGenerated_; }
void setTreeHasBeenAnalyzed() { treeHasBeenAnalyzed_ = true; }
- void setdocsHaveBeenGenerated() { docsHaveBeenGenerated_ = true; }
- QString getNewLinkTarget(const Node *locNode, const Node *t, const QString &fileName,
- QString &text, bool broken);
- TargetList *getTargetList(const QString &module);
FunctionNode *findFunctionNodeForTag(const QString &tag, Aggregate *parent = nullptr);
FunctionNode *findMacroNode(const QString &t, const Aggregate *parent = nullptr);
private:
bool treeHasBeenAnalyzed_;
- bool docsHaveBeenGenerated_;
QString camelCaseModuleName_;
QString physicalModuleName_;
QString indexFileName_;
diff --git a/src/qdoc/typedefnode.cpp b/src/qdoc/typedefnode.cpp
index 6046a9aaa..760379db5 100644
--- a/src/qdoc/typedefnode.cpp
+++ b/src/qdoc/typedefnode.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
diff --git a/src/qdoc/typedefnode.h b/src/qdoc/typedefnode.h
index 308f62a3a..da14d7dec 100644
--- a/src/qdoc/typedefnode.h
+++ b/src/qdoc/typedefnode.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -68,13 +68,10 @@ public:
}
const QString &aliasedType() const { return m_aliasedType; }
- const Node *aliasedNode() const { return m_aliasedNode; }
- void setAliasedNode(const Node *node) { m_aliasedNode = node; }
Node *clone(Aggregate *parent) override;
private:
QString m_aliasedType {};
- const Node *m_aliasedNode { nullptr };
};
QT_END_NAMESPACE
diff --git a/src/qdoc/usingclause.cpp b/src/qdoc/usingclause.cpp
index 23591358a..e4ce57f3d 100644
--- a/src/qdoc/usingclause.cpp
+++ b/src/qdoc/usingclause.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -28,8 +28,6 @@
#include "usingclause.h"
-#include "node.h"
-
QT_BEGIN_NAMESPACE
/*!
diff --git a/src/qdoc/usingclause.h b/src/qdoc/usingclause.h
index 48db8411b..911b6a432 100644
--- a/src/qdoc/usingclause.h
+++ b/src/qdoc/usingclause.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -32,6 +32,8 @@
#include <QtCore/qglobal.h>
#include <QtCore/qstring.h>
+#include <utility>
+
QT_BEGIN_NAMESPACE
class Node;
@@ -39,7 +41,7 @@ class Node;
struct UsingClause
{
UsingClause() = default;
- explicit UsingClause(const QString &signature) : m_signature(signature) {}
+ explicit UsingClause(QString signature) : m_signature(std::move(signature)) { }
const QString &signature() const { return m_signature; }
const Node *node() const { return m_node; }
void setNode(const Node *n) { m_node = n; }
diff --git a/src/qdoc/utilities.cpp b/src/qdoc/utilities.cpp
index 355ceede8..19e1572f6 100644
--- a/src/qdoc/utilities.cpp
+++ b/src/qdoc/utilities.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -71,7 +71,7 @@ bool debugging()
\sa comma()
*/
-QString separator(int wordPosition, int numberOfWords)
+QString separator(qsizetype wordPosition, qsizetype numberOfWords)
{
static QString terminator = QStringLiteral(".");
if (wordPosition == numberOfWords - 1)
@@ -91,7 +91,7 @@ QString separator(int wordPosition, int numberOfWords)
\sa comma()
*/
-QString comma(int wordPosition, int numberOfWords)
+QString comma(qsizetype wordPosition, qsizetype numberOfWords)
{
if (wordPosition == numberOfWords - 1)
return QString();
diff --git a/src/qdoc/utilities.h b/src/qdoc/utilities.h
index 705738258..eb5abedeb 100644
--- a/src/qdoc/utilities.h
+++ b/src/qdoc/utilities.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -42,8 +42,8 @@ void startDebugging(const QString &message);
void stopDebugging(const QString &message);
bool debugging();
-QString separator(int wordPosition, int numberOfWords);
-QString comma(int wordPosition, int numberOfWords);
+QString separator(qsizetype wordPosition, qsizetype numberOfWords);
+QString comma(qsizetype wordPosition, qsizetype numberOfWords);
};
QT_END_NAMESPACE
diff --git a/src/qdoc/webxmlgenerator.cpp b/src/qdoc/webxmlgenerator.cpp
index dbb4ba52a..05c5827e3 100644
--- a/src/qdoc/webxmlgenerator.cpp
+++ b/src/qdoc/webxmlgenerator.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -72,7 +72,7 @@ QString WebXMLGenerator::fileExtension() const
Some pages produce supplementary output while being generated, and that's
handled here.
*/
-int WebXMLGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker)
+qsizetype WebXMLGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker)
{
if (m_supplement && currentWriter)
addAtomElements(*currentWriter.data(), atom, relative, marker);
diff --git a/src/qdoc/webxmlgenerator.h b/src/qdoc/webxmlgenerator.h
index f4e5623e8..0b3c7beb2 100644
--- a/src/qdoc/webxmlgenerator.h
+++ b/src/qdoc/webxmlgenerator.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -52,7 +52,7 @@ public:
void append(QXmlStreamWriter &writer, Node *node) override;
protected:
- int generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker) override;
+ qsizetype generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker) override;
void generateCppReferencePage(Aggregate *aggregate, CodeMarker *marker) override;
void generatePageNode(PageNode *pn, CodeMarker *marker) override;
void generateDocumentation(Node *node) override;
diff --git a/src/qdoc/xmlgenerator.cpp b/src/qdoc/xmlgenerator.cpp
index e5d879e5e..8a16654d4 100644
--- a/src/qdoc/xmlgenerator.cpp
+++ b/src/qdoc/xmlgenerator.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2019 Thibaut Cuvelier
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -418,7 +419,7 @@ QString XmlGenerator::getAutoLink(const Atom *atom, const Node *relative, const
if (link.isEmpty())
link = linkForNode(*node, relative);
if (!ref.isEmpty()) {
- int hashtag = link.lastIndexOf(QChar('#'));
+ qsizetype hashtag = link.lastIndexOf(QChar('#'));
if (hashtag != -1)
link.truncate(hashtag);
link += QLatin1Char('#') + ref;
diff --git a/src/qdoc/xmlgenerator.h b/src/qdoc/xmlgenerator.h
index a57648412..c5dfdc33f 100644
--- a/src/qdoc/xmlgenerator.h
+++ b/src/qdoc/xmlgenerator.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2019 Thibaut Cuvelier
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.