void Rewriter::appendToArrayBinding(UiArrayBinding *arrayBinding, const QString &content) { UiObjectMember *lastMember = 0; for (UiArrayMemberList *iter = arrayBinding->members; iter; iter = iter->next) if (iter->member) lastMember = iter->member; if (!lastMember) return; // an array binding cannot be empty, so there will (or should) always be a last member. const int insertionPoint = lastMember->lastSourceLocation().end(); m_changeSet->insert(insertionPoint, QLatin1String(",\n") + content); }
void appendToArray(UiArrayBinding *ast) { UiObjectMember *lastMember = 0; for (UiArrayMemberList *iter = ast->members; iter; iter = iter->next) { if (iter->member) lastMember = iter->member; } if (!lastMember) Q_ASSERT(!"Invalid QML: empty array found."); moveInfo.destination = lastMember->lastSourceLocation().end(); moveInfo.suffixToInsert = QLatin1String(",\n"); move(moveInfo); }
void Rewriter::insertIntoArray(UiArrayBinding *ast, const QString &newValue) { if (!ast) return; UiObjectMember *lastMember = 0; for (UiArrayMemberList *iter = ast->members; iter; iter = iter->next) { lastMember = iter->member; } if (!lastMember) return; const int insertionPoint = lastMember->lastSourceLocation().end(); m_changeSet->insert(insertionPoint, QLatin1String(",\n") + newValue); }
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this void AddArrayMemberVisitor::insertInto(QmlJS::AST::UiArrayBinding *arrayBinding) { UiObjectMember *lastMember = 0; for (UiArrayMemberList *iter = arrayBinding->members; iter; iter = iter->next) if (iter->member) lastMember = iter->member; if (!lastMember) return; // an array binding cannot be empty, so there will (or should) always be a last member. const int insertionPoint = lastMember->lastSourceLocation().end(); const int indentDepth = calculateIndentDepth(lastMember->firstSourceLocation()); replace(insertionPoint, 0, QLatin1String(",\n") + addIndentation(m_content, indentDepth)); setDidRewriting(true); }
// FIXME: duplicate code in the QmlJS::Rewriter class, remove this void ChangePropertyVisitor::insertIntoArray(QmlJS::AST::UiArrayBinding *ast) { if (!ast) return; UiObjectMember *lastMember = 0; for (UiArrayMemberList *iter = ast->members; iter; iter = iter->next) { lastMember = iter->member; } if (!lastMember) return; const int insertionPoint = lastMember->lastSourceLocation().end(); const int depth = calculateIndentDepth(lastMember->firstSourceLocation()); const QString indentedArrayMember = addIndentation(m_value, depth); replace(insertionPoint, 0, QStringLiteral(",\n") + indentedArrayMember); setDidRewriting(true); }