Example usage for org.eclipse.jdt.core.dom InfixExpression getLeftOperand

List of usage examples for org.eclipse.jdt.core.dom InfixExpression getLeftOperand

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom InfixExpression getLeftOperand.

Prototype

public Expression getLeftOperand() 

Source Link

Document

Returns the left operand of this infix expression.

Usage

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(InfixExpression node) {
    node.getLeftOperand().accept(this);
    this.fBuffer.append(' '); // for cases like x= i - -1; or x= i++ + ++i;
    this.fBuffer.append(node.getOperator().toString());
    this.fBuffer.append(' ');
    node.getRightOperand().accept(this);
    final List<Expression> extendedOperands = node.extendedOperands();
    if (extendedOperands.size() != 0) {
        this.fBuffer.append(' ');
        for (Iterator<Expression> it = extendedOperands.iterator(); it.hasNext();) {
            this.fBuffer.append(node.getOperator().toString()).append(' ');
            Expression e = it.next();
            e.accept(this);
        }//from  w  w w .j  a v a  2  s  .  c om
    }
    return false;
}

From source file:boa.datagen.util.Java7Visitor.java

License:Apache License

@Override
public boolean visit(InfixExpression node) {
    boa.types.Ast.Expression.Builder b = boa.types.Ast.Expression.newBuilder();
    //      b.setPosition(pos.build());
    if (node.getOperator() == InfixExpression.Operator.AND)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.BIT_AND);
    else if (node.getOperator() == InfixExpression.Operator.CONDITIONAL_AND)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.LOGICAL_AND);
    else if (node.getOperator() == InfixExpression.Operator.CONDITIONAL_OR)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.LOGICAL_OR);
    else if (node.getOperator() == InfixExpression.Operator.DIVIDE)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.OP_DIV);
    else if (node.getOperator() == InfixExpression.Operator.EQUALS)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.EQ);
    else if (node.getOperator() == InfixExpression.Operator.GREATER)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.GT);
    else if (node.getOperator() == InfixExpression.Operator.GREATER_EQUALS)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.GTEQ);
    else if (node.getOperator() == InfixExpression.Operator.LEFT_SHIFT)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.BIT_LSHIFT);
    else if (node.getOperator() == InfixExpression.Operator.LESS)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.LT);
    else if (node.getOperator() == InfixExpression.Operator.LESS_EQUALS)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.LTEQ);
    else if (node.getOperator() == InfixExpression.Operator.MINUS)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.OP_SUB);
    else if (node.getOperator() == InfixExpression.Operator.NOT_EQUALS)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.NEQ);
    else if (node.getOperator() == InfixExpression.Operator.OR)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.BIT_OR);
    else if (node.getOperator() == InfixExpression.Operator.PLUS)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.OP_ADD);
    else if (node.getOperator() == InfixExpression.Operator.REMAINDER)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.OP_MOD);
    else if (node.getOperator() == InfixExpression.Operator.RIGHT_SHIFT_SIGNED)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.BIT_RSHIFT);
    else if (node.getOperator() == InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.BIT_UNSIGNEDRSHIFT);
    else if (node.getOperator() == InfixExpression.Operator.TIMES)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.OP_MULT);
    else if (node.getOperator() == InfixExpression.Operator.XOR)
        b.setKind(boa.types.Ast.Expression.ExpressionKind.BIT_XOR);
    node.getLeftOperand().accept(this);
    b.addExpressions(expressions.pop());
    node.getRightOperand().accept(this);
    b.addExpressions(expressions.pop());
    for (Object e : node.extendedOperands()) {
        ((org.eclipse.jdt.core.dom.Expression) e).accept(this);
        b.addExpressions(expressions.pop());
    }/* w  w w  . ja v a  2s .c om*/
    expressions.push(b.build());
    return false;
}

From source file:ca.mcgill.cs.swevo.ppa.inference.BinaryInferenceStrategy.java

License:Open Source License

private boolean isLeftIndex(ASTNode node, TypeFact fact) {
    boolean isLeft = false;
    InfixExpression infix = (InfixExpression) node;
    Expression left = infix.getLeftOperand();

    if (indexer.isIndexable(left)) {
        isLeft = indexer.getMainIndex(left).equals(fact.getIndex());
    }/* w ww  . ja va2  s .  c  om*/

    return isLeft;
}

From source file:ca.mcgill.cs.swevo.ppa.inference.BinaryInferenceStrategy.java

License:Open Source License

@Override
public List<PPAIndex> getSecondaryIndexes(ASTNode node) {
    List<PPAIndex> list = super.getSecondaryIndexes(node);
    InfixExpression infix = (InfixExpression) node;
    Expression left = infix.getLeftOperand();
    Expression right = infix.getRightOperand();
    if (indexer.isIndexable(left)) {
        list.add(indexer.getMainIndex(left));
    }/*from  w w  w  . ja v  a  2 s . c om*/

    if (indexer.isIndexable(right)) {
        list.add(indexer.getMainIndex(right));
    }

    return list;
}

