### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java,v retrieving revision 1.92 diff -u -r1.92 AbstractCommentParser.java --- compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 14 Dec 2009 19:54:53 -0000 1.92 +++ compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java 8 Feb 2010 16:09:55 -0000 @@ -147,6 +147,7 @@ boolean verifText = (this.kind & TEXT_VERIF) != 0; boolean isDomParser = (this.kind & DOM_PARSER) != 0; boolean isFormatterParser = (this.kind & FORMATTER_COMMENT_PARSER) != 0; + int lastStarPosition = -1; // Init scanner position this.linePtr = getLineNumber(this.firstTagPosition); @@ -325,6 +326,7 @@ break; case '*' : // Store the star position as text start while formatting + lastStarPosition = previousPosition; if (previousChar != '*') { this.starPosition = previousPosition; if (isDomParser || isFormatterParser) { @@ -401,7 +403,7 @@ } refreshInlineTagPosition(textEndPosition); setInlineTagStarted(false); - } else if (this.lineStarted && this.textStart != -1 && this.textStart <= textEndPosition) { + } else if (this.lineStarted && this.textStart != -1 && this.textStart <= textEndPosition && (this.textStart < this.starPosition || this.starPosition == lastStarPosition)) { pushText(this.textStart, textEndPosition); } updateDocComment(); #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java,v retrieving revision 1.17 diff -u -r1.17 FormatterBugsTests.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 4 Jan 2010 19:48:24 -0000 1.17 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java 8 Feb 2010 16:09:57 -0000 @@ -3928,4 +3928,94 @@ "}\n"; formatSource(source); } + +/** + * @bug 302123: [formatter] AssertionFailedException occurs while formatting a source containing the specific javadoc comment... + * @test Verify that no exception occurs while formatting source including the specific comment + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=302123" + */ +public void testBug302123() { + String source = + "package test;\n" + + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " String s=\"X\"+/** ***/\"Y\";\n" + + " }\n" + + "\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " String s = \"X\" + /** ***/\n" + + " \"Y\";\n" + + " }\n" + + "\n" + + "}\n" + ); +} +public void testBug302123b() { + String source = + "package test;\n" + + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " String s=\"X\"+/** XXX ***/\"Y\";\n" + + " }\n" + + "\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " String s = \"X\" + /** XXX ***/\n" + + " \"Y\";\n" + + " }\n" + + "\n" + + "}\n" + ); +} +public void testBug302123c() { + String source = + "package test;\n" + + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " String s=\"X\"+/** ** XXX ** ***/\"Y\";\n" + + " }\n" + + "\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " String s = \"X\" + /** ** XXX ** ***/\n" + + " \"Y\";\n" + + " }\n" + + "\n" + + "}\n" + ); +} +public void testBug302123d() { + String source = + "package test;\n" + + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " String s=\"X\"+/**AAA *** BBB *** CCC***/\"Y\";\n" + + " }\n" + + "\n" + + "}\n"; + formatSource(source, + "package test;\n" + + "\n" + + "public class Test {\n" + + " public static void main(String[] args) {\n" + + " String s = \"X\" + /** AAA *** BBB *** CCC ***/\n" + + " \"Y\";\n" + + " }\n" + + "\n" + + "}\n" + ); +} }