switch (binary.getOperator()) { case EQUALITY: binary.setOperator(BinaryOperatorType.INEQUALITY); break; binary.setOperator(BinaryOperatorType.EQUALITY); break; binary.setOperator(BinaryOperatorType.LESS_THAN_OR_EQUAL); break; binary.setOperator(BinaryOperatorType.LESS_THAN); break; binary.setOperator(BinaryOperatorType.GREATER_THAN_OR_EQUAL); break; binary.setOperator(BinaryOperatorType.GREATER_THAN); break; return binary.acceptVisitor(this, p); switch (binary.getOperator()) { case LOGICAL_AND: binary.setOperator(BinaryOperatorType.LOGICAL_OR); break; binary.setOperator(BinaryOperatorType.LOGICAL_AND); break;
public final JavaTokenNode getOperatorToken() { return getChildByRole(getOperatorRole(getOperator())); }
@Override public boolean matches(final INode other, final Match match) { if (other instanceof BinaryOperatorExpression) { final BinaryOperatorExpression otherExpression = (BinaryOperatorExpression) other; return !otherExpression.isNull() && (otherExpression._operator == _operator || _operator == BinaryOperatorType.ANY || otherExpression._operator == BinaryOperatorType.ANY) && getLeft().matches(otherExpression.getLeft(), match) && getRight().matches(otherExpression.getRight(), match); } return false; }
@Override public boolean matches(final INode other, final Match match) { if (_matchWithoutOperator || other instanceof BinaryOperatorExpression) { INode current = other; while (current instanceof BinaryOperatorExpression && (_operatorType == BinaryOperatorType.ANY || ((BinaryOperatorExpression) current).getOperator() == _operatorType)) { current = ((BinaryOperatorExpression) current).getLeft(); } return current != null && _operandPattern.matches(current, match); } return false; } }
@Override public Void visitBinaryOperatorExpression(final BinaryOperatorExpression node, final Void data) { final TypeReference leftType = getType(node.getLeft()); final TypeReference rightType = getType(node.getRight()); processBinaryExpressionOperand(node.getLeft(), rightType, node.getOperator()); processBinaryExpressionOperand(node.getRight(), leftType, node.getOperator()); return super.visitBinaryOperatorExpression(node, data); }
@Override public AstNode visitBinaryOperatorExpression(final BinaryOperatorExpression node, final Void data) { final BinaryOperatorType operator = node.getOperator(); final Expression left = node.getLeft(); final Expression right = node.getRight(); return new PrimitiveExpression( node.getOffset(), (TRUE_CONSTANT.matches(left) == TRUE_CONSTANT.matches(right)) ^ operator == BinaryOperatorType.INEQUALITY : right; node.replaceWith(replacement); : left; node.replaceWith(replacement);
super.visitBinaryOperatorExpression(node, data); final BinaryOperatorType operator = node.getOperator(); final ResolveResult leftResult = _resolver.apply(node.getLeft()); if (node.getRight() instanceof PrimitiveExpression) { final PrimitiveExpression right = (PrimitiveExpression) node.getRight(); final boolean isNegative; right.setValue(negatedValue); node.setOperator( operator == BinaryOperatorType.ADD ? BinaryOperatorType.SUBTRACT : BinaryOperatorType.ADD if (node.getRight() instanceof PrimitiveExpression) { final Expression left = node.getLeft(); final PrimitiveExpression right = (PrimitiveExpression) node.getRight(); ); node.replaceWith(replacement);
@Override public Void visitBinaryOperatorExpression(final BinaryOperatorExpression node, final Void ignored) { startNode(node); node.getLeft().acceptVisitor(this, ignored); switch (node.getOperator()) { case BITWISE_AND: case BITWISE_OR: writeToken(BinaryOperatorExpression.getOperatorRole(node.getOperator())); space(spacePolicy); node.getRight().acceptVisitor(this, ignored); endNode(node); return null;
@Override public AstNode apply(final AstNode input) { return new BinaryOperatorExpression( operand, BinaryOperatorType.INEQUALITY, new PrimitiveExpression(Expression.MYSTERY_OFFSET, JavaPrimitiveCast.cast(comparandType.getSimpleType(), 0)) ); } }
if (binary.getLeft() instanceof NullReferenceExpression || binary.getRight() instanceof NullReferenceExpression) { final ResolveResult leftResult = _resolver.apply(binary.getLeft()); final ResolveResult rightResult = _resolver.apply(binary.getRight()); leftResult.getType() != null && rightResult.getType() != null && (node == binary.getLeft() ? rightResult.getType().isPrimitive() : leftResult.getType().isPrimitive());
private static BinaryOperatorType getBinaryOperatorType(final Expression e) { if (e instanceof BinaryOperatorExpression) { return ((BinaryOperatorExpression) e).getOperator(); } return null; }
public final Expression getRight() { return getChildByRole(RIGHT_ROLE); }
@Override public Void visitBinaryOperatorExpression(final BinaryOperatorExpression node, final Void data) { final TypeReference leftType = getType(node.getLeft()); final TypeReference rightType = getType(node.getRight()); processBinaryExpressionOperand(node.getLeft(), rightType, node.getOperator()); processBinaryExpressionOperand(node.getRight(), leftType, node.getOperator()); return super.visitBinaryOperatorExpression(node, data); }
@Override public AstNode visitBinaryOperatorExpression(final BinaryOperatorExpression node, final Void data) { final BinaryOperatorType operator = node.getOperator(); final Expression left = node.getLeft(); final Expression right = node.getRight(); return new PrimitiveExpression( node.getOffset(), (TRUE_CONSTANT.matches(left) == TRUE_CONSTANT.matches(right)) ^ operator == BinaryOperatorType.INEQUALITY : right; node.replaceWith(replacement); : left; node.replaceWith(replacement);
super.visitBinaryOperatorExpression(node, data); final BinaryOperatorType operator = node.getOperator(); final ResolveResult leftResult = _resolver.apply(node.getLeft()); if (node.getRight() instanceof PrimitiveExpression) { final PrimitiveExpression right = (PrimitiveExpression) node.getRight(); final boolean isNegative; right.setValue(negatedValue); node.setOperator( operator == BinaryOperatorType.ADD ? BinaryOperatorType.SUBTRACT : BinaryOperatorType.ADD if (node.getRight() instanceof PrimitiveExpression) { final Expression left = node.getLeft(); final PrimitiveExpression right = (PrimitiveExpression) node.getRight(); ); node.replaceWith(replacement);
@Override public Void visitBinaryOperatorExpression(final BinaryOperatorExpression node, final Void ignored) { startNode(node); node.getLeft().acceptVisitor(this, ignored); switch (node.getOperator()) { case BITWISE_AND: case BITWISE_OR: writeToken(BinaryOperatorExpression.getOperatorRole(node.getOperator())); space(spacePolicy); node.getRight().acceptVisitor(this, ignored); endNode(node); return null;
@Override public AstNode apply(final AstNode input) { return new BinaryOperatorExpression( operand, BinaryOperatorType.INEQUALITY, new PrimitiveExpression(Expression.MYSTERY_OFFSET, JavaPrimitiveCast.cast(comparandType.getSimpleType(), 0)) ); } }
@Override public boolean matches(final INode other, final Match match) { if (_matchWithoutOperator || other instanceof BinaryOperatorExpression) { INode current = other; while (current instanceof BinaryOperatorExpression && (_operatorType == BinaryOperatorType.ANY || ((BinaryOperatorExpression) current).getOperator() == _operatorType)) { current = ((BinaryOperatorExpression) current).getLeft(); } return current != null && _operandPattern.matches(current, match); } return false; } }
if (binary.getLeft() instanceof NullReferenceExpression || binary.getRight() instanceof NullReferenceExpression) { final ResolveResult leftResult = _resolver.apply(binary.getLeft()); final ResolveResult rightResult = _resolver.apply(binary.getRight()); leftResult.getType() != null && rightResult.getType() != null && (node == binary.getLeft() ? rightResult.getType().isPrimitive() : leftResult.getType().isPrimitive());