Search in sources :

Example 21 with Expression

use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.

the class ModelSequencerStateReactionTest method testAlwaysTriggerCondition.

/**
 * The 'always' trigger event will be converted to a simple 'true'
 * condition.
 */
@Test
public void testAlwaysTriggerCondition() {
    ReactionTrigger tr1 = _createReactionTrigger(null);
    _createAlwaysEventSpec(tr1);
    Expression s = behaviorMapping.buildCondition(tr1);
    assertNotNull(s);
    assertTrue(s instanceof PrimitiveValueExpression);
    assertBoolLiteral(true, ((PrimitiveValueExpression) s).getValue());
}
Also used : StextTestFactory._createReactionTrigger(org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionTrigger) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) LogicalAndExpression(org.yakindu.base.expressions.expressions.LogicalAndExpression) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) LogicalOrExpression(org.yakindu.base.expressions.expressions.LogicalOrExpression) NumericalMultiplyDivideExpression(org.yakindu.base.expressions.expressions.NumericalMultiplyDivideExpression) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) StextTestFactory.createGuardExpression(org.yakindu.sct.model.stext.test.util.StextTestFactory.createGuardExpression) Expression(org.yakindu.base.expressions.expressions.Expression) ParenthesizedExpression(org.yakindu.base.expressions.expressions.ParenthesizedExpression) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression) Test(org.junit.Test)

Example 22 with Expression

use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.

the class ModelSequencerStateReactionTest method testSingleRegularEventTriggerCondition.

/**
 * Single trigger events of a Reaction Trigger will be converted into a
 * single condition that consists of a ElementReferenceExpression to the
 * corresponding event definition.
 */
@Test
public void testSingleRegularEventTriggerCondition() {
    EventDefinition e1 = _createEventDefinition("e1", null);
    ReactionTrigger tr1 = _createReactionTrigger(null);
    _createRegularEventSpec(e1, tr1);
    Expression s = behaviorMapping.buildCondition(tr1);
    assertClass(ElementReferenceExpression.class, s);
}
Also used : StextTestFactory._createReactionTrigger(org.yakindu.sct.model.stext.test.util.StextTestFactory._createReactionTrigger) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) LogicalAndExpression(org.yakindu.base.expressions.expressions.LogicalAndExpression) AssignmentExpression(org.yakindu.base.expressions.expressions.AssignmentExpression) LogicalOrExpression(org.yakindu.base.expressions.expressions.LogicalOrExpression) NumericalMultiplyDivideExpression(org.yakindu.base.expressions.expressions.NumericalMultiplyDivideExpression) ElementReferenceExpression(org.yakindu.base.expressions.expressions.ElementReferenceExpression) StextTestFactory.createGuardExpression(org.yakindu.sct.model.stext.test.util.StextTestFactory.createGuardExpression) Expression(org.yakindu.base.expressions.expressions.Expression) ParenthesizedExpression(org.yakindu.base.expressions.expressions.ParenthesizedExpression) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression) StextTestFactory._createEventDefinition(org.yakindu.sct.model.stext.test.util.StextTestFactory._createEventDefinition) EventDefinition(org.yakindu.sct.model.stext.stext.EventDefinition) Test(org.junit.Test)

Example 23 with Expression

use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.

the class STextJavaValidatorTest method checkAssignmentExpression.

/**
 * @see STextJavaValidator#checkAssignmentExpression(org.yakindu.sct.model.stext.stext.AssignmentExpression)
 */
@Test
public void checkAssignmentExpression() {
    String context = "interface: var i : integer = 42 var j : integer =23";
    EObject expression = super.parseExpression("i += (i+=3) +4", Expression.class.getSimpleName(), context);
    AssertableDiagnostics validationResult = tester.validate(expression);
    validationResult.assertErrorContains(STextJavaValidator.ASSIGNMENT_EXPRESSION);
    expression = super.parseExpression("i += (j+=3) +4", Expression.class.getSimpleName(), context);
    validationResult = tester.validate(expression);
    validationResult.assertOK();
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) Expression(org.yakindu.base.expressions.expressions.Expression) EObject(org.eclipse.emf.ecore.EObject) Test(org.junit.Test)

Example 24 with Expression

use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.

the class ScheduleTimeEventImpl method basicSetTimeValue.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetTimeValue(Expression newTimeValue, NotificationChain msgs) {
    Expression oldTimeValue = timeValue;
    timeValue = newTimeValue;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SexecPackage.SCHEDULE_TIME_EVENT__TIME_VALUE, oldTimeValue, newTimeValue);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.yakindu.base.expressions.expressions.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 25 with Expression

use of org.yakindu.base.expressions.expressions.Expression in project statecharts by Yakindu.

the class FeatureParameterValueImpl method basicSetExpression.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetExpression(Expression newExpression, NotificationChain msgs) {
    Expression oldExpression = expression;
    expression = newExpression;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SGenPackage.FEATURE_PARAMETER_VALUE__EXPRESSION, oldExpression, newExpression);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.yakindu.base.expressions.expressions.Expression) PrimitiveValueExpression(org.yakindu.base.expressions.expressions.PrimitiveValueExpression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

Expression (org.yakindu.base.expressions.expressions.Expression)48 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)24 AssignmentExpression (org.yakindu.base.expressions.expressions.AssignmentExpression)11 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)10 ReactionEffect (org.yakindu.sct.model.stext.stext.ReactionEffect)9 EObject (org.eclipse.emf.ecore.EObject)7 FeatureCall (org.yakindu.base.expressions.expressions.FeatureCall)6 PrimitiveValueExpression (org.yakindu.base.expressions.expressions.PrimitiveValueExpression)6 Effect (org.yakindu.sct.model.sgraph.Effect)6 ArrayList (java.util.ArrayList)5 ParenthesizedExpression (org.yakindu.base.expressions.expressions.ParenthesizedExpression)5 PostFixUnaryExpression (org.yakindu.base.expressions.expressions.PostFixUnaryExpression)5 ReactionTrigger (org.yakindu.sct.model.stext.stext.ReactionTrigger)5 Test (org.junit.Test)4 ConditionalExpression (org.yakindu.base.expressions.expressions.ConditionalExpression)4 LogicalAndExpression (org.yakindu.base.expressions.expressions.LogicalAndExpression)4 LogicalOrExpression (org.yakindu.base.expressions.expressions.LogicalOrExpression)4 NumericalMultiplyDivideExpression (org.yakindu.base.expressions.expressions.NumericalMultiplyDivideExpression)4 Scope (org.yakindu.sct.model.sgraph.Scope)4 Transition (org.yakindu.sct.model.sgraph.Transition)4