### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java,v retrieving revision 1.69 diff -u -r1.69 DefaultCodeFormatterConstants.java --- formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 6 Oct 2005 15:36:45 -0000 1.69 +++ formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 6 Feb 2006 19:30:29 -0000 @@ -708,6 +708,18 @@ public static final String FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER = JavaCore.PLUGIN_ID + ".formatter.continuation_indentation_for_array_initializer"; //$NON-NLS-1$ /** *
+ * FORMATTER / Option to indent body declarations compare to its enclosing annotation declaration header + * - option id: "org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" + * - possible values: { TRUE, FALSE } + * - default: TRUE + *+ * @see #TRUE + * @see #FALSE + * @since 3.2 + */ + public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER = JavaCore.PLUGIN_ID + ".formatter.indent_body_declarations_compare_to_annotation_declaration_header"; //$NON-NLS-1$ + /** + *
* FORMATTER / Option to indent body declarations compare to its enclosing enum constant header * - option id: "org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" * - possible values: { TRUE, FALSE } @@ -953,6 +965,18 @@ public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_in_empty_block"; //$NON-NLS-1$ /** *+ * FORMATTER / Option to insert a new line in an empty annotation declaration + * - option id: "org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" + * - possible values: { INSERT, DO_NOT_INSERT } + * - default: INSERT + *+ * @see JavaCore#INSERT + * @see JavaCore#DO_NOT_INSERT + * @since 3.1 + */ + public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_in_empty_annotation_declaration"; //$NON-NLS-1$ + /** + ** FORMATTER / Option to insert a new line in an empty enum constant * - option id: "org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" * - possible values: { INSERT, DO_NOT_INSERT } Index: formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java,v retrieving revision 1.177 diff -u -r1.177 CodeFormatterVisitor.java --- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 2 Feb 2006 16:26:52 -0000 1.177 +++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 6 Feb 2006 19:30:30 -0000 @@ -1034,8 +1034,7 @@ indent_body_declarations_compare_to_header = this.preferences.indent_body_declarations_compare_to_enum_declaration_header; break; case TypeDeclaration.ANNOTATION_TYPE_DECL : - // TODO (olivier) might want to add an option for annotation type - indent_body_declarations_compare_to_header = this.preferences.indent_body_declarations_compare_to_type_header; + indent_body_declarations_compare_to_header = this.preferences.indent_body_declarations_compare_to_annotation_declaration_header; break; default: indent_body_declarations_compare_to_header = this.preferences.indent_body_declarations_compare_to_type_header; @@ -1130,8 +1129,7 @@ } break; case TypeDeclaration.ANNOTATION_TYPE_DECL : - // TODO (olivier) might want an option for annotation type - if (this.preferences.insert_new_line_in_empty_type_declaration) { + if (this.preferences.insert_new_line_in_empty_annotation_declaration) { this.scribe.printNewLine(); } break; Index: formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java,v retrieving revision 1.72 diff -u -r1.72 DefaultCodeFormatterOptions.java --- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 6 Oct 2005 15:36:45 -0000 1.72 +++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 6 Feb 2006 19:30:30 -0000 @@ -108,6 +108,7 @@ public boolean indent_statements_compare_to_block; public boolean indent_statements_compare_to_body; + public boolean indent_body_declarations_compare_to_annotation_declaration_header; public boolean indent_body_declarations_compare_to_enum_constant_header; public boolean indent_body_declarations_compare_to_enum_declaration_header; public boolean indent_body_declarations_compare_to_type_header; @@ -127,6 +128,7 @@ public boolean insert_new_line_before_while_in_do_statement; public boolean insert_new_line_in_empty_anonymous_type_declaration; public boolean insert_new_line_in_empty_block; + public boolean insert_new_line_in_empty_annotation_declaration; public boolean insert_new_line_in_empty_enum_constant; public boolean insert_new_line_in_empty_enum_declaration; public boolean insert_new_line_in_empty_method_body; @@ -374,6 +376,7 @@ options.put(DefaultCodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY, Integer.toString(this.blank_lines_at_beginning_of_method_body)); options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, this.indent_statements_compare_to_block ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, this.indent_statements_compare_to_body ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); + options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER, this.indent_body_declarations_compare_to_annotation_declaration_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER, this.indent_body_declarations_compare_to_enum_constant_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER, this.indent_body_declarations_compare_to_enum_declaration_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER, this.indent_body_declarations_compare_to_type_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); @@ -392,6 +395,7 @@ options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT, this.insert_new_line_before_while_in_do_statement? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION, this.insert_new_line_in_empty_anonymous_type_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK, this.insert_new_line_in_empty_block? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION, this.insert_new_line_in_empty_annotation_declaration ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT, this.insert_new_line_in_empty_enum_constant? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION, this.insert_new_line_in_empty_enum_declaration? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY, this.insert_new_line_in_empty_method_body? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); @@ -1051,6 +1055,10 @@ if (indentStatementsCompareToBodyOption != null) { this.indent_statements_compare_to_body = DefaultCodeFormatterConstants.TRUE.equals(indentStatementsCompareToBodyOption); } + final Object indentBodyDeclarationsCompareToAnnotationDeclarationHeaderOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER); + if (indentBodyDeclarationsCompareToAnnotationDeclarationHeaderOption != null) { + this.indent_body_declarations_compare_to_annotation_declaration_header = DefaultCodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToAnnotationDeclarationHeaderOption); + } final Object indentBodyDeclarationsCompareToEnumConstantHeaderOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER); if (indentBodyDeclarationsCompareToEnumConstantHeaderOption != null) { this.indent_body_declarations_compare_to_enum_constant_header = DefaultCodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToEnumConstantHeaderOption); @@ -1129,6 +1137,10 @@ if (insertNewLineInEmptyBlockOption != null) { this.insert_new_line_in_empty_block = JavaCore.INSERT.equals(insertNewLineInEmptyBlockOption); } + final Object insertNewLineInEmptyAnnotationDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION); + if (insertNewLineInEmptyAnnotationDeclarationOption != null) { + this.insert_new_line_in_empty_annotation_declaration = JavaCore.INSERT.equals(insertNewLineInEmptyAnnotationDeclarationOption); + } final Object insertNewLineInEmptyEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT); if (insertNewLineInEmptyEnumConstantOption != null) { this.insert_new_line_in_empty_enum_constant = JavaCore.INSERT.equals(insertNewLineInEmptyEnumConstantOption); @@ -1889,6 +1901,7 @@ this.blank_lines_at_beginning_of_method_body = 0; this.indent_statements_compare_to_block = true; this.indent_statements_compare_to_body = true; + this.indent_body_declarations_compare_to_annotation_declaration_header = true; this.indent_body_declarations_compare_to_enum_constant_header = true; this.indent_body_declarations_compare_to_enum_declaration_header = true; this.indent_body_declarations_compare_to_type_header = true; @@ -1907,6 +1920,7 @@ this.insert_new_line_before_while_in_do_statement = false; this.insert_new_line_in_empty_anonymous_type_declaration = true; this.insert_new_line_in_empty_block = true; + this.insert_new_line_in_empty_annotation_declaration = true; this.insert_new_line_in_empty_enum_constant = true; this.insert_new_line_in_empty_enum_declaration = true; this.insert_new_line_in_empty_method_body = true; @@ -2141,6 +2155,7 @@ this.blank_lines_at_beginning_of_method_body = 0; this.indent_statements_compare_to_block = true; this.indent_statements_compare_to_body = true; + this.indent_body_declarations_compare_to_annotation_declaration_header = true; this.indent_body_declarations_compare_to_enum_constant_header = true; this.indent_body_declarations_compare_to_enum_declaration_header = true; this.indent_body_declarations_compare_to_type_header = true; @@ -2159,6 +2174,7 @@ this.insert_new_line_before_while_in_do_statement = false; this.insert_new_line_in_empty_anonymous_type_declaration = true; this.insert_new_line_in_empty_block = true; + this.insert_new_line_in_empty_annotation_declaration = true; this.insert_new_line_in_empty_enum_constant = true; this.insert_new_line_in_empty_enum_declaration = true; this.insert_new_line_in_empty_method_body = true; Index: formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor2.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor2.java,v retrieving revision 1.13 diff -u -r1.13 CodeFormatterVisitor2.java --- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor2.java 23 Nov 2005 20:40:23 -0000 1.13 +++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor2.java 6 Feb 2006 19:30:30 -0000 @@ -916,8 +916,7 @@ final List bodyDeclarations = node.bodyDeclarations(); formatTypeOpeningBrace(class_declaration_brace, space_before_opening_brace, bodyDeclarations.size() != 0, node); - // TODO (olivier) might want to add an option for annotation type - boolean indent_body_declarations_compare_to_header = this.preferences.indent_body_declarations_compare_to_type_header; + boolean indent_body_declarations_compare_to_header = this.preferences.indent_body_declarations_compare_to_annotation_declaration_header; if (indent_body_declarations_compare_to_header) { this.scribe.indent(); } @@ -928,8 +927,7 @@ this.scribe.unIndent(); } - // TODO (olivier) might want an option for annotation type - if (this.preferences.insert_new_line_in_empty_type_declaration) { + if (this.preferences.insert_new_line_in_empty_annotation_declaration) { this.scribe.printNewLine(); } this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE); @@ -1899,7 +1897,6 @@ if (this.preferences.insert_space_after_comma_in_for_inits) { this.scribe.space(); } - // TODO (olivier) need to check why we need this here this.scribe.printTrailingComment(); } } @@ -1963,7 +1960,6 @@ * statement */ this.scribe.printNextToken(TerminalTokens.TokenNameLBRACE, this.preferences.insert_space_before_opening_brace_in_block); - // TODO (olivier) might need an option for this this.scribe.space(); ((Statement) statements.get(0)).accept(this); this.scribe.printNextToken(TerminalTokens.TokenNameRBRACE, true); @@ -2601,9 +2597,11 @@ } public boolean visit(NumberLiteral node) { - // TODO (olivier) possible option for space if (isNextToken(TerminalTokens.TokenNameMINUS)) { - this.scribe.printNextToken(TerminalTokens.TokenNameMINUS); + this.scribe.printNextToken(TerminalTokens.TokenNameMINUS, this.preferences.insert_space_before_unary_operator); + if (this.preferences.insert_space_after_unary_operator) { + this.scribe.space(); + } } this.scribe.printNextToken(NUMBER_LITERALS_EXPECTEDTOKENS); return false;