// if (this.hasEventListener("propertyChange"))
// this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "$entry.qualifiedPropertyName", oldValue, value));
ThisExpressionNode innerThisExpression = nodeFactory.thisExpression(0);
IdentifierNode dispatchEventIdentifier = nodeFactory.identifier(DISPATCH_EVENT, false);
MemberExpressionNode propertyChangeEventMemberExpression =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, MX_EVENTS, PROPERTY_CHANGE_EVENT, false);;
IdentifierNode createUpdateEventIdentifier = nodeFactory.identifier(CREATE_UPDATE_EVENT, false);
ThisExpressionNode thisExpression = nodeFactory.thisExpression(0);
ArgumentListNode createUpdateEventArgumentList = nodeFactory.argumentList(null, innerThisExpression);
LiteralStringNode literalString = nodeFactory.literalString(qualifiedPropertyName);
createUpdateEventArgumentList = nodeFactory.argumentList(createUpdateEventArgumentList, literalString);
MemberExpressionNode oldValueMemberExpression =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, OLD_VALUE, false);
createUpdateEventArgumentList =
nodeFactory.argumentList(createUpdateEventArgumentList, oldValueMemberExpression);
MemberExpressionNode valueMemberExpression =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, VALUE, false);
createUpdateEventArgumentList =
nodeFactory.argumentList(createUpdateEventArgumentList, valueMemberExpression);
CallExpressionNode createUpdateEventCallExpression =
(CallExpressionNode) nodeFactory.callExpression(createUpdateEventIdentifier, createUpdateEventArgumentList);
createUpdateEventCallExpression.setRValue(false);
MemberExpressionNode createUpdateEventMemberExpression =
nodeFactory.memberExpression(propertyChangeEventMemberExpression, createUpdateEventCallExpression);
ArgumentListNode dispatchEventArgumentList =
nodeFactory.argumentList(null, createUpdateEventMemberExpression);
CallExpressionNode dispatchEventCallExpression =
(CallExpressionNode) nodeFactory.callExpression(dispatchEventIdentifier, dispatchEventArgumentList);
dispatchEventCallExpression.setRValue(false);
MemberExpressionNode memberExpression =
nodeFactory.memberExpression(thisExpression, dispatchEventCallExpression);
ListNode list = nodeFactory.list(null, memberExpression);
ExpressionStatementNode expressionStatement =
nodeFactory.expressionStatement(list);
// if (this.hasEventListener("propertyChange"))
ThisExpressionNode ifThisExpression = nodeFactory.thisExpression(0);
IdentifierNode hasEventListenerIdentifier = nodeFactory.identifier(HAS_EVENT_LISTENER, false);
LiteralStringNode propChangeLiteralString = nodeFactory.literalString(PROPERTY_CHANGE);
CallExpressionNode hasEventListenerCallExpression =
(CallExpressionNode) nodeFactory.callExpression(hasEventListenerIdentifier, nodeFactory.argumentList(null, propChangeLiteralString));
hasEventListenerCallExpression.setRValue(false);
MemberExpressionNode ifMemberExpression =
nodeFactory.memberExpression(ifThisExpression, hasEventListenerCallExpression);
ListNode iftest = nodeFactory.list(null, ifMemberExpression);
Node ifStatement = nodeFactory.ifStatement(iftest, expressionStatement, null);
return nodeFactory.statementList(then, ifStatement);