public void breakBefore() { putLineBreaksBefore(1); }
public void breakBefore() { putLineBreaksBefore(1); }
public void breakBefore() { putLineBreaksBefore(1); }
@Override public void endVisit(Javadoc node) { if (this.ctm == null) return; if (this.options.comment_insert_empty_line_before_root_tags && this.firstTagToken != null && this.ctm.indexOf(this.firstTagToken) > 1) { this.firstTagToken.putLineBreaksBefore(2); } addSubstituteWraps(); }
@Override public void endVisit(Javadoc node) { if (this.ctm == null) return; if (this.options.comment_insert_empty_line_before_root_tags && this.firstTagToken != null && this.ctm.indexOf(this.firstTagToken) > 1) { this.firstTagToken.putLineBreaksBefore(2); } addSubstituteWraps(); }
@Override public void endVisit(Javadoc node) { if (this.ctm == null) return; if (this.options.comment_insert_empty_line_before_root_tags && this.firstTagToken != null && this.ctm.indexOf(this.firstTagToken) > 1) { this.firstTagToken.putLineBreaksBefore(2); } addSubstituteWraps(); }
@Override public boolean visit(CompilationUnit node) { List<ImportDeclaration> imports = node.imports(); if (!imports.isEmpty()) { int index = this.tm.firstIndexIn(imports.get(0), -1); if (index > 0) this.tm.get(index).putLineBreaksBefore(this.options.blank_lines_before_imports + 1); } List<AnnotationTypeDeclaration> types = node.types(); if (!types.isEmpty()) { if (!imports.isEmpty()) putBlankLinesBefore(types.get(0), this.options.blank_lines_after_imports); for (int i = 1; i < types.size(); i++) putBlankLinesBefore(types.get(i), this.options.blank_lines_between_type_declarations); } return true; }
@Override public boolean visit(CompilationUnit node) { List<ImportDeclaration> imports = node.imports(); if (!imports.isEmpty()) { int index = this.tm.firstIndexIn(imports.get(0), -1); if (index > 0) this.tm.get(index).putLineBreaksBefore(this.options.blank_lines_before_imports + 1); } List<AnnotationTypeDeclaration> types = node.types(); if (!types.isEmpty()) { if (!imports.isEmpty()) putBlankLinesBefore(types.get(0), this.options.blank_lines_after_imports); for (int i = 1; i < types.size(); i++) putBlankLinesBefore(types.get(i), this.options.blank_lines_between_type_declarations); } return true; }
@Override protected boolean token(Token token, int index) { boolean isBetweenImports = index > WrapPreparator.this.importsStart && index < WrapPreparator.this.importsEnd; int lineBreaks = getLineBreaksToPreserve(getPrevious(), token, isBetweenImports); if (lineBreaks > 1 || (!this.join_wrapped_lines && token.isWrappable()) || index == 0) token.putLineBreaksBefore(lineBreaks); return true; }
@Override protected boolean token(Token token, int index) { boolean isBetweenImports = index > WrapPreparator.this.importsStart && index < WrapPreparator.this.importsEnd; int lineBreaks = getLineBreaksToPreserve(getPrevious(), token, isBetweenImports); if (lineBreaks > 1 || (!this.join_wrapped_lines && token.isWrappable()) || index == 0) token.putLineBreaksBefore(lineBreaks); return true; }
private void putBlankLinesBefore(ASTNode node, int linesCount) { int index = this.tm.firstIndexIn(node, -1); while (index > 0 && this.tm.get(index - 1).tokenType == TokenNameCOMMENT_JAVADOC) index--; this.tm.get(index).putLineBreaksBefore(linesCount + 1); }
private void putBlankLinesBefore(ASTNode node, int linesCount) { int index = this.tm.firstIndexIn(node, -1); while (index > 0 && this.tm.get(index - 1).tokenType == TokenNameCOMMENT_JAVADOC) index--; this.tm.get(index).putLineBreaksBefore(linesCount + 1); }
private void putBlankLinesBefore(ASTNode node, int linesCount) { int index = this.tm.firstIndexIn(node, -1); while (index > 0 && this.tm.get(index - 1).tokenType == TokenNameCOMMENT_JAVADOC) index--; this.tm.get(index).putLineBreaksBefore(linesCount + 1); }
@Override public boolean visit(PackageDeclaration node) { int blanks = this.options.blank_lines_before_package; if (blanks > 0) { List<Annotation> annotations = node.annotations(); int firstTokenIndex = annotations.isEmpty() ? this.tm.firstIndexBefore(node.getName(), TokenNamepackage) : this.tm.firstIndexIn(annotations.get(0), -1); this.tm.get(firstTokenIndex).putLineBreaksBefore(blanks + 1); } this.tm.lastTokenIn(node, TokenNameSEMICOLON).putLineBreaksAfter(this.options.blank_lines_after_package + 1); this.declarationModifierVisited = false; return true; }
@Override public boolean visit(PackageDeclaration node) { int blanks = this.options.blank_lines_before_package; if (blanks > 0) { List<Annotation> annotations = node.annotations(); int firstTokenIndex = annotations.isEmpty() ? this.tm.firstIndexBefore(node.getName(), TokenNamepackage) : this.tm.firstIndexIn(annotations.get(0), -1); this.tm.get(firstTokenIndex).putLineBreaksBefore(blanks + 1); } this.tm.lastTokenIn(node, TokenNameSEMICOLON).putLineBreaksAfter(this.options.blank_lines_after_package + 1); this.declarationModifierVisited = false; return true; }
@Override public boolean visit(PackageDeclaration node) { int blanks = this.options.blank_lines_before_package; if (blanks > 0) { List<Annotation> annotations = node.annotations(); int firstTokenIndex = annotations.isEmpty() ? this.tm.firstIndexBefore(node.getName(), TokenNamepackage) : this.tm.firstIndexIn(annotations.get(0), -1); this.tm.get(firstTokenIndex).putLineBreaksBefore(blanks + 1); } this.tm.lastTokenIn(node, TokenNameSEMICOLON).putLineBreaksAfter(this.options.blank_lines_after_package + 1); this.declarationModifierVisited = false; return true; }
@Override protected boolean token(Token token, int index) { boolean isBetweenImports = index > WrapPreparator.this.importsStart && index < WrapPreparator.this.importsEnd; int lineBreaks = getLineBreaksToPreserve(getPrevious(), token, isBetweenImports); if (lineBreaks <= getLineBreaksBefore()) return true; if (lineBreaks == 1) { if ((!this.options2.join_wrapped_lines && token.isWrappable()) || index == 0) token.breakBefore(); } else if (lineBreaks > 1) { token.putLineBreaksBefore(lineBreaks); } return true; }
private void splitToken(Token token, int tokenIndex, int splitPosition) { assert splitPosition > token.originalStart && splitPosition <= token.originalEnd; Token part1 = new Token(token.originalStart, splitPosition - 1, token.tokenType); Token part2 = new Token(splitPosition, token.originalEnd, token.tokenType); if (token.isSpaceBefore()) part1.spaceBefore(); part1.putLineBreaksBefore(token.getLineBreaksBefore()); if (token.isSpaceAfter()) part2.spaceAfter(); part2.putLineBreaksAfter(token.getLineBreaksAfter()); part1.setIndent(token.getIndent()); part2.setIndent(token.getIndent()); part1.setWrapPolicy(token.getWrapPolicy()); this.commentStructure.set(tokenIndex, part1); this.commentStructure.add(tokenIndex + 1, part2); }
private void splitToken(Token token, int tokenIndex, int splitPosition) { assert splitPosition > token.originalStart && splitPosition <= token.originalEnd; Token part1 = new Token(token.originalStart, splitPosition - 1, token.tokenType); Token part2 = new Token(splitPosition, token.originalEnd, token.tokenType); if (token.isSpaceBefore()) part1.spaceBefore(); part1.putLineBreaksBefore(token.getLineBreaksBefore()); if (token.isSpaceAfter()) part2.spaceAfter(); part2.putLineBreaksAfter(token.getLineBreaksAfter()); part1.setIndent(token.getIndent()); part2.setIndent(token.getIndent()); part1.setWrapPolicy(token.getWrapPolicy()); this.commentStructure.set(tokenIndex, part1); this.commentStructure.add(tokenIndex + 1, part2); }
private void splitToken(Token token, int tokenIndex, int splitPosition) { assert splitPosition > token.originalStart && splitPosition <= token.originalEnd; Token part1 = new Token(token.originalStart, splitPosition - 1, token.tokenType); Token part2 = new Token(splitPosition, token.originalEnd, token.tokenType); if (token.isSpaceBefore()) part1.spaceBefore(); part1.putLineBreaksBefore(token.getLineBreaksBefore()); if (token.isSpaceAfter()) part2.spaceAfter(); part2.putLineBreaksAfter(token.getLineBreaksAfter()); part1.setIndent(token.getIndent()); part2.setIndent(token.getIndent()); part1.setWrapPolicy(token.getWrapPolicy()); this.commentStructure.set(tokenIndex, part1); this.commentStructure.add(tokenIndex + 1, part2); }