### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v retrieving revision 1.45 diff -u -r1.45 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 18 Jun 2009 11:20:56 -0000 1.45 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 19 Jun 2009 16:15:30 -0000 @@ -4501,6 +4501,28 @@ } /** + * @bug 267551: [formatter] Wrong spacing in default array parameter for annotation type + * @test Ensure that no space is inserted before the array initializer when used inside annotation + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=267551" + */ +public void testBug267551() throws JavaModelException { + String source = + "import java.lang.annotation.*;\n" + + "\n" + + "@Target({ ElementType.ANNOTATION_TYPE })\n" + + "@Retention(RetentionPolicy.RUNTIME)\n" + + "public @interface Foo { }\n"; + formatSource(source, + "import java.lang.annotation.*;\n" + + "\n" + + "@Target({ ElementType.ANNOTATION_TYPE })\n" + + "@Retention(RetentionPolicy.RUNTIME)\n" + + "public @interface Foo {\n" + + "}\n" + ); +} + +/** * @bug 267658: [formatter] Javadoc comments may be still formatted as block comments * @test Ensure that javadoc comment are formatted as block comment with certain * options configuration #P org.eclipse.jdt.core 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.166 diff -u -r1.166 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 18 Jun 2009 11:20:54 -0000 1.166 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 19 Jun 2009 16:15:32 -0000 @@ -3623,7 +3623,10 @@ } this.scanner.resetTo(this.scanner.getCurrentTokenStartPosition(), this.scannerEndPosition - 1); if (annotationsIndex < annotationsLength) { + boolean insertSpaceBeforeBrace = this.formatter.preferences.insert_space_before_opening_brace_in_array_initializer; + this.formatter.preferences.insert_space_before_opening_brace_in_array_initializer = false; annotations[annotationsIndex++].traverse(visitor, (BlockScope) null); + this.formatter.preferences.insert_space_before_opening_brace_in_array_initializer = insertSpaceBeforeBrace; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=122247 boolean shouldAddNewLine = false; switch (annotationSourceKind) {