forked from qt-creator/qt-creator
QmlJsEditor: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464 Change-Id: I77741a639d8585d1e0ad04d7c5e6588852202e4a Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -101,7 +101,7 @@ static void addCompletions(QList<AssistProposalItemInterface *> *completions,
|
|||||||
const QIcon &icon,
|
const QIcon &icon,
|
||||||
int order)
|
int order)
|
||||||
{
|
{
|
||||||
foreach (const QString &text, newCompletions)
|
for (const QString &text : newCompletions)
|
||||||
addCompletion(completions, text, icon, order);
|
addCompletion(completions, text, icon, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,7 +226,8 @@ public:
|
|||||||
_processed.clear();
|
_processed.clear();
|
||||||
_propertyProcessor = processor;
|
_propertyProcessor = processor;
|
||||||
|
|
||||||
foreach (const ObjectValue *scope, _scopeChain->all())
|
const QList<const ObjectValue *> scopes = _scopeChain->all();
|
||||||
|
for (const ObjectValue *scope : scopes)
|
||||||
processProperties(scope);
|
processProperties(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +303,7 @@ const Value *getPropertyValue(const ObjectValue *object,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const Value *value = object;
|
const Value *value = object;
|
||||||
foreach (const QString &name, propertyNames) {
|
for (const QString &name : propertyNames) {
|
||||||
if (const ObjectValue *objectValue = value->asObjectValue()) {
|
if (const ObjectValue *objectValue = value->asObjectValue()) {
|
||||||
value = objectValue->lookupMember(name, context);
|
value = objectValue->lookupMember(name, context);
|
||||||
if (!value)
|
if (!value)
|
||||||
@@ -687,7 +688,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
QStringList nCompletions;
|
QStringList nCompletions;
|
||||||
QString prefix(libVersion.left(toSkip));
|
QString prefix(libVersion.left(toSkip));
|
||||||
nCompletions.reserve(completions.size());
|
nCompletions.reserve(completions.size());
|
||||||
foreach (const QString &completion, completions)
|
for (const QString &completion : qAsConst(completions))
|
||||||
if (completion.startsWith(prefix))
|
if (completion.startsWith(prefix))
|
||||||
nCompletions.append(completion.right(completion.size()-toSkip));
|
nCompletions.append(completion.right(completion.size()-toSkip));
|
||||||
completions = nCompletions;
|
completions = nCompletions;
|
||||||
@@ -800,7 +801,8 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
|
|||||||
if (const QmlEnumValue *enumValue =
|
if (const QmlEnumValue *enumValue =
|
||||||
value_cast<QmlEnumValue>(value)) {
|
value_cast<QmlEnumValue>(value)) {
|
||||||
const QString &name = context->imports(document.data())->nameForImportedObject(enumValue->owner(), context.data());
|
const QString &name = context->imports(document.data())->nameForImportedObject(enumValue->owner(), context.data());
|
||||||
foreach (const QString &key, enumValue->keys()) {
|
const QStringList keys = enumValue->keys();
|
||||||
|
for (const QString &key : keys) {
|
||||||
QString completion;
|
QString completion;
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
completion = QString::fromLatin1("\"%1\"").arg(key);
|
completion = QString::fromLatin1("\"%1\"").arg(key);
|
||||||
@@ -910,7 +912,7 @@ bool QmlJSCompletionAssistProcessor::acceptsIdleEditor() const
|
|||||||
Scanner scanner;
|
Scanner scanner;
|
||||||
const QList<Token> tokens = scanner(blockText, blockState);
|
const QList<Token> tokens = scanner(blockText, blockState);
|
||||||
const int column = block.position() - m_interface->position();
|
const int column = block.position() - m_interface->position();
|
||||||
foreach (const Token &tk, tokens) {
|
for (const Token &tk : tokens) {
|
||||||
if (column >= tk.begin() && column <= tk.end()) {
|
if (column >= tk.begin() && column <= tk.end()) {
|
||||||
if (charBeforeCursor == QLatin1Char('/') && tk.is(Token::String))
|
if (charBeforeCursor == QLatin1Char('/') && tk.is(Token::String))
|
||||||
return true; // path completion inside string literals
|
return true; // path completion inside string literals
|
||||||
@@ -1051,7 +1053,7 @@ void QmlJSAssistProposalModel::filter(const QString &prefix)
|
|||||||
return;
|
return;
|
||||||
QList<AssistProposalItemInterface *> newCurrentItems;
|
QList<AssistProposalItemInterface *> newCurrentItems;
|
||||||
newCurrentItems.reserve(m_currentItems.size());
|
newCurrentItems.reserve(m_currentItems.size());
|
||||||
foreach (AssistProposalItemInterface *item, m_currentItems)
|
for (AssistProposalItemInterface *item : qAsConst(m_currentItems))
|
||||||
if (!item->text().startsWith(QLatin1String("__")))
|
if (!item->text().startsWith(QLatin1String("__")))
|
||||||
newCurrentItems << item;
|
newCurrentItems << item;
|
||||||
m_currentItems = newCurrentItems;
|
m_currentItems = newCurrentItems;
|
||||||
|
@@ -123,13 +123,14 @@ public:
|
|||||||
|
|
||||||
QStringList sortedPropertiesWithoutId;
|
QStringList sortedPropertiesWithoutId;
|
||||||
|
|
||||||
foreach (const QString &property, propertyReader.properties())
|
const QStringList properties = propertyReader.properties();
|
||||||
|
for (const QString &property : properties)
|
||||||
if (property != QLatin1String("id"))
|
if (property != QLatin1String("id"))
|
||||||
sortedPropertiesWithoutId.append(property);
|
sortedPropertiesWithoutId.append(property);
|
||||||
|
|
||||||
sortedPropertiesWithoutId.sort();
|
sortedPropertiesWithoutId.sort();
|
||||||
|
|
||||||
foreach (const QString &property, sortedPropertiesWithoutId)
|
for (const QString &property : qAsConst(sortedPropertiesWithoutId))
|
||||||
sourcePreview.append(QLatin1String(" ") + property + QLatin1String(": ") + propertyReader.readAstValue(property));
|
sourcePreview.append(QLatin1String(" ") + property + QLatin1String(": ") + propertyReader.readAstValue(property));
|
||||||
|
|
||||||
const bool confirm = ComponentNameDialog::go(&componentName, &path, &suffix,
|
const bool confirm = ComponentNameDialog::go(&componentName, &path, &suffix,
|
||||||
@@ -178,7 +179,7 @@ public:
|
|||||||
if (program->members)
|
if (program->members)
|
||||||
astRootNode = program->members->member;
|
astRootNode = program->members->member;
|
||||||
|
|
||||||
foreach (const QString &property, result)
|
for (const QString &property : qAsConst(result))
|
||||||
rewriter.removeBindingByName(initializerOfObject(astRootNode), property);
|
rewriter.removeBindingByName(initializerOfObject(astRootNode), property);
|
||||||
} else {
|
} else {
|
||||||
qWarning() << Q_FUNC_INFO << "parsing failed:" << newComponentSource;
|
qWarning() << Q_FUNC_INFO << "parsing failed:" << newComponentSource;
|
||||||
@@ -208,7 +209,7 @@ public:
|
|||||||
if (!m_idName.isEmpty())
|
if (!m_idName.isEmpty())
|
||||||
replacement += QLatin1String("id: ") + m_idName + QLatin1Char('\n');
|
replacement += QLatin1String("id: ") + m_idName + QLatin1Char('\n');
|
||||||
|
|
||||||
foreach (const QString &property, result)
|
for (const QString &property : qAsConst(result))
|
||||||
replacement += property + QLatin1String(": ") + propertyReader.readAstValue(property) + QLatin1Char('\n');
|
replacement += property + QLatin1String(": ") + propertyReader.readAstValue(property) + QLatin1Char('\n');
|
||||||
|
|
||||||
Utils::ChangeSet changes;
|
Utils::ChangeSet changes;
|
||||||
|
@@ -189,7 +189,7 @@ static void appendExtraSelectionsForMessages(
|
|||||||
const QList<DiagnosticMessage> &messages,
|
const QList<DiagnosticMessage> &messages,
|
||||||
const QTextDocument *document)
|
const QTextDocument *document)
|
||||||
{
|
{
|
||||||
foreach (const DiagnosticMessage &d, messages) {
|
for (const DiagnosticMessage &d : messages) {
|
||||||
const int line = d.loc.startLine;
|
const int line = d.loc.startLine;
|
||||||
const int column = qMax(1U, d.loc.startColumn);
|
const int column = qMax(1U, d.loc.startColumn);
|
||||||
|
|
||||||
@@ -511,10 +511,10 @@ void QmlJSEditorWidget::setSelectedElements()
|
|||||||
|
|
||||||
if (m_qmlJsEditorDocument->semanticInfo().isValid()) {
|
if (m_qmlJsEditorDocument->semanticInfo().isValid()) {
|
||||||
SelectedElement selectedMembers;
|
SelectedElement selectedMembers;
|
||||||
QList<UiObjectMember *> members
|
const QList<UiObjectMember *> members
|
||||||
= selectedMembers(m_qmlJsEditorDocument->semanticInfo().document, startPos, endPos);
|
= selectedMembers(m_qmlJsEditorDocument->semanticInfo().document, startPos, endPos);
|
||||||
if (!members.isEmpty()) {
|
if (!members.isEmpty()) {
|
||||||
foreach (UiObjectMember *m, members) {
|
for (UiObjectMember *m : members) {
|
||||||
offsets << m;
|
offsets << m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -768,7 +768,8 @@ void QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor,
|
|||||||
|
|
||||||
if (auto importAst = cast<const AST::UiImport *>(node)) {
|
if (auto importAst = cast<const AST::UiImport *>(node)) {
|
||||||
// if it's a file import, link to the file
|
// if it's a file import, link to the file
|
||||||
foreach (const ImportInfo &import, semanticInfo.document->bind()->imports()) {
|
const QList<ImportInfo> imports = semanticInfo.document->bind()->imports();
|
||||||
|
for (const ImportInfo &import : imports) {
|
||||||
if (import.ast() == importAst && import.type() == ImportType::File) {
|
if (import.ast() == importAst && import.type() == ImportType::File) {
|
||||||
Utils::Link link(Utils::FilePath::fromString(import.path()));
|
Utils::Link link(Utils::FilePath::fromString(import.path()));
|
||||||
link.linkTextStart = importAst->firstSourceLocation().begin();
|
link.linkTextStart = importAst->firstSourceLocation().begin();
|
||||||
@@ -896,7 +897,8 @@ void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e)
|
|||||||
|
|
||||||
if (ActionContainer *mcontext = ActionManager::actionContainer(Constants::M_CONTEXT)) {
|
if (ActionContainer *mcontext = ActionManager::actionContainer(Constants::M_CONTEXT)) {
|
||||||
QMenu *contextMenu = mcontext->menu();
|
QMenu *contextMenu = mcontext->menu();
|
||||||
foreach (QAction *action, contextMenu->actions()) {
|
const QList<QAction *> actions = contextMenu->actions();
|
||||||
|
for (QAction *action : actions) {
|
||||||
menu->addAction(action);
|
menu->addAction(action);
|
||||||
if (action->objectName() == QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT))
|
if (action->objectName() == QLatin1String(Constants::M_REFACTORING_MENU_INSERTION_POINT))
|
||||||
menu->addMenu(refactoringMenu);
|
menu->addMenu(refactoringMenu);
|
||||||
|
@@ -260,7 +260,8 @@ private:
|
|||||||
if (root && root->lookupMember(_name, _scopeChain.context()))
|
if (root && root->lookupMember(_name, _scopeChain.context()))
|
||||||
return check(root);
|
return check(root);
|
||||||
|
|
||||||
foreach (const QmlComponentChain *parent, chain->instantiatingComponents()) {
|
const QList<const QmlComponentChain *> parents = chain->instantiatingComponents();
|
||||||
|
for (const QmlComponentChain *parent : parents) {
|
||||||
if (contains(parent))
|
if (contains(parent))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -278,7 +279,8 @@ private:
|
|||||||
|
|
||||||
bool checkQmlScope()
|
bool checkQmlScope()
|
||||||
{
|
{
|
||||||
foreach (const ObjectValue *s, _scopeChain.qmlScopeObjects()) {
|
const QList<const ObjectValue *> scopes = _scopeChain.qmlScopeObjects();
|
||||||
|
for (const ObjectValue *s : scopes) {
|
||||||
if (check(s))
|
if (check(s))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -749,8 +751,8 @@ public:
|
|||||||
|
|
||||||
// find all idenfifier expressions, try to resolve them and check if the result is in scope
|
// find all idenfifier expressions, try to resolve them and check if the result is in scope
|
||||||
FindUsages findUsages(doc, context);
|
FindUsages findUsages(doc, context);
|
||||||
FindUsages::Result results = findUsages(name, scope);
|
const FindUsages::Result results = findUsages(name, scope);
|
||||||
foreach (const SourceLocation &loc, results)
|
for (const SourceLocation &loc : results)
|
||||||
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
||||||
if (future->isPaused())
|
if (future->isPaused())
|
||||||
future->waitForResume();
|
future->waitForResume();
|
||||||
@@ -791,8 +793,8 @@ public:
|
|||||||
|
|
||||||
// find all idenfifier expressions, try to resolve them and check if the result is in scope
|
// find all idenfifier expressions, try to resolve them and check if the result is in scope
|
||||||
FindTypeUsages findUsages(doc, context);
|
FindTypeUsages findUsages(doc, context);
|
||||||
FindTypeUsages::Result results = findUsages(name, scope);
|
const FindTypeUsages::Result results = findUsages(name, scope);
|
||||||
foreach (const SourceLocation &loc, results)
|
for (const SourceLocation &loc : results)
|
||||||
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
usages.append(Usage(fileName, matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
||||||
if (future->isPaused())
|
if (future->isPaused())
|
||||||
future->waitForResume();
|
future->waitForResume();
|
||||||
@@ -815,7 +817,7 @@ public:
|
|||||||
|
|
||||||
void operator()(QList<Usage> &, const QList<Usage> &usages)
|
void operator()(QList<Usage> &, const QList<Usage> &usages)
|
||||||
{
|
{
|
||||||
foreach (const Usage &u, usages)
|
for (const Usage &u : usages)
|
||||||
future->reportResult(u);
|
future->reportResult(u);
|
||||||
|
|
||||||
future->setProgressValue(future->progressValue() + 1);
|
future->setProgressValue(future->progressValue() + 1);
|
||||||
@@ -892,7 +894,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
|
|||||||
replacement = name;
|
replacement = name;
|
||||||
|
|
||||||
QStringList files;
|
QStringList files;
|
||||||
foreach (const Document::Ptr &doc, snapshot) {
|
for (const Document::Ptr &doc : qAsConst(snapshot)) {
|
||||||
// ### skip files that don't contain the name token
|
// ### skip files that don't contain the name token
|
||||||
files.append(doc->fileName());
|
files.append(doc->fileName());
|
||||||
}
|
}
|
||||||
@@ -974,10 +976,10 @@ QList<FindReferences::Usage> FindReferences::findUsageOfType(const QString &file
|
|||||||
|
|
||||||
QmlJS::Snapshot snapshot = modelManager->snapshot();
|
QmlJS::Snapshot snapshot = modelManager->snapshot();
|
||||||
|
|
||||||
foreach (const QmlJS::Document::Ptr &doc, snapshot) {
|
for (const QmlJS::Document::Ptr &doc : qAsConst(snapshot)) {
|
||||||
FindTypeUsages findUsages(doc, context);
|
FindTypeUsages findUsages(doc, context);
|
||||||
FindTypeUsages::Result results = findUsages(typeName, targetValue);
|
const FindTypeUsages::Result results = findUsages(typeName, targetValue);
|
||||||
foreach (const SourceLocation &loc, results) {
|
for (const SourceLocation &loc : results) {
|
||||||
usages.append(Usage(doc->fileName(), matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
usages.append(Usage(doc->fileName(), matchingLine(loc.offset, doc->source()), loc.startLine, loc.startColumn - 1, loc.length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -268,15 +268,17 @@ void QmlJSHoverHandler::identifyMatch(TextEditorWidget *editorWidget, int pos, R
|
|||||||
|
|
||||||
bool QmlJSHoverHandler::matchDiagnosticMessage(QmlJSEditorWidget *qmlEditor, int pos)
|
bool QmlJSHoverHandler::matchDiagnosticMessage(QmlJSEditorWidget *qmlEditor, int pos)
|
||||||
{
|
{
|
||||||
foreach (const QTextEdit::ExtraSelection &sel,
|
const QList<QTextEdit::ExtraSelection> selections =
|
||||||
qmlEditor->extraSelections(TextEditorWidget::CodeWarningsSelection)) {
|
qmlEditor->extraSelections(TextEditorWidget::CodeWarningsSelection);
|
||||||
|
for (const QTextEdit::ExtraSelection &sel : selections) {
|
||||||
if (pos >= sel.cursor.selectionStart() && pos <= sel.cursor.selectionEnd()) {
|
if (pos >= sel.cursor.selectionStart() && pos <= sel.cursor.selectionEnd()) {
|
||||||
setToolTip(sel.format.toolTip());
|
setToolTip(sel.format.toolTip());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (const QTextLayout::FormatRange &range,
|
const QVector<QTextLayout::FormatRange> ranges =
|
||||||
qmlEditor->qmlJsEditorDocument()->diagnosticRanges()) {
|
qmlEditor->qmlJsEditorDocument()->diagnosticRanges();
|
||||||
|
for (const QTextLayout::FormatRange &range : ranges) {
|
||||||
if (pos >= range.start && pos < range.start+range.length) {
|
if (pos >= range.start && pos < range.start+range.length) {
|
||||||
setToolTip(range.format.toolTip());
|
setToolTip(range.format.toolTip());
|
||||||
return true;
|
return true;
|
||||||
@@ -357,7 +359,8 @@ void QmlJSHoverHandler::handleImport(const ScopeChain &scopeChain, AST::UiImport
|
|||||||
if (!imports)
|
if (!imports)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (const Import &import, imports->all()) {
|
const QList<Import> importList = imports->all();
|
||||||
|
for (const Import &import : importList) {
|
||||||
if (import.info.ast() == node) {
|
if (import.info.ast() == node) {
|
||||||
if (import.info.type() == ImportType::Library
|
if (import.info.type() == ImportType::Library
|
||||||
&& !import.libraryPath.isEmpty()) {
|
&& !import.libraryPath.isEmpty()) {
|
||||||
|
@@ -154,7 +154,7 @@ void matchAddAnalysisMessageSuppressionCommentQuickFix(const QmlJSQuickFixInterf
|
|||||||
{
|
{
|
||||||
const QList<StaticAnalysis::Message> &messages = interface->semanticInfo().staticAnalysisMessages;
|
const QList<StaticAnalysis::Message> &messages = interface->semanticInfo().staticAnalysisMessages;
|
||||||
|
|
||||||
foreach (const StaticAnalysis::Message &message, messages) {
|
for (const StaticAnalysis::Message &message : messages) {
|
||||||
if (interface->currentFile()->isCursorOn(message.location)) {
|
if (interface->currentFile()->isCursorOn(message.location)) {
|
||||||
result << new AnalysizeMessageSuppressionOperation(interface, message);
|
result << new AnalysizeMessageSuppressionOperation(interface, message);
|
||||||
return;
|
return;
|
||||||
|
@@ -59,7 +59,7 @@ namespace {
|
|||||||
|
|
||||||
static bool isIdScope(const ObjectValue *scope, const QList<const QmlComponentChain *> &chain)
|
static bool isIdScope(const ObjectValue *scope, const QList<const QmlComponentChain *> &chain)
|
||||||
{
|
{
|
||||||
foreach (const QmlComponentChain *c, chain) {
|
for (const QmlComponentChain *c : chain) {
|
||||||
if (c->idScope() == scope)
|
if (c->idScope() == scope)
|
||||||
return true;
|
return true;
|
||||||
if (isIdScope(scope, c->instantiatingComponents()))
|
if (isIdScope(scope, c->instantiatingComponents()))
|
||||||
@@ -391,7 +391,7 @@ protected:
|
|||||||
void addMessages(QList<DiagnosticMessage> messages,
|
void addMessages(QList<DiagnosticMessage> messages,
|
||||||
const Document::Ptr &doc)
|
const Document::Ptr &doc)
|
||||||
{
|
{
|
||||||
foreach (const DiagnosticMessage &d, messages) {
|
for (const DiagnosticMessage &d : messages) {
|
||||||
int line = d.loc.startLine;
|
int line = d.loc.startLine;
|
||||||
int column = qMax(1U, d.loc.startColumn);
|
int column = qMax(1U, d.loc.startColumn);
|
||||||
int length = d.loc.length;
|
int length = d.loc.length;
|
||||||
@@ -426,7 +426,7 @@ protected:
|
|||||||
void addMessages(const QList<StaticAnalysis::Message> &messages,
|
void addMessages(const QList<StaticAnalysis::Message> &messages,
|
||||||
const Document::Ptr &doc)
|
const Document::Ptr &doc)
|
||||||
{
|
{
|
||||||
foreach (const StaticAnalysis::Message &d, messages) {
|
for (const StaticAnalysis::Message &d : messages) {
|
||||||
int line = d.location.startLine;
|
int line = d.location.startLine;
|
||||||
int column = qMax(1U, d.location.startColumn);
|
int column = qMax(1U, d.location.startColumn);
|
||||||
int length = d.location.length;
|
int length = d.location.length;
|
||||||
|
@@ -400,7 +400,7 @@ bool QmlOutlineModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
|||||||
stream >> rowPath;
|
stream >> rowPath;
|
||||||
|
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
foreach (int row, rowPath) {
|
for (int row : qAsConst(rowPath)) {
|
||||||
index = this->index(row, 0, index);
|
index = this->index(row, 0, index);
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
continue;
|
continue;
|
||||||
@@ -883,7 +883,7 @@ void QmlOutlineModel::reparentNodes(QmlOutlineItem *targetItem, int row, QList<Q
|
|||||||
TextEditor::RefactoringFilePtr file = refactoring.file(
|
TextEditor::RefactoringFilePtr file = refactoring.file(
|
||||||
Utils::FilePath::fromString(m_semanticInfo.document->fileName()));
|
Utils::FilePath::fromString(m_semanticInfo.document->fileName()));
|
||||||
file->setChangeSet(changeSet);
|
file->setChangeSet(changeSet);
|
||||||
foreach (const Utils::ChangeSet::Range &range, changedRanges) {
|
for (const Utils::ChangeSet::Range &range : qAsConst(changedRanges)) {
|
||||||
file->appendIndentRange(range);
|
file->appendIndentRange(range);
|
||||||
}
|
}
|
||||||
file->apply();
|
file->apply();
|
||||||
|
@@ -63,7 +63,7 @@ QmlTaskManager::QmlTaskManager()
|
|||||||
static Tasks convertToTasks(const QList<DiagnosticMessage> &messages, const FilePath &fileName, Utils::Id category)
|
static Tasks convertToTasks(const QList<DiagnosticMessage> &messages, const FilePath &fileName, Utils::Id category)
|
||||||
{
|
{
|
||||||
Tasks result;
|
Tasks result;
|
||||||
foreach (const DiagnosticMessage &msg, messages) {
|
for (const DiagnosticMessage &msg : messages) {
|
||||||
Task::TaskType type = msg.isError() ? Task::Error : Task::Warning;
|
Task::TaskType type = msg.isError() ? Task::Error : Task::Warning;
|
||||||
Task task(type, msg.message, fileName, msg.loc.startLine, category);
|
Task task(type, msg.message, fileName, msg.loc.startLine, category);
|
||||||
result += task;
|
result += task;
|
||||||
@@ -74,17 +74,18 @@ static Tasks convertToTasks(const QList<DiagnosticMessage> &messages, const File
|
|||||||
static Tasks convertToTasks(const QList<StaticAnalysis::Message> &messages, const FilePath &fileName, Utils::Id category)
|
static Tasks convertToTasks(const QList<StaticAnalysis::Message> &messages, const FilePath &fileName, Utils::Id category)
|
||||||
{
|
{
|
||||||
QList<DiagnosticMessage> diagnostics;
|
QList<DiagnosticMessage> diagnostics;
|
||||||
foreach (const StaticAnalysis::Message &msg, messages)
|
for (const StaticAnalysis::Message &msg : messages)
|
||||||
diagnostics += msg.toDiagnosticMessage();
|
diagnostics += msg.toDiagnosticMessage();
|
||||||
return convertToTasks(diagnostics, fileName, category);
|
return convertToTasks(diagnostics, fileName, category);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlTaskManager::collectMessages(
|
void QmlTaskManager::collectMessages(QFutureInterface<FileErrorMessages> &future,
|
||||||
QFutureInterface<FileErrorMessages> &future,
|
Snapshot snapshot,
|
||||||
Snapshot snapshot, QList<ModelManagerInterface::ProjectInfo> projectInfos,
|
const QList<ModelManagerInterface::ProjectInfo> &projectInfos,
|
||||||
ViewerContext vContext, bool updateSemantic)
|
ViewerContext vContext,
|
||||||
|
bool updateSemantic)
|
||||||
{
|
{
|
||||||
foreach (const ModelManagerInterface::ProjectInfo &info, projectInfos) {
|
for (const ModelManagerInterface::ProjectInfo &info : projectInfos) {
|
||||||
QHash<QString, QList<DiagnosticMessage> > linkMessages;
|
QHash<QString, QList<DiagnosticMessage> > linkMessages;
|
||||||
ContextPtr context;
|
ContextPtr context;
|
||||||
if (updateSemantic) {
|
if (updateSemantic) {
|
||||||
@@ -92,7 +93,7 @@ void QmlTaskManager::collectMessages(
|
|||||||
context = link(&linkMessages);
|
context = link(&linkMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QString &fileName, info.sourceFiles) {
|
for (const QString &fileName : qAsConst(info.sourceFiles)) {
|
||||||
Document::Ptr document = snapshot.document(fileName);
|
Document::Ptr document = snapshot.document(fileName);
|
||||||
if (!document)
|
if (!document)
|
||||||
continue;
|
continue;
|
||||||
@@ -157,15 +158,15 @@ void QmlTaskManager::updateMessagesNow(bool updateSemantic)
|
|||||||
|
|
||||||
void QmlTaskManager::documentsRemoved(const QStringList &path)
|
void QmlTaskManager::documentsRemoved(const QStringList &path)
|
||||||
{
|
{
|
||||||
foreach (const QString &item, path)
|
for (const QString &item : path)
|
||||||
removeTasksForFile(item);
|
removeTasksForFile(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlTaskManager::displayResults(int begin, int end)
|
void QmlTaskManager::displayResults(int begin, int end)
|
||||||
{
|
{
|
||||||
for (int i = begin; i < end; ++i) {
|
for (int i = begin; i < end; ++i) {
|
||||||
FileErrorMessages result = m_messageCollector.resultAt(i);
|
const ProjectExplorer::Tasks tasks = m_messageCollector.resultAt(i).tasks;
|
||||||
foreach (const Task &task, result.tasks) {
|
for (const Task &task : tasks) {
|
||||||
insertTask(task);
|
insertTask(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,7 +190,7 @@ void QmlTaskManager::removeTasksForFile(const QString &fileName)
|
|||||||
{
|
{
|
||||||
if (m_docsWithTasks.contains(fileName)) {
|
if (m_docsWithTasks.contains(fileName)) {
|
||||||
const Tasks tasks = m_docsWithTasks.value(fileName);
|
const Tasks tasks = m_docsWithTasks.value(fileName);
|
||||||
foreach (const Task &task, tasks)
|
for (const Task &task : tasks)
|
||||||
TaskHub::removeTask(task);
|
TaskHub::removeTask(task);
|
||||||
m_docsWithTasks.remove(fileName);
|
m_docsWithTasks.remove(fileName);
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,7 @@ private:
|
|||||||
};
|
};
|
||||||
static void collectMessages(QFutureInterface<FileErrorMessages> &future,
|
static void collectMessages(QFutureInterface<FileErrorMessages> &future,
|
||||||
QmlJS::Snapshot snapshot,
|
QmlJS::Snapshot snapshot,
|
||||||
QList<QmlJS::ModelManagerInterface::ProjectInfo> projectInfos,
|
const QList<QmlJS::ModelManagerInterface::ProjectInfo> &projectInfos,
|
||||||
QmlJS::ViewerContext vContext,
|
QmlJS::ViewerContext vContext,
|
||||||
bool updateSemantic);
|
bool updateSemantic);
|
||||||
|
|
||||||
|
@@ -129,20 +129,20 @@ void QuickToolBar::apply(TextEditor::TextEditorWidget *editorWidget, Document::P
|
|||||||
|
|
||||||
if (scopeChain && scopeObject) {
|
if (scopeChain && scopeObject) {
|
||||||
m_prototypes.clear();
|
m_prototypes.clear();
|
||||||
foreach (const ObjectValue *object,
|
const QList<const ObjectValue *> objects
|
||||||
PrototypeIterator(scopeObject, scopeChain->context()).all()) {
|
= PrototypeIterator(scopeObject, scopeChain->context()).all();
|
||||||
|
for (const ObjectValue *object : objects)
|
||||||
m_prototypes.append(object->className());
|
m_prototypes.append(object->className());
|
||||||
}
|
|
||||||
|
|
||||||
if (m_prototypes.contains(QLatin1String("PropertyChanges"))) {
|
if (m_prototypes.contains(QLatin1String("PropertyChanges"))) {
|
||||||
isPropertyChanges = true;
|
isPropertyChanges = true;
|
||||||
const ObjectValue *targetObject = getPropertyChangesTarget(node, *scopeChain);
|
const ObjectValue *targetObject = getPropertyChangesTarget(node, *scopeChain);
|
||||||
m_prototypes.clear();
|
m_prototypes.clear();
|
||||||
if (targetObject) {
|
if (targetObject) {
|
||||||
foreach (const ObjectValue *object,
|
const QList<const ObjectValue *> objects
|
||||||
PrototypeIterator(targetObject, scopeChain->context()).all()) {
|
= PrototypeIterator(targetObject, scopeChain->context()).all();
|
||||||
|
for (const ObjectValue *object : objects)
|
||||||
m_prototypes.append(object->className());
|
m_prototypes.append(object->className());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user