### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.ui Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java,v retrieving revision 1.22 diff -u -r1.22 FormatterMessages.java --- ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java 29 May 2007 18:41:36 -0000 1.22 +++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java 24 Jan 2008 11:21:33 -0000 @@ -427,6 +427,7 @@ public static String NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer; public static String NewLinesTabPage_annotations_group_title; public static String NewLinesTabPage_annotations_group_option_after_annotation; + public static String NewLinesTabPage_annotations_group_option_after_arg_annotation; public static String ProfileManager_default_profile_name; public static String ProfileManager_eclipse_profile_name; public static String ProfileManager_java_conventions_profile_name; Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/NewLinesTabPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/NewLinesTabPage.java,v retrieving revision 1.24 diff -u -r1.24 NewLinesTabPage.java --- ui/org/eclipse/jdt/internal/ui/preferences/formatter/NewLinesTabPage.java 29 May 2007 18:41:36 -0000 1.24 +++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/NewLinesTabPage.java 24 Jan 2008 11:21:33 -0000 @@ -92,6 +92,7 @@ final Group annotationsGroup= createGroup(numColumns, composite, FormatterMessages.NewLinesTabPage_annotations_group_title); createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_option_after_annotation, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION, DO_NOT_INSERT_INSERT); + createPref(annotationsGroup, numColumns, FormatterMessages.NewLinesTabPage_annotations_group_option_after_arg_annotation, DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ARG_ANNOTATION, DO_NOT_INSERT_INSERT); } Index: ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties,v retrieving revision 1.72 diff -u -r1.72 FormatterMessages.properties --- ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties 29 May 2007 18:41:36 -0000 1.72 +++ ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties 24 Jan 2008 11:21:33 -0000 @@ -485,6 +485,7 @@ NewLinesTabPage_annotations_group_title=Annotations NewLinesTabPage_annotations_group_option_after_annotation=&Insert new line after annotations +NewLinesTabPage_annotations_group_option_after_arg_annotation=Insert new line after argument annotations ProfileManager_default_profile_name=Eclipse 2.1 [built-in] ProfileManager_eclipse_profile_name=Eclipse [built-in] #P org.eclipse.jdt.core 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.202 diff -u -r1.202 CodeFormatterVisitor.java --- formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 31 Oct 2007 12:48:49 -0000 1.202 +++ formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java 24 Jan 2008 11:21:38 -0000 @@ -2396,7 +2396,7 @@ if (argument.modifiers != NO_MODIFIERS || argument.annotations != null) { this.scribe.printComment(); - this.scribe.printModifiers(argument.annotations, this); + this.scribe.printModifiers(argument.annotations, this, true); this.scribe.space(); } 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.85 diff -u -r1.85 DefaultCodeFormatterOptions.java --- formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 23 May 2007 13:43:37 -0000 1.85 +++ formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java 24 Jan 2008 11:21:39 -0000 @@ -123,6 +123,7 @@ public int indentation_size; public boolean insert_new_line_after_annotation; + public boolean insert_new_line_after_arg_annotation; public boolean insert_new_line_after_opening_brace_in_array_initializer; public boolean insert_new_line_at_end_of_file_if_missing; public boolean insert_new_line_before_catch_in_try_statement; @@ -398,6 +399,7 @@ 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, this.insert_new_line_after_annotation ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); + options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ARG_ANNOTATION, this.insert_new_line_after_arg_annotation ? 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); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, this.insert_new_line_at_end_of_file_if_missing ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); options.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, this.insert_new_line_before_catch_in_try_statement? JavaCore.INSERT : JavaCore.DO_NOT_INSERT); @@ -1132,6 +1134,10 @@ if (insertNewLineAfterAnnotationOption != null) { this.insert_new_line_after_annotation = JavaCore.INSERT.equals(insertNewLineAfterAnnotationOption); } + final Object insertNewLineAfterArgAnnotationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_ARG_ANNOTATION); + if (insertNewLineAfterArgAnnotationOption != null) { + this.insert_new_line_after_arg_annotation = JavaCore.INSERT.equals(insertNewLineAfterArgAnnotationOption); + } final Object insertNewLineAfterOpeningBraceInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER); if (insertNewLineAfterOpeningBraceInArrayInitializerOption != null) { this.insert_new_line_after_opening_brace_in_array_initializer = JavaCore.INSERT.equals(insertNewLineAfterOpeningBraceInArrayInitializerOption); @@ -2246,6 +2252,7 @@ this.indent_switchstatements_compare_to_switch = false; this.indentation_size = 4; this.insert_new_line_after_annotation = true; + this.insert_new_line_after_arg_annotation = false; this.insert_new_line_after_opening_brace_in_array_initializer = false; this.insert_new_line_at_end_of_file_if_missing = false; this.insert_new_line_before_catch_in_try_statement = false; 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.113 diff -u -r1.113 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 29 Dec 2007 07:36:22 -0000 1.113 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 24 Jan 2008 11:21:40 -0000 @@ -1470,6 +1470,10 @@ } public void printModifiers(Annotation[] annotations, ASTVisitor visitor) { + printModifiers(annotations, visitor, false); + } + + public void printModifiers(Annotation[] annotations, ASTVisitor visitor, boolean atArg) { try { int annotationsLength = annotations != null ? annotations.length : 0; int annotationsIndex = 0; @@ -1502,8 +1506,20 @@ } this.scanner.resetTo(this.scanner.getCurrentTokenStartPosition(), this.scannerEndPosition - 1); if (annotationsIndex < annotationsLength) { + boolean hasMemberValuePairs = annotations[annotationsIndex].memberValuePairs().length > 0; annotations[annotationsIndex++].traverse(visitor, (BlockScope) null); - if (this.formatter.preferences.insert_new_line_after_annotation) { + if (atArg) { + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 + if (hasMemberValuePairs) { + if (this.formatter.preferences.insert_new_line_after_annotation) { + this.printNewLine(); + } + } else { + if (this.formatter.preferences.insert_new_line_after_arg_annotation) { + this.printNewLine(); + } + } + } else if (this.formatter.preferences.insert_new_line_after_annotation) { this.printNewLine(); } } else { 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.84 diff -u -r1.84 DefaultCodeFormatterConstants.java --- formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 1 Jun 2007 19:31:00 -0000 1.84 +++ formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java 24 Jan 2008 11:21:36 -0000 @@ -942,6 +942,20 @@ /** *
+	 * FORMATTER / Option to insert a new line after an argument annotation
+	 *     - option id:         "org.eclipse.jdt.core.formatter.insert_new_line_after_arg_annotation"
+	 *     - possible values:   { INSERT, DO_NOT_INSERT }
+	 *     - default:           INSERT
+	 * 
+ * @see JavaCore#INSERT + * @see JavaCore#DO_NOT_INSERT + * @since 3.4 + */ + public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ARG_ANNOTATION = JavaCore.PLUGIN_ID + ".formatter.insert_new_line_after_arg_annotation";//$NON-NLS-1$ + + + /** + *
 	 * FORMATTER / Option to insert a new line after the opening brace in an array initializer
 	 *     - option id:         "org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer"
 	 *     - possible values:   { INSERT, DO_NOT_INSERT }
