aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIvan Komissarov <abbapoh@gmail.com>2020-11-01 15:57:44 +0100
committerIvan Komissarov <ABBAPOH@gmail.com>2020-11-09 10:25:00 +0000
commit8644a096bba1cef9a0dad75938f362d3ea367a89 (patch)
treee9b566143ee12464ecd63a4c1b4624db9379f99d /src
parentc1574c112d1a406d7c46c8ab1f459b6288bcc74e (diff)
qt6: replace some QStringRefs with QStringViews
QStringRef does not exist anymore. Qml parser is not ported yet. Change-Id: Ifb99a529b69c0085363031e852ffd7576f1d93be Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/app/qbs-setup-toolchains/keilprobe.cpp4
-rw-r--r--src/lib/corelib/buildgraph/filedependency.h4
-rw-r--r--src/lib/corelib/language/astpropertiesitemhandler.cpp2
-rw-r--r--src/lib/corelib/language/asttools.cpp4
-rw-r--r--src/lib/corelib/language/asttools.h2
-rw-r--r--src/lib/corelib/language/item.cpp4
-rw-r--r--src/lib/corelib/language/itemreaderastvisitor.cpp2
-rw-r--r--src/lib/corelib/language/projectresolver.h4
-rw-r--r--src/lib/corelib/language/scriptimporter.cpp9
-rw-r--r--src/lib/corelib/language/value.h6
-rw-r--r--src/lib/corelib/tools/fileinfo.cpp17
-rw-r--r--src/lib/corelib/tools/fileinfo.h5
12 files changed, 29 insertions, 34 deletions
diff --git a/src/app/qbs-setup-toolchains/keilprobe.cpp b/src/app/qbs-setup-toolchains/keilprobe.cpp
index ee0144c77..b62da0f8f 100644
--- a/src/app/qbs-setup-toolchains/keilprobe.cpp
+++ b/src/app/qbs-setup-toolchains/keilprobe.cpp
@@ -356,8 +356,8 @@ static QString extractVersion(const QString &toolsIniFile, const QString &sectio
switch (state) {
case Enter: {
if (hasSection) {
- const auto content = line.midRef(firstBracket + 1,
- lastBracket - firstBracket - 1);
+ const auto content = QStringView(line).mid(firstBracket + 1,
+ lastBracket - firstBracket - 1);
if (content == section)
state = Lookup;
}
diff --git a/src/lib/corelib/buildgraph/filedependency.h b/src/lib/corelib/buildgraph/filedependency.h
index 802654e9f..93bfc5d05 100644
--- a/src/lib/corelib/buildgraph/filedependency.h
+++ b/src/lib/corelib/buildgraph/filedependency.h
@@ -77,8 +77,8 @@ private:
FileTime m_timestamp;
QString m_filePath;
- QStringRef m_dirPath;
- QStringRef m_fileName;
+ QStringView m_dirPath;
+ QStringView m_fileName;
};
class FileDependency : public FileResourceBase
diff --git a/src/lib/corelib/language/astpropertiesitemhandler.cpp b/src/lib/corelib/language/astpropertiesitemhandler.cpp
index 1ea78bf79..b28fe7d76 100644
--- a/src/lib/corelib/language/astpropertiesitemhandler.cpp
+++ b/src/lib/corelib/language/astpropertiesitemhandler.cpp
@@ -139,7 +139,7 @@ private:
value = JSSourceValue::create(true);
value->setFile(conditionalValue->file());
item->setProperty(propertyName, value);
- value->setSourceCode(QStringRef(&StringConstants::baseVar()));
+ value->setSourceCode(StringConstants::baseVar());
value->setSourceUsesBaseFlag();
}
m_alternative.value = conditionalValue;
diff --git a/src/lib/corelib/language/asttools.cpp b/src/lib/corelib/language/asttools.cpp
index 1b6abac7f..0d0c234c4 100644
--- a/src/lib/corelib/language/asttools.cpp
+++ b/src/lib/corelib/language/asttools.cpp
@@ -64,10 +64,10 @@ QString textOf(const QString &source, QbsQmlJS::AST::Node *node)
int(node->lastSourceLocation().end() - node->firstSourceLocation().begin()));
}
-QStringRef textRefOf(const QString &source, QbsQmlJS::AST::Node *node)
+QStringView textViewOf(const QString &source, QbsQmlJS::AST::Node *node)
{
const quint32 firstBegin = node->firstSourceLocation().begin();
- return source.midRef(firstBegin, int(node->lastSourceLocation().end() - firstBegin));
+ return QStringView(source).mid(firstBegin, int(node->lastSourceLocation().end() - firstBegin));
}
} // namespace Internal
diff --git a/src/lib/corelib/language/asttools.h b/src/lib/corelib/language/asttools.h
index b4f5c4d98..086d59290 100644
--- a/src/lib/corelib/language/asttools.h
+++ b/src/lib/corelib/language/asttools.h
@@ -50,7 +50,7 @@ namespace Internal {
QStringList toStringList(QbsQmlJS::AST::UiQualifiedId *qid);
CodeLocation toCodeLocation(const QString &filePath, const QbsQmlJS::AST::SourceLocation &location);
QString textOf(const QString &source, QbsQmlJS::AST::Node *node);
-QStringRef textRefOf(const QString &source, QbsQmlJS::AST::Node *node);
+QStringView textViewOf(const QString &source, QbsQmlJS::AST::Node *node);
} // namespace Internal
} // namespace qbs
diff --git a/src/lib/corelib/language/item.cpp b/src/lib/corelib/language/item.cpp
index a86cfeac1..fa33a264d 100644
--- a/src/lib/corelib/language/item.cpp
+++ b/src/lib/corelib/language/item.cpp
@@ -260,8 +260,8 @@ void Item::setupForBuiltinType(Logger &logger)
sourceValue->setIsBuiltinDefaultValue();
sourceValue->setFile(file());
sourceValue->setSourceCode(pd.initialValueSource().isEmpty()
- ? QStringRef(&StringConstants::undefinedValue())
- : QStringRef(&pd.initialValueSource()));
+ ? StringConstants::undefinedValue()
+ : pd.initialValueSource());
m_properties.insert(pd.name(), sourceValue);
} else if (pd.isDeprecated()) {
const DeprecationInfo &di = pd.deprecationInfo();
diff --git a/src/lib/corelib/language/itemreaderastvisitor.cpp b/src/lib/corelib/language/itemreaderastvisitor.cpp
index 901772d16..f22a1c4e8 100644
--- a/src/lib/corelib/language/itemreaderastvisitor.cpp
+++ b/src/lib/corelib/language/itemreaderastvisitor.cpp
@@ -271,7 +271,7 @@ bool ItemReaderASTVisitor::handleBindingRhs(AST::Statement *statement,
value->m_flags |= JSSourceValue::HasFunctionForm;
value->setFile(m_file);
- value->setSourceCode(textRefOf(m_file->content(), statement));
+ value->setSourceCode(textViewOf(m_file->content(), statement));
value->setLocation(statement->firstSourceLocation().startLine,
statement->firstSourceLocation().startColumn);
diff --git a/src/lib/corelib/language/projectresolver.h b/src/lib/corelib/language/projectresolver.h
index 73f3442ac..52d835535 100644
--- a/src/lib/corelib/language/projectresolver.h
+++ b/src/lib/corelib/language/projectresolver.h
@@ -186,8 +186,8 @@ private:
QHash<ResolvedProductPtr, Item *> m_productItemMap;
mutable QHash<FileContextConstPtr, ResolvedFileContextPtr> m_fileContextMap;
mutable QHash<CodeLocation, ScriptFunctionPtr> m_scriptFunctionMap;
- mutable QHash<std::pair<QStringRef, QStringList>, QString> m_scriptFunctions;
- mutable QHash<QStringRef, QString> m_sourceCode;
+ mutable QHash<std::pair<QStringView, QStringList>, QString> m_scriptFunctions;
+ mutable QHash<QStringView, QString> m_sourceCode;
const SetupProjectParameters m_setupParams;
ModuleLoaderResult m_loadResult;
Set<CodeLocation> m_groupLocationWarnings;
diff --git a/src/lib/corelib/language/scriptimporter.cpp b/src/lib/corelib/language/scriptimporter.cpp
index 9c6d4d38e..40162eb12 100644
--- a/src/lib/corelib/language/scriptimporter.cpp
+++ b/src/lib/corelib/language/scriptimporter.cpp
@@ -95,7 +95,7 @@ private:
return false;
}
- void add(const QStringRef &name)
+ void add(QStringView name)
{
if (m_first) {
m_first = false;
@@ -104,9 +104,10 @@ private:
m_suffix.reserve(m_suffix.length() + name.length() * 2 + 2);
m_suffix += QLatin1Char(',');
}
- m_suffix += name;
- m_suffix += QLatin1Char(':');
- m_suffix += name;
+ // ugly, but qt5 does not have append overload for QStringView
+ m_suffix.append(name.data(), name.size());
+ m_suffix.append(QLatin1Char(':'));
+ m_suffix.append(name.data(), name.size());
}
bool m_first = false;
diff --git a/src/lib/corelib/language/value.h b/src/lib/corelib/language/value.h
index 287060809..5f6b5ca16 100644
--- a/src/lib/corelib/language/value.h
+++ b/src/lib/corelib/language/value.h
@@ -121,8 +121,8 @@ public:
void apply(ValueHandler *handler) override { handler->handle(this); }
ValuePtr clone() const override;
- void setSourceCode(const QStringRef &sourceCode) { m_sourceCode = sourceCode; }
- const QStringRef &sourceCode() const { return m_sourceCode; }
+ void setSourceCode(QStringView sourceCode) { m_sourceCode = sourceCode; }
+ QStringView sourceCode() const { return m_sourceCode; }
QString sourceCodeForEvaluation() const;
void setLocation(int line, int column);
@@ -179,7 +179,7 @@ public:
void setDefiningItem(Item *item) override;
private:
- QStringRef m_sourceCode;
+ QStringView m_sourceCode;
int m_line;
int m_column;
FileContextPtr m_file;
diff --git a/src/lib/corelib/tools/fileinfo.cpp b/src/lib/corelib/tools/fileinfo.cpp
index 6fdd90fb1..382843a33 100644
--- a/src/lib/corelib/tools/fileinfo.cpp
+++ b/src/lib/corelib/tools/fileinfo.cpp
@@ -133,16 +133,16 @@ void FileInfo::splitIntoDirectoryAndFileName(const QString &filePath, QString *d
*fileName = filePath.mid(idx + 1);
}
-void FileInfo::splitIntoDirectoryAndFileName(const QString &filePath, QStringRef *dirPath, QStringRef *fileName)
+void FileInfo::splitIntoDirectoryAndFileName(const QString &filePath, QStringView *dirPath, QStringView *fileName)
{
int idx = filePath.lastIndexOf(QLatin1Char('/'));
if (idx < 0) {
- dirPath->clear();
- *fileName = QStringRef(&filePath);
+ *dirPath = QStringView();
+ *fileName = QStringView(filePath);
return;
}
- *dirPath = filePath.leftRef(idx);
- *fileName = filePath.midRef(idx + 1);
+ *dirPath = QStringView(filePath).left(idx);
+ *fileName = QStringView(filePath).mid(idx + 1);
}
bool FileInfo::exists(const QString &fp)
@@ -180,12 +180,7 @@ bool FileInfo::isAbsolute(const QString &path, HostOsInfo::HostOs hostOs)
return false;
}
-bool FileInfo::isPattern(const QString &str)
-{
- return isPattern(QStringRef(&str));
-}
-
-bool FileInfo::isPattern(const QStringRef &str)
+bool FileInfo::isPattern(QStringView str)
{
for (const QChar &ch : str) {
if (ch == QLatin1Char('*') || ch == QLatin1Char('?')
diff --git a/src/lib/corelib/tools/fileinfo.h b/src/lib/corelib/tools/fileinfo.h
index c4ca5931a..f0a09a16b 100644
--- a/src/lib/corelib/tools/fileinfo.h
+++ b/src/lib/corelib/tools/fileinfo.h
@@ -72,11 +72,10 @@ public:
static QString completeSuffix(const QString &fp);
static QString path(const QString &fp, HostOsInfo::HostOs hostOs = HostOsInfo::hostOs());
static void splitIntoDirectoryAndFileName(const QString &filePath, QString *dirPath, QString *fileName);
- static void splitIntoDirectoryAndFileName(const QString &filePath, QStringRef *dirPath, QStringRef *fileName);
+ static void splitIntoDirectoryAndFileName(const QString &filePath, QStringView *dirPath, QStringView *fileName);
static bool exists(const QString &fp);
static bool isAbsolute(const QString &fp, HostOsInfo::HostOs hostOs = HostOsInfo::hostOs());
- static bool isPattern(const QStringRef &str);
- static bool isPattern(const QString &str);
+ static bool isPattern(QStringView str);
static QString resolvePath(const QString &base, const QString &rel,
HostOsInfo::HostOs hostOs = HostOsInfo::hostOs());
static bool isFileCaseCorrect(const QString &filePath);