private void wrapAssignOpTree(final String operator, int col, final Runnable print) { final boolean spaceAroundAssignOps = cs.spaceAroundAssignOps(); if (cs.wrapAfterAssignOps()) { if (spaceAroundAssignOps) print(' '); print(operator); } wrapTree(cs.wrapAssignOps(), spaceAroundAssignOps, cs.alignMultilineAssignment() ? col : out.leftMargin + cs.getContinuationIndentSize(), new Runnable() { @Override public void run() { if (!cs.wrapAfterAssignOps()) { print(operator); if (spaceAroundAssignOps) print(' '); } print.run(); } }); }
@Override public Boolean visitCompoundAssignment(CompoundAssignmentTree node, Void p) { int alignIndent = cs.alignMultilineAssignment() ? col : -1; scan(node.getVariable(), p); if (cs.wrapAfterAssignOps()) { boolean containedNewLine = spaces(cs.spaceAroundAssignOps() ? 1 : 0, false); if (OPERATOR.equals(tokens.token().id().primaryCategory())) { col += tokens.token().length(); lastBlankLines = -1; lastBlankLinesTokenIndex = -1; lastBlankLinesDiff = null; tokens.moveNext(); if (containedNewLine) newline(); } wrapTree(cs.wrapAssignOps(), alignIndent, cs.spaceAroundAssignOps() ? 1 : 0, node.getExpression()); } else { wrapOperatorAndTree(cs.wrapAssignOps(), alignIndent, cs.spaceAroundAssignOps() ? 1 : 0, node.getExpression()); } return true; }
case XOR_ASSIGNMENT: case OR_ASSIGNMENT: if (cs.alignMultilineAssignment()) { int c = getColumn(tree); return c < 0 ? currentIndent : c;
@Override public void visitAssignop(JCAssignOp tree) { int col = out.col; printExpr(tree.lhs, TreeInfo.assignopPrec + 1); if (cs.spaceAroundAssignOps()) print(' '); print(operators.operatorName(tree.getTag().noAssignOp())); print('='); int rm = cs.getRightMargin(); switch(cs.wrapAssignOps()) { case WRAP_IF_LONG: if (widthEstimator.estimateWidth(tree.rhs, rm - out.col) + out.col <= cs.getRightMargin()) { if(cs.spaceAroundAssignOps()) print(' '); break; } case WRAP_ALWAYS: newline(); toColExactly(cs.alignMultilineAssignment() ? col : out.leftMargin + cs.getContinuationIndentSize()); break; case WRAP_NEVER: if(cs.spaceAroundAssignOps()) print(' '); break; } printExpr(tree.rhs, TreeInfo.assignopPrec); }
if (init != null) { int alignIndent = -1; if (cs.alignMultilineAssignment()) { alignIndent = col; if (!ERROR.contentEquals(node.getName()))
|| (token = findFirstNonWhitespaceToken(startOffset, endOffset)) == null || token.token().id() != JavaTokenId.LBRACE) { if (cs.alignMultilineAssignment()) { int c = getColumn(last); if (c >= 0) {
@Override public Boolean visitAssignment(AssignmentTree node, Void p) { int alignIndent = cs.alignMultilineAssignment() ? col : -1; boolean b = scan(node.getVariable(), p); if (b || getCurrentPath().getParentPath().getLeaf().getKind() != Tree.Kind.ANNOTATION) { boolean spaceAroundAssignOps = insideAnnotation ? cs.spaceAroundAnnotationValueAssignOps() : cs.spaceAroundAssignOps(); if (cs.wrapAfterAssignOps()) { boolean containedNewLine = spaces(spaceAroundAssignOps ? 1 : 0, false); if (accept(EQ) == EQ && containedNewLine) newline(); ExpressionTree expr = node.getExpression(); if (expr.getKind() == Tree.Kind.NEW_ARRAY && ((NewArrayTree)expr).getType() == null) { if (cs.getOtherBracePlacement() == CodeStyle.BracePlacement.SAME_LINE) spaces(spaceAroundAssignOps ? 1 : 0); scan(expr, p); } else { if (wrapAnnotation && expr.getKind() == Tree.Kind.ANNOTATION) { wrapTree(CodeStyle.WrapStyle.WRAP_ALWAYS, alignIndent, spaceAroundAssignOps ? 1 : 0, expr); } else { wrapTree(cs.wrapAssignOps(), alignIndent, spaceAroundAssignOps ? 1 : 0, expr); } } } else { wrapOperatorAndTree(cs.wrapAssignOps(), alignIndent, spaceAroundAssignOps ? 1 : 0, node.getExpression()); } } else { scan(node.getExpression(), p); } return true; }