forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -666,7 +666,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
||||
QStringList nCompletions;
|
||||
QString prefix(libVersion.left(toSkip));
|
||||
nCompletions.reserve(completions.size());
|
||||
for (const QString &completion : qAsConst(completions))
|
||||
for (const QString &completion : std::as_const(completions))
|
||||
if (completion.startsWith(prefix))
|
||||
nCompletions.append(completion.right(completion.size()-toSkip));
|
||||
completions = nCompletions;
|
||||
@@ -1031,7 +1031,7 @@ void QmlJSAssistProposalModel::filter(const QString &prefix)
|
||||
return;
|
||||
QList<AssistProposalItemInterface *> newCurrentItems;
|
||||
newCurrentItems.reserve(m_currentItems.size());
|
||||
for (AssistProposalItemInterface *item : qAsConst(m_currentItems))
|
||||
for (AssistProposalItemInterface *item : std::as_const(m_currentItems))
|
||||
if (!item->text().startsWith(QLatin1String("__")))
|
||||
newCurrentItems << item;
|
||||
m_currentItems = newCurrentItems;
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
|
||||
sortedPropertiesWithoutId.sort();
|
||||
|
||||
for (const QString &property : qAsConst(sortedPropertiesWithoutId))
|
||||
for (const QString &property : std::as_const(sortedPropertiesWithoutId))
|
||||
sourcePreview.append(QLatin1String(" ") + property + QLatin1String(": ") + propertyReader.readAstValue(property));
|
||||
|
||||
const bool confirm = ComponentNameDialog::go(&componentName,
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
if (program->members)
|
||||
astRootNode = program->members->member;
|
||||
|
||||
for (const QString &property : qAsConst(result))
|
||||
for (const QString &property : std::as_const(result))
|
||||
rewriter.removeBindingByName(initializerOfObject(astRootNode), property);
|
||||
} else {
|
||||
qWarning() << Q_FUNC_INFO << "parsing failed:" << newComponentSource;
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
if (!m_idName.isEmpty())
|
||||
replacement += QLatin1String("id: ") + m_idName + QLatin1Char('\n');
|
||||
|
||||
for (const QString &property : qAsConst(result))
|
||||
for (const QString &property : std::as_const(result))
|
||||
replacement += property + QLatin1String(": ") + propertyReader.readAstValue(property) + QLatin1Char('\n');
|
||||
|
||||
Utils::ChangeSet changes;
|
||||
|
||||
@@ -357,7 +357,7 @@ void QmlJSEditorWidget::updateUses()
|
||||
Utils::sort(locations, [](const SourceLocation &lhs, const SourceLocation &rhs) {
|
||||
return lhs.begin() < rhs.begin();
|
||||
});
|
||||
for (const SourceLocation &loc : qAsConst(locations)) {
|
||||
for (const SourceLocation &loc : std::as_const(locations)) {
|
||||
if (! loc.isValid())
|
||||
continue;
|
||||
|
||||
|
||||
@@ -618,13 +618,13 @@ void QmlJSEditorDocumentPrivate::createTextMarks(const SemanticInfo &info)
|
||||
m_semanticMarks.removeAll(mark);
|
||||
delete mark;
|
||||
};
|
||||
for (const DiagnosticMessage &diagnostic : qAsConst(info.semanticMessages)) {
|
||||
for (const DiagnosticMessage &diagnostic : std::as_const(info.semanticMessages)) {
|
||||
auto mark = new QmlJSTextMark(q->filePath(),
|
||||
diagnostic, onMarkRemoved);
|
||||
m_semanticMarks.append(mark);
|
||||
q->addMark(mark);
|
||||
}
|
||||
for (const QmlJS::StaticAnalysis::Message &message : qAsConst(info.staticAnalysisMessages)) {
|
||||
for (const QmlJS::StaticAnalysis::Message &message : std::as_const(info.staticAnalysisMessages)) {
|
||||
auto mark = new QmlJSTextMark(q->filePath(),
|
||||
message, onMarkRemoved);
|
||||
m_semanticMarks.append(mark);
|
||||
|
||||
@@ -879,7 +879,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
||||
replacement = name;
|
||||
|
||||
Utils::FilePaths files;
|
||||
for (const Document::Ptr &doc : qAsConst(snapshot)) {
|
||||
for (const Document::Ptr &doc : std::as_const(snapshot)) {
|
||||
// ### skip files that don't contain the name token
|
||||
files.append(modelManager->fileToSource(doc->fileName()));
|
||||
}
|
||||
@@ -965,7 +965,7 @@ QList<FindReferences::Usage> FindReferences::findUsageOfType(const Utils::FilePa
|
||||
QmlJS::Snapshot snapshot = modelManager->snapshot();
|
||||
|
||||
QSet<Utils::FilePath> docDone;
|
||||
for (const QmlJS::Document::Ptr &doc : qAsConst(snapshot)) {
|
||||
for (const QmlJS::Document::Ptr &doc : std::as_const(snapshot)) {
|
||||
Utils::FilePath sourceFile = modelManager->fileToSource(doc->fileName());
|
||||
if (docDone.contains(sourceFile))
|
||||
continue;
|
||||
|
||||
@@ -378,7 +378,7 @@ bool QmlOutlineModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
stream >> rowPath;
|
||||
|
||||
QModelIndex index;
|
||||
for (int row : qAsConst(rowPath)) {
|
||||
for (int row : std::as_const(rowPath)) {
|
||||
index = this->index(row, 0, index);
|
||||
if (!index.isValid())
|
||||
continue;
|
||||
@@ -860,7 +860,7 @@ void QmlOutlineModel::reparentNodes(QmlOutlineItem *targetItem, int row, QList<Q
|
||||
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(), m_semanticInfo.snapshot);
|
||||
TextEditor::RefactoringFilePtr file = refactoring.file(m_semanticInfo.document->fileName());
|
||||
file->setChangeSet(changeSet);
|
||||
for (const Utils::ChangeSet::Range &range : qAsConst(changedRanges)) {
|
||||
for (const Utils::ChangeSet::Range &range : std::as_const(changedRanges)) {
|
||||
file->appendIndentRange(range);
|
||||
}
|
||||
file->apply();
|
||||
|
||||
@@ -71,7 +71,7 @@ void QmlTaskManager::collectMessages(QFutureInterface<FileErrorMessages> &future
|
||||
context = link(&linkMessages);
|
||||
}
|
||||
|
||||
for (const Utils::FilePath &fileName : qAsConst(info.sourceFiles)) {
|
||||
for (const Utils::FilePath &fileName : std::as_const(info.sourceFiles)) {
|
||||
Document::Ptr document = snapshot.document(fileName);
|
||||
if (!document)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user