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

@@ -25,7 +25,6 @@
#include "LookupContext.h"
#include "ResolveExpression.h"
#include "Overview.h"
#include "DeprecatedGenTemplateInstance.h"
#include "CppRewriter.h"
@@ -38,7 +37,6 @@
#include <cplusplus/Control.h>
#include <utils/algorithm.h>
#include <utils/porting.h>
#include <QStack>
#include <QHash>

View File

@@ -26,7 +26,6 @@
#pragma once
#include <cplusplus/FullySpecifiedType.h>
#include <utils/porting.h>
#include <QHash>

View File

@@ -38,7 +38,6 @@
#include "qmt/infrastructure/qmtassert.h"
#include <utils/algorithm.h>
#include <utils/porting.h>
#include <QSet>

View File

@@ -27,8 +27,6 @@
#include "qmt/diagram/dobject.h"
#include <utils/porting.h>
#include <QColor>
namespace qmt {

View File

@@ -27,7 +27,6 @@
#include "qmldebugclient.h"
#include "qpacketprotocol.h"
#include <utils/porting.h>
#include <utils/temporaryfile.h>
#include <QLocalServer>

View File

@@ -27,8 +27,6 @@
#include "qmleditorwidgets_global.h"
#include <utils/porting.h>
#include <QFrame>
QT_BEGIN_NAMESPACE

View File

@@ -25,8 +25,6 @@
#include "qmljscodeformatter.h"
#include <utils/porting.h>
#include <QLoggingCategory>
#include <QMetaEnum>
#include <QTextBlock>
@@ -229,7 +227,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
break;
case property_list_open: {
const QStringView tok = Utils::midView(m_currentLine,
const QStringView tok = QStringView(m_currentLine).mid(
m_currentToken.begin(),
m_currentToken.length);
if (tok == QLatin1String(">"))
@@ -876,7 +874,7 @@ int CodeFormatter::column(int index) const
QStringView CodeFormatter::currentTokenText() const
{
return Utils::midView(m_currentLine, m_currentToken.begin(), m_currentToken.length);
return QStringView(m_currentLine).mid(m_currentToken.begin(), m_currentToken.length);
}
void CodeFormatter::turnInto(int newState)
@@ -950,7 +948,7 @@ int CodeFormatter::tokenizeBlock(const QTextBlock &block)
CodeFormatter::TokenKind CodeFormatter::extendedTokenKind(const QmlJS::Token &token) const
{
const int kind = token.kind;
const QStringView text = Utils::midView(m_currentLine, token.begin(), token.length);
const QStringView text = QStringView(m_currentLine).mid(token.begin(), token.length);
if (kind == Identifier) {
if (text == QLatin1String("as"))

View File

@@ -26,8 +26,6 @@
#include "qmljscompletioncontextfinder.h"
#include "qmljsscanner.h"
#include <utils/porting.h>
#include <QTextDocument>
#include <QStringList>
@@ -163,7 +161,7 @@ void CompletionContextFinder::checkBinding()
break;
case Token::Identifier: {
const QStringView tokenString = Utils::midView(*yyLine, token.begin(), token.length);
const QStringView tokenString = QStringView(*yyLine).mid(token.begin(), token.length);
dotExpected = false;
if (identifierExpected) {
m_bindingPropertyName.prepend(tokenString.toString());
@@ -233,7 +231,7 @@ void CompletionContextFinder::checkImport()
switch (token.kind) {
case Token::Identifier: {
const QStringView tokenString = Utils::midView(*yyLine, token.begin(), token.length);
const QStringView tokenString = QStringView(*yyLine).mid(token.begin(), token.length);
if (tokenString == QLatin1String("as")) {
isInLibVersionImport = 0;
if (state == Unknown) {

View File

@@ -27,8 +27,7 @@
#include "qmljs_global.h"
#include <utils/fileutils.h>
#include <utils/porting.h>
#include <utils/filepath.h>
#include <QDebug>
#include <QString>

View File

@@ -29,7 +29,6 @@
#include "qmljsdialect.h"
#include <languageutils/componentversion.h>
#include <utils/porting.h>
#include <QObject>
#include <QString>

View File

@@ -31,7 +31,6 @@
#include <qmljs/parser/qmljsastfwd_p.h>
#include <languageutils/fakemetaobject.h>
#include <utils/porting.h>
#include <QFileInfoList>
#include <QHash>

View File

@@ -64,8 +64,6 @@
#include <qmljs/qmljslineinfo.h>
#include <qmljs/qmljsscanner.h>
#include <utils/porting.h>
using namespace QmlJS;
/*
@@ -281,7 +279,7 @@ Token LineInfo::lastToken() const
QStringView LineInfo::tokenText(const Token &token) const
{
return Utils::midView(yyLinizerState.line, token.offset, token.length);
return QStringView(yyLinizerState.line).mid(token.offset, token.length);
}
/*

View File

@@ -34,7 +34,6 @@
#include <utils/algorithm.h>
#include <utils/filepath.h>
#include <utils/porting.h>
#include <utils/qrcparser.h>
#include <QDir>

View File

@@ -31,6 +31,7 @@
#include <QObject>
#include <QSet>
#include <QVariant>
#include <functional>

View File

@@ -264,10 +264,9 @@ MimeMagicRule::MimeMagicRule(const QString &type,
// Parse for offset as "1" or "1:10"
const int colonIndex = offsets.indexOf(QLatin1Char(':'));
const QStringView startPosStr
= Utils::midView(offsets, 0, colonIndex); // \ These decay to returning 'offsets'
const QStringView endPosStr = Utils::midView(offsets,
colonIndex
+ 1); // / unchanged when colonIndex == -1
= QStringView(offsets).mid(0, colonIndex); // \ These decay to returning 'offsets'
const QStringView endPosStr = QStringView(offsets)
.mid(colonIndex + 1); // / unchanged when colonIndex == -1
if (Q_UNLIKELY(!MimeTypeParserBase::parseNumber(startPosStr, &m_startPos, errorString)) ||
Q_UNLIKELY(!MimeTypeParserBase::parseNumber(endPosStr, &m_endPos, errorString))) {
m_type = Invalid;

View File

@@ -42,10 +42,11 @@
#include "mimedatabase.h"
#include "mimedatabase_p.h"
#include "mimemagicrule_p.h"
#include "mimeprovider_p.h"
#include "filepath.h"
#include <QUrl>
namespace Utils {
MimeType mimeTypeForName(const QString &nameOrAlias)

View File

@@ -27,9 +27,6 @@
#include "utils_global.h"
#ifdef QT_GUI_LIB
#include <QEnterEvent>
#endif
#include <QString>
namespace Utils {

View File

@@ -27,8 +27,6 @@
#include <debugger/analyzer/diagnosticlocation.h>
#include <utils/porting.h>
#include <QMetaType>
#include <QString>
#include <QVector>

View File

@@ -25,8 +25,6 @@
#pragma once
#include <utils/porting.h>
#include <QMetaType>
#include <QString>

View File

@@ -25,8 +25,6 @@
#pragma once
#include <utils/porting.h>
#include <QMetaType>
#include <QString>

View File

@@ -28,7 +28,6 @@
#include "cmake_global.h"
#include <utils/optional.h>
#include <utils/porting.h>
#include <QByteArray>
#include <QStringList>

View File

@@ -26,7 +26,6 @@
#pragma once
#include <utils/infobar.h>
#include <utils/porting.h>
#include <QIcon>
#include <QWidget>

View File

@@ -32,7 +32,6 @@
#include "locator/locatormanager.h"
#include <utils/algorithm.h>
#include <utils/porting.h>
#include <utils/qtcassert.h>
#include <utils/stringutils.h>

View File

@@ -25,7 +25,6 @@
#include "pastebindotcomprotocol.h"
#include <utils/porting.h>
#include <utils/qtcassert.h>
#include <QDebug>

View File

@@ -26,7 +26,6 @@
#pragma once
#include <utils/fileutils.h>
#include <utils/porting.h>
namespace Cppcheck {
namespace Internal {

View File

@@ -34,8 +34,6 @@
#include <cplusplus/SimpleLexer.h>
#include <cplusplus/Lexer.h>
#include <utils/porting.h>
#include <QTextDocument>
using namespace CppEditor;
@@ -160,9 +158,9 @@ void CppHighlighter::highlightBlock(const QString &text)
formatForCategory(C_PREPROCESSOR));
expectPreprocessorKeyword = true;
} else if (highlightCurrentWordAsPreprocessor && (tk.isKeyword() || tk.is(T_IDENTIFIER))
&& isPPKeyword(Utils::midView(text, tk.utf16charsBegin(), tk.utf16chars()))) {
&& isPPKeyword(QStringView(text).mid(tk.utf16charsBegin(), tk.utf16chars()))) {
setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_PREPROCESSOR));
const QStringView ppKeyword = Utils::midView(text, tk.utf16charsBegin(), tk.utf16chars());
const QStringView ppKeyword = QStringView(text).mid(tk.utf16charsBegin(), tk.utf16chars());
if (ppKeyword == QLatin1String("error")
|| ppKeyword == QLatin1String("warning")
|| ppKeyword == QLatin1String("pragma")) {
@@ -221,7 +219,7 @@ void CppHighlighter::highlightBlock(const QString &text)
} else if (i == 0 && tokens.size() > 1 && tk.is(T_IDENTIFIER) && tokens.at(1).is(T_COLON)) {
setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_LABEL));
} else if (tk.is(T_IDENTIFIER)) {
highlightWord(Utils::midView(text, tk.utf16charsBegin(), tk.utf16chars()),
highlightWord(QStringView(text).mid(tk.utf16charsBegin(), tk.utf16chars()),
tk.utf16charsBegin(),
tk.utf16chars());
}

View File

@@ -50,7 +50,6 @@
#include <cplusplus/Overview.h>
#include <cplusplus/SimpleLexer.h>
#include <utils/algorithm.h>
#include <utils/porting.h>
#include <utils/textutils.h>
#include <utils/qtcassert.h>
@@ -321,7 +320,7 @@ bool isInCommentOrString(const TextEditor::AssistInterface *interface,
&& tokens.at(1).kind() == T_IDENTIFIER) {
const QString &line = tc.block().text();
const Token &idToken = tokens.at(1);
QStringView identifier = Utils::midView(line, idToken.utf16charsBegin(),
QStringView identifier = QStringView(line).mid(idToken.utf16charsBegin(),
idToken.utf16chars());
if (identifier == QLatin1String("include")
|| identifier == QLatin1String("include_next")

View File

@@ -1010,7 +1010,7 @@ void CdbEngine::runCommand(const DebuggerCommand &dbgCmd)
QList<QStringView> splittedArguments;
int maxArgumentSize = maxCommandLength - prefix.length() - maxTokenLength;
while (argumentSplitPos < arguments.size()) {
splittedArguments << midView(arguments, argumentSplitPos, maxArgumentSize);
splittedArguments << QStringView(arguments).mid(argumentSplitPos, maxArgumentSize);
argumentSplitPos += splittedArguments.last().length();
}
QTC_CHECK(argumentSplitPos == arguments.size());

View File

@@ -49,7 +49,6 @@
#include <texteditor/textdocument.h>
#include <utils/algorithm.h>
#include <utils/porting.h>
#include <utils/qtcassert.h>
#include <utils/tooltip/tooltip.h>
#include <utils/stringutils.h>

View File

@@ -27,7 +27,6 @@
#include <utils/algorithm.h>
#include <utils/differ.h>
#include <utils/porting.h>
#include <QFutureInterfaceBase>
#include <QRegularExpression>

View File

@@ -45,7 +45,6 @@
#include <coreplugin/find/highlightscrollbarcontroller.h>
#include <coreplugin/minisplitter.h>
#include <utils/porting.h>
#include <utils/tooltip/tooltip.h>
using namespace Core;

View File

@@ -31,8 +31,6 @@
#include <texteditor/textdocumentlayout.h>
#include <texteditor/textdocument.h>
#include <utils/porting.h>
#include <QDebug>
using namespace TextEditor;
@@ -155,7 +153,7 @@ void GlslHighlighter::highlightBlock(const QString &text)
highlightAsPreprocessor = true;
} else if (highlightCurrentWordAsPreprocessor
&& isPPKeyword(Utils::midView(text, tk.begin(), tk.length))) {
&& isPPKeyword(QStringView(text).mid(tk.begin(), tk.length))) {
setFormat(tk.begin(), tk.length, formatForCategory(C_PREPROCESSOR));
} else if (tk.is(GLSL::Parser::T_NUMBER)) {

View File

@@ -25,13 +25,12 @@
#pragma once
#include <utils/porting.h>
#include <utils/filepath.h>
#include <QSettings>
#include <QSharedPointer>
#include <QString>
#include <QStringList>
#include <utils/fileutils.h>
namespace Ios {

View File

@@ -25,8 +25,6 @@
#pragma once
#include <utils/porting.h>
#include <QWidget>
#include <QIcon>

View File

@@ -44,7 +44,6 @@
#include <projectexplorer/projectnodes.h>
#include <utils/mimeutils.h>
#include <utils/porting.h>
#include <utils/qtcassert.h>
#include <QQueue>

View File

@@ -25,8 +25,6 @@
#pragma once
#include <utils/porting.h>
#include <QObject>
namespace qmt { class Uid; }

View File

@@ -29,7 +29,6 @@
#include <utils/environment.h>
#include <utils/filepath.h>
#include <utils/porting.h>
#include <QList>

View File

@@ -27,8 +27,7 @@
#include "projectexplorer_export.h"
#include <utils/fileutils.h>
#include <utils/porting.h>
#include <utils/filepath.h>
#include <QString>

View File

@@ -25,8 +25,6 @@
#pragma once
#include <utils/porting.h>
#include <QString>
#include <QHash>
#include <QDebug>

View File

@@ -29,7 +29,6 @@
#include <utils/id.h>
#include <utils/fileutils.h>
#include <utils/porting.h>
#include <QIcon>
#include <QMetaType>

View File

@@ -30,6 +30,7 @@
#include <QFutureWatcher>
#include <QTimer>
#include <QUrl>
namespace Python {
namespace Internal {

View File

@@ -31,7 +31,6 @@
#include <coreplugin/idocument.h>
#include <cppeditor/generatedcodemodelsupport.h>
#include <utils/porting.h>
#include <utils/textfileformat.h>
#include <QFutureWatcher>

View File

@@ -25,8 +25,6 @@
#pragma once
#include <utils/porting.h>
#include <QString>
#include <QStringList>
#include <QMetaType>

View File

@@ -29,6 +29,7 @@
#include <documentmessage.h>
#include <QMimeData>
#include <QObject>
#include <QPair>

View File

@@ -38,8 +38,6 @@
#include "internalnodeproperty.h"
#include "internalnodeabstractproperty.h"
#include <utils/porting.h>
namespace QmlDesigner {
namespace Internal {

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;

View File

@@ -25,8 +25,6 @@
#pragma once
#include <utils/porting.h>
#include <QFrame>
#include <QPen>

View File

@@ -41,7 +41,6 @@
#include <utils/elidinglabel.h>
#include <utils/link.h>
#include <utils/multitextcursor.h>
#include <utils/porting.h>
#include <utils/uncommentselection.h>
#include <QPlainTextEdit>

View File

@@ -45,7 +45,6 @@
#include <texteditor/textdocument.h>
#include <texteditor/textdocumentlayout.h>
#include <utils/algorithm.h>
#include <utils/porting.h>
#include <utils/progressindicator.h>
#include <utils/qtcassert.h>
#include <utils/shellcommand.h>

View File

@@ -46,7 +46,6 @@
#include <utils/fileutils.h>
#include <utils/hostosinfo.h>
#include <utils/icon.h>
#include <utils/porting.h>
#include <utils/qtcassert.h>
#include <utils/styledbar.h>
#include <utils/theme/theme.h>

View File

@@ -27,7 +27,6 @@
#include "qmake_global.h"
#include "proitems.h"
#include <utils/porting.h>
#ifdef QT_BUILD_QMAKE
# include <property.h>

View File

@@ -47,8 +47,6 @@
#include <unistd.h>
#include <sys/prctl.h>
#include <utils/porting.h>
// Enable compilation with older header that doesn't contain this constant
// for running on newer libraries that do support it
#ifndef PR_SET_PTRACER

View File

@@ -25,7 +25,6 @@
#include <utils/algorithm.h>
#include <utils/mapreduce.h>
#include <utils/porting.h>
#include <QThreadPool>
#include <QtTest>

View File

@@ -30,7 +30,6 @@
#include <utils/environment.h>
#include <utils/hostosinfo.h>
#include <utils/launcherinterface.h>
#include <utils/porting.h>
#include <utils/processinfo.h>
#include <utils/processinterface.h>
#include <utils/qtcassert.h>