use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class FoldIncomingActionsRefactoring method getLastActions.
private List<Expression> getLastActions(Transition transition, int number) {
List<Expression> lastActions = new ArrayList<Expression>();
Effect effect = transition.getEffect();
if (effect instanceof ReactionEffect) {
ReactionEffect reactionEffect = (ReactionEffect) effect;
List<Expression> actions = reactionEffect.getActions();
for (int i = 1; i <= number; i++) {
lastActions.add(actions.get(actions.size() - i));
}
}
return lastActions;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class FoldIncomingActionsRefactoring method removeLastActions.
private void removeLastActions(EList<Transition> transitions, int number) {
for (Transition transition : transitions) {
List<Expression> actionsToRemove = getLastActions(transition, number);
Effect effect = transition.getEffect();
if (effect instanceof ReactionEffect && actionsToRemove.size() == ((ReactionEffect) effect).getActions().size()) {
// we need to remove all actions, so just remove the effect
// recursively which avoids serializer exceptions
EcoreUtil.delete(effect, true);
} else {
for (Expression action : actionsToRemove) {
EcoreUtil.delete(action);
}
}
}
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class FoldIncomingActionsRefactoring method getFoldableActions.
private List<Expression> getFoldableActions() {
EList<Transition> transitions = getContextObject().getIncomingTransitions();
List<Expression> foldableActions = new ArrayList<Expression>();
Expression lastFoldableAction;
int indexFromBack = 0;
while ((lastFoldableAction = getLastFoldableAction(helper.getAllActions(transitions), indexFromBack)) != null) {
foldableActions.add(0, lastFoldableAction);
indexFromBack++;
}
removeLastActions(transitions, indexFromBack);
return foldableActions;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class ArgumentSorter method getOrderedExpressions.
public static EList<Expression> getOrderedExpressions(List<Argument> arguments, Operation operation) {
Expression[] result = new Expression[arguments.size()];
for (int index = 0; index < arguments.size(); index++) {
Argument argument = arguments.get(index);
List<INode> nodes = NodeModelUtils.findNodesForFeature(argument, ExpressionsPackage.Literals.ARGUMENT__PARAMETER);
if (nodes.isEmpty()) {
result[index] = argument.getValue();
} else {
// EcoreUtil.equals.)
for (Parameter param : operation.getParameters()) {
if (param.getName().equals(nodes.get(0).getText())) {
int parameterIndex = operation.getParameters().indexOf(param);
if (parameterIndex < result.length)
result[parameterIndex] = argument.getValue();
break;
}
}
}
}
EList<Expression> resultAsList = new BasicEList<Expression>();
for (int i = 0; i < result.length; i++) {
Expression expression = result[i];
if (expression != null)
resultAsList.add(expression);
}
return resultAsList;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class AssignmentExpressionImpl method basicSetVarRef.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetVarRef(Expression newVarRef, NotificationChain msgs) {
Expression oldVarRef = varRef;
varRef = newVarRef;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExpressionsPackage.ASSIGNMENT_EXPRESSION__VAR_REF, oldVarRef, newVarRef);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
Aggregations