AbstractSyntaxTreeUtil.generateVariable(nodeFactory, REPEATER,
standardDefs.CLASS_REPEATER_DOT, true,
value);
nodeFactory.statementList(statementList, variableDefinition);
MemberExpressionNode repeaterBase =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, REPEATER, false);
IdentifierNode initializeRepeaterIdentifier = nodeFactory.identifier(INITIALIZE_REPEATER, false);
MemberExpressionNode lvalueBaseMemberExpression =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, name, true);
ArgumentListNode initializeRepeaterArgumentList =
nodeFactory.argumentList(null, lvalueBaseMemberExpression);
LiteralBooleanNode literalBoolean = nodeFactory.literalBoolean(true);
initializeRepeaterArgumentList = nodeFactory.argumentList(initializeRepeaterArgumentList,
literalBoolean);
CallExpressionNode initializeRepeaterCallExpression =
(CallExpressionNode) nodeFactory.callExpression(initializeRepeaterIdentifier,
initializeRepeaterArgumentList);
initializeRepeaterCallExpression.setRValue(false);
MemberExpressionNode initializeRepeaterMemberExpression =
nodeFactory.memberExpression(repeaterBase, initializeRepeaterCallExpression);
ListNode initializeRepeaterList = nodeFactory.list(null, initializeRepeaterMemberExpression);
ExpressionStatementNode initializeRepeaterExpressionStatement =
nodeFactory.expressionStatement(initializeRepeaterList);
nodeFactory.statementList(statementList, initializeRepeaterExpressionStatement);
MemberExpressionNode condition = generateChildRepeaters(nodeFactory, lvalueBase);
MemberExpressionNode thenExpr = generateThen(nodeFactory, name);
ListNode elseExpr = generateElse(nodeFactory, name);
ConditionalExpressionNode conditionalExpression =
nodeFactory.conditionalExpression(condition, thenExpr, elseExpr);
ListNode base = nodeFactory.list(null, conditionalExpression);
IdentifierNode pushIdentifier = nodeFactory.identifier(PUSH, false);
MemberExpressionNode repeaterMemberExpression =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, REPEATER, false);
ArgumentListNode pushArgumentList = nodeFactory.argumentList(null, repeaterMemberExpression);
CallExpressionNode pushCallExpression =
(CallExpressionNode) nodeFactory.callExpression(pushIdentifier, pushArgumentList);
pushCallExpression.setRValue(false);
MemberExpressionNode pushMemberExpression = nodeFactory.memberExpression(base, pushCallExpression);
ListNode pushList = nodeFactory.list(null, pushMemberExpression);
ExpressionStatementNode pushExpressionStatement = nodeFactory.expressionStatement(pushList);
return nodeFactory.statementList(statementList, pushExpressionStatement);
}
else
{
IdentifierNode identifier = nodeFactory.identifier(ADD_CHILD, false);
Node valueExpr = generateValueExpr(nodeFactory, configNamespaces, generateDocComments);
ArgumentListNode argumentList = nodeFactory.argumentList(null, valueExpr);
CallExpressionNode callExpression =
(CallExpressionNode) nodeFactory.callExpression(identifier, argumentList);
callExpression.setRValue(false);
MemberExpressionNode memberExpression = nodeFactory.memberExpression(lvalueBase, callExpression);
ListNode list = nodeFactory.list(null, memberExpression);
ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
return nodeFactory.statementList(statementList, expressionStatement);
}
}