private void formatLeftCurlyBrace(final int line, final String bracePosition) { /* * deal with (quite unexpected) comments right before lcurly */ this.scribe.printComment(Scribe.PRESERVE_EMPTY_LINES_IN_FORMAT_LEFT_CURLY_BRACE); if (DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP.equals(bracePosition) && (this.scribe.line > line || this.scribe.column >= this.preferences.page_width)) { this.scribe.printNewLine(); } }
private void formatLeftCurlyBrace(final int line, final String bracePosition) { /* * deal with (quite unexpected) comments right before lcurly */ this.scribe.printComment(Scribe.PRESERVE_EMPTY_LINES_IN_FORMAT_LEFT_CURLY_BRACE); if (DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP.equals(bracePosition) && (this.scribe.line > line || this.scribe.column >= this.preferences.page_width)) { this.scribe.printNewLine(); } }
private void formatLeftCurlyBrace(final int line, final String bracePosition) { /* * deal with (quite unexpected) comments right before lcurly */ this.scribe.printComment(Scribe.PRESERVE_EMPTY_LINES_IN_FORMAT_LEFT_CURLY_BRACE); if (DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP.equals(bracePosition) && (this.scribe.line > line || this.scribe.column >= this.preferences.page_width)) { this.scribe.printNewLine(); } }
public void printNewLine() { this.printNewLine(this.scanner.getCurrentTokenEndPosition() + 1); }
private void formatOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace) { if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) { this.scribe.printNewLine(); } else if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(bracePosition)) { this.scribe.printNewLine(); this.scribe.indent(); } else if (DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP.equals(bracePosition) && this.scribe.column >= this.preferences.page_width) { this.scribe.printNewLine(); } this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, insertSpaceBeforeBrace, Scribe.PRESERVE_EMPTY_LINES_IN_FORMAT_OPENING_BRACE); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.UNMODIFIABLE_TRAILING_COMMENT); } private void formatStatements(BlockScope scope, final Statement[] statements, boolean insertNewLineAfterLastStatement) {
public void printNewLine() { this.printNewLine(this.scanner.getCurrentTokenEndPosition() + 1); }
private void formatOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace) { if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) { this.scribe.printNewLine(); } else if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(bracePosition)) { this.scribe.printNewLine(); this.scribe.indent(); } else if (DefaultCodeFormatterConstants.NEXT_LINE_ON_WRAP.equals(bracePosition) && this.scribe.column >= this.preferences.page_width) { this.scribe.printNewLine(); } this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, insertSpaceBeforeBrace, Scribe.PRESERVE_EMPTY_LINES_IN_FORMAT_OPENING_BRACE); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.UNMODIFIABLE_TRAILING_COMMENT); } private void formatStatements(BlockScope scope, final Statement[] statements, boolean insertNewLineAfterLastStatement) {
private void formatOpeningBrace(String bracePosition, boolean insertSpaceBeforeBrace) { if (DefaultCodeFormatterConstants.NEXT_LINE.equals(bracePosition)) { this.scribe.printNewLine(); } else if (DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(bracePosition)) { this.scribe.printNewLine(); this.scribe.indent(); } this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, insertSpaceBeforeBrace, Scribe.PRESERVE_EMPTY_LINES_IN_FORMAT_OPENING_BRACE); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.UNMODIFIABLE_TRAILING_COMMENT); } private void formatStatements(BlockScope scope, final Statement[] statements, boolean insertNewLineAfterLastStatement) {
private void preserveEmptyLines(int count, int insertPosition) { if (count > 0) { if (this.blank_lines_between_import_groups >= 0) { printEmptyLines(this.blank_lines_between_import_groups, insertPosition); } else if (this.formatter.preferences.number_of_empty_lines_to_preserve != 0) { int linesToPreserve = Math.min(count, this.formatter.preferences.number_of_empty_lines_to_preserve); printEmptyLines(linesToPreserve, insertPosition); } else { printNewLine(insertPosition); } } }
private void preserveEmptyLines(int count, int insertPosition) { if (count > 0) { if (this.blank_lines_between_import_groups >= 0) { printEmptyLines(this.blank_lines_between_import_groups, insertPosition); } else if (this.formatter.preferences.number_of_empty_lines_to_preserve != 0) { int linesToPreserve = Math.min(count, this.formatter.preferences.number_of_empty_lines_to_preserve); printEmptyLines(linesToPreserve, insertPosition); } else { printNewLine(insertPosition); } } }
private void preserveEmptyLines(int count, int insertPosition) { if (count > 0) { if (this.blank_lines_between_import_groups >= 0) { printEmptyLines(this.blank_lines_between_import_groups, insertPosition); } else if (this.formatter.preferences.number_of_empty_lines_to_preserve != 0) { int linesToPreserve = Math.min(count, this.formatter.preferences.number_of_empty_lines_to_preserve); printEmptyLines(linesToPreserve, insertPosition); } else { printNewLine(insertPosition); } } }
/** * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.EmptyStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope) */ public boolean visit(EmptyStatement statement, BlockScope scope) { if (this.preferences.put_empty_statement_on_new_line) { this.scribe.printNewLine(); } this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); return false; } // field is an enum constant
/** * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.EmptyStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope) */ public boolean visit(EmptyStatement statement, BlockScope scope) { if (this.preferences.put_empty_statement_on_new_line) { this.scribe.printNewLine(); } this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); return false; } // field is an enum constant
/** * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.EmptyStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope) */ public boolean visit(EmptyStatement statement, BlockScope scope) { if (this.preferences.put_empty_statement_on_new_line) { this.scribe.printNewLine(); } this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); return false; } // field is an enum constant
private void formatEmptyTypeDeclaration(boolean isFirst) { boolean hasSemiColon = isNextToken(TerminalTokens.TokenNameSEMICOLON); while(isNextToken(TerminalTokens.TokenNameSEMICOLON)) { this.scribe.printComment(); this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); } if (hasSemiColon && isFirst) { this.scribe.printNewLine(); } }
private void formatEmptyTypeDeclaration(boolean isFirst) { boolean hasSemiColon = isNextToken(TerminalTokens.TokenNameSEMICOLON); while(isNextToken(TerminalTokens.TokenNameSEMICOLON)) { this.scribe.printComment(); this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); } if (hasSemiColon && isFirst) { this.scribe.printNewLine(); } }
private void formatEmptyTypeDeclaration(boolean isFirst) { boolean hasSemiColon = isNextToken(TerminalTokens.TokenNameSEMICOLON); while(isNextToken(TerminalTokens.TokenNameSEMICOLON)) { this.scribe.printComment(); this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); } if (hasSemiColon && isFirst) { this.scribe.printNewLine(); } }
private void formatNecessaryEmptyStatement() { if (this.preferences.put_empty_statement_on_new_line) { this.scribe.printNewLine(); this.scribe.indent(); this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); this.scribe.unIndent(); } else { this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); } }
private void formatNecessaryEmptyStatement() { if (this.preferences.put_empty_statement_on_new_line) { this.scribe.printNewLine(); this.scribe.indent(); this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); this.scribe.unIndent(); } else { this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); } }
private void formatNecessaryEmptyStatement() { if (this.preferences.put_empty_statement_on_new_line) { this.scribe.printNewLine(); this.scribe.indent(); this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); this.scribe.unIndent(); } else { this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon); this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT); } }