use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class CheckImpl method basicSetCondition.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCondition(Expression newCondition, NotificationChain msgs) {
Expression oldCondition = condition;
condition = newCondition;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SexecPackage.CHECK__CONDITION, oldCondition, newCondition);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class FoldOutgoingActionsRefactoring method createExitBlock.
private EList<Expression> createExitBlock(List<Expression> actionsToAdd) {
EList<Expression> actionsOriginal;
LocalReaction newLocalReaction = StextFactory.eINSTANCE.createLocalReaction();
ReactionTrigger newReactionTrigger = StextFactory.eINSTANCE.createReactionTrigger();
ExitEvent exitEvent = StextFactory.eINSTANCE.createExitEvent();
ReactionEffect newReactionEffect = StextFactory.eINSTANCE.createReactionEffect();
newLocalReaction.setTrigger(newReactionTrigger);
newReactionTrigger.getTriggers().add(exitEvent);
newReactionEffect.getActions().addAll(actionsToAdd);
newLocalReaction.setEffect(newReactionEffect);
Scope scope = getContextObject().getScopes().get(0);
scope.getReactions().add(newLocalReaction);
actionsOriginal = newReactionEffect.getActions();
return actionsOriginal;
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class STextJavaValidator method checkValueDefinitionExpression.
@Check(CheckType.FAST)
public void checkValueDefinitionExpression(VariableDefinition definition) {
// applies only to constants
if (!definition.isConst())
return;
Expression initialValue = definition.getInitialValue();
if (initialValue == null) {
error(CONST_MUST_HAVE_VALUE_MSG, definition, null, CONST_MUST_HAVE_VALUE_CODE);
return;
}
List<Expression> toCheck = Lists.newArrayList(initialValue);
TreeIterator<EObject> eAllContents = initialValue.eAllContents();
while (eAllContents.hasNext()) {
EObject next = eAllContents.next();
if (next instanceof Expression)
toCheck.add((Expression) next);
}
for (Expression expression : toCheck) {
EObject referencedObject = null;
if (expression instanceof FeatureCall)
referencedObject = ((FeatureCall) expression).getFeature();
else if (expression instanceof ElementReferenceExpression)
referencedObject = ((ElementReferenceExpression) expression).getReference();
if (referencedObject instanceof VariableDefinition) {
if (!((VariableDefinition) referencedObject).isConst()) {
error(REFERENCE_TO_VARIABLE, StextPackage.Literals.VARIABLE_DEFINITION__INITIAL_VALUE);
}
}
}
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class STextJavaValidator method checkValueReferenedBeforeDefined.
@Check(CheckType.NORMAL)
public void checkValueReferenedBeforeDefined(Scope scope) {
EList<Declaration> declarations = scope.getDeclarations();
Set<QualifiedName> defined = Sets.newHashSet();
for (Declaration declaration : declarations) {
if (declaration instanceof VariableDefinition) {
VariableDefinition definition = (VariableDefinition) declaration;
if (!definition.isConst())
return;
Expression initialValue = definition.getInitialValue();
List<Expression> toCheck = Lists.newArrayList(initialValue);
TreeIterator<EObject> eAllContents = initialValue.eAllContents();
while (eAllContents.hasNext()) {
EObject next = eAllContents.next();
if (next instanceof Expression)
toCheck.add((Expression) next);
}
for (Expression expression : toCheck) {
EObject referencedObject = null;
if (expression instanceof FeatureCall)
referencedObject = ((FeatureCall) expression).getFeature();
else if (expression instanceof ElementReferenceExpression)
referencedObject = ((ElementReferenceExpression) expression).getReference();
if (referencedObject instanceof VariableDefinition) {
if (!defined.contains(nameProvider.getFullyQualifiedName(referencedObject)))
error(REFERENCE_CONSTANT_BEFORE_DEFINED, definition, StextPackage.Literals.VARIABLE_DEFINITION__INITIAL_VALUE);
}
}
defined.add(nameProvider.getFullyQualifiedName(definition));
}
}
}
use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.
the class STextJavaValidator method checkValueOfNoEvent.
@Check(CheckType.FAST)
public void checkValueOfNoEvent(EventValueReferenceExpression exp) {
Expression eventExpr = exp.getValue();
EObject element = null;
if (eventExpr instanceof ElementReferenceExpression) {
element = ((ElementReferenceExpression) eventExpr).getReference();
} else if (eventExpr instanceof FeatureCall) {
element = ((FeatureCall) eventExpr).getFeature();
}
if (element != null && (!(element instanceof Event))) {
String elementName = "";
if (element instanceof NamedElement) {
elementName = "'" + ((NamedElement) element).getName() + "' ";
}
error(elementName + "is no event.", StextPackage.Literals.EVENT_VALUE_REFERENCE_EXPRESSION__VALUE, 0, VALUE_OF_REQUIRES_EVENT);
}
}
Aggregations