Example usage for org.eclipse.jdt.core.dom InfixExpression.Operator toString

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

Introduction

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

Prototype

@Override
public final String toString() 

Source Link

Document

Returns a string representation of this node suitable for debugging purposes only.

Usage

From source file:com.google.devtools.j2objc.gen.StatementGenerator.java

License:Open Source License

@Override
public boolean visit(InfixExpression node) {
    InfixExpression.Operator op = node.getOperator();
    Expression lhs = node.getLeftOperand();
    Expression rhs = node.getRightOperand();
    List<Expression> extendedOperands = node.getExtendedOperands();
    if ((op.equals(InfixExpression.Operator.EQUALS) || op.equals(InfixExpression.Operator.NOT_EQUALS))
            && (lhs instanceof StringLiteral || rhs instanceof StringLiteral)) {
        Expression first = lhs;/*  www  .j  ava 2  s . c om*/
        Expression second = rhs;
        if (!(lhs instanceof StringLiteral)) {
            // In case the lhs can't call isEqual.
            first = rhs;
            second = lhs;
        }
        buffer.append(op.equals(InfixExpression.Operator.NOT_EQUALS) ? "![" : "[");
        first.accept(this);
        buffer.append(" isEqual:");
        second.accept(this);
        buffer.append("]");
    } else {
        lhs.accept(this);
        buffer.append(' ');
        buffer.append(op.toString());
        buffer.append(' ');
        rhs.accept(this);
        for (Iterator<Expression> it = extendedOperands.iterator(); it.hasNext();) {
            buffer.append(' ').append(op.toString()).append(' ');
            it.next().accept(this);
        }
    }
    return false;
}

From source file:org.eclipse.xtend.core.javaconverter.JavaASTFlattener.java

License:Open Source License

public StringBuffer handleInfixRightSide(final InfixExpression infixParent,
        final InfixExpression.Operator operator, final Expression rightSide) {
    StringBuffer _switchResult = null;
    boolean _matched = false;
    if (Objects.equal(operator, InfixExpression.Operator.XOR)) {
        _matched = true;//www.ja  v  a2 s.  c om
        StringBuffer _xifexpression = null;
        boolean _isBooleanInvolved = this.isBooleanInvolved(infixParent);
        if (_isBooleanInvolved) {
            StringBuffer _xblockexpression = null;
            {
                this.appendToBuffer(".xor(");
                rightSide.accept(this);
                _xblockexpression = this.appendToBuffer(")");
            }
            _xifexpression = _xblockexpression;
        } else {
            StringBuffer _xblockexpression_1 = null;
            {
                this.appendToBuffer(".bitwiseXor(");
                rightSide.accept(this);
                _xblockexpression_1 = this.appendToBuffer(")");
            }
            _xifexpression = _xblockexpression_1;
        }
        _switchResult = _xifexpression;
    }
    if (!_matched) {
        if (Objects.equal(operator, InfixExpression.Operator.AND)) {
            _matched = true;
        }
        if (!_matched) {
            if (Objects.equal(operator, InfixExpression.Operator.OR)) {
                _matched = true;
            }
        }
        if (_matched) {
            StringBuffer _xifexpression_1 = null;
            boolean _isBooleanInvolved_1 = this.isBooleanInvolved(infixParent);
            boolean _not = (!_isBooleanInvolved_1);
            if (_not) {
                StringBuffer _xblockexpression_2 = null;
                {
                    StringConcatenation _builder = new StringConcatenation();
                    _builder.append(".bitwise");
                    String _xifexpression_2 = null;
                    boolean _equals = Objects.equal(operator, InfixExpression.Operator.AND);
                    if (_equals) {
                        _xifexpression_2 = "And";
                    } else {
                        _xifexpression_2 = "Or";
                    }
                    _builder.append(_xifexpression_2);
                    _builder.append("(");
                    this.appendToBuffer(_builder.toString());
                    rightSide.accept(this);
                    _xblockexpression_2 = this.appendToBuffer(")");
                }
                _xifexpression_1 = _xblockexpression_2;
            } else {
                this.appendSpaceToBuffer();
                String _string = operator.toString();
                String _multiply = this.operator_multiply(_string, 2);
                this.appendToBuffer(_multiply);
                this.appendSpaceToBuffer();
                rightSide.accept(this);
            }
            _switchResult = _xifexpression_1;
        }
    }
    if (!_matched) {
        if (Objects.equal(operator, InfixExpression.Operator.EQUALS)) {
            _matched = true;
            this.appendToBuffer(" === ");
            rightSide.accept(this);
        }
    }
    if (!_matched) {
        if (Objects.equal(operator, InfixExpression.Operator.NOT_EQUALS)) {
            _matched = true;
            this.appendToBuffer(" !== ");
            rightSide.accept(this);
        }
    }
    if (!_matched) {
        {
            this.appendSpaceToBuffer();
            this.appendToBuffer(operator.toString());
            this.appendSpaceToBuffer();
            rightSide.accept(this);
        }
    }
    return _switchResult;
}