### 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.116 diff -u -r1.116 DefaultCodeFormatterConstants.java --- formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 27 May 2010 15:54:44 -0000 1.116 +++ formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 11 Aug 2010 12:05:56 -0000 @@ -1206,11 +1206,69 @@ * @see JavaCore#INSERT * @see JavaCore#DO_NOT_INSERT * @since 3.4 + * @deprecated + * All new options must be enabled to activate old strategy + * {@link #FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD} + * {@link #FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD} + * {@link #FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE} + * {@link #FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE} */ public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_member";//$NON-NLS-1$ /** *
+ * FORMATTER / Option to insert a new line after an annotation on a field declaration + * - option id: "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" + * - possible values: { INSERT, DO_NOT_INSERT } + * - default: INSERT + *+ * @see JavaCore#INSERT + * @see JavaCore#DO_NOT_INSERT + * @since 3.7 + */ + public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_field";//$NON-NLS-1$ + + /** + *
+ * FORMATTER / Option to insert a new line after an annotation on a method declaration + * - option id: "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" + * - possible values: { INSERT, DO_NOT_INSERT } + * - default: INSERT + *+ * @see JavaCore#INSERT + * @see JavaCore#DO_NOT_INSERT + * @since 3.7 + */ + public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_method";//$NON-NLS-1$ + + /** + *
+ * FORMATTER / Option to insert a new line after an annotation on a package declaration + * - option id: "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" + * - possible values: { INSERT, DO_NOT_INSERT } + * - default: INSERT + *+ * @see JavaCore#INSERT + * @see JavaCore#DO_NOT_INSERT + * @since 3.7 + */ + public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_package";//$NON-NLS-1$ + + /** + *
+ * FORMATTER / Option to insert a new line after an annotation on a type declaration + * - option id: "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" + * - possible values: { INSERT, DO_NOT_INSERT } + * - default: INSERT + *+ * @see JavaCore#INSERT + * @see JavaCore#DO_NOT_INSERT + * @since 3.7 + */ + public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_annotation_on_type";//$NON-NLS-1$ + + /** + *
* FORMATTER / Option to insert a new line after an annotation on a parameter * - option id: "org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" * - 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.235 diff -u -r1.235 CodeFormatterVisitor.java --- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 20 May 2010 09:41:48 -0000 1.235 +++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 11 Aug 2010 12:05:57 -0000 @@ -561,7 +561,7 @@ Alignment memberAlignment = this.scribe.getMemberAlignment(); this.scribe.printComment(); - this.scribe.printModifiers(fieldDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER); + this.scribe.printModifiers(fieldDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_FIELD); this.scribe.space(); /* * Field type @@ -675,7 +675,7 @@ Alignment fieldAlignment = this.scribe.getMemberAlignment(); this.scribe.printComment(); - this.scribe.printModifiers(multiFieldDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER); + this.scribe.printModifiers(multiFieldDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_FIELD); this.scribe.space(); multiFieldDeclaration.declarations[0].type.traverse(this, scope); @@ -911,7 +911,7 @@ this.scribe.printComment(); int line = this.scribe.line; - this.scribe.printModifiers(typeDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER); + this.scribe.printModifiers(typeDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_TYPE); if (this.scribe.line > line) { // annotations introduced new line, but this is not a line wrapping @@ -2443,7 +2443,7 @@ * Print comments to get proper line number */ this.scribe.printComment(); - this.scribe.printModifiers(annotationTypeMemberDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER); + this.scribe.printModifiers(annotationTypeMemberDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_METHOD); this.scribe.space(); /* * Print the method return type @@ -3070,7 +3070,7 @@ this.scribe.printEmptyLines(blankLinesBeforePackage); } - this.scribe.printModifiers(currentPackage.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER); + this.scribe.printModifiers(currentPackage.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_PACKAGE); this.scribe.space(); // dump the package keyword this.scribe.printNextToken(TerminalTokens.TokenNamepackage); @@ -3306,7 +3306,7 @@ */ this.scribe.printComment(); int line = this.scribe.line; - this.scribe.printModifiers(constructorDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER); + this.scribe.printModifiers(constructorDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_METHOD); if (this.scribe.line > line) { // annotations introduced new line, but this is not a line wrapping // see 158267 @@ -3523,7 +3523,7 @@ */ this.scribe.printComment(); final int line = this.scribe.line; - this.scribe.printModifiers(enumConstant.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER); + this.scribe.printModifiers(enumConstant.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_FIELD); this.scribe.printNextToken(TerminalTokens.TokenNameIdentifier, false); formatEnumConstantArguments( enumConstant, @@ -4219,7 +4219,7 @@ do { try { - this.scribe.printModifiers(methodDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_MEMBER); + this.scribe.printModifiers(methodDeclaration.annotations, this, ICodeFormatterConstants.ANNOTATION_ON_METHOD); int fragmentIndex = 0; this.scribe.alignFragment(methodDeclAlignment, fragmentIndex); 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.108 diff -u -r1.108 DefaultCodeFormatterOptions.java --- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 20 May 2010 09:41:48 -0000 1.108 +++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 11 Aug 2010 12:05:58 -0000 @@ -135,7 +135,10 @@ public boolean indent_switchstatements_compare_to_switch; public int indentation_size; - public boolean insert_new_line_after_annotation_on_member; + public boolean insert_new_line_after_annotation_on_type; + public boolean insert_new_line_after_annotation_on_field; + public boolean insert_new_line_after_annotation_on_method; + public boolean insert_new_line_after_annotation_on_package; public boolean insert_new_line_after_annotation_on_parameter; public boolean insert_new_line_after_annotation_on_local_variable; public boolean insert_new_line_after_label; @@ -421,7 +424,10 @@ options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, this.indent_switchstatements_compare_to_cases ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, this.indent_switchstatements_compare_to_switch ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE); options.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, Integer.toString(this.indentation_size)); - options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, this.insert_new_line_after_annotation_on_member ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, this.insert_new_line_after_annotation_on_type ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, this.insert_new_line_after_annotation_on_field ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, this.insert_new_line_after_annotation_on_method ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, this.insert_new_line_after_annotation_on_package ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, this.insert_new_line_after_annotation_on_parameter ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, this.insert_new_line_after_annotation_on_local_variable ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_new_line_after_opening_brace_in_array_initializer? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); @@ -2028,16 +2034,41 @@ this.comment_clear_blank_lines_in_block_comment = DefaultCodeFormatterConstants.TRUE.equals(commentClearBlankLinesInBlockCommentOption); } } - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + // New line after annotations final Object insertNewLineAfterAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION); - if (insertNewLineAfterAnnotationOption != null) { // check if deprecated option was used - this.insert_new_line_after_annotation_on_member = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption); - this.insert_new_line_after_annotation_on_parameter = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption); - this.insert_new_line_after_annotation_on_local_variable = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption); + if (insertNewLineAfterAnnotationOption != null) { // check if deprecated 3.1 option was used + boolean insert = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption); + this.insert_new_line_after_annotation_on_type = insert; + this.insert_new_line_after_annotation_on_field = insert; + this.insert_new_line_after_annotation_on_method = insert; + this.insert_new_line_after_annotation_on_package = insert; + this.insert_new_line_after_annotation_on_parameter = insert; + this.insert_new_line_after_annotation_on_local_variable = insert; } else { final Object insertNewLineAfterAnnotationOnMemberOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER); - if (insertNewLineAfterAnnotationOnMemberOption != null) { // otherwhise, use the new options - this.insert_new_line_after_annotation_on_member = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnMemberOption); + if (insertNewLineAfterAnnotationOnMemberOption != null) { // check if deprecated 3.4 option was used + boolean insert = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnMemberOption); + this.insert_new_line_after_annotation_on_type = insert; + this.insert_new_line_after_annotation_on_field = insert; + this.insert_new_line_after_annotation_on_method = insert; + this.insert_new_line_after_annotation_on_package = insert; + } else { // otherwise use new options + final Object insertNewLineAfterAnnotationOnTypeOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE); + if (insertNewLineAfterAnnotationOnTypeOption != null) { + this.insert_new_line_after_annotation_on_type = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnTypeOption); + } + final Object insertNewLineAfterAnnotationOnFieldOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD); + if (insertNewLineAfterAnnotationOnFieldOption != null) { + this.insert_new_line_after_annotation_on_field = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnFieldOption); + } + final Object insertNewLineAfterAnnotationOnMethodOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD); + if (insertNewLineAfterAnnotationOnMethodOption != null) { + this.insert_new_line_after_annotation_on_method = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnMethodOption); + } + final Object insertNewLineAfterAnnotationOnPackageOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE); + if (insertNewLineAfterAnnotationOnPackageOption != null) { + this.insert_new_line_after_annotation_on_package = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOnPackageOption); + } } final Object insertNewLineAfterAnnotationOnParameterOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER); if (insertNewLineAfterAnnotationOnParameterOption != null) { @@ -2126,7 +2157,10 @@ this.indent_switchstatements_compare_to_cases = true; this.indent_switchstatements_compare_to_switch = true; this.indentation_size = 4; - this.insert_new_line_after_annotation_on_member = true; + this.insert_new_line_after_annotation_on_type = true; + this.insert_new_line_after_annotation_on_field = true; + this.insert_new_line_after_annotation_on_method = true; + this.insert_new_line_after_annotation_on_package = true; this.insert_new_line_after_annotation_on_parameter = false; this.insert_new_line_after_annotation_on_local_variable = true; this.insert_new_line_after_opening_brace_in_array_initializer = false; @@ -2401,7 +2435,10 @@ this.indent_switchstatements_compare_to_cases = true; this.indent_switchstatements_compare_to_switch = false; this.indentation_size = 4; - this.insert_new_line_after_annotation_on_member = true; + this.insert_new_line_after_annotation_on_type = true; + this.insert_new_line_after_annotation_on_field = true; + this.insert_new_line_after_annotation_on_method = true; + this.insert_new_line_after_annotation_on_package = true; this.insert_new_line_after_annotation_on_parameter = false; this.insert_new_line_after_annotation_on_local_variable = true; this.insert_new_line_after_opening_brace_in_array_initializer = false; Index: formatter/org/eclipse/jdt/internal/formatter/ICodeFormatterConstants.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/ICodeFormatterConstants.java,v retrieving revision 1.2 diff -u -r1.2 ICodeFormatterConstants.java --- formatter/org/eclipse/jdt/internal/formatter/ICodeFormatterConstants.java 27 Jun 2008 16:04:08 -0000 1.2 +++ formatter/org/eclipse/jdt/internal/formatter/ICodeFormatterConstants.java 11 Aug 2010 12:05:58 -0000 @@ -24,12 +24,21 @@ /** annotation on unspecified source*/ public static final int ANNOTATION_UNSPECIFIED = 0; - /** annotation on a member (type, method, field) */ - public static final int ANNOTATION_ON_MEMBER = 1; + /** annotation on a type */ + public static final int ANNOTATION_ON_TYPE = 1; + + /** annotation on a field */ + public static final int ANNOTATION_ON_FIELD = 2; + + /** annotation on a method */ + public static final int ANNOTATION_ON_METHOD = 3; + + /** annotation on a package */ + public static final int ANNOTATION_ON_PACKAGE = 4; /** annotation on a parameter */ - public static final int ANNOTATION_ON_PARAMETER = 2; + public static final int ANNOTATION_ON_PARAMETER = 5; /** annotation on a local variable */ - public static final int ANNOTATION_ON_LOCAL_VARIABLE = 3; + public static final int ANNOTATION_ON_LOCAL_VARIABLE = 6; } Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v retrieving revision 1.213 diff -u -r1.213 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 19 Jul 2010 23:38:44 -0000 1.213 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 11 Aug 2010 12:05:59 -0000 @@ -4469,8 +4469,23 @@ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 boolean shouldAddNewLine = false; switch (annotationSourceKind) { - case ICodeFormatterConstants.ANNOTATION_ON_MEMBER : - if (this.formatter.preferences.insert_new_line_after_annotation_on_member) { + case ICodeFormatterConstants.ANNOTATION_ON_TYPE : + if (this.formatter.preferences.insert_new_line_after_annotation_on_type) { + shouldAddNewLine = true; + } + break; + case ICodeFormatterConstants.ANNOTATION_ON_FIELD : + if (this.formatter.preferences.insert_new_line_after_annotation_on_field) { + shouldAddNewLine = true; + } + break; + case ICodeFormatterConstants.ANNOTATION_ON_METHOD : + if (this.formatter.preferences.insert_new_line_after_annotation_on_method) { + shouldAddNewLine = true; + } + break; + case ICodeFormatterConstants.ANNOTATION_ON_PACKAGE : + if (this.formatter.preferences.insert_new_line_after_annotation_on_package) { shouldAddNewLine = true; } break; #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java,v retrieving revision 1.260 diff -u -r1.260 FormatterRegressionTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 20 May 2010 09:41:37 -0000 1.260 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java 11 Aug 2010 12:06:04 -0000 @@ -10364,7 +10364,10 @@ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_member = false; + preferences.insert_new_line_after_annotation_on_type = false; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.insert_new_line_after_annotation_on_package = false; preferences.insert_new_line_after_annotation_on_parameter = true; DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); IRegion[] regions = new IRegion[] { @@ -10378,7 +10381,10 @@ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_member = false; + preferences.insert_new_line_after_annotation_on_type = false; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.insert_new_line_after_annotation_on_package = false; preferences.insert_new_line_after_annotation_on_parameter = false; DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences); IRegion[] regions = new IRegion[] { @@ -10393,7 +10399,10 @@ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_member = false; + preferences.insert_new_line_after_annotation_on_type = false; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.insert_new_line_after_annotation_on_package = false; preferences.insert_new_line_after_annotation_on_parameter = true; preferences.insert_new_line_after_annotation_on_local_variable = false; Hashtable javaCoreOptions = JavaCore.getOptions(); @@ -10419,7 +10428,10 @@ public void test707() { final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_new_line_after_annotation_on_member = true; + preferences.insert_new_line_after_annotation_on_type = true; + preferences.insert_new_line_after_annotation_on_field = true; + preferences.insert_new_line_after_annotation_on_method = true; + preferences.insert_new_line_after_annotation_on_package = true; preferences.insert_new_line_after_annotation_on_parameter = true; preferences.insert_new_line_after_annotation_on_local_variable = false; preferences.line_separator = "\n";//$NON-NLS-1$ @@ -10447,7 +10459,10 @@ final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); preferences.line_separator = "\n";//$NON-NLS-1$ - preferences.insert_new_line_after_annotation_on_member = true; + preferences.insert_new_line_after_annotation_on_type = true; + preferences.insert_new_line_after_annotation_on_field = true; + preferences.insert_new_line_after_annotation_on_method = true; + preferences.insert_new_line_after_annotation_on_package = true; preferences.insert_new_line_after_annotation_on_parameter = false; preferences.insert_new_line_after_annotation_on_local_variable = false; Hashtable javaCoreOptions = JavaCore.getOptions(); @@ -10473,7 +10488,10 @@ public void test709() { final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_new_line_after_annotation_on_member = false; + preferences.insert_new_line_after_annotation_on_type = false; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.insert_new_line_after_annotation_on_package = false; preferences.insert_new_line_after_annotation_on_parameter = false; preferences.insert_new_line_after_annotation_on_local_variable = false; preferences.line_separator = "\n";//$NON-NLS-1$ @@ -10500,7 +10518,10 @@ public void test710() { final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_new_line_after_annotation_on_member = false; + preferences.insert_new_line_after_annotation_on_type = false; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.insert_new_line_after_annotation_on_package = false; preferences.insert_new_line_after_annotation_on_parameter = true; preferences.insert_new_line_after_annotation_on_local_variable = true; preferences.line_separator = "\n";//$NON-NLS-1$ @@ -10527,7 +10548,10 @@ public void test711() { final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options); - preferences.insert_new_line_after_annotation_on_member = false; + preferences.insert_new_line_after_annotation_on_type = false; + preferences.insert_new_line_after_annotation_on_field = false; + preferences.insert_new_line_after_annotation_on_method = false; + preferences.insert_new_line_after_annotation_on_package = false; preferences.insert_new_line_after_annotation_on_parameter = false; preferences.insert_new_line_after_annotation_on_local_variable = true; preferences.line_separator = "\n";//$NON-NLS-1$ @@ -10726,4 +10750,147 @@ "}\n" ); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=308000 +public void test725() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); + String source = + "@Deprecated package pack;\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {}\n" + + " @Deprecated String label;\n" + + " @Deprecated void foo() {}\n" + + " @Deprecated interface I {}\n" + + "}\n"; + formatSource(source, + "@Deprecated\n" + + "package pack;\n" + + "\n" + + "public class Test {\n" + + " @Deprecated\n" + + " Test(String s) {\n" + + " }\n" + + "\n" + + " @Deprecated\n" + + " String label;\n" + + "\n" + + " @Deprecated\n" + + " void foo() {\n" + + " }\n" + + "\n" + + " @Deprecated\n" + + " interface I {\n" + + " }\n" + + "}\n" + ); +} +public void test726() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_TYPE, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_FIELD, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_METHOD, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PACKAGE, DefaultCodeFormatterConstants.FALSE); + String source = + "@Deprecated package pack;\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {}\n" + + " @Deprecated String label;\n" + + " @Deprecated void foo() {}\n" + + " @Deprecated interface I {}\n" + + "}\n"; + formatSource(source, + "@Deprecated package pack;\n" + + "\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {\n" + + " }\n" + + "\n" + + " @Deprecated String label;\n" + + "\n" + + " @Deprecated void foo() {\n" + + " }\n" + + "\n" + + " @Deprecated interface I {\n" + + " }\n" + + "}\n" + ); +} + +/** + * @deprecated Use a deprecated formatter option. + */ +public void test727() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_LOCAL_VARIABLE, DefaultCodeFormatterConstants.TRUE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_MEMBER, DefaultCodeFormatterConstants.FALSE); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION_ON_PARAMETER, DefaultCodeFormatterConstants.FALSE); + String source = + "@Deprecated package pack;\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {}\n" + + " @Deprecated String label;\n" + + " @Deprecated void foo() {}\n" + + " @Deprecated interface I {}\n" + + "}\n"; + formatSource(source, + "@Deprecated package pack;\n" + + "\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {\n" + + " }\n" + + "\n" + + " @Deprecated String label;\n" + + "\n" + + " @Deprecated void foo() {\n" + + " }\n" + + "\n" + + " @Deprecated interface I {\n" + + " }\n" + + "}\n" + ); +} + +/** + * @deprecated Use a deprecated formatter option. + */ +public void test728() { + this.formatterPrefs = null; + this.formatterOptions.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_6); + this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, DefaultCodeFormatterConstants.FALSE); + String source = + "@Deprecated package pack;\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {}\n" + + " @Deprecated String label;\n" + + " @Deprecated void foo() {}\n" + + " @Deprecated interface I {}\n" + + "}\n"; + formatSource(source, + "@Deprecated package pack;\n" + + "\n" + + "public class Test {\n" + + " @Deprecated Test(String s) {\n" + + " }\n" + + "\n" + + " @Deprecated String label;\n" + + "\n" + + " @Deprecated void foo() {\n" + + " }\n" + + "\n" + + " @Deprecated interface I {\n" + + " }\n" + + "}\n" + ); +} + }