summaryrefslogtreecommitdiffstats
path: root/src/linguist/lupdate/qdeclarative.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-10-05 08:17:22 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-10-06 18:20:17 +0200
commitc338447261878111df7198fbd96051926464e865 (patch)
treed21b5af1efae225f75d5c05dfe370daefb1ea1d1 /src/linguist/lupdate/qdeclarative.cpp
parent6495329e6de803025e6e4e8291b648f94893551c (diff)
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/linguist/lupdate/qdeclarative.cpp')
-rw-r--r--src/linguist/lupdate/qdeclarative.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/linguist/lupdate/qdeclarative.cpp b/src/linguist/lupdate/qdeclarative.cpp
index f787f004b..a99f7dff6 100644
--- a/src/linguist/lupdate/qdeclarative.cpp
+++ b/src/linguist/lupdate/qdeclarative.cpp
@@ -263,7 +263,7 @@ QString createErrorString(const QString &filename, const QString &code, Parser &
const QString textLine = lines.at(line > 0 ? line - 1 : 0);
error += textLine + QLatin1Char('\n');
- for (int i = 0, end = qMin(column > 0 ? column - 1 : 0, textLine.length()); i < end; ++i) {
+ for (int i = 0, end = qMin(column > 0 ? column - 1 : 0, textLine.size()); i < end; ++i) {
const QChar ch = textLine.at(i);
if (ch.isSpace())
error += ch;
@@ -315,7 +315,7 @@ void FindTrCalls::processComment(const SourceLocation &loc)
const QStringView commentStr = engine->midRef(loc.begin(), loc.length);
const QChar *chars = commentStr.constData();
- const int length = commentStr.length();
+ const int length = commentStr.size();
// Try to match the logic of the C++ parser.
if (*chars == QLatin1Char(':') && chars[1].isSpace()) {
@@ -330,8 +330,8 @@ void FindTrCalls::processComment(const SourceLocation &loc)
if (k > -1)
extra.insert(text.left(k), text.mid(k + 1).trimmed());
} else if (*chars == QLatin1Char('%') && chars[1].isSpace()) {
- sourcetext.reserve(sourcetext.length() + length-2);
- ushort *ptr = (ushort *)sourcetext.data() + sourcetext.length();
+ sourcetext.reserve(sourcetext.size() + length-2);
+ ushort *ptr = (ushort *)sourcetext.data() + sourcetext.size();
int p = 2, c;
forever {
if (p >= length)
@@ -369,8 +369,8 @@ void FindTrCalls::processComment(const SourceLocation &loc)
ushort c;
while ((c = chars[idx].unicode()) == ' ' || c == '\t' || c == '\r' || c == '\n')
++idx;
- if (!memcmp(chars + idx, MagicComment.unicode(), MagicComment.length() * 2)) {
- idx += MagicComment.length();
+ if (!memcmp(chars + idx, MagicComment.unicode(), MagicComment.size() * 2)) {
+ idx += MagicComment.size();
QString comment = QString(chars + idx, length - idx).simplified();
int k = comment.indexOf(QLatin1Char(' '));
if (k == -1) {