### 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.11.2.7 diff -u -r1.11.2.7 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 3 Jul 2008 09:19:59 -0000 1.11.2.7 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 8 Jul 2008 16:14:24 -0000 @@ -1722,4 +1722,50 @@ "}\n" ); } -} + +/** + * @bug 239941: [formatter] Unclosed html tags make the formatter to produce incorrect outputs + * @test Ensure that unclosed html tags do not screw up the formatter in following javadoc comments + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=239941" + */ +public void testBug239941() throws JavaModelException { + String source = + "public class X01 {\n" + + "\n" + + " /**\n" + + " *
\n" + + " * Unclosed pre tag\n" + + " */\n" + + " int foo;\n" + + "\n" + + " /**\n" + + " * Gets the signers of this class.\n" + + " *\n" + + " * @return the signers of this class, or null if there are no signers. In\n" + + " * particular, this method returns null if this object represents\n" + + " * a primitive type or void.\n" + + " * @since JDK1.1\n" + + " */\n" + + " public native Object[] getSigners();\n" + + "}\n"; + formatSource(source, + "public class X01 {\n" + + "\n" + + " /**\n" + + " *\n" + + " * Unclosed pre tag\n" + + " */\n" + + " int foo;\n" + + "\n" + + " /**\n" + + " * Gets the signers of this class.\n" + + " * \n" + + " * @return the signers of this class, or null if there are no signers. In\n" + + " * particular, this method returns null if this object represents a\n" + + " * primitive type or void.\n" + + " * @since JDK1.1\n" + + " */\n" + + " public native Object[] getSigners();\n" + + "}\n" + ); +}} #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.13.2.5 diff -u -r1.13.2.5 FormatterCommentParser.java --- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 3 Jul 2008 09:19:57 -0000 1.13.2.5 +++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 8 Jul 2008 16:14:25 -0000 @@ -42,6 +42,9 @@ this.javadocStart = start; this.javadocEnd = end; this.firstTagPosition = this.javadocStart; + // Need to flush html tags stack in case of unclosed ones in previous javadoc comments + // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=239941 + this.htmlTagsPtr = -1; // parse comment boolean valid = commentParse();