use of org.eclipse.n4js.n4JS.Expression in project n4js by eclipse.
the class GuardFactory method createGuardForTypeof.
private static Guard createGuardForTypeof(EObject topContainer, UnaryExpression ue, boolean negateTree, boolean negateEqe, Expression rhs) {
if (rhs instanceof StringLiteral) {
StringLiteral rhsStringLit = (StringLiteral) rhs;
String lit = rhsStringLit.getValue();
if (!"undefined".equals(lit)) {
return null;
}
}
Expression typeofExpr = ue.getExpression();
if (SymbolFactory.canCreate(typeofExpr)) {
GuardAssertion asserts = FlowAssertionFactory.getGuard(topContainer, ue.eContainer(), negateTree, negateEqe);
Guard guard = createIsUndefinedGuard(ue, asserts, typeofExpr);
return guard;
}
return null;
}
use of org.eclipse.n4js.n4JS.Expression in project n4js by eclipse.
the class GuardStructureFactory method getCondition.
/**
* @return the top {@link Expression} of a {@link GuardStructure}, or null.
*/
private static Expression getCondition(ControlFlowEdge edge) {
Expression condition = null;
Node previousNode = edge.start;
ControlFlowElement previousCFE = previousNode.getControlFlowElement();
if (previousCFE instanceof ConditionalExpression) {
ConditionalExpression ce = (ConditionalExpression) previousCFE;
condition = ce.getExpression();
} else if (previousCFE instanceof BinaryLogicalExpression) {
BinaryLogicalExpression ble = (BinaryLogicalExpression) previousCFE;
condition = ble.getLhs();
} else if (previousCFE instanceof IfStatement) {
IfStatement is = (IfStatement) previousCFE;
condition = is.getExpression();
} else if (previousCFE instanceof WhileStatement) {
WhileStatement ws = (WhileStatement) previousCFE;
condition = ws.getExpression();
} else if (previousCFE instanceof DoStatement) {
DoStatement ws = (DoStatement) previousCFE;
condition = ws.getExpression();
} else if (previousCFE instanceof ForStatement) {
ForStatement ws = (ForStatement) previousCFE;
condition = ws.getExpression();
}
return condition;
}
use of org.eclipse.n4js.n4JS.Expression in project n4js by eclipse.
the class NullDereferenceAnalyser method isDereferencing.
private boolean isDereferencing(ControlFlowElement cfe) {
EObject parent = cfe.eContainer();
if (parent instanceof ParameterizedPropertyAccessExpression) {
ParameterizedPropertyAccessExpression ppae = (ParameterizedPropertyAccessExpression) parent;
Expression target = ppae.getTarget();
return cfe == target;
}
return false;
}
use of org.eclipse.n4js.n4JS.Expression in project n4js by eclipse.
the class GuardStructure method getGuardList.
private List<Guard> getGuardList() {
LinkedList<Guard> gList = new LinkedList<>();
List<Expression> allExpressions = EcoreUtil2.getAllContentsOfType(condition, Expression.class);
allExpressions.add(condition);
EObject conditionContainer = condition.eContainer();
for (Expression expr : allExpressions) {
Guard guard = GuardFactory.create(conditionContainer, expr, negate);
if (guard != null) {
gList.add(guard);
}
}
return gList;
}
use of org.eclipse.n4js.n4JS.Expression in project n4js by eclipse.
the class PostfixExpressionImpl 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.POSTFIX_EXPRESSION__EXPRESSION, oldExpression, newExpression);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
Aggregations