### Eclipse Workspace Patch 1.0 #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.134 diff -u -r1.134 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 6 May 2008 17:42:28 -0000 1.134 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 8 May 2008 17:31:14 -0000 @@ -1025,8 +1025,9 @@ this.pendingSpace = false; if (includesBlockComments()) { - printBlockComment(currentTokenStartPosition, currentTokenEndPosition); - return; + if (printBlockComment(currentTokenStartPosition, currentTokenEndPosition)) { + return; + } } int currentCommentOffset = onFirstColumn ? 0 : getCurrentCommentOffset(start); @@ -1137,7 +1138,7 @@ this.scanner.resetTo(currentTokenEndPosition, this.scannerEndPosition - 1); } - private void printBlockComment(int currentTokenStartPosition, int currentTokenEndPosition) { + private boolean printBlockComment(int currentTokenStartPosition, int currentTokenEndPosition) { // Compute indentation @@ -1264,6 +1265,17 @@ scannerLine = Util.getLineNumber(this.scanner.getCurrentTokenEndPosition(), this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines); continue; } + case TerminalTokens.TokenNameMINUS: + if (previousToken == -1) { + // Do not format comment starting with /*- + // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=230944 + this.indentationLevel = indentLevel; + this.numberOfIndentations = indentations; + this.lastNumberOfNewLines = 0; + needSpace = false; + this.scanner.skipComments = false; + return false; + } } // Look at gap and insert corresponding lines if necessary @@ -1398,6 +1410,7 @@ needSpace = false; this.scanner.resetTo(currentTokenEndPosition, this.scannerEndPosition - 1); this.scanner.skipComments = false; + return true; } private void printBlockCommentHeaderLine(StringBuffer buffer) { #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java,v retrieving revision 1.14 diff -u -r1.14 FormatterCommentsTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 6 May 2008 19:34:27 -0000 1.14 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java 8 May 2008 17:31:16 -0000 @@ -868,6 +868,9 @@ public void testBlockComments18() throws JavaModelException { formatUnit("comments.block", "X18.java"); } +public void testBlockComments19() throws JavaModelException { + formatUnit("comments.block", "X19.java"); +} /* * Test formatter on example got from workspaces Index: workspace/FormatterJavadoc/test/comments/block/out/default/X19.java =================================================================== RCS file: workspace/FormatterJavadoc/test/comments/block/out/default/X19.java diff -N workspace/FormatterJavadoc/test/comments/block/out/default/X19.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/comments/block/out/default/X19.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +package test.comments.block; + +public class X19 { + + /*- + * Here is a block comment with some very special + * formatting that I want indent(1) to ignore. + * + * one + * two + * three + */ + void foo() { + } +} Index: workspace/FormatterJavadoc/test/comments/block/X19.java =================================================================== RCS file: workspace/FormatterJavadoc/test/comments/block/X19.java diff -N workspace/FormatterJavadoc/test/comments/block/X19.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ workspace/FormatterJavadoc/test/comments/block/X19.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +package test.comments.block; + +public class X19 { + +/*- + * Here is a block comment with some very special + * formatting that I want indent(1) to ignore. + * + * one + * two + * three + */ +void foo() { +} +}