diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-05 08:17:22 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-06 18:20:17 +0200 |
commit | c338447261878111df7198fbd96051926464e865 (patch) | |
tree | d21b5af1efae225f75d5c05dfe370daefb1ea1d1 /src/qdoc | |
parent | 6495329e6de803025e6e4e8291b648f94893551c (diff) | |
download | qttools-c338447261878111df7198fbd96051926464e865.tar.gz |
Port from container::count() and length() to size()
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:
auto QtContainerClass = anyOf(
expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.
Change-Id: I95f6410e57a6a92b1cf91bbedfbe3d517cab6b44
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/qdoc')
-rw-r--r-- | src/qdoc/aggregate.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/codechunk.h | 6 | ||||
-rw-r--r-- | src/qdoc/codemarker.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/config.cpp | 16 | ||||
-rw-r--r-- | src/qdoc/cppcodemarker.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 6 | ||||
-rw-r--r-- | src/qdoc/doc.cpp | 8 | ||||
-rw-r--r-- | src/qdoc/docbookgenerator.cpp | 10 | ||||
-rw-r--r-- | src/qdoc/docparser.cpp | 56 | ||||
-rw-r--r-- | src/qdoc/editdistance.cpp | 6 | ||||
-rw-r--r-- | src/qdoc/generator.cpp | 34 | ||||
-rw-r--r-- | src/qdoc/headernode.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/helpprojectwriter.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/htmlgenerator.cpp | 12 | ||||
-rw-r--r-- | src/qdoc/location.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/main.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/manifestwriter.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/parameters.cpp | 2 | ||||
-rw-r--r-- | src/qdoc/qdocdatabase.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/qmlmarkupvisitor.cpp | 16 | ||||
-rw-r--r-- | src/qdoc/qmlvisitor.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/quoter.cpp | 14 | ||||
-rw-r--r-- | src/qdoc/sections.cpp | 8 | ||||
-rw-r--r-- | src/qdoc/tokenizer.cpp | 6 |
25 files changed, 116 insertions, 116 deletions
diff --git a/src/qdoc/aggregate.cpp b/src/qdoc/aggregate.cpp index 6e969a1d1..06adb4891 100644 --- a/src/qdoc/aggregate.cpp +++ b/src/qdoc/aggregate.cpp @@ -341,7 +341,7 @@ bool Aggregate::isSameSignature(const FunctionNode *f1, const FunctionNode *f2) QString t1 = p1.at(i).type(); QString t2 = p2.at(i).type(); - if (t1.length() < t2.length()) + if (t1.size() < t2.size()) qSwap(t1, t2); /* diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 4dc5083f5..d2d72abfe 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -717,7 +717,7 @@ CXChildVisitResult ClangVisitor::visitHeader(CXCursor cursor, CXSourceLocation l #endif case CXCursor_EnumDecl: { auto *en = static_cast<EnumNode *>(findNodeForCursor(qdb_, cursor)); - if (en && en->items().count()) + if (en && en->items().size()) return CXChildVisit_Continue; // Was already parsed, probably in another TU QString enumTypeName = fromCXString(clang_getCursorSpelling(cursor)); if (enumTypeName.isEmpty()) { diff --git a/src/qdoc/codechunk.h b/src/qdoc/codechunk.h index 788e8224d..00ad26c6d 100644 --- a/src/qdoc/codechunk.h +++ b/src/qdoc/codechunk.h @@ -19,7 +19,7 @@ public: void appendHotspot() { if (m_hotspot == -1) - m_hotspot = m_str.length(); + m_hotspot = m_str.size(); } [[nodiscard]] bool isEmpty() const { return m_str.isEmpty(); } @@ -27,11 +27,11 @@ public: [[nodiscard]] QString toString() const { return m_str; } [[nodiscard]] QString left() const { - return m_str.left(m_hotspot == -1 ? m_str.length() : m_hotspot); + return m_str.left(m_hotspot == -1 ? m_str.size() : m_hotspot); } [[nodiscard]] QString right() const { - return m_str.mid(m_hotspot == -1 ? m_str.length() : m_hotspot); + return m_str.mid(m_hotspot == -1 ? m_str.size() : m_hotspot); } private: diff --git a/src/qdoc/codemarker.cpp b/src/qdoc/codemarker.cpp index 757fb98a2..ffeb9072c 100644 --- a/src/qdoc/codemarker.cpp +++ b/src/qdoc/codemarker.cpp @@ -213,7 +213,7 @@ static const QString squot = QLatin1String("""); QString CodeMarker::protect(const QString &str) { - qsizetype n = str.length(); + qsizetype n = str.size(); QString marked; marked.reserve(n * 2 + 30); const QChar *data = str.constData(); @@ -240,7 +240,7 @@ QString CodeMarker::protect(const QString &str) void CodeMarker::appendProtectedString(QString *output, QStringView str) { - qsizetype n = str.length(); + qsizetype n = str.size(); output->reserve(output->size() + n * 2 + 30); const QChar *data = str.constData(); for (int i = 0; i != n; ++i) { diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp index 88a19b648..83c9b509f 100644 --- a/src/qdoc/config.cpp +++ b/src/qdoc/config.cpp @@ -699,7 +699,7 @@ QSet<QString> Config::subVars(const QString &var) 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()); + QString subVar = it.key().mid(varDot.size()); int dot = subVar.indexOf(QLatin1Char('.')); if (dot != -1) subVar.truncate(dot); @@ -1025,7 +1025,7 @@ QString Config::copyFile(const Location &location, const QString &sourceFilePath int Config::numParams(const QString &value) { int max = 0; - for (int i = 0; i != value.length(); ++i) { + for (int i = 0; i != value.size(); ++i) { uint c = value[i].unicode(); if (c > 0 && c < 8) max = qMax(max, static_cast<int>(c)); @@ -1053,9 +1053,9 @@ QStringList Config::loadMaster(const QString &fileName) QFile fin(fileName); if (!fin.open(QFile::ReadOnly | QFile::Text)) { if (!Config::installDir.isEmpty()) { - qsizetype prefix = location.filePath().length() - location.fileName().length(); + qsizetype prefix = location.filePath().size() - location.fileName().size(); fin.setFileName(Config::installDir + QLatin1Char('/') - + fileName.right(fileName.length() - prefix)); + + fileName.right(fileName.size() - prefix)); } if (!fin.open(QFile::ReadOnly | QFile::Text)) location.fatal(QStringLiteral("Cannot open master qdocconf file '%1': %2") @@ -1110,9 +1110,9 @@ void Config::load(Location location, const QString &fileName) QFile fin(fileInfo.fileName()); if (!fin.open(QFile::ReadOnly | QFile::Text)) { if (!Config::installDir.isEmpty()) { - qsizetype prefix = location.filePath().length() - location.fileName().length(); + qsizetype prefix = location.filePath().size() - location.fileName().size(); fin.setFileName(Config::installDir + QLatin1Char('/') - + fileName.right(fileName.length() - prefix)); + + fileName.right(fileName.size() - prefix)); } if (!fin.open(QFile::ReadOnly | QFile::Text)) location.fatal( @@ -1131,7 +1131,7 @@ void Config::load(Location location, const QString &fileName) int i = 0; QChar c = text.at(0); uint cc = c.unicode(); - while (i < text.length()) { + while (i < text.size()) { if (cc == 0) { ++i; } else if (c.isSpace()) { @@ -1158,7 +1158,7 @@ void Config::load(Location location, const QString &fileName) const QStringList keys = stack.getExpanded(location); SKIP_SPACES(); - if (keys.count() == 1 && keys.first() == QLatin1String("include")) { + if (keys.size() == 1 && keys.first() == QLatin1String("include")) { QString includeFile; if (cc != '(') diff --git a/src/qdoc/cppcodemarker.cpp b/src/qdoc/cppcodemarker.cpp index 3ba925018..647fb4b8f 100644 --- a/src/qdoc/cppcodemarker.cpp +++ b/src/qdoc/cppcodemarker.cpp @@ -393,7 +393,7 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */, bool atEOF = false; auto readChar = [&]() { - if (i < code.length()) + if (i < code.size()) ch = code[i++]; else atEOF = true; @@ -583,7 +583,7 @@ QString CppCodeMarker::addMarkUp(const QString &in, const Node * /* relative */, } } - if (start < code.length()) { + if (start < code.size()) { appendProtectedString(&out, QStringView{code}.mid(start)); } diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index a0519fc8f..7cca45ca6 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -700,7 +700,7 @@ FunctionNode *CppCodeParser::parseOtherFuncArg(const QString &topic, const Locat qsizetype firstBlank = funcName.indexOf(QChar(' ')); if (firstBlank > 0) { returnType = funcName.left(firstBlank); - funcName = funcName.right(funcName.length() - firstBlank - 1); + funcName = funcName.right(funcName.size() - firstBlank - 1); } QStringList colonSplit(funcName.split("::")); @@ -774,7 +774,7 @@ FunctionNode *CppCodeParser::parseMacroArg(const Location &location, const QStri params = afterParen.left(rightParen); } int i = 0; - while (i < macroName.length() && !macroName.at(i).isLetter()) + while (i < macroName.size() && !macroName.at(i).isLetter()) i++; if (i > 0) { returnType += QChar(' ') + macroName.left(i); @@ -978,7 +978,7 @@ void CppCodeParser::processMetaCommands(NodeList &nodes, DocList &docs) bool CppCodeParser::hasTooManyTopics(const Doc &doc) const { const QSet<QString> topicCommandsUsed = topicCommands() & doc.metaCommandsUsed(); - if (topicCommandsUsed.count() > 1) { + if (topicCommandsUsed.size() > 1) { bool ok = true; for (const auto &t : topicCommandsUsed) { if (!t.startsWith(QLatin1String("qml"))) diff --git a/src/qdoc/doc.cpp b/src/qdoc/doc.cpp index b000fda22..158486538 100644 --- a/src/qdoc/doc.cpp +++ b/src/qdoc/doc.cpp @@ -168,7 +168,7 @@ Text Doc::trimmedBriefText(const QString &className) const whats = w.join(' '); if (whats.endsWith(QLatin1Char('.'))) - whats.truncate(whats.length() - 1); + whats.truncate(whats.size() - 1); if (!whats.isEmpty()) whats[0] = whats[0].toUpper(); @@ -376,7 +376,7 @@ void Doc::trimCStyleComment(Location &location, QString &str) int asterColumn = location.columnNo() + 1; int i; - for (i = 0; i < str.length(); ++i) { + for (i = 0; i < str.size(); ++i) { if (m.columnNo() == asterColumn) { if (str[i] != '*') break; @@ -392,12 +392,12 @@ void Doc::trimCStyleComment(Location &location, QString &str) } m.advance(str[i]); } - if (cleaned.length() == str.length()) + if (cleaned.size() == str.size()) str = cleaned; for (int i = 0; i < 3; ++i) location.advance(str[i]); - str = str.mid(3, str.length() - 5); + str = str.mid(3, str.size() - 5); } CodeMarker *Doc::quoteFromFile(const Location &location, Quoter "er, ResolvedFile resolved_file) diff --git a/src/qdoc/docbookgenerator.cpp b/src/qdoc/docbookgenerator.cpp index ab6bfdb3f..c02d6a654 100644 --- a/src/qdoc/docbookgenerator.cpp +++ b/src/qdoc/docbookgenerator.cpp @@ -1272,7 +1272,7 @@ void DocBookGenerator::generateCompactList(ListType listType, const Node *relati return; const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_' - qsizetype commonPrefixLen = commonPrefix.length(); + qsizetype commonPrefixLen = commonPrefix.size(); /* Divide the data into 37 paragraphs: 0, ..., 9, A, ..., Z, @@ -1922,7 +1922,7 @@ void DocBookGenerator::generateSortedNames(const ClassNode *cn, const QList<Rela int index = 0; for (const QString &className : classNames) { generateFullName(classMap.value(className), cn); - m_writer->writeCharacters(Utilities::comma(index++, classNames.count())); + m_writer->writeCharacters(Utilities::comma(index++, classNames.size())); } } @@ -1942,7 +1942,7 @@ void DocBookGenerator::generateSortedQmlNames(const Node *base, const NodeList & for (const QString &name : names) { generateFullName(classMap.value(name), base); - m_writer->writeCharacters(Utilities::comma(index++, names.count())); + m_writer->writeCharacters(Utilities::comma(index++, names.size())); } } @@ -2008,7 +2008,7 @@ void DocBookGenerator::generateRequisites(const Aggregate *aggregate) else if ((*r).m_access == Access::Private) m_writer->writeCharacters(" (private)"); m_writer->writeCharacters( - Utilities::comma(index++, classe->baseClasses().count())); + Utilities::comma(index++, classe->baseClasses().size())); } ++r; } @@ -3128,7 +3128,7 @@ void DocBookGenerator::generateDocBookSynopsis(const Node *node) m_writer->writeCharacters(" (private)"); } m_writer->writeCharacters( - Utilities::comma(index++, classe->baseClasses().count())); + Utilities::comma(index++, classe->baseClasses().size())); } ++r; } diff --git a/src/qdoc/docparser.cpp b/src/qdoc/docparser.cpp index 178aa7c38..4e9e1c8d8 100644 --- a/src/qdoc/docparser.cpp +++ b/src/qdoc/docparser.cpp @@ -288,7 +288,7 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate, { m_input = source; m_position = 0; - m_inputLength = m_input.length(); + m_inputLength = m_input.size(); m_cachedLocation = docPrivate->m_start_loc; m_cachedPosition = 0; m_private = docPrivate; @@ -469,7 +469,7 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate, } break; case CMD_ENDIF: - if (preprocessorSkipping.count() > 0) { + if (preprocessorSkipping.size() > 0) { if (preprocessorSkipping.pop()) --numPreprocessorSkipping; (void)getRestOfLine(); // ### should ensure that it's empty @@ -988,7 +988,7 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate, p1 = getArgument(); if (p1.startsWith(QLatin1String("[since ")) && p1.endsWith(QLatin1String("]"))) { - p2 = p1.mid(7, p1.length() - 8); + p2 = p1.mid(7, p1.size() - 8); p1 = getArgument(); } if (!m_private->m_enumItemList.contains(p1)) @@ -1090,7 +1090,7 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate, macro.numParams, matchExpr); m_input.replace(m_backslashPosition, m_endPosition - m_backslashPosition, expanded); - m_inputLength = m_input.length(); + m_inputLength = m_input.size(); m_position = m_backslashPosition; } } @@ -1254,7 +1254,7 @@ void DocParser::parse(const QString &source, DocPrivate *docPrivate, if (m_openedCommands.top() != CMD_OMIT) { location().warning( QStringLiteral("Missing '\\%1'").arg(endCmdName(m_openedCommands.top()))); - } else if (preprocessorSkipping.count() > 0) { + } else if (preprocessorSkipping.size() > 0) { location().warning(QStringLiteral("Missing '\\%1'").arg(cmdName(CMD_ENDIF))); } @@ -1339,8 +1339,8 @@ void DocParser::include(const QString &fileName, const QString &identifier, cons if (identifier.isEmpty()) { expandArgumentsInString(includedContent, parameters); m_input.insert(m_position, includedContent); - m_inputLength = m_input.length(); - m_openedInputs.push(m_position + includedContent.length()); + m_inputLength = m_input.size(); + m_openedInputs.push(m_position + includedContent.size()); } else { QStringList lineBuffer = includedContent.split(QLatin1Char('\n')); int i = 0; @@ -1379,8 +1379,8 @@ void DocParser::include(const QString &fileName, const QString &identifier, cons .arg(identifier, filePath)); } else { m_input.insert(m_position, result); - m_inputLength = m_input.length(); - m_openedInputs.push(m_position + result.length()); + m_inputLength = m_input.size(); + m_openedInputs.push(m_position + result.size()); } } } @@ -1523,7 +1523,7 @@ bool DocParser::openCommand(int cmd) inline bool DocParser::isAutoLinkString(const QString &word) { qsizetype start = 0; - return isAutoLinkString(word, start) && (start == word.length()); + return isAutoLinkString(word, start) && (start == word.size()); } /*! @@ -1928,7 +1928,7 @@ bool DocParser::expandMacro() QString cmdStr; qsizetype backslashPos = m_position++; - while (m_position < m_input.length() && m_input[m_position].isLetterOrNumber()) + while (m_position < m_input.size() && m_input[m_position].isLetterOrNumber()) cmdStr += m_input[m_position++]; m_endPosition = m_position; @@ -1939,7 +1939,7 @@ bool DocParser::expandMacro() QString expanded = expandMacroToString(cmdStr, macro.m_defaultDef, macro.numParams, macro.m_otherDefs.value("match")); m_input.replace(backslashPos, m_position - backslashPos, expanded); - m_inputLength = m_input.length(); + m_inputLength = m_input.size(); m_position = backslashPos; return true; } else { @@ -2085,9 +2085,9 @@ QString DocParser::getBracedArgument(bool verbatim) { QString arg; int delimDepth = 0; - if (m_position < m_input.length() && m_input[m_position] == '{') { + if (m_position < m_input.size() && m_input[m_position] == '{') { ++m_position; - while (m_position < m_input.length() && delimDepth >= 0) { + while (m_position < m_input.size() && delimDepth >= 0) { switch (m_input[m_position].unicode()) { case '{': ++delimDepth; @@ -2140,7 +2140,7 @@ QString DocParser::getArgument(bool verbatim) qsizetype startPos = m_position; QString arg = getBracedArgument(verbatim); if (arg.isEmpty()) { - while ((m_position < m_input.length()) + while ((m_position < m_input.size()) && ((delimDepth > 0) || ((delimDepth == 0) && !m_input[m_position].isSpace()))) { switch (m_input[m_position].unicode()) { case '(': @@ -2169,13 +2169,13 @@ QString DocParser::getArgument(bool verbatim) } } m_endPosition = m_position; - if ((arg.length() > 1) && (QString(".,:;!?").indexOf(m_input[m_position - 1]) != -1) + if ((arg.size() > 1) && (QString(".,:;!?").indexOf(m_input[m_position - 1]) != -1) && !arg.endsWith("...")) { - arg.truncate(arg.length() - 1); + arg.truncate(arg.size() - 1); --m_position; } - if (arg.length() > 2 && m_input.mid(m_position - 2, 2) == "'s") { - arg.truncate(arg.length() - 2); + if (arg.size() > 2 && m_input.mid(m_position - 2, 2) == "'s") { + arg.truncate(arg.size() - 2); m_position -= 2; } } @@ -2193,9 +2193,9 @@ QString DocParser::getBracketedArgument() QString arg; int delimDepth = 0; skipSpacesOrOneEndl(); - if (m_position < m_input.length() && m_input[m_position] == '[') { + if (m_position < m_input.size() && m_input[m_position] == '[') { ++m_position; - while (m_position < m_input.length() && delimDepth >= 0) { + while (m_position < m_input.size() && delimDepth >= 0) { switch (m_input[m_position].unicode()) { case '[': ++delimDepth; @@ -2226,7 +2226,7 @@ QString DocParser::getBracketedArgument() QString DocParser::getOptionalArgument() { skipSpacesOrOneEndl(); - if (m_position + 1 < m_input.length() && m_input[m_position] == '\\' + if (m_position + 1 < m_input.size() && m_input[m_position] == '\\' && m_input[m_position + 1].isLetterOrNumber()) { return QString(); } else { @@ -2313,7 +2313,7 @@ QString DocParser::getUntilEnd(int cmd) if (!match.hasMatch()) { location().warning(QStringLiteral("Missing '\\%1'").arg(cmdName(endCmd))); - m_position = m_input.length(); + m_position = m_input.size(); } else { qsizetype end = match.capturedStart(); t = m_input.mid(m_position, end - m_position); @@ -2412,7 +2412,7 @@ bool DocParser::isLeftBracketAhead() */ void DocParser::skipSpacesOnLine() { - while ((m_position < m_input.length()) && m_input[m_position].isSpace() + while ((m_position < m_input.size()) && m_input[m_position].isSpace() && (m_input[m_position].unicode() != '\n')) ++m_position; } @@ -2423,7 +2423,7 @@ void DocParser::skipSpacesOnLine() void DocParser::skipSpacesOrOneEndl() { qsizetype firstEndl = -1; - while (m_position < m_input.length() && m_input[m_position].isSpace()) { + while (m_position < m_input.size() && m_input[m_position].isSpace()) { QChar ch = m_input[m_position]; if (ch == '\n') { if (firstEndl == -1) { @@ -2450,7 +2450,7 @@ void DocParser::skipToNextPreprocessorCommand() auto match = rx.match(m_input, m_position + 1); // ### + 1 necessary? if (!match.hasMatch()) - m_position = m_input.length(); + m_position = m_input.size(); else m_position = match.capturedStart(); } @@ -2512,7 +2512,7 @@ QString DocParser::endCmdName(int cmd) QString DocParser::untabifyEtc(const QString &str) { QString result; - result.reserve(str.length()); + result.reserve(str.size()); int column = 0; for (const auto &character : str) { @@ -2535,7 +2535,7 @@ QString DocParser::untabifyEtc(const QString &str) } while (result.endsWith("\n\n")) - result.truncate(result.length() - 1); + result.truncate(result.size() - 1); while (result.startsWith(QLatin1Char('\n'))) result = result.mid(1); diff --git a/src/qdoc/editdistance.cpp b/src/qdoc/editdistance.cpp index 5a5f8f155..303979ec3 100644 --- a/src/qdoc/editdistance.cpp +++ b/src/qdoc/editdistance.cpp @@ -10,8 +10,8 @@ int editDistance(const QString &s, const QString &t) #define D(i, j) d[(i)*n + (j)] int i; int j; - qsizetype m = s.length() + 1; - qsizetype n = t.length() + 1; + qsizetype m = s.size() + 1; + qsizetype n = t.size() + 1; int *d = new int[m * n]; int result; @@ -59,7 +59,7 @@ QString nearestName(const QString &actual, const QSet<QString> &candidates) } } - if (numBest == 1 && deltaBest <= 2 && actual.length() + best.length() >= 5) + if (numBest == 1 && deltaBest <= 2 && actual.size() + best.size() >= 5) return best; return QString(); diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp index 8c99c3e1e..bddab831d 100644 --- a/src/qdoc/generator.cpp +++ b/src/qdoc/generator.cpp @@ -152,7 +152,7 @@ int Generator::appendSortedNames(Text &text, const ClassNode *cn, const QList<Re const QStringList classNames = classMap.keys(); for (const auto &className : classNames) { text << classMap[className]; - text << Utilities::comma(index++, classNames.count()); + text << Utilities::comma(index++, classNames.size()); } return index; } @@ -174,7 +174,7 @@ int Generator::appendSortedQmlNames(Text &text, const Node *base, const NodeList const QStringList names = classMap.keys(); for (const auto &name : names) { text << classMap[name]; - text << Utilities::comma(index++, names.count()); + text << Utilities::comma(index++, names.size()); } return index; } @@ -279,7 +279,7 @@ QString Generator::fileBase(const Node *node) const if (node->isCollectionNode()) { base = node->name() + outputSuffix(node); if (base.endsWith(".html")) - base.truncate(base.length() - 5); + base.truncate(base.size() - 5); if (node->isQmlModule()) base.append("-qmlmodule"); @@ -289,7 +289,7 @@ QString Generator::fileBase(const Node *node) const } else if (node->isTextPageNode()) { base = node->name(); if (base.endsWith(".html")) - base.truncate(base.length() - 5); + base.truncate(base.size() - 5); if (node->isExample()) { base.prepend(s_project.toLower() + QLatin1Char('-')); @@ -423,7 +423,7 @@ QString Generator::cleanRef(const QString &ref, bool xmlCompliant) clean += QLatin1Char('A'); } - for (int i = 1; i < ref.length(); i++) { + for (int i = 1; i < ref.size(); i++) { const QChar c = ref[i]; const uint u = c.unicode(); if ((u >= 'a' && u <= 'z') || (u >= 'A' && u <= 'Z') || (u >= '0' && u <= '9') || u == '-' @@ -773,8 +773,8 @@ void Generator::generateBody(const Node *node, CodeMarker *marker) const auto &documentedItemList = enume->doc().enumItemNames(); QSet<QString> documentedItems(documentedItemList.cbegin(), documentedItemList.cend()); const QSet<QString> allItems = definedItems + documentedItems; - if (allItems.count() > definedItems.count() - || allItems.count() > documentedItems.count()) { + if (allItems.size() > definedItems.size() + || allItems.size() > documentedItems.size()) { for (const auto &it : allItems) { if (!definedItems.contains(it)) { QString details; @@ -1185,7 +1185,7 @@ QString Generator::formatSince(const Node *node) QStringList since = node->since().split(QLatin1Char(' ')); // If there is only one argument, assume it is the Qt version number. - if (since.count() == 1) + if (since.size() == 1) return "Qt " + since[0]; // Otherwise, use the original <project> <version> string. @@ -1589,7 +1589,7 @@ QString Generator::indent(int level, const QString &markedCode) int column = 0; int i = 0; - while (i < markedCode.length()) { + while (i < markedCode.size()) { if (markedCode.at(i) == QLatin1Char('\n')) { column = 0; } else { @@ -1846,7 +1846,7 @@ bool Generator::parseArg(const QString &src, const QString &tag, int *pos, int n // SKIP_CHAR('<'); // SKIP_CHAR('@'); - if (tag != QStringView(src).mid(i, tag.length())) { + if (tag != QStringView(src).mid(i, tag.size())) { return false; } @@ -1854,7 +1854,7 @@ bool Generator::parseArg(const QString &src, const QString &tag, int *pos, int n qDebug() << "haystack:" << src << "needle:" << tag << "i:" << i; // skip tag - i += tag.length(); + i += tag.size(); // parse stuff like: linkTag("(<@link node=\"([^\"]+)\">).*(</@link>)"); if (par1) { @@ -1886,7 +1886,7 @@ bool Generator::parseArg(const QString &src, const QString &tag, int *pos, int n // find contents up to closing "</@tag> j = i; for (; true; ++i) { - if (i + 4 + tag.length() > n) + if (i + 4 + tag.size() > n) return false; if (src[i] != '<') continue; @@ -1894,16 +1894,16 @@ bool Generator::parseArg(const QString &src, const QString &tag, int *pos, int n continue; if (src[i + 2] != '@') continue; - if (tag != QStringView(src).mid(i + 3, tag.length())) + if (tag != QStringView(src).mid(i + 3, tag.size())) continue; - if (src[i + 3 + tag.length()] != '>') + if (src[i + 3 + tag.size()] != '>') continue; break; } *contents = QStringView(src).mid(j, i - j); - i += tag.length() + 4; + i += tag.size() + 4; *pos = i; if (debug) @@ -2045,8 +2045,8 @@ QString Generator::trimmedTrailing(const QString &string, const QString &prefix, const QString &suffix) { QString trimmed = string; - while (trimmed.length() > 0 && trimmed[trimmed.length() - 1].isSpace()) - trimmed.truncate(trimmed.length() - 1); + while (trimmed.size() > 0 && trimmed[trimmed.size() - 1].isSpace()) + trimmed.truncate(trimmed.size() - 1); trimmed.append(suffix); trimmed.prepend(prefix); diff --git a/src/qdoc/headernode.cpp b/src/qdoc/headernode.cpp index 96647b1fc..ab576fbd6 100644 --- a/src/qdoc/headernode.cpp +++ b/src/qdoc/headernode.cpp @@ -13,7 +13,7 @@ QT_BEGIN_NAMESPACE HeaderNode::HeaderNode(Aggregate *parent, const QString &name) : Aggregate(HeaderFile, parent, name) { // Set the include file with enclosing angle brackets removed - if (name.startsWith(QChar('<')) && name.length() > 2) + if (name.startsWith(QChar('<')) && name.size() > 2) Aggregate::setIncludeFile(name.mid(1).chopped(1)); else Aggregate::setIncludeFile(name); diff --git a/src/qdoc/helpprojectwriter.cpp b/src/qdoc/helpprojectwriter.cpp index 8d3f22c2d..a6d54594b 100644 --- a/src/qdoc/helpprojectwriter.cpp +++ b/src/qdoc/helpprojectwriter.cpp @@ -212,7 +212,7 @@ bool HelpProjectWriter::generateSection(HelpProject &project, QXmlStreamWriter & // Only add nodes to the set for each subproject if they match a selector. // Those that match will be listed in the table of contents. - for (int i = 0; i < project.m_subprojects.length(); i++) { + for (int i = 0; i < project.m_subprojects.size(); i++) { SubProject subproject = project.m_subprojects[i]; // No selectors: accept all nodes. if (subproject.m_selectors.isEmpty()) { @@ -627,7 +627,7 @@ void HelpProjectWriter::generateProject(HelpProject &project) generateSections(project, writer, rootNode); - for (int i = 0; i < project.m_subprojects.length(); i++) { + for (int i = 0; i < project.m_subprojects.size(); i++) { SubProject subproject = project.m_subprojects[i]; if (subproject.m_type == QLatin1String("manual")) { diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index d447c4e22..baa9a3bbb 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -1704,7 +1704,7 @@ void HtmlGenerator::generateNavigationBar(const QString &title, const Node *node // If no nav. parent was found but the page is in a single group, use that if (navNodes.empty()) { QStringList groups = static_cast<const PageNode *>(node)->groupNames(); - if (groups.length() == 1) { + if (groups.size() == 1) { const Node *groupNode = m_qdb->findNodeByNameAndType(QStringList(groups[0]), &Node::isGroup); if (groupNode && !groupNode->title().isEmpty()) @@ -2027,7 +2027,7 @@ void HtmlGenerator::addInheritsToMap(QMap<QString, Text> &requisites, Text *text } else if (cls.m_access == Access::Private) { *text << " (private)"; } - *text << Utilities::comma(index++, classe->baseClasses().count()); + *text << Utilities::comma(index++, classe->baseClasses().size()); } } *text << Atom::ParaRight; @@ -2710,7 +2710,7 @@ void HtmlGenerator::generateCompactList(ListType listType, const Node *relative, return; const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_' - qsizetype commonPrefixLen = commonPrefix.length(); + qsizetype commonPrefixLen = commonPrefix.size(); /* Divide the data into 37 paragraphs: 0, ..., 9, A, ..., Z, @@ -3299,7 +3299,7 @@ QString HtmlGenerator::highlightedCode(const QString &markedCode, const Node *re bool handled = false; for (int k = 0; k != nTags; ++k) { const QLatin1String &tag = spanTags[2 * k]; - if (i + tag.size() <= src.length() && tag == QStringView(src).mid(i, tag.size())) { + if (i + tag.size() <= src.size() && tag == QStringView(src).mid(i, tag.size())) { html += spanTags[2 * k + 1]; i += tag.size(); handled = true; @@ -3318,7 +3318,7 @@ QString HtmlGenerator::highlightedCode(const QString &markedCode, const Node *re bool handled = false; for (int k = 0; k != nTags; ++k) { const QLatin1String &tag = spanTags[2 * k]; - if (i + tag.size() <= src.length() && tag == QStringView(src).mid(i, tag.size())) { + if (i + tag.size() <= src.size() && tag == QStringView(src).mid(i, tag.size())) { html += QLatin1String("</span>"); i += tag.size(); handled = true; @@ -3373,7 +3373,7 @@ QString HtmlGenerator::protect(const QString &string) html += (x); QString html; - qsizetype n = string.length(); + qsizetype n = string.size(); for (int i = 0; i < n; ++i) { QChar ch = string.at(i); diff --git a/src/qdoc/location.cpp b/src/qdoc/location.cpp index 7b799ff0f..87cf481af 100644 --- a/src/qdoc/location.cpp +++ b/src/qdoc/location.cpp @@ -342,7 +342,7 @@ void Location::emitMessage(MessageType type, const QString &message, const QStri if (type == Warning && s_spuriousRegExp != nullptr) { auto match = s_spuriousRegExp->match(message, 0, QRegularExpression::NormalMatch, QRegularExpression::AnchorAtOffsetMatchOption); - if (match.hasMatch() && match.capturedLength() == message.length()) + if (match.hasMatch() && match.capturedLength() == message.size()) return; } diff --git a/src/qdoc/main.cpp b/src/qdoc/main.cpp index c750ddeb9..118ab9031 100644 --- a/src/qdoc/main.cpp +++ b/src/qdoc/main.cpp @@ -135,7 +135,7 @@ static void loadIndexFiles(const QSet<QString> &formats) config.dependModules().removeAll(config.getString(CONFIG_PROJECT).toLower()); config.dependModules().removeDuplicates(); qCCritical(lcQdoc) << "qdocconf file has depends = *; loading all " - << config.dependModules().count() + << config.dependModules().size() << " index files found"; } for (const auto &module : config.dependModules()) { diff --git a/src/qdoc/manifestwriter.cpp b/src/qdoc/manifestwriter.cpp index ab1ddaaae..0162bfe68 100644 --- a/src/qdoc/manifestwriter.cpp +++ b/src/qdoc/manifestwriter.cpp @@ -225,7 +225,7 @@ void ManifestWriter::generateManifestFile(const QString &manifest, const QString for (const auto &attribute : attributes) { const QLatin1Char div(':'); QStringList attrList = attribute.split(div); - if (attrList.count() == 1) + if (attrList.size() == 1) attrList.append(QStringLiteral("true")); QString attrName = attrList.takeFirst(); if (!usedAttributes.contains(attrName)) diff --git a/src/qdoc/parameters.cpp b/src/qdoc/parameters.cpp index 08bea7a3a..c0cee5e58 100644 --- a/src/qdoc/parameters.cpp +++ b/src/qdoc/parameters.cpp @@ -459,7 +459,7 @@ void Parameters::set(const QString &signature) qSwap(pType, pName); else { int j = 0; - while (j < pName.length() && !pName.at(j).isLetter()) + while (j < pName.size() && !pName.at(j).isLetter()) j++; if (j > 0) { pType += QChar(' ') + pName.left(j); diff --git a/src/qdoc/qdocdatabase.cpp b/src/qdoc/qdocdatabase.cpp index 99598dcd3..ae7152e9a 100644 --- a/src/qdoc/qdocdatabase.cpp +++ b/src/qdoc/qdocdatabase.cpp @@ -1172,7 +1172,7 @@ const FunctionNode *QDocDatabase::findFunctionNode(const QString &target, const { QString signature; QString function = target; - qsizetype length = target.length(); + qsizetype length = target.size(); if (function.endsWith("()")) function.chop(2); if (function.endsWith(QChar(')'))) { @@ -1559,7 +1559,7 @@ const Node *QDocDatabase::findNodeForAtom(const Atom *a, const Node *relative, Q else if (first.endsWith(QChar(')'))) { QString signature; QString function = first; - qsizetype length = first.length(); + qsizetype length = first.size(); if (function.endsWith("()")) function.chop(2); if (function.endsWith(QChar(')'))) { diff --git a/src/qdoc/qmlmarkupvisitor.cpp b/src/qdoc/qmlmarkupvisitor.cpp index 58c0a06f3..c46c60f8e 100644 --- a/src/qdoc/qmlmarkupvisitor.cpp +++ b/src/qdoc/qmlmarkupvisitor.cpp @@ -28,7 +28,7 @@ QmlMarkupVisitor::QmlMarkupVisitor(const QString &source, int i = 0; int j = 0; const QList<QQmlJS::SourceLocation> comments = engine->comments(); - while (i < comments.size() && j < pragmas.length()) { + while (i < comments.size() && j < pragmas.size()) { if (comments[i].offset < pragmas[j].offset) { m_extraTypes.append(Comment); m_extraLocations.append(comments[i]); @@ -46,7 +46,7 @@ QmlMarkupVisitor::QmlMarkupVisitor(const QString &source, ++i; } - while (j < pragmas.length()) { + while (j < pragmas.size()) { m_extraTypes.append(Pragma); m_extraLocations.append(pragmas[j]); ++j; @@ -62,7 +62,7 @@ static const QString squot = QLatin1String("""); QString QmlMarkupVisitor::protect(const QString &str) { - qsizetype n = str.length(); + qsizetype n = str.size(); QString marked; marked.reserve(n * 2 + 30); const QChar *data = str.constData(); @@ -89,8 +89,8 @@ QString QmlMarkupVisitor::protect(const QString &str) QString QmlMarkupVisitor::markedUpCode() { - if (int(m_cursor) < m_source.length()) - addExtra(m_cursor, m_source.length()); + if (int(m_cursor) < m_source.size()) + addExtra(m_cursor, m_source.size()); return m_output; } @@ -102,7 +102,7 @@ bool QmlMarkupVisitor::hasError() const void QmlMarkupVisitor::addExtra(quint32 start, quint32 finish) { - if (m_extraIndex >= m_extraLocations.length()) { + if (m_extraIndex >= m_extraLocations.size()) { QString extra = m_source.mid(start, finish - start); if (extra.trimmed().isEmpty()) m_output += extra; @@ -113,7 +113,7 @@ void QmlMarkupVisitor::addExtra(quint32 start, quint32 finish) return; } - while (m_extraIndex < m_extraLocations.length()) { + while (m_extraIndex < m_extraLocations.size()) { if (m_extraTypes[m_extraIndex] == Comment) { if (m_extraLocations[m_extraIndex].offset - 2 >= start) break; @@ -125,7 +125,7 @@ void QmlMarkupVisitor::addExtra(quint32 start, quint32 finish) } quint32 i = start; - while (i < finish && m_extraIndex < m_extraLocations.length()) { + while (i < finish && m_extraIndex < m_extraLocations.size()) { quint32 j = m_extraLocations[m_extraIndex].offset - 2; if (i <= j && j < finish) { if (i < j) diff --git a/src/qdoc/qmlvisitor.cpp b/src/qdoc/qmlvisitor.cpp index bf0cefadc..94e5865c9 100644 --- a/src/qdoc/qmlvisitor.cpp +++ b/src/qdoc/qmlvisitor.cpp @@ -381,7 +381,7 @@ void QmlDocVisitor::applyMetacommands(QQmlJS::SourceLocation, Node *node, Doc &d { QDocDatabase *qdb = QDocDatabase::qdocDB(); QSet<QString> metacommands = doc.metaCommandsUsed(); - if (metacommands.count() > 0) { + if (metacommands.size() > 0) { metacommands.subtract(m_topics); for (const auto &command : qAsConst(metacommands)) { const ArgList args = doc.metaCommandArgs(command); @@ -510,7 +510,7 @@ bool QmlDocVisitor::visit(QQmlJS::AST::UiImport *import) { QString name = m_document.mid(import->fileNameToken.offset, import->fileNameToken.length); if (name[0] == '\"') - name = name.mid(1, name.length() - 2); + name = name.mid(1, name.size() - 2); QString version; if (import->version) { const auto start = import->version->firstSourceLocation().begin(); diff --git a/src/qdoc/quoter.cpp b/src/qdoc/quoter.cpp index 1da812334..37799a9e9 100644 --- a/src/qdoc/quoter.cpp +++ b/src/qdoc/quoter.cpp @@ -55,7 +55,7 @@ QStringList Quoter::splitLines(const QString &line) static void trimWhiteSpace(QString &str) { enum { Normal, MetAlnum, MetSpace } state = Normal; - const qsizetype n = str.length(); + const qsizetype n = str.size(); int j = -1; QChar *d = str.data(); @@ -141,7 +141,7 @@ void Quoter::quoteFromFile(const QString &userFriendlyFilePath, const QString &p m_plainLines = splitLines(plainCode); m_markedLines = splitLines(markedCode); - if (m_markedLines.count() != m_plainLines.count()) { + if (m_markedLines.size() != m_plainLines.size()) { m_codeLocation.warning( QStringLiteral("Something is wrong with qdoc's handling of marked code")); m_markedLines = m_plainLines; @@ -189,7 +189,7 @@ QString Quoter::quoteSnippet(const Location &docLocation, const QString &identif while (!m_plainLines.isEmpty()) { if (match(docLocation, delimiter, m_plainLines.first())) { QString startLine = getLine(); - while (indent < startLine.length() && startLine[indent] == QLatin1Char(' ')) + while (indent < startLine.size() && startLine[indent] == QLatin1Char(' ')) indent++; break; } @@ -260,7 +260,7 @@ QString Quoter::getLine(int unindent) QString t = m_markedLines.takeFirst(); int i = 0; - while (i < unindent && i < t.length() && t[i] == QLatin1Char(' ')) + while (i < unindent && i < t.size() && t[i] == QLatin1Char(' ')) i++; t = t.mid(i); @@ -273,12 +273,12 @@ bool Quoter::match(const Location &docLocation, const QString &pattern0, const Q { QString str = line; while (str.endsWith(QLatin1Char('\n'))) - str.truncate(str.length() - 1); + str.truncate(str.size() - 1); QString pattern = pattern0; if (pattern.startsWith(QLatin1Char('/')) && pattern.endsWith(QLatin1Char('/')) - && pattern.length() > 2) { - QRegularExpression rx(pattern.mid(1, pattern.length() - 2)); + && pattern.size() > 2) { + QRegularExpression rx(pattern.mid(1, pattern.size() - 2)); if (!m_silent && !rx.isValid()) { docLocation.warning( QStringLiteral("Invalid regular expression '%1'").arg(rx.pattern())); diff --git a/src/qdoc/sections.cpp b/src/qdoc/sections.cpp index 57d24a45a..12656b22a 100644 --- a/src/qdoc/sections.cpp +++ b/src/qdoc/sections.cpp @@ -183,7 +183,7 @@ QString sortName(const Node *node) sortNo = QLatin1String("C"); else if (fn->isDtor()) sortNo = QLatin1String("D"); - else if (nodeName.startsWith(QLatin1String("operator")) && nodeName.length() > 8 + else if (nodeName.startsWith(QLatin1String("operator")) && nodeName.size() > 8 && !nodeName[8].isLetterOrNumber()) sortNo = QLatin1String("F"); else @@ -552,7 +552,7 @@ void Sections::stdRefPageSwitch(SectionVector &v, Node *n, Node *t) return; case Node::SharedComment: { auto *scn = static_cast<SharedCommentNode *>(t); - if (!scn->doc().isEmpty() && scn->collective().count()) + if (!scn->doc().isEmpty() && scn->collective().size()) stdRefPageSwitch( v, scn, scn->collective().first()); // TODO: warn about mixed node types in collective? @@ -717,7 +717,7 @@ void Sections::distributeNodeInDetailsVector(SectionVector &dv, Node *n) if (n->isSharedCommentNode() && n->hasDoc()) { auto *scn = static_cast<SharedCommentNode *>(n); - if (scn->collective().count()) + if (scn->collective().size()) t = scn->collective().first(); // TODO: warn about mixed node types in collective? } @@ -766,7 +766,7 @@ void Sections::distributeQmlNodeInDetailsVector(SectionVector &dv, Node *n) return; } auto *scn = static_cast<SharedCommentNode *>(n); - if (scn->collective().count()) + if (scn->collective().size()) t = scn->collective().first(); // TODO: warn about mixed node types in collective? } diff --git a/src/qdoc/tokenizer.cpp b/src/qdoc/tokenizer.cpp index 34aac5c6e..ea9060f97 100644 --- a/src/qdoc/tokenizer.cpp +++ b/src/qdoc/tokenizer.cpp @@ -466,7 +466,7 @@ int Tokenizer::getToken() } } - if (m_preprocessorSkipping.count() > 1) { + if (m_preprocessorSkipping.size() > 1) { m_tokLoc.warning(QStringLiteral("Expected #endif before end of file")); // clear it out or we get an infinite loop! while (!m_preprocessorSkipping.isEmpty()) { @@ -733,7 +733,7 @@ bool Tokenizer::isTrue(const QString &condition) X && Y || Z // the or (X || Y) && Z // the and */ - for (int i = 0; i < condition.length() - 1; i++) { + for (int i = 0; i < condition.size() - 1; i++) { QChar ch = condition[i]; if (ch == QChar('(')) { parenDepth++; @@ -763,7 +763,7 @@ bool Tokenizer::isTrue(const QString &condition) if (t[0] == QChar('!')) return !isTrue(t.mid(1)); if (t[0] == QChar('(') && t.endsWith(QChar(')'))) - return isTrue(t.mid(1, t.length() - 2)); + return isTrue(t.mid(1, t.size() - 2)); auto match = definedX->match(t); if (match.hasMatch()) |