diff options
author | Fawzi Mohamed <fawzi.mohamed@qt.io> | 2021-07-19 14:05:01 +0200 |
---|---|---|
committer | Fawzi Mohamed <fawzi.mohamed@qt.io> | 2021-07-20 08:43:18 +0000 |
commit | dc654cfcba7f1c446ea1bd32e326d3f8c747cf4f (patch) | |
tree | e3c799fdfe9b73c83de6cd9e1f644aa55eddbf34 | |
parent | 42fe70b93ee675b68e184eb09e2edbe94983e25b (diff) | |
download | qt-creator-dc654cfcba7f1c446ea1bd32e326d3f8c747cf4f.tar.gz |
qmljs: use SourceLocation::length in reformatter instead of isValid
isValid becomes more strict in Qt6.2, meaning invalid (default
initialized) SourceLocation.
Reformatter used it to check for absent (i.e. 0 length) tokens, which
might still be valid (according to the new definition) as they mark
the start or end of an AST element.
Thus use length != 0 instead of isValid() in these places.
Change-Id: I4fbc1466ccef6b4b4e2c1d6b5169189b34dc6ae3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | src/libs/qmljs/qmljsreformatter.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/libs/qmljs/qmljsreformatter.cpp b/src/libs/qmljs/qmljsreformatter.cpp index c83ee11a35..6711790cef 100644 --- a/src/libs/qmljs/qmljsreformatter.cpp +++ b/src/libs/qmljs/qmljsreformatter.cpp @@ -210,7 +210,7 @@ protected: if (_hasOpenComment) { newLine(); } - if (lastLoc.isValid()) { + if (lastLoc.length != 0) { QList<SourceLocation> comments = _doc->engine()->comments(); for (; _nextComment < comments.size(); ++_nextComment) { SourceLocation commentLoc = comments.at(_nextComment); @@ -237,7 +237,7 @@ protected: void out(const SourceLocation &loc) { - if (!loc.isValid()) + if (loc.length == 0) return; out(toString(loc), loc); } @@ -489,7 +489,7 @@ protected: else if (UiImport *import = cast<UiImport *>(ast)) firstLoc = import->firstSourceLocation(); - if (firstLoc.isValid() && int(firstLoc.offset) != _lastNewlineOffset) { + if (firstLoc.length != 0 && int(firstLoc.offset) != _lastNewlineOffset) { _lastNewlineOffset = firstLoc.offset; if (precededByEmptyLine(firstLoc) && !_result.endsWith(QLatin1String("\n\n"))) @@ -511,7 +511,7 @@ protected: else if (UiImport *import = cast<UiImport *>(ast)) lastLoc = import->lastSourceLocation(); - if (lastLoc.isValid()) { + if (lastLoc.length != 0) { const QList<SourceLocation> &comments = _doc->engine()->comments(); // preserve trailing comments @@ -566,7 +566,7 @@ protected: { for (UiEnumMemberList *it = list; it; it = it->next) { out(it->memberToken); - if (it->valueToken.isValid()) { + if (it->valueToken.length != 0) { out(" = "); out(it->valueToken); } @@ -1136,7 +1136,7 @@ protected: { out(ast->returnToken); if (ast->expression) { - if (ast->returnToken.isValid()) + if (ast->returnToken.length != 0) out(" "); accept(ast->expression); } @@ -1277,7 +1277,7 @@ protected: out("=> "); out(ast->lbraceToken); if (ast->body) { - if (ast->body->next || ast->lbraceToken.isValid()) { + if (ast->body->next || ast->lbraceToken.length != 0) { lnAcceptIndented(ast->body); newLine(); } else { |