#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.223
diff -u -r1.223 FormatterRegressionTests.java
--- src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java	29 Dec 2007 07:36:16 -0000	1.223
+++ src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java	24 Jan 2008 11:21:46 -0000
@@ -9813,4 +9813,29 @@
 		};
 		runTest(codeFormatter, "test699", "A.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$
 	}
+	
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247
+	public void test700() {
+		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
+		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
+		preferences.line_separator = "\n";//$NON-NLS-1$
+		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
+		IRegion[] regions = new IRegion[] {
+				new Region(0, 221) // nothing selected --> format all
+		};
+		runTest(codeFormatter, "test700", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$
+	}
+	
+	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247
+	public void test701() {
+		final Map options = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
+		DefaultCodeFormatterOptions preferences = new DefaultCodeFormatterOptions(options);
+		preferences.line_separator = "\n";//$NON-NLS-1$
+		preferences.insert_new_line_after_arg_annotation = true;
+		DefaultCodeFormatter codeFormatter = new DefaultCodeFormatter(preferences);
+		IRegion[] regions = new IRegion[] {
+				new Region(0, 221) // nothing selected --> format all
+		};
+		runTest(codeFormatter, "test701", "X.java", CodeFormatter.K_UNKNOWN, 0, false, regions, "\n");//$NON-NLS-1$ //$NON-NLS-2$
+	}
 }
Index: workspace/Formatter/test700/X_out.java
===================================================================
RCS file: workspace/Formatter/test700/X_out.java
diff -N workspace/Formatter/test700/X_out.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ workspace/Formatter/test700/X_out.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,8 @@
+public class X {
+
+	@Deprecated
+	@SuppressWarnings("unused")
+	public void setFoo(@Required String name, @NotNull int value,
+			@Required int start, @Required int length) {
+	}
+}
Index: workspace/Formatter/test700/X_in.java
===================================================================
RCS file: workspace/Formatter/test700/X_in.java
diff -N workspace/Formatter/test700/X_in.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ workspace/Formatter/test700/X_in.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,8 @@
+public class X {
+	
+	@Deprecated @SuppressWarnings("unused") public void setFoo(@Required String name,
+																@NotNull int value,
+																@Required int start,
+																@Required int length) {
+			}
+}
Index: workspace/Formatter/test701/X_in.java
===================================================================
RCS file: workspace/Formatter/test701/X_in.java
diff -N workspace/Formatter/test701/X_in.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ workspace/Formatter/test701/X_in.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,8 @@
+public class X {
+	
+	@Deprecated @SuppressWarnings("unused") public void setFoo(@Required String name,
+																@NotNull int value,
+																@Required int start,
+																@Required int length) {
+			}
+}
Index: workspace/Formatter/test701/X_out.java
===================================================================
RCS file: workspace/Formatter/test701/X_out.java
diff -N workspace/Formatter/test701/X_out.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ workspace/Formatter/test701/X_out.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,11 @@
+public class X {
+
+	@Deprecated
+	@SuppressWarnings("unused")
+	public void setFoo(@Required
+	String name, @NotNull
+	int value, @Required
+	int start, @Required
+	int length) {
+	}
+}