use of com.github.javaparser.ast.expr.BinaryExpr in project drools by kiegroup.
the class DrlxParseUtil method trasformHalfBinaryToBinary.
public static Expression trasformHalfBinaryToBinary(Expression drlxExpr) {
final Optional<Node> parent = drlxExpr.getParentNode();
if (drlxExpr instanceof HalfBinaryExpr && parent.isPresent()) {
HalfBinaryExpr halfBinaryExpr = (HalfBinaryExpr) drlxExpr;
Expression parentLeft = findLeftLeafOfNameExprTraversingParent(halfBinaryExpr);
Operator operator = toBinaryExprOperator(halfBinaryExpr.getOperator());
return new BinaryExpr(parentLeft, halfBinaryExpr.getRight(), operator);
}
return drlxExpr;
}
use of com.github.javaparser.ast.expr.BinaryExpr in project checker-framework by typetools.
the class DoubleJavaParserVisitor method visit.
@Override
public void visit(final BinaryExpr node1, final Node other) {
BinaryExpr node2 = (BinaryExpr) other;
defaultAction(node1, node2);
node1.getLeft().accept(this, node2.getLeft());
node1.getRight().accept(this, node2.getRight());
}
use of com.github.javaparser.ast.expr.BinaryExpr in project vue-gwt by Axellience.
the class TemplateParser method getTypeFromCast.
/**
* Get the type of an expression from the cast at the beginning.
* (int) 12 -> 12 of type int
* (int) 15 + 5 -> 15 + 5 of type int
* (float) (12 + 3) -> 12 + 3 of type float
* ((int) 12) + 3 -> ((int) 12) + 3 of type Any
* ((JsArray) myArray).getAt(0) -> ((JsArray) myArray).getAt(0) of type Any
* @param expression The expression to process
* @return The modified expression (where cast has been removed if necessary)
*/
private Expression getTypeFromCast(Expression expression) {
if (expression instanceof BinaryExpr) {
Expression mostLeft = getLeftmostExpression(expression);
if (mostLeft instanceof CastExpr) {
CastExpr castExpr = (CastExpr) mostLeft;
currentExpressionReturnType = stringTypeToTypeName(castExpr.getType().toString());
BinaryExpr parent = (BinaryExpr) mostLeft.getParentNode().get();
parent.setLeft(castExpr.getExpression());
}
} else if (expression instanceof CastExpr) {
CastExpr castExpr = (CastExpr) expression;
currentExpressionReturnType = stringTypeToTypeName(castExpr.getType().toString());
expression = castExpr.getExpression();
}
return expression;
}
Aggregations