private void handleBodyDeclarations(List<BodyDeclaration> bodyDeclarations) { BodyDeclaration previous = null; for (BodyDeclaration bodyDeclaration : bodyDeclarations) { if (previous == null) { putBlankLinesBefore(bodyDeclaration, this.options.blank_lines_before_first_class_body_declaration); } else { int blankLines = 0; if (bodyDeclaration instanceof FieldDeclaration) { blankLines = this.options.blank_lines_before_field; } else if (bodyDeclaration instanceof AbstractTypeDeclaration) { blankLines = this.options.blank_lines_before_member_type; } else if (bodyDeclaration instanceof MethodDeclaration || bodyDeclaration instanceof AnnotationTypeMemberDeclaration) { blankLines = this.options.blank_lines_before_method; } if (!sameChunk(previous, bodyDeclaration)) blankLines = Math.max(blankLines, this.options.blank_lines_before_new_chunk); putBlankLinesBefore(bodyDeclaration, blankLines); } previous = bodyDeclaration; } }
private void handleBodyDeclarations(List<BodyDeclaration> bodyDeclarations) { BodyDeclaration previous = null; for (BodyDeclaration bodyDeclaration : bodyDeclarations) { if (previous == null) { putBlankLinesBefore(bodyDeclaration, this.options.blank_lines_before_first_class_body_declaration); } else { int blankLines = 0; if (bodyDeclaration instanceof FieldDeclaration) { blankLines = this.options.blank_lines_before_field; } else if (bodyDeclaration instanceof AbstractTypeDeclaration) { blankLines = this.options.blank_lines_before_member_type; } else if (bodyDeclaration instanceof MethodDeclaration || bodyDeclaration instanceof AnnotationTypeMemberDeclaration) { blankLines = this.options.blank_lines_before_method; } if (!sameChunk(previous, bodyDeclaration)) blankLines = Math.max(blankLines, this.options.blank_lines_before_new_chunk); putBlankLinesBefore(bodyDeclaration, blankLines); } previous = bodyDeclaration; } }
private void handleBodyDeclarations(List<BodyDeclaration> bodyDeclarations) { BodyDeclaration previous = null; for (BodyDeclaration bodyDeclaration : bodyDeclarations) { if (previous == null) { putBlankLinesBefore(bodyDeclaration, this.options.blank_lines_before_first_class_body_declaration); } else { int blankLines = 0; if (bodyDeclaration instanceof FieldDeclaration) { blankLines = this.options.blank_lines_before_field; } else if (bodyDeclaration instanceof AbstractTypeDeclaration) { blankLines = this.options.blank_lines_before_member_type; } else if (bodyDeclaration instanceof MethodDeclaration || bodyDeclaration instanceof AnnotationTypeMemberDeclaration) { blankLines = this.options.blank_lines_before_method; } if (!sameChunk(previous, bodyDeclaration)) blankLines = Math.max(blankLines, this.options.blank_lines_before_new_chunk); putBlankLinesBefore(bodyDeclaration, blankLines); } previous = bodyDeclaration; } }
@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 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(ModuleDeclaration node) { // using settings for type declaration and fields for now, add new settings if necessary breakLineBefore(node); handleBracedCode(node, node.getName(), this.options.brace_position_for_type_declaration, this.options.indent_body_declarations_compare_to_type_header); List<ModuleDirective> statements = node.moduleStatements(); ModuleDirective previous = null; for (ModuleDirective statement : statements) { int blankLines = previous == null ? this.options.blank_lines_before_first_class_body_declaration : previous.getClass().equals(statement.getClass()) ? this.options.blank_lines_before_field : this.options.blank_lines_before_new_chunk; putBlankLinesBefore(statement, blankLines); previous = statement; } this.declarationModifierVisited = false; return true; }
@Override public boolean visit(ModuleDeclaration node) { // using settings for type declaration and fields for now, add new settings if necessary breakLineBefore(node); handleBracedCode(node, node.getName(), this.options.brace_position_for_type_declaration, this.options.indent_body_declarations_compare_to_type_header, this.options.insert_new_line_in_empty_type_declaration); List<ModuleDirective> statements = node.moduleStatements(); ModuleDirective previous = null; for (ModuleDirective statement : statements) { int blankLines = previous == null ? this.options.blank_lines_before_first_class_body_declaration : previous.getClass().equals(statement.getClass()) ? this.options.blank_lines_before_field : this.options.blank_lines_before_new_chunk; putBlankLinesBefore(statement, blankLines); previous = statement; } this.declarationModifierVisited = false; return true; }