Search in sources :

Example 6 with Expression

use of org.eclipse.xtext.example.arithmetics.arithmetics.Expression in project xtext-eclipse by eclipse.

the class DefinitionImpl method basicSetExpr.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetExpr(Expression newExpr, NotificationChain msgs) {
    Expression oldExpr = expr;
    expr = newExpr;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ArithmeticsPackage.DEFINITION__EXPR, oldExpr, newExpr);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.xtext.example.arithmetics.arithmetics.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 7 with Expression

use of org.eclipse.xtext.example.arithmetics.arithmetics.Expression in project xtext-eclipse by eclipse.

the class DivImpl method basicSetRight.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetRight(Expression newRight, NotificationChain msgs) {
    Expression oldRight = right;
    right = newRight;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ArithmeticsPackage.DIV__RIGHT, oldRight, newRight);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.xtext.example.arithmetics.arithmetics.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 8 with Expression

use of org.eclipse.xtext.example.arithmetics.arithmetics.Expression in project xtext-eclipse by eclipse.

the class CalculatorTest method check.

protected void check(final double expected, final String expression) throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("module test ");
    _builder.append(expression);
    final org.eclipse.xtext.example.arithmetics.arithmetics.Module module = this.parseHelper.parse(_builder);
    BigDecimal result = this.calculator.evaluate(IterableExtensions.<Expression>head(Iterables.<Expression>filter(IterableExtensions.<Statement>head(module.getStatements()).eContents(), Expression.class)));
    Assert.assertEquals(expected, result.doubleValue(), 0.0001);
}
Also used : Expression(org.eclipse.xtext.example.arithmetics.arithmetics.Expression) Statement(org.eclipse.xtext.example.arithmetics.arithmetics.Statement) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) BigDecimal(java.math.BigDecimal)

Example 9 with Expression

use of org.eclipse.xtext.example.arithmetics.arithmetics.Expression in project xtext-eclipse by eclipse.

the class EvaluationImpl 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, ArithmeticsPackage.EVALUATION__EXPRESSION, oldExpression, newExpression);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.xtext.example.arithmetics.arithmetics.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 10 with Expression

use of org.eclipse.xtext.example.arithmetics.arithmetics.Expression in project xtext-eclipse by eclipse.

the class PlusImpl method basicSetRight.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetRight(Expression newRight, NotificationChain msgs) {
    Expression oldRight = right;
    right = newRight;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ArithmeticsPackage.PLUS__RIGHT, oldRight, newRight);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.xtext.example.arithmetics.arithmetics.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

Expression (org.eclipse.xtext.example.arithmetics.arithmetics.Expression)12 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)10 BigDecimal (java.math.BigDecimal)2 Statement (org.eclipse.xtext.example.arithmetics.arithmetics.Statement)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 Module (org.eclipse.xtext.example.arithmetics.arithmetics.Module)1