From source file:ca.mcgill.cs.swevo.ppa.inference.BinaryInferenceStrategy.java

License:Open Source License

private void processOperators(ASTNode node, TypeFact newFact) {
    InfixExpression infix = (InfixExpression) node;
    InfixExpression.Operator operator = infix.getOperator();

    //      if (node.toString().equals("falseTb == ShortBinding")) {
    //         System.out.println();
    //      }/*  ww w.j  a  v a 2  s . co  m*/

    Expression left = infix.getLeftOperand();
    Expression right = infix.getRightOperand();
    boolean isSecondaryIndex = newFact != null && isSecondary(node, newFact);
    boolean isPrimaryIndex = newFact != null && !isSecondaryIndex;

    boolean leftSafe = !PPABindingsUtil.isUnknownType(left.resolveTypeBinding())
            && (indexer.isSafe(left) || (isSecondaryIndex && isLeftIndex(node, newFact)));
    boolean rightSafe = !PPABindingsUtil.isUnknownType(right.resolveTypeBinding())
            && (indexer.isSafe(right) || (isSecondaryIndex && !isLeftIndex(node, newFact)));
    boolean leftBoolean = isBoolean(left, leftSafe);
    boolean rightBoolean = isBoolean(right, rightSafe);
    ITypeBinding newType = null;
    ITypeBinding factType = newFact != null ? newFact.getNewType() : null;

    boolean isNewType = true;

    // && and ||
    if (operator == InfixExpression.Operator.CONDITIONAL_AND
            || operator == InfixExpression.Operator.CONDITIONAL_OR) {
        if (!leftSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("boolean", left);
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
        }

        if (!rightSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("boolean", right);
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
        }
    }

    // & and |
    else if (operator == InfixExpression.Operator.AND || operator == InfixExpression.Operator.CONDITIONAL_OR
            || operator == InfixExpression.Operator.XOR) {
        if (leftBoolean && !rightSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("boolean", right);
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (rightBoolean && !leftSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("boolean", left);
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (leftSafe && !rightSafe) {
            ITypeBinding newBinding = left.resolveTypeBinding();
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (rightSafe && !leftSafe) {
            ITypeBinding newBinding = right.resolveTypeBinding();
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (!rightSafe && !leftSafe && isPrimaryIndex) {
            ITypeBinding newBinding = factType;
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newBinding = factType;
            oldBinding = right.resolveTypeBinding();
            typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN, newBinding,
                    TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        }
    }
    // << >> >>>
    else if (operator == InfixExpression.Operator.LEFT_SHIFT
            || operator == InfixExpression.Operator.RIGHT_SHIFT_SIGNED
            || operator == InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED) {
        if (!leftSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("int", left);
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
        }

        if (!rightSafe) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("int", right);
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        }
    }
    // - / * % < <= > >=
    else if (operator == InfixExpression.Operator.MINUS || operator == InfixExpression.Operator.DIVIDE
            || operator == InfixExpression.Operator.REMAINDER || operator == InfixExpression.Operator.TIMES
            || operator == InfixExpression.Operator.LESS || operator == InfixExpression.Operator.LESS_EQUALS
            || operator == InfixExpression.Operator.GREATER
            || operator == InfixExpression.Operator.GREATER_EQUALS) {
        if (leftSafe && !rightSafe) {
            ITypeBinding newBinding = left.resolveTypeBinding();
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (rightSafe && !leftSafe) {
            ITypeBinding newBinding = right.resolveTypeBinding();
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (!rightSafe && !leftSafe && !isPrimaryIndex) {
            ITypeBinding newBinding = ppaEngine.getRegistry().getPrimitiveBinding("int", left);
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);

            newBinding = ppaEngine.getRegistry().getPrimitiveBinding("int", right);
            oldBinding = right.resolveTypeBinding();
            typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN, newBinding,
                    TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        } else if (!rightSafe && !leftSafe && isPrimaryIndex) {
            ITypeBinding newBinding = factType;
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);

            newBinding = factType;
            oldBinding = right.resolveTypeBinding();
            typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN, newBinding,
                    TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            newType = newBinding;
        }
    }
    // == !=
    else if (operator == InfixExpression.Operator.EQUALS || operator == InfixExpression.Operator.NOT_EQUALS) {
        if (leftSafe && !rightSafe) {
            ITypeBinding newBinding = left.resolveTypeBinding();
            ITypeBinding oldBinding = right.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
        } else if (rightSafe && !leftSafe) {
            ITypeBinding newBinding = right.resolveTypeBinding();
            ITypeBinding oldBinding = left.resolveTypeBinding();
            TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                    newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
            isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
        }
    }
    // +
    else if (operator == InfixExpression.Operator.PLUS) {
        if (isPrimaryIndex && !factType.isPrimitive()) {
            ITypeBinding newBinding = factType;
            if (!leftSafe) {

                ITypeBinding oldBinding = left.resolveTypeBinding();
                TypeFact typeFact = new TypeFact(indexer.getMainIndex(left), oldBinding, TypeFact.UNKNOWN,
                        newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
                isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            }
            if (!rightSafe) {
                newBinding = factType;
                ITypeBinding oldBinding = right.resolveTypeBinding();
                TypeFact typeFact = new TypeFact(indexer.getMainIndex(right), oldBinding, TypeFact.UNKNOWN,
                        newBinding, TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
                isNewType = isNewType && ppaEngine.reportTypeFact(typeFact);
            }
            newType = newBinding;
        }
    }

    if (newType != null && !isPrimaryIndex && isNewType) {
        ITypeBinding oldBinding = infix.resolveTypeBinding();
        TypeFact typeFact = new TypeFact(indexer.getMainIndex(node), oldBinding, TypeFact.UNKNOWN, newType,
                TypeFact.SUBTYPE, TypeFact.BINARY_STRATEGY);
        ppaEngine.reportTypeFact(typeFact);
        // report new type for this expression.
        // fix this expression.
    } else if (isPrimaryIndex) {
        if (newType != null && isNewType) {
            ppaEngine.getRegistry().fixBinary(node, newType);
        } else if (factType != null) {
            ppaEngine.getRegistry().fixBinary(node, factType);
        }
    }
}

From source file:ca.mcgill.cs.swevo.ppa.inference.BinaryInferenceStrategy.java

License:Open Source License

public boolean isSafe(ASTNode node) {
    InfixExpression infix = (InfixExpression) node;
    boolean leftSafe = true;
    boolean rightSafe = true;

    Expression left = infix.getLeftOperand();
    Expression right = infix.getRightOperand();

    leftSafe = indexer.isSafe(left);// w  w w . j  a v  a  2  s .co  m

    rightSafe = indexer.isSafe(right);

    return leftSafe && rightSafe;
}

From source file:ch.acanda.eclipse.pmd.java.resolution.design.UseCollectionIsEmptyQuickFix.java

License:Open Source License

/**
 * Replaces {@code x.size() == 0} or {@code 0 == x.size()} with {@code x.isEmpty()}. Replaces {@code x.size() != 0}
 * or {@code 0 != x.size()} with {@code !x.isEmpty()}.
 *//*from ww  w.  j a v  a  2  s.c o m*/
@Override
protected boolean apply(final InfixExpression node) {
    final MethodInvocation size;
    if (node.getLeftOperand() instanceof MethodInvocation) {
        size = (MethodInvocation) node.getLeftOperand();
    } else if (node.getRightOperand() instanceof MethodInvocation) {
        size = (MethodInvocation) node.getRightOperand();
    } else {
        return false;
    }

    final AST ast = node.getAST();
    final MethodInvocation invocation = (MethodInvocation) ast.createInstance(MethodInvocation.class);
    invocation.setExpression(ASTUtil.copy(size.getExpression()));
    final SimpleName isEmpty = (SimpleName) ast.createInstance(SimpleName.class);
    isEmpty.setIdentifier("isEmpty");
    invocation.setName(isEmpty);

    final Expression replacement;
    if (isNotEmpty(node)) {
        final PrefixExpression not = (PrefixExpression) ast.createInstance(PrefixExpression.class);
        not.setOperator(org.eclipse.jdt.core.dom.PrefixExpression.Operator.NOT);
        not.setOperand(invocation);
        replacement = not;
    } else {
        replacement = invocation;
    }

    ASTUtil.replace(node, replacement);
    return true;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(InfixExpression node) {
    node.getLeftOperand().accept(this);
    this.buffer.append(' '); // for cases like x= i - -1; or x= i++ +
    // ++i;/*from w w  w .j  a  va 2  s.  c  o  m*/
    this.buffer.append(node.getOperator().toString());
    this.buffer.append(' ');
    node.getRightOperand().accept(this);
    final List extendedOperands = node.extendedOperands();
    if (extendedOperands.size() != 0) {
        this.buffer.append(' ');
        for (Iterator it = extendedOperands.iterator(); it.hasNext();) {
            this.buffer.append(node.getOperator().toString()).append(' ');
            Expression e = (Expression) it.next();
            e.accept(this);
        }
    }
    return false;
}

From source file:com.bsiag.eclipse.jdt.java.formatter.linewrap.WrapPreparator.java

License:Open Source License

private void findTokensToWrap(InfixExpression node, int depth) {
    Expression left = node.getLeftOperand();
    if (left instanceof InfixExpression && samePrecedence(node, (InfixExpression) left)) {
        findTokensToWrap((InfixExpression) left, depth + 1);
    } else if (this.wrapIndexes.isEmpty() // always add first operand, it will be taken as wrap parent
            || !this.options.wrap_before_binary_operator) {
        this.wrapIndexes.add(this.tm.firstIndexIn(left, -1));
    }//from   www .  j a v  a 2 s . c  om

    Expression right = node.getRightOperand();
    List<Expression> extended = node.extendedOperands();
    for (int i = -1; i < extended.size(); i++) {
        Expression operand = (i == -1) ? right : extended.get(i);
        if (operand instanceof InfixExpression && samePrecedence(node, (InfixExpression) operand)) {
            findTokensToWrap((InfixExpression) operand, depth + 1);
        }
        int indexBefore = this.tm.firstIndexBefore(operand, -1);
        while (this.tm.get(indexBefore).isComment())
            indexBefore--;
        assert node.getOperator().toString().equals(this.tm.toString(indexBefore));
        int indexAfter = this.tm.firstIndexIn(operand, -1);
        this.wrapIndexes.add(this.options.wrap_before_binary_operator ? indexBefore : indexAfter);

        if (!this.options.join_wrapped_lines) {
            // TODO there should be an option for never joining wraps on opposite side of the operator
            if (this.options.wrap_before_binary_operator) {
                if (this.tm.countLineBreaksBetween(this.tm.get(indexAfter - 1), this.tm.get(indexAfter)) > 0)
                    this.wrapIndexes.add(indexAfter);
            } else {
                if (this.tm.countLineBreaksBetween(this.tm.get(indexBefore), this.tm.get(indexBefore - 1)) > 0)
                    this.wrapIndexes.add(indexBefore);
            }
        }
    }
}

From source file:com.google.dart.java2dart.SyntaxTranslator.java

License:Open Source License

@Override
public boolean visit(org.eclipse.jdt.core.dom.InfixExpression node) {
    Expression left = translate(node.getLeftOperand());
    Expression right = translate(node.getRightOperand());
    // operator/*from  ww w .jav a2 s .co  m*/
    TokenType tokenType = null;
    org.eclipse.jdt.core.dom.InfixExpression.Operator javaOperator = node.getOperator();
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.PLUS) {
        tokenType = TokenType.PLUS;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.MINUS) {
        tokenType = TokenType.MINUS;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.TIMES) {
        tokenType = TokenType.STAR;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.DIVIDE) {
        if (isIntegerType(node.getLeftOperand()) && isIntegerType(node.getRightOperand())) {
            tokenType = TokenType.TILDE_SLASH;
        } else {
            tokenType = TokenType.SLASH;
        }
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.REMAINDER) {
        tokenType = TokenType.PERCENT;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.LEFT_SHIFT) {
        tokenType = TokenType.LT_LT;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.RIGHT_SHIFT_SIGNED
            || javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.RIGHT_SHIFT_UNSIGNED) {
        tokenType = TokenType.GT_GT;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.CONDITIONAL_OR) {
        tokenType = TokenType.BAR_BAR;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.CONDITIONAL_AND) {
        tokenType = TokenType.AMPERSAND_AMPERSAND;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.XOR) {
        tokenType = TokenType.CARET;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.OR) {
        tokenType = TokenType.BAR;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.AND) {
        tokenType = TokenType.AMPERSAND;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.LESS) {
        tokenType = TokenType.LT;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.GREATER) {
        tokenType = TokenType.GT;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.LESS_EQUALS) {
        tokenType = TokenType.LT_EQ;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.GREATER_EQUALS) {
        tokenType = TokenType.GT_EQ;
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.EQUALS) {
        if (isNumberOrNull(left) || isNumberOrNull(right)) {
            tokenType = TokenType.EQ_EQ;
        } else {
            return done(methodInvocation("identical", left, right));
        }
    }
    if (javaOperator == org.eclipse.jdt.core.dom.InfixExpression.Operator.NOT_EQUALS) {
        tokenType = TokenType.BANG_EQ;
    }
    Assert.isNotNull(tokenType, "No token for: " + javaOperator);
    // create BinaryExpression
    BinaryExpression binary = binaryExpression(left, tokenType, right);
    for (Object javaOperand : node.extendedOperands()) {
        Expression operand = translate((org.eclipse.jdt.core.dom.ASTNode) javaOperand);
        binary = binaryExpression(binary, tokenType, operand);
    }
    return done(binary);
}