Commit 700975ad authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlJS: ALlow users of the Rewriter to specify where to insert stuff

parent 15629b03
......@@ -55,11 +55,13 @@ Rewriter::Rewriter(const QString &originalText,
void Rewriter::addBinding(AST::UiObjectInitializer *ast,
const QString &propertyName,
const QString &propertyValue,
BindingType bindingType)
BindingType bindingType,
UiObjectMemberList *insertAfter)
{
UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members,
propertyName,
m_propertyOrder);
if (!insertAfter)
insertAfter = searchMemberToInsertAfter(ast->members,
propertyName,
m_propertyOrder);
SourceLocation endOfPreviousMember;
SourceLocation startOfNextMember;
......@@ -568,9 +570,10 @@ void Rewriter::appendToArrayBinding(UiArrayBinding *arrayBinding,
m_changeSet->insert(insertionPoint, QLatin1String(",\n") + content);
}
void Rewriter::addObject(UiObjectInitializer *ast, const QString &content)
void Rewriter::addObject(UiObjectInitializer *ast, const QString &content, UiObjectMemberList *insertAfter = 0)
{
UiObjectMemberList *insertAfter = searchMemberToInsertAfter(ast->members, m_propertyOrder);
if (!insertAfter)
insertAfter = searchMemberToInsertAfter(ast->members, m_propertyOrder);
int insertionPoint;
QString textToInsert;
......
......@@ -59,7 +59,8 @@ public:
void addBinding(AST::UiObjectInitializer *ast,
const QString &propertyName,
const QString &propertyValue,
BindingType bindingType);
BindingType bindingType,
UiObjectMemberList *insertAfter = 0);
void changeProperty(AST::UiObjectInitializer *ast,
const QString &propertyName,
......@@ -70,7 +71,7 @@ public:
void appendToArrayBinding(AST::UiArrayBinding *arrayBinding,
const QString &content);
void addObject(AST::UiObjectInitializer *ast, const QString &content);
void addObject(AST::UiObjectInitializer *ast, const QString &content, UiObjectMemberList *insertAfter = 0);
void removeObjectMember(AST::UiObjectMember *member, AST::UiObjectMember *parent);
static AST::UiObjectMemberList *searchMemberToInsertAfter(AST::UiObjectMemberList *members, const QStringList &propertyOrder);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment