### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java,v retrieving revision 1.17 diff -u -r1.17 FormatterCommentParser.java --- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 27 Jun 2008 16:04:07 -0000 1.17 +++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 1 Jul 2008 16:10:37 -0000 @@ -234,6 +234,10 @@ incremented = true; } } + // Accept xhtml syntax + if (readToken() == TerminalTokens.TokenNameDIVIDE) { + consumeToken(); + } break; case TerminalTokens.TokenNameDIVIDE: // HTML tag closing @@ -280,7 +284,7 @@ // Push texts if (this.lineStarted && this.textStart != -1 && this.textStart < endTextPosition) { - pushText(this.textStart, endTextPosition, -1, htmlPtr == -1 ? 0 : htmlPtr); + pushText(this.textStart, endTextPosition, -1, htmlPtr); } pushText(previousPosition, this.index, htmlIndex, this.htmlTagsPtr); this.textStart = -1; @@ -645,7 +649,7 @@ } // Add the text - FormatJavadocText text = new FormatJavadocText(start, end-1, lineStart, htmlIndex, htmlDepth); + FormatJavadocText text = new FormatJavadocText(start, end-1, lineStart, htmlIndex, htmlDepth==-1 ? 0 : htmlDepth); previousBlock.addText(text); previousBlock.sourceStart = previousStart; if (lineStart == previousBlock.lineStart) { #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.17 diff -u -r1.17 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 1 Jul 2008 10:04:25 -0000 1.17 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 1 Jul 2008 16:10:38 -0000 @@ -1618,4 +1618,38 @@ "}\n" ); } + +/** + * @bug 238853: [formatter] Code Formatter does not properly format valid xhtml in javadoc. + * @test Ensure that xhtml valid tags are taken into account by the comment formatter + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=238853" + */ +public void testBug238853() throws JavaModelException { + String source = + "public class Test {\n" + + "\n" + + "/**\n" + + " * This is a test comment. \n" + + " *

\n" + + " * Another comment.
\n" + + " * Another comment.\n" + + " */\n" + + "public void testMethod1()\n" + + "{\n" + + "}\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + "\n" + + " /**\n" + + " * This is a test comment.\n" + + " *

\n" + + " * Another comment.
\n" + + " * Another comment.\n" + + " */\n" + + " public void testMethod1() {\n" + + " }\n" + + "}\n" + ); +} }