QmlJS Rewriter: Allow disambiguation of where ObjectMember should be added to

With 700975ade3 one could specify that a UiObjectMember should be inserted
after another one. But 0 'the default parameter' was ambiguous in that
either you want to have it inserted at the beginning of the member list,
or the heuristics should be applied.

Make this explicit by providing two methods.
This commit is contained in:
Kai Koehne
2010-07-21 09:19:51 +02:00
parent 5df0f0a050
commit 715aafaba5
2 changed files with 25 additions and 9 deletions

View File

@@ -52,16 +52,23 @@ Rewriter::Rewriter(const QString &originalText,
Q_ASSERT(changeSet);
}
void Rewriter::addBinding(AST::UiObjectInitializer *ast,
const QString &propertyName,
const QString &propertyValue,
BindingType bindingType)
{
UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members,
propertyName,
m_propertyOrder);
addBinding(ast, propertyName, propertyValue, bindingType, insertAfter);
}
void Rewriter::addBinding(AST::UiObjectInitializer *ast,
const QString &propertyName,
const QString &propertyValue,
BindingType bindingType,
UiObjectMemberList *insertAfter)
{
if (!insertAfter)
insertAfter = searchMemberToInsertAfter(ast->members,
propertyName,
m_propertyOrder);
SourceLocation endOfPreviousMember;
SourceLocation startOfNextMember;
@@ -570,11 +577,14 @@ void Rewriter::appendToArrayBinding(UiArrayBinding *arrayBinding,
m_changeSet->insert(insertionPoint, QLatin1String(",\n") + content);
}
void Rewriter::addObject(UiObjectInitializer *ast, const QString &content)
{
UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members, m_propertyOrder);
addObject(ast, content, insertAfter);
}
void Rewriter::addObject(UiObjectInitializer *ast, const QString &content, UiObjectMemberList *insertAfter)
{
if (!insertAfter)
insertAfter = searchMemberToInsertAfter(ast->members, m_propertyOrder);
int insertionPoint;
QString textToInsert;
if (insertAfter && insertAfter->member) {