aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/qmljs
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-10-07 14:46:06 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-10-07 13:47:53 +0000
commit8eb4d52342fe3a6ede1c1dce3174d95bfa0cea88 (patch)
tree0f5556c5e4098e75853e3d9ee2620e0306f0cf2a /src/libs/qmljs
parent90de29d530dfc2921d5179977b3393c11a3cc238 (diff)
Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace. Task-number: QTBUG-99313 Change-Id: I88edd91395849574436299b8badda21bb93bea39 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/libs/qmljs')
-rw-r--r--src/libs/qmljs/qmljsimportdependencies.cpp2
-rw-r--r--src/libs/qmljs/qmljsinterpreter.cpp2
-rw-r--r--src/libs/qmljs/qmljslink.cpp4
-rw-r--r--src/libs/qmljs/qmljsmodelmanagerinterface.cpp50
-rw-r--r--src/libs/qmljs/qmljsplugindumper.cpp2
5 files changed, 30 insertions, 30 deletions
diff --git a/src/libs/qmljs/qmljsimportdependencies.cpp b/src/libs/qmljs/qmljsimportdependencies.cpp
index 25b9959d004..db8e7905440 100644
--- a/src/libs/qmljs/qmljsimportdependencies.cpp
+++ b/src/libs/qmljs/qmljsimportdependencies.cpp
@@ -554,7 +554,7 @@ QByteArray DependencyInfo::calculateFingerprint(const ImportDependencies &deps)
hash.addData("/", 1);
QList<ImportKey> imports = Utils::toList(allImports);
std::sort(imports.begin(), imports.end());
- for (const ImportKey &k : qAsConst(imports))
+ for (const ImportKey &k : std::as_const(imports))
k.addToHash(hash);
return hash.result();
}
diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp
index 0c8c5bb6f3a..91dbf8eae81 100644
--- a/src/libs/qmljs/qmljsinterpreter.cpp
+++ b/src/libs/qmljs/qmljsinterpreter.cpp
@@ -2565,7 +2565,7 @@ const ObjectValue *Imports::resolveAliasAndMarkUsed(const QString &name) const
{
if (const ObjectValue *value = m_aliased.value(name, nullptr)) {
// mark all respective ImportInfo objects to avoid dropping imports (QmlDesigner) on rewrite
- for (const Import &i : qAsConst(m_imports)) {
+ for (const Import &i : std::as_const(m_imports)) {
const ImportInfo &info = i.info;
if (info.as() == name)
i.used = true; // FIXME: This evilly modifies a 'const' object
diff --git a/src/libs/qmljs/qmljslink.cpp b/src/libs/qmljs/qmljslink.cpp
index c09eedf7b1f..6c04966cedd 100644
--- a/src/libs/qmljs/qmljslink.cpp
+++ b/src/libs/qmljs/qmljslink.cpp
@@ -212,7 +212,7 @@ Context::ImportsPerDocument LinkPrivate::linkImports()
importsPerDocument.insert(document.data(), QSharedPointer<Imports>(imports));
}
- for (const Document::Ptr &doc : qAsConst(m_snapshot)) {
+ for (const Document::Ptr &doc : std::as_const(m_snapshot)) {
if (doc == document)
continue;
@@ -413,7 +413,7 @@ Import LinkPrivate::importNonFile(const Document::Ptr &doc, const ImportInfo &im
}
if (!importFound) {
- for (const Utils::FilePath &dir : qAsConst(m_applicationDirectories)) {
+ for (const Utils::FilePath &dir : std::as_const(m_applicationDirectories)) {
auto qmltypes = dir.dirEntries(
Utils::FileFilter(QStringList{"*.qmltypes"}, QDir::Files));
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
index bcf5fcb78ab..c39c48415dc 100644
--- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
+++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp
@@ -278,9 +278,9 @@ void ModelManagerInterface::loadQmlTypeDescriptionsInternal(const QString &resou
for (auto it = objs.cbegin(); it != objs.cend(); ++it)
CppQmlTypesLoader::defaultLibraryObjects.insert(it.key(), it.value());
- for (const QString &error : qAsConst(errors))
+ for (const QString &error : std::as_const(errors))
writeMessageInternal(error);
- for (const QString &warning : qAsConst(warnings))
+ for (const QString &warning : std::as_const(warnings))
writeMessageInternal(warning);
}
@@ -462,7 +462,7 @@ void ModelManagerInterface::iterateQrcFiles(
}
QSet<Utils::FilePath> pathsChecked;
- for (const ModelManagerInterface::ProjectInfo &pInfo : qAsConst(pInfos)) {
+ for (const ModelManagerInterface::ProjectInfo &pInfo : std::as_const(pInfos)) {
QList<Utils::FilePath> qrcFilePaths;
if (resources == ActiveQrcResources)
qrcFilePaths = pInfo.activeResourceFiles;
@@ -470,7 +470,7 @@ void ModelManagerInterface::iterateQrcFiles(
qrcFilePaths = pInfo.allResourceFiles;
for (const Utils::FilePath &p : generatedQrc(pInfo.applicationDirectories))
qrcFilePaths.append(p);
- for (const Utils::FilePath &qrcFilePath : qAsConst(qrcFilePaths)) {
+ for (const Utils::FilePath &qrcFilePath : std::as_const(qrcFilePaths)) {
if (pathsChecked.contains(qrcFilePath))
continue;
pathsChecked.insert(qrcFilePath);
@@ -566,19 +566,19 @@ void ModelManagerInterface::updateProjectInfo(const ProjectInfo &pinfo, ProjectE
// remove files that are no longer in the project and have been deleted
QList<Utils::FilePath> deletedFiles;
- for (const Utils::FilePath &oldFile : qAsConst(oldInfo.sourceFiles)) {
+ for (const Utils::FilePath &oldFile : std::as_const(oldInfo.sourceFiles)) {
if (snapshot.document(oldFile) && !pinfo.sourceFiles.contains(oldFile)
&& !oldFile.exists()) {
deletedFiles += oldFile;
}
}
removeFiles(deletedFiles);
- for (const Utils::FilePath &oldFile : qAsConst(deletedFiles))
+ for (const Utils::FilePath &oldFile : std::as_const(deletedFiles))
m_fileToProject.remove(oldFile, p);
// parse any files not yet in the snapshot
QList<Utils::FilePath> newFiles;
- for (const Utils::FilePath &file : qAsConst(pinfo.sourceFiles)) {
+ for (const Utils::FilePath &file : std::as_const(pinfo.sourceFiles)) {
if (!m_fileToProject.contains(file, p))
m_fileToProject.insert(file, p);
if (!snapshot.document(file))
@@ -589,11 +589,11 @@ void ModelManagerInterface::updateProjectInfo(const ProjectInfo &pinfo, ProjectE
// update qrc cache
m_qrcContents = pinfo.resourceFileContents;
- for (const Utils::FilePath &newQrc : qAsConst(pinfo.allResourceFiles))
+ for (const Utils::FilePath &newQrc : std::as_const(pinfo.allResourceFiles))
m_qrcCache.addPath(newQrc.toString(), m_qrcContents.value(newQrc));
for (const Utils::FilePath &newQrc : generatedQrc(pinfo.applicationDirectories))
m_qrcCache.addPath(newQrc.toString(), m_qrcContents.value(newQrc));
- for (const Utils::FilePath &oldQrc : qAsConst(oldInfo.allResourceFiles))
+ for (const Utils::FilePath &oldQrc : std::as_const(oldInfo.allResourceFiles))
m_qrcCache.removePath(oldQrc.toString());
m_pluginDumper->loadBuiltinTypes(pinfo);
@@ -654,7 +654,7 @@ QList<ModelManagerInterface::ProjectInfo> ModelManagerInterface::allProjectInfos
projects = m_fileToProject.values(path.canonicalPath());
}
QList<ProjectInfo> infos;
- for (ProjectExplorer::Project *project : qAsConst(projects)) {
+ for (ProjectExplorer::Project *project : std::as_const(projects)) {
ProjectInfo info = projectInfo(project);
if (!info.project.isNull())
infos.append(info);
@@ -1011,7 +1011,7 @@ void ModelManagerInterface::parseLoop(QSet<Utils::FilePath> &scannedPaths,
}
// add new files to parse list
- for (const Utils::FilePath &file : qAsConst(importedFiles)) {
+ for (const Utils::FilePath &file : std::as_const(importedFiles)) {
if (!files.contains(file))
files.append(file);
}
@@ -1200,7 +1200,7 @@ static QList<Utils::FilePath> minimalPrefixPaths(const QList<Utils::FilePath> &p
{
QList<Utils::FilePath> sortedPaths;
// find minimal prefix, ensure '/' at end
- for (Utils::FilePath path : qAsConst(paths)) {
+ for (Utils::FilePath path : std::as_const(paths)) {
if (!path.endsWith("/"))
path = path.withNewPath(path.path() + "/");
if (path.path().length() > 1)
@@ -1226,7 +1226,7 @@ void ModelManagerInterface::updateImportPaths()
QList<Utils::FilePath> allApplicationDirectories;
QmlLanguageBundles activeBundles;
QmlLanguageBundles extendedBundles;
- for (const ProjectInfo &pInfo : qAsConst(m_projects)) {
+ for (const ProjectInfo &pInfo : std::as_const(m_projects)) {
for (const auto &importPath : pInfo.importPaths) {
const FilePath canonicalPath = importPath.path().canonicalPath();
if (!canonicalPath.isEmpty())
@@ -1235,13 +1235,13 @@ void ModelManagerInterface::updateImportPaths()
allApplicationDirectories.append(pInfo.applicationDirectories);
}
- for (const ViewerContext &vContext : qAsConst(m_defaultVContexts)) {
+ for (const ViewerContext &vContext : std::as_const(m_defaultVContexts)) {
for (const Utils::FilePath &path : vContext.paths)
allImportPaths.maybeInsert(path, vContext.language);
allApplicationDirectories.append(vContext.applicationDirectories);
}
- for (const ProjectInfo &pInfo : qAsConst(m_projects)) {
+ for (const ProjectInfo &pInfo : std::as_const(m_projects)) {
activeBundles.mergeLanguageBundles(pInfo.activeBundle);
const auto languages = pInfo.activeBundle.languages();
for (Dialect l : languages) {
@@ -1254,7 +1254,7 @@ void ModelManagerInterface::updateImportPaths()
}
}
- for (const ProjectInfo &pInfo : qAsConst(m_projects)) {
+ for (const ProjectInfo &pInfo : std::as_const(m_projects)) {
if (!pInfo.qtQmlPath.isEmpty())
allImportPaths.maybeInsert(pInfo.qtQmlPath, Dialect::QmlQtQuick2);
}
@@ -1269,7 +1269,7 @@ void ModelManagerInterface::updateImportPaths()
allImportPaths.maybeInsert(importPath);
}
- for (const Utils::FilePath &path : qAsConst(m_defaultImportPaths))
+ for (const Utils::FilePath &path : std::as_const(m_defaultImportPaths))
allImportPaths.maybeInsert(path, Dialect::Qml);
allImportPaths.compact();
allApplicationDirectories = Utils::filteredUnique(allApplicationDirectories);
@@ -1288,9 +1288,9 @@ void ModelManagerInterface::updateImportPaths()
QList<Utils::FilePath> importedFiles;
QSet<Utils::FilePath> scannedPaths;
QSet<Utils::FilePath> newLibraries;
- for (const Document::Ptr &doc : qAsConst(snapshot))
+ for (const Document::Ptr &doc : std::as_const(snapshot))
findNewLibraryImports(doc, snapshot, this, &importedFiles, &scannedPaths, &newLibraries);
- for (const Utils::FilePath &path : qAsConst(allApplicationDirectories)) {
+ for (const Utils::FilePath &path : std::as_const(allApplicationDirectories)) {
allImportPaths.maybeInsert(path, Dialect::Qml);
findNewQmlApplicationInPath(path, snapshot, this, &newLibraries);
}
@@ -1381,9 +1381,9 @@ bool rescanExports(const QString &fileName, FindExportedCppTypes &finder,
}
if (!hasNewInfo) {
QHash<QString, QByteArray> newFingerprints;
- for (const auto &newType : qAsConst(exported))
+ for (const auto &newType : std::as_const(exported))
newFingerprints[newType->className()]=newType->fingerprint();
- for (const auto &oldType : qAsConst(data.exportedTypes)) {
+ for (const auto &oldType : std::as_const(data.exportedTypes)) {
if (newFingerprints.value(oldType->className()) != oldType->fingerprint()) {
hasNewInfo = true;
break;
@@ -1521,7 +1521,7 @@ ViewerContext ModelManagerInterface::getVContext(const ViewerContext &vCtx,
Q_FALLTHROUGH();
case ViewerContext::AddAllPaths:
{
- for (const Utils::FilePath &path : qAsConst(defaultVCtx.paths))
+ for (const Utils::FilePath &path : std::as_const(defaultVCtx.paths))
maybeAddPath(res, path);
switch (res.language.dialect()) {
case Dialect::AnyLanguage:
@@ -1552,7 +1552,7 @@ ViewerContext ModelManagerInterface::getVContext(const ViewerContext &vCtx,
allProjects = m_projects.values();
}
std::sort(allProjects.begin(), allProjects.end(), &pInfoLessThanImports);
- for (const ProjectInfo &pInfo : qAsConst(allProjects))
+ for (const ProjectInfo &pInfo : std::as_const(allProjects))
addPathsOnLanguageMatch(pInfo.importPaths);
}
const auto environmentPaths = environmentImportPaths();
@@ -1574,7 +1574,7 @@ ViewerContext ModelManagerInterface::getVContext(const ViewerContext &vCtx,
res.selectors.append(defaultVCtx.selectors);
Q_FALLTHROUGH();
case ViewerContext::AddDefaultPaths:
- for (const Utils::FilePath &path : qAsConst(defaultVCtx.paths))
+ for (const Utils::FilePath &path : std::as_const(defaultVCtx.paths))
maybeAddPath(res, path);
if (res.language == Dialect::AnyLanguage || res.language == Dialect::Qml)
maybeAddPath(res, info.qtQmlPath);
@@ -1692,7 +1692,7 @@ void ModelManagerInterface::resetCodeModel()
QMutexLocker locker(&m_mutex);
// find all documents currently in the code model
- for (const Document::Ptr &doc : qAsConst(m_validSnapshot))
+ for (const Document::Ptr &doc : std::as_const(m_validSnapshot))
documents.append(doc->fileName());
// reset the snapshot
diff --git a/src/libs/qmljs/qmljsplugindumper.cpp b/src/libs/qmljs/qmljsplugindumper.cpp
index b00a2be83c9..882d3b8ef53 100644
--- a/src/libs/qmljs/qmljsplugindumper.cpp
+++ b/src/libs/qmljs/qmljsplugindumper.cpp
@@ -151,7 +151,7 @@ void PluginDumper::onLoadPluginTypes(const Utils::FilePath &libraryPath,
// watch library qmltypes file
if (!plugin.typeInfoPaths.isEmpty()) {
- for (const FilePath &path : qAsConst(plugin.typeInfoPaths)) {
+ for (const FilePath &path : std::as_const(plugin.typeInfoPaths)) {
if (!path.exists())
continue;
if (!pluginWatcher()->watchesFile(path.toString()))