@Override public boolean visit(EnumConstantDeclaration node) { WrapPreparator.this.tm.firstTokenIn(node, -1).setWrapPolicy(null); return true; } });
@Override public boolean visit(LabeledStatement node) { if (this.options.insert_new_line_after_label) this.tm.firstTokenIn(node, TokenNameCOLON).breakAfter(); return true; }
@Override public boolean visit(EnumConstantDeclaration node) { WrapPreparator.this.tm.firstTokenIn(node, -1).setWrapPolicy(null); return true; } });
@Override public boolean visit(EnumConstantDeclaration node) { WrapPreparator.this.tm.firstTokenIn(node, -1).setWrapPolicy(null); return true; } });
@Override public boolean visit(LabeledStatement node) { if (this.options.insert_new_line_after_label) this.tm.firstTokenIn(node, TokenNameCOLON).breakAfter(); return true; }
@Override public boolean visit(LabeledStatement node) { if (this.options.insert_new_line_after_label) this.tm.firstTokenIn(node, TokenNameCOLON).breakAfter(); return true; }
private boolean areKeptOnOneLine(List<? extends ASTNode> nodes) { return nodes.stream().allMatch(n -> this.tm.firstTokenIn(n, -1).getLineBreaksBefore() == 0); }
private void breakLineBefore(ASTNode node) { this.tm.firstTokenIn(node, -1).breakBefore(); }
private void breakLineBefore(ASTNode node) { this.tm.firstTokenIn(node, -1).breakBefore(); }
private void breakLineBefore(ASTNode node) { this.tm.firstTokenIn(node, -1).breakBefore(); }
@Override public boolean preVisit2(ASTNode node) { this.currentDepth++; assert this.wrapIndexes.isEmpty() && this.secondaryWrapIndexes.isEmpty() && this.wrapPenalties.isEmpty(); assert this.wrapParentIndex == -1 && this.wrapGroupEnd == -1; boolean isMalformed = (node.getFlags() & ASTNode.MALFORMED) != 0; if (isMalformed) { this.tm.addDisableFormatTokenPair(this.tm.firstTokenIn(node, -1), this.tm.lastTokenIn(node, -1)); } return !isMalformed; }
@Override public boolean preVisit2(ASTNode node) { this.currentDepth++; assert this.wrapIndexes.isEmpty() && this.secondaryWrapIndexes.isEmpty() && this.wrapPenalties.isEmpty(); assert this.wrapParentIndex == -1 && this.wrapGroupEnd == -1; boolean isMalformed = (node.getFlags() & ASTNode.MALFORMED) != 0; if (isMalformed) { this.tm.addDisableFormatTokenPair(this.tm.firstTokenIn(node, -1), this.tm.lastTokenIn(node, -1)); } return !isMalformed; }
@Override public boolean preVisit2(ASTNode node) { this.currentDepth++; assert this.wrapIndexes.isEmpty() && this.secondaryWrapIndexes.isEmpty() && this.wrapPenalties.isEmpty(); assert this.wrapParentIndex == -1 && this.wrapGroupEnd == -1; boolean isMalformed = (node.getFlags() & ASTNode.MALFORMED) != 0; if (isMalformed) { this.tm.addDisableFormatTokenPair(this.tm.firstTokenIn(node, -1), this.tm.lastTokenIn(node, -1)); } return !isMalformed; }
@Override public boolean visit(AssertStatement node) { this.tm.firstTokenIn(node, TokenNameassert).spaceAfter(); if (node.getMessage() != null) { handleTokenBefore(node.getMessage(), TokenNameCOLON, this.options.insert_space_before_colon_in_assert, this.options.insert_space_after_colon_in_assert); } return true; }
@Override public boolean visit(AssertStatement node) { this.tm.firstTokenIn(node, TokenNameassert).spaceAfter(); if (node.getMessage() != null) { handleTokenBefore(node.getMessage(), TokenNameCOLON, this.options.insert_space_before_colon_in_assert, this.options.insert_space_after_colon_in_assert); } return true; }
@Override public boolean visit(AssertStatement node) { this.tm.firstTokenIn(node, TokenNameassert).spaceAfter(); if (node.getMessage() != null) { handleTokenBefore(node.getMessage(), TokenNameCOLON, this.options.insert_space_before_colon_in_assert, this.options.insert_space_after_colon_in_assert); } return true; }
@Override public void endVisit(SingleVariableDeclaration node) { // this must be endVisit in case a space added by a visit on a child node needs to be cleared if (node.isVarargs()) { handleTokenBefore(node.getName(), TokenNameELLIPSIS, this.options.insert_space_before_ellipsis, this.options.insert_space_after_ellipsis); List<Annotation> varargsAnnotations = node.varargsAnnotations(); if (!varargsAnnotations.isEmpty()) { this.tm.firstTokenIn(varargsAnnotations.get(0), TokenNameAT).spaceBefore(); this.tm.lastTokenIn(varargsAnnotations.get(varargsAnnotations.size() - 1), -1).clearSpaceAfter(); } } else { handleToken(node.getName(), TokenNameIdentifier, true, false); } }
@Override public void endVisit(SingleVariableDeclaration node) { // this must be endVisit in case a space added by a visit on a child node needs to be cleared if (node.isVarargs()) { handleTokenBefore(node.getName(), TokenNameELLIPSIS, this.options.insert_space_before_ellipsis, this.options.insert_space_after_ellipsis); List<Annotation> varargsAnnotations = node.varargsAnnotations(); if (!varargsAnnotations.isEmpty()) { this.tm.firstTokenIn(varargsAnnotations.get(0), TokenNameAT).spaceBefore(); this.tm.lastTokenIn(varargsAnnotations.get(varargsAnnotations.size() - 1), -1).clearSpaceAfter(); } } else { handleToken(node.getName(), TokenNameIdentifier, true, false); } }
@Override public void endVisit(SingleVariableDeclaration node) { // this must be endVisit in case a space added by a visit on a child node needs to be cleared if (node.isVarargs()) { handleTokenBefore(node.getName(), TokenNameELLIPSIS, this.options.insert_space_before_ellipsis, this.options.insert_space_after_ellipsis); List<Annotation> varargsAnnotations = node.varargsAnnotations(); if (!varargsAnnotations.isEmpty()) { this.tm.firstTokenIn(varargsAnnotations.get(0), TokenNameAT).spaceBefore(); this.tm.lastTokenIn(varargsAnnotations.get(varargsAnnotations.size() - 1), -1).clearSpaceAfter(); } } else { handleToken(node.getName(), TokenNameIdentifier, true, false); } }
@Override public boolean visit(MethodDeclaration node) { this.declarationModifierVisited = false; int lParen = this.tm.firstIndexAfter(node.getName(), TokenNameLPAREN); int rParen = node.getBody() == null ? this.tm.lastIndexIn(node, TokenNameRPAREN) : this.tm.firstIndexBefore(node.getBody(), TokenNameRPAREN); handleParenthesesPositions(lParen, rParen, this.options.parenthesis_positions_in_method_declaration); if (node.getBody() == null) return true; String bracePosition = node.isConstructor() ? this.options.brace_position_for_constructor_declaration : this.options.brace_position_for_method_declaration; handleBracedCode(node.getBody(), null, bracePosition, this.options.indent_statements_compare_to_body); Token openBrace = this.tm.firstTokenIn(node.getBody(), TokenNameLBRACE); if (openBrace.getLineBreaksAfter() > 0) // if not, these are empty braces openBrace.putLineBreaksAfter(this.options.blank_lines_at_beginning_of_method_body + 1); return true; }