use of org.eclipse.n4js.n4JS.Statement in project n4js by eclipse.
the class BinaryLogicalExpressionFactory method isTopJumpCatcher.
/**
* Short circuit evaluation of a {@link BinaryLogicalExpression} <i>ble</i> causes jumps that start at a lhs
* condition and jump e.g. directly into the then or else block. However, sometimes this jump does not target such a
* then or else block, for instance when <i>ble</i> is not used as a condition. In this case, the <i>ble</i> itself
* or one of its parents will catch the short circuit jump.
* <p>
* This method returns true if the given {@link BinaryLogicalExpression} is catching a jump that is caused by a
* short circuit evaluation. It returns false, if there is a parent element that will catch the jump instead.
*/
private static boolean isTopJumpCatcher(BinaryLogicalExpression ble) {
EObject child, parent = ble;
do {
// skip parentheses
child = parent;
parent = parent.eContainer();
} while (parent instanceof ParenExpression);
if (parent instanceof BinaryLogicalExpression) {
return false;
}
if (parent instanceof ConditionalExpression) {
ConditionalExpression isParent = (ConditionalExpression) parent;
return isParent.getExpression() != child;
}
if (parent instanceof Statement) {
if (parent instanceof IfStatement) {
IfStatement isParent = (IfStatement) parent;
return isParent.getExpression() != child;
}
if (parent instanceof ForStatement) {
ForStatement isParent = (ForStatement) parent;
return isParent.getExpression() != child || !isParent.isForPlain();
}
if (parent instanceof WhileStatement) {
WhileStatement isParent = (WhileStatement) parent;
return isParent.getExpression() != child;
}
if (parent instanceof DoStatement) {
DoStatement isParent = (DoStatement) parent;
return isParent.getExpression() != child;
}
}
return true;
}
use of org.eclipse.n4js.n4JS.Statement in project n4js by eclipse.
the class WithStatementImpl method basicSetStatement.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetStatement(Statement newStatement, NotificationChain msgs) {
Statement oldStatement = statement;
statement = newStatement;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, N4JSPackage.WITH_STATEMENT__STATEMENT, oldStatement, newStatement);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.eclipse.n4js.n4JS.Statement in project n4js by eclipse.
the class IfStatementImpl method basicSetElseStmt.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetElseStmt(Statement newElseStmt, NotificationChain msgs) {
Statement oldElseStmt = elseStmt;
elseStmt = newElseStmt;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, N4JSPackage.IF_STATEMENT__ELSE_STMT, oldElseStmt, newElseStmt);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.eclipse.n4js.n4JS.Statement in project n4js by eclipse.
the class ForStatementImpl method basicSetStatement.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetStatement(Statement newStatement, NotificationChain msgs) {
Statement oldStatement = statement;
statement = newStatement;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, N4JSPackage.FOR_STATEMENT__STATEMENT, oldStatement, newStatement);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.eclipse.n4js.n4JS.Statement in project n4js by eclipse.
the class PrettyPrinterSwitch method caseIfStatement.
@Override
public Boolean caseIfStatement(IfStatement original) {
write("if (");
process(original.getExpression());
write(") ");
final Statement ifStmnt = original.getIfStmt();
processInBlock(ifStmnt);
final Statement elseStmnt = original.getElseStmt();
if (elseStmnt != null) {
write(" else ");
if (elseStmnt instanceof IfStatement) {
// don't enforce block in this case to better support "else if"
process(elseStmnt);
} else {
processInBlock(elseStmnt);
}
}
return DONE;
}
Aggregations