Utils: More porting.h related changes

Change-Id: I528a6950dfa6e09eb7f7ada265c8c41dba816bfd
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2022-07-13 10:06:41 +02:00
parent 06023df8be
commit d842862944
55 changed files with 31 additions and 100 deletions

View File

@@ -27,10 +27,6 @@
#include <qmljs/qmljsscanner.h>
#include <utils/porting.h>
#include <QChar>
#include <QLatin1Char>
#include <QTextDocument>
#include <QTextCursor>
#include <QTextBlock>
@@ -175,7 +171,7 @@ bool AutoCompleter::contextAllowsAutoBrackets(const QTextCursor &cursor,
case Token::String: {
const QString blockText = cursor.block().text();
const QStringView tokenText = Utils::midView(blockText, token.offset, token.length);
const QStringView tokenText = QStringView(blockText).mid(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('\'')) {
@@ -219,7 +215,7 @@ bool AutoCompleter::contextAllowsAutoQuotes(const QTextCursor &cursor,
case Token::String: {
const QString blockText = cursor.block().text();
const QStringView tokenText = Utils::midView(blockText, token.offset, token.length);
const QStringView tokenText = QStringView(blockText).mid(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('\'')) {

View File

@@ -27,7 +27,6 @@
#include <QSet>
#include <utils/porting.h>
#include <utils/qtcassert.h>
using namespace QmlJS;
@@ -77,7 +76,7 @@ void QmlJSHighlighter::highlightBlock(const QString &text)
case Token::Comment:
if (m_inMultilineComment
&& Utils::midView(text, token.end() - 2, 2) == QLatin1String("*/")) {
&& QStringView(text).mid(token.end() - 2, 2) == QLatin1String("*/")) {
onClosingParenthesis(QLatin1Char('-'), token.end() - 1, index == tokens.size()-1);
m_inMultilineComment = false;
} else if (!m_inMultilineComment
@@ -121,7 +120,7 @@ void QmlJSHighlighter::highlightBlock(const QString &text)
if (!m_qmlEnabled)
break;
const QStringView spell = Utils::midView(text, token.offset, token.length);
const QStringView spell = QStringView(text).mid(token.offset, token.length);
if (maybeQmlKeyword(spell)) {
// check the previous token
@@ -131,7 +130,7 @@ void QmlJSHighlighter::highlightBlock(const QString &text)
break;
}
}
if (Utils::midView(text, token.offset, token.length) == QLatin1String("enum")) {
if (QStringView(text).mid(token.offset, token.length) == QLatin1String("enum")) {
setFormat(token.offset, token.length, formatForCategory(C_KEYWORD));
break;
}
@@ -139,7 +138,7 @@ void QmlJSHighlighter::highlightBlock(const QString &text)
const Token &previousToken = tokens.at(index - 1);
if (previousToken.is(Token::Identifier)
&& text.at(previousToken.offset) == QLatin1Char('p')
&& Utils::midView(text, previousToken.offset, previousToken.length)
&& QStringView(text).mid(previousToken.offset, previousToken.length)
== QLatin1String("property")) {
setFormat(token.offset, token.length, formatForCategory(C_KEYWORD));
break;
@@ -148,7 +147,7 @@ void QmlJSHighlighter::highlightBlock(const QString &text)
const Token &previousToken = tokens.at(0);
if (previousToken.is(Token::Identifier)
&& text.at(previousToken.offset) == QLatin1Char('e')
&& Utils::midView(text, previousToken.offset, previousToken.length)
&& QStringView(text).mid(previousToken.offset, previousToken.length)
== QLatin1String("enum")) {
setFormat(token.offset, token.length, formatForCategory(C_ENUMERATION));
break;