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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations