@Override public String visitBinary(BinaryTree node, Void v) { StringBuilder out = new StringBuilder(); ExpressionTree lOp = node.getLeftOperand(); ExpressionTree rOp = node.getRightOperand(); JCTree.Tag operator = ((JCTree.JCBinary) node).getTag(); out.append(lOp.accept(this, v)); out.append(" ").append(operatorName(operator)).append(" "); out.append(rOp.accept(this, v)); return out.toString(); }
@Override public String visitBinary( BinaryTree node, Object v ) { StringBuilder out = new StringBuilder(); appendComment( node, out ); ExpressionTree lOp = node.getLeftOperand(); ExpressionTree rOp = node.getRightOperand(); JCTree.Tag operator = ((JCTree.JCBinary)node).getTag(); out.append( lOp.accept( this, v ) ); out.append( " " ).append( operatorName( operator ) ).append( " " ); out.append( rOp.accept( this, v ) ); return out.toString(); }
protected int diffBinary(JCBinary oldT, JCBinary newT, int[] bounds) { int localPointer = bounds[0]; int[] lhsBounds = getBounds(oldT.lhs); copyTo(localPointer, lhsBounds[0]); localPointer = diffTree(oldT.lhs, newT.lhs, lhsBounds); if (oldT.getTag() != newT.getTag()) { copyTo(localPointer, oldT.pos); printer.print(operatorName(newT.getTag())); localPointer = oldT.pos + operatorName(oldT.getTag()).toString().length(); } int[] rhsBounds = getCommentCorrectedBounds(oldT.rhs); rhsBounds[0] = copyUpTo(localPointer, rhsBounds[0]); localPointer = diffTree(oldT.rhs, newT.rhs, rhsBounds); return copyUpTo(localPointer, bounds[1]); }
@Override public void visitBinary( JCBinary tree ) { Env<AttrContext> env = getField( this, "env" ); Type left = attribExpr( tree.lhs, env ); Type right = attribExpr( tree.rhs, env ); OperatorMethod foundOpMeth = null; for( OperatorMethod opMeth : ops ) { opMeth.resolve( reader, names, rs, types, env ); if( tree.getTag() == opMeth.op && types.isAssignable( opMeth.arg0, left ) && types.isAssignable( opMeth.arg1, right ) ) { foundOpMeth = opMeth; break; } } if( foundOpMeth != null ) { tree.type = foundOpMeth.res; tree.operator = foundOpMeth.sym; setField( this, "result", tree.type ); debug( "Attributing overloaded operator '" + foundOpMeth.op + "' tree type to '" + tree.type + "'" ); } else { super.visitBinary( tree ); } }
@Override public void visitBinary( JCBinary tree ) { super.visitBinary( tree ); OperatorMethod foundOpMeth = null; for( OperatorMethod opMeth : ops ) { if( tree.getTag() == opMeth.op && types.isAssignable( opMeth.arg0, tree.lhs.type ) && types.isAssignable( opMeth.arg1, tree.rhs.type ) ) { foundOpMeth = opMeth; break; } } if( foundOpMeth != null ) { result = make.Apply( List.<JCExpression> nil(), make.Select( make.Ident( foundOpMeth.sym.owner ), foundOpMeth.sym ).setType( foundOpMeth.mt ), List.of( tree.lhs, tree.rhs ) ) .setType( foundOpMeth.res ); debug( "Replacing overloaded operator '" + foundOpMeth.op + "' by call to '" + foundOpMeth.sym + "'" ); } }
public Kind getKind() { return TreeInfo.tagToKind(getTag()); } public JCExpression getLeftOperand() { return lhs; }
@Override public void visitBinary(JCBinary tree) { switch (tree.getTag()) { case MUL: case DIV: case MOD: case PLUS: case MINUS: case SL: case SR: case USR: case LT: case LE: case GT: case GE: case EQ: case NE: case BITAND: case BITXOR: case BITOR: case AND: case OR: break; default: maybeConstantExpr = false; } }
public Kind getKind() { return TreeInfo.tagToKind(getTag()); } public JCExpression getLeftOperand() { return lhs; }
@Override public Description matchBinary(BinaryTree tree, VisitorState state) { Tree parent = state.getPath().getParentPath().getLeaf(); if (!(parent instanceof BinaryTree)) { return NO_MATCH; } if (TreeInfo.opPrec(((JCBinary) tree).getTag()) == TreeInfo.opPrec(((JCBinary) parent).getTag())) { return NO_MATCH; } if (!isConfusing(tree.getKind(), parent.getKind())) { return NO_MATCH; } return createAppropriateFix(tree, state); }
public Kind getKind() { return TreeInfo.tagToKind(getTag()); } public JCExpression getLeftOperand() { return lhs; }
public void visitBinary(JCBinary tree) { try { int ownprec = TreeInfo.opPrec(tree.getTag()); String opname = operatorName(tree.getTag()); open(prec, ownprec); printExpr(tree.lhs, ownprec); print(" " + opname + " "); printExpr(tree.rhs, ownprec + 1); close(prec, ownprec); } catch (IOException e) { throw new UncheckedIOException(e); } }
public void visitBinary(JCBinary tree) { try { int ownprec = TreeInfo.opPrec(tree.getTag()); String opname = operatorName(tree.getTag()); open(prec, ownprec); printExpr(tree.lhs, ownprec); print(" " + opname + " "); printExpr(tree.rhs, ownprec + 1); close(prec, ownprec); } catch (IOException e) { throw new UncheckedIOException(e); } }
public void visitBinary(JCBinary tree) { try { int ownprec = TreeInfo.opPrec(tree.getTag()); String opname = operatorName(tree.getTag()); open(prec, ownprec); printExpr(tree.lhs, ownprec); print(" " + opname + " "); printExpr(tree.rhs, ownprec + 1); close(prec, ownprec); } catch (IOException e) { throw new UncheckedIOException(e); } }
public JCTree visitBinary(BinaryTree node, P p) { JCBinary t = (JCBinary) node; JCExpression lhs = copy(t.lhs, p); JCExpression rhs = copy(t.rhs, p); return M.at(t.pos).Binary(t.getTag(), lhs, rhs); }
@Override public Choice<State<JCBinary>> visitBinary(final BinaryTree node, State<?> state) { final Tag tag = ((JCBinary) node).getTag(); return chooseSubtrees( state, s -> unifyExpression(node.getLeftOperand(), s), s -> unifyExpression(node.getRightOperand(), s), (l, r) -> maker().Binary(tag, l, r)); }
public JCTree visitBinary(BinaryTree node, P p) { JCBinary t = (JCBinary) node; JCExpression lhs = copy(t.lhs, p); JCExpression rhs = copy(t.rhs, p); return M.at(t.pos).Binary(t.getTag(), lhs, rhs); }
public JCTree visitBinary(BinaryTree node, P p) { JCBinary t = (JCBinary) node; JCExpression lhs = copy(t.lhs, p); JCExpression rhs = copy(t.rhs, p); return M.at(t.pos).Binary(t.getTag(), lhs, rhs); }
@Override public Description matchBinary(BinaryTree tree, VisitorState state) { Tree parent = state.getPath().getParentPath().getLeaf(); if (!(parent instanceof BinaryTree)) { return NO_MATCH; } if (TreeInfo.opPrec(((JCBinary) tree).getTag()) == TreeInfo.opPrec(((JCBinary) parent).getTag())) { return NO_MATCH; } if (!isConfusing(tree.getKind(), parent.getKind())) { return NO_MATCH; } return createAppropriateFix(tree, state); }
@Override public Choice<State<JCBinary>> visitBinary(final BinaryTree node, State<?> state) { final Tag tag = ((JCBinary) node).getTag(); return chooseSubtrees( state, s -> unifyExpression(node.getLeftOperand(), s), s -> unifyExpression(node.getRightOperand(), s), (l, r) -> maker().Binary(tag, l, r)); }