Search in sources :

Example 46 with Expression

use of org.eclipse.n4js.n4JS.Expression in project n4js by eclipse.

the class SymbolFactory method create.

/**
 * This method creates a {@link Symbol} based on a synthesized {@link ParameterizedPropertyAccessExpression}. It
 * assumes that the given list is ordered from right to left, starting with the most inner context symbol and ending
 * with a {@link Symbol} of the last {@link ParameterizedPropertyAccessExpression}.
 *
 * @param baseExpression
 *            {@link Expression} that is the target of the outer most {@link ParameterizedPropertyAccessExpression}
 * @param wrappers
 *            list of Symbols that represent {@link ParameterizedPropertyAccessExpression}s
 * @return a symbol created from the given base expression and list of contexts, or {@code null} iff contexts is
 *         empty.
 */
public Symbol create(Expression baseExpression, List<Symbol> wrappers) {
    if (wrappers.isEmpty()) {
        return create(baseExpression);
    }
    Expression lastTarget = EcoreUtil.copy(baseExpression);
    for (Symbol wrapper : wrappers) {
        ParameterizedPropertyAccessExpression ppae = ((SymbolOfParameterizedPropertyAccessExpression) wrapper).ppae;
        ParameterizedPropertyAccessExpression copy = N4JSFactory.eINSTANCE.createParameterizedPropertyAccessExpression();
        copy.setProperty(ppae.getProperty());
        copy.setTarget(lastTarget);
        lastTarget = copy;
    }
    ParameterizedPropertyAccessExpression ppae = (ParameterizedPropertyAccessExpression) lastTarget;
    return new SymbolOfParameterizedPropertyAccessExpression(this, ppae);
}
Also used : ParameterizedPropertyAccessExpression(org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression) ParameterizedPropertyAccessExpression(org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression) Expression(org.eclipse.n4js.n4JS.Expression) UnaryExpression(org.eclipse.n4js.n4JS.UnaryExpression)

Example 47 with Expression

use of org.eclipse.n4js.n4JS.Expression in project n4js by eclipse.

the class SymbolOfParameterizedPropertyAccessExpression method getName.

@Override
public String getName() {
    String name = ppae.getProperty().getName();
    Expression tgtExpr = ppae.getTarget();
    Symbol tgtSymbol = symbolFactory.create(tgtExpr);
    if (tgtSymbol != null) {
        name = tgtSymbol.getName() + "." + name;
    }
    return name;
}
Also used : ParameterizedPropertyAccessExpression(org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression) Expression(org.eclipse.n4js.n4JS.Expression)

Example 48 with Expression

use of org.eclipse.n4js.n4JS.Expression in project n4js by eclipse.

the class GuardFactory method createGuardForVoid.

private static Guard createGuardForVoid(EObject topContainer, UnaryExpression ue, boolean negateTree, boolean negateEqe, Expression symbolExpr) {
    Expression voidExpr = ue.getExpression();
    if (voidExpr instanceof NumericLiteral) {
        NumericLiteral nl = (NumericLiteral) voidExpr;
        String numVal = nl.getValueAsString();
        if (!"0".equals(numVal)) {
            return null;
        }
    }
    GuardAssertion asserts = FlowAssertionFactory.getGuard(topContainer, ue.eContainer(), negateTree, negateEqe);
    Guard guard = createIsUndefinedGuard(ue, asserts, symbolExpr);
    return guard;
}
Also used : NumericLiteral(org.eclipse.n4js.n4JS.NumericLiteral) BinaryLogicalExpression(org.eclipse.n4js.n4JS.BinaryLogicalExpression) RelationalExpression(org.eclipse.n4js.n4JS.RelationalExpression) UnaryExpression(org.eclipse.n4js.n4JS.UnaryExpression) EqualityExpression(org.eclipse.n4js.n4JS.EqualityExpression) ParenExpression(org.eclipse.n4js.n4JS.ParenExpression) Expression(org.eclipse.n4js.n4JS.Expression) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) ConditionalExpression(org.eclipse.n4js.n4JS.ConditionalExpression)

Example 49 with Expression

use of org.eclipse.n4js.n4JS.Expression in project n4js by eclipse.

the class ThrowStatementImpl 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, N4JSPackage.THROW_STATEMENT__EXPRESSION, oldExpression, newExpression);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.n4js.n4JS.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 50 with Expression

use of org.eclipse.n4js.n4JS.Expression in project n4js by eclipse.

the class VariableDeclarationImpl 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, N4JSPackage.VARIABLE_DECLARATION__EXPRESSION, oldExpression, newExpression);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.n4js.n4JS.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

Expression (org.eclipse.n4js.n4JS.Expression)111 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)58 ConditionalExpression (org.eclipse.n4js.n4JS.ConditionalExpression)40 BinaryLogicalExpression (org.eclipse.n4js.n4JS.BinaryLogicalExpression)38 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)37 AssignmentExpression (org.eclipse.n4js.n4JS.AssignmentExpression)35 ParameterizedPropertyAccessExpression (org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression)33 EqualityExpression (org.eclipse.n4js.n4JS.EqualityExpression)31 ParenExpression (org.eclipse.n4js.n4JS.ParenExpression)31 RelationalExpression (org.eclipse.n4js.n4JS.RelationalExpression)31 UnaryExpression (org.eclipse.n4js.n4JS.UnaryExpression)31 AdditiveExpression (org.eclipse.n4js.n4JS.AdditiveExpression)27 BinaryBitwiseExpression (org.eclipse.n4js.n4JS.BinaryBitwiseExpression)27 IndexedAccessExpression (org.eclipse.n4js.n4JS.IndexedAccessExpression)27 MultiplicativeExpression (org.eclipse.n4js.n4JS.MultiplicativeExpression)27 ShiftExpression (org.eclipse.n4js.n4JS.ShiftExpression)27 AwaitExpression (org.eclipse.n4js.n4JS.AwaitExpression)26 CastExpression (org.eclipse.n4js.n4JS.CastExpression)26 FunctionExpression (org.eclipse.n4js.n4JS.FunctionExpression)26 NewExpression (org.eclipse.n4js.n4JS.NewExpression)26