use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class FoldOutgoingActionsRefactoring method getFoldableActions.
private List<Expression> getFoldableActions(EList<Transition> transitions) {
List<Expression> foldableActions = new ArrayList<Expression>();
Expression firstFoldableAction;
int index = 0;
while ((firstFoldableAction = getFirstFoldableAction(helper.getAllActions(transitions), index)) != null) {
foldableActions.add(firstFoldableAction);
index++;
}
removeFirstActions(transitions, index);
return foldableActions;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class FoldOutgoingActionsRefactoring method removeFirstActions.
private void removeFirstActions(EList<Transition> transitions, int number) {
for (Transition transition : transitions) {
List<Expression> actionsToRemove = getFirstActions(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 ExpressionsJavaValidator method checkAssignmentToFinalVariable.
@Check(CheckType.FAST)
public void checkAssignmentToFinalVariable(AssignmentExpression exp) {
Expression varRef = exp.getVarRef();
EObject referencedObject = null;
if (varRef instanceof FeatureCall)
referencedObject = ((FeatureCall) varRef).getFeature();
else if (varRef instanceof ElementReferenceExpression)
referencedObject = ((ElementReferenceExpression) varRef).getReference();
if (referencedObject instanceof Property) {
if (((Property) referencedObject).isConst()) {
error(ERROR_ASSIGNMENT_TO_CONST_MSG, ExpressionsPackage.Literals.ASSIGNMENT_EXPRESSION__VAR_REF, ERROR_ASSIGNMENT_TO_CONST_CODE);
}
}
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class STextScopeProvider method scope_FeatureCall_feature.
public IScope scope_FeatureCall_feature(final FeatureCall context, EReference reference) {
Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
Expression owner = context.getOwner();
EObject element = null;
if (owner instanceof ElementReferenceExpression) {
element = ((ElementReferenceExpression) owner).getReference();
} else if (owner instanceof FeatureCall) {
element = ((FeatureCall) owner).getFeature();
} else {
return getDelegate().getScope(context, reference);
}
IScope scope = IScope.NULLSCOPE;
InferenceResult result = typeInferrer.infer(owner);
Type ownerType = result != null ? result.getType() : null;
if (element instanceof Scope) {
scope = Scopes.scopeFor(((Scope) element).getDeclarations());
return new FilteringScope(scope, predicate);
} else if (ownerType != null) {
scope = Scopes.scopeFor(typeSystem.getPropertyExtensions(ownerType));
scope = Scopes.scopeFor(typeSystem.getOperationExtensions(ownerType), scope);
}
if (ownerType instanceof ComplexType) {
return addScopeForComplexType((ComplexType) ownerType, scope, predicate);
}
if (ownerType instanceof EnumerationType) {
return addScopeForEnumType((EnumerationType) ownerType, scope, predicate);
}
return scope;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class FoldIncomingActionsRefactoring method createEntryBlock.
private EList<Expression> createEntryBlock(List<Expression> actionsToAdd) {
EList<Expression> actionsOriginal;
LocalReaction newLocalReaction = StextFactory.eINSTANCE.createLocalReaction();
ReactionTrigger newReactionTrigger = StextFactory.eINSTANCE.createReactionTrigger();
EntryEvent entryEvent = StextFactory.eINSTANCE.createEntryEvent();
ReactionEffect newReactionEffect = StextFactory.eINSTANCE.createReactionEffect();
newLocalReaction.setTrigger(newReactionTrigger);
newReactionTrigger.getTriggers().add(entryEvent);
newReactionEffect.getActions().addAll(actionsToAdd);
newLocalReaction.setEffect(newReactionEffect);
Scope scope = getContextObject().getScopes().get(0);
scope.getReactions().add(newLocalReaction);
actionsOriginal = newReactionEffect.getActions();
return actionsOriginal;
}
Aggregations