Make QmlJS(Tools) build with Qt5 & Qt6

Port from QStringRef to QStringView

Change-Id: I472d16f20e40ca52b8e5d481850a6bd8a1a38f3b
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2020-09-16 15:08:57 +02:00
parent 5ad724c61b
commit cf2a651c3b
37 changed files with 442 additions and 321 deletions

View File

@@ -27,6 +27,8 @@
#include <qmljs/qmljsscanner.h>
#include <utils/porting.h>
#include <QChar>
#include <QLatin1Char>
#include <QTextDocument>
@@ -119,7 +121,7 @@ static bool shouldInsertNewline(const QTextCursor &tc)
return false;
}
static bool isCompleteStringLiteral(const QStringRef &text)
static bool isCompleteStringLiteral(const QStringView &text)
{
if (text.length() < 2)
return false;
@@ -173,7 +175,7 @@ bool AutoCompleter::contextAllowsAutoBrackets(const QTextCursor &cursor,
case Token::String: {
const QString blockText = cursor.block().text();
const QStringRef tokenText = blockText.midRef(token.offset, token.length);
const QStringView tokenText = Utils::midView(blockText, token.offset, token.length);
QChar quote = tokenText.at(0);
// if a string literal doesn't start with a quote, it must be multiline
if (quote != QLatin1Char('"') && quote != QLatin1Char('\'')) {
@@ -217,7 +219,7 @@ bool AutoCompleter::contextAllowsAutoQuotes(const QTextCursor &cursor,
case Token::String: {
const QString blockText = cursor.block().text();
const QStringRef tokenText = blockText.midRef(token.offset, token.length);
const QStringView tokenText = Utils::midView(blockText, token.offset, token.length);
QChar quote = tokenText.at(0);
// if a string literal doesn't start with a quote, it must be multiline
if (quote != QLatin1Char('"') && quote != QLatin1Char('\'')) {