### 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:12:37 -0000 @@ -1722,4 +1722,91 @@ "}\n" ); } + +/** + * @bug 239719: [formatter] Code formatter destroys pre formatted javadoc comments + * @test Ensure that annotations inside
...
tags are not considered as javadoc tags + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=239719" + */ +public void testBug239719() throws JavaModelException { + String source = + "/**\n" + + " *
\n" + 
+		" *  public class Test implements Runnable\n" + 
+		" *  {\n" + 
+		" *    @Override\n" + 
+		" *    public void run()\n" + 
+		" *    { \n" + 
+		" *      // Hello really bad Ganymede formatter !!!\n" + 
+		" *      // Shit happens when somebody tries to change a running system\n" + 
+		" *      System.out.println(\"Press Shift+Ctrl+F to format\");\n" + 
+		" *    }\n" + 
+		" *  }
\n" + + " */\n" + + " public class Test \n" + + " {\n" + + " }\n"; + formatSource(source, + "/**\n" + + " *
\n" + 
+		" * public class Test implements Runnable {\n" + 
+		" * 	@Override\n" + 
+		" * 	public void run() {\n" + 
+		" * 		// Hello really bad Ganymede formatter !!!\n" + 
+		" * 		// Shit happens when somebody tries to change a running system\n" + 
+		" * 		System.out.println("Press Shift+Ctrl+F to format");\n" + 
+		" * 	}\n" + 
+		" * }\n" + 
+		" * 
\n" + + " */\n" + + "public class Test {\n" + + "}\n" + ); +} +public void testBug239719b() throws JavaModelException { + String source = + "public class X01 {\n" + + " \n" + + " private int fLength;\n" + + " private int fOffset;\n" + + "\n" + + " /**\n" + + " * Returns the inclusive end position of this edit. The inclusive end\n" + + " * position denotes the last character of the region manipulated by\n" + + " * this edit. The returned value is the result of the following\n" + + " * calculation:\n" + + " *
\n" + 
+		"	 *   getOffset() + getLength() - 1;\n" + 
+		"	 * 
\n" + 
+		"	 * \n" + 
+		"	 * @return the inclusive end position\n" + 
+		"	 */\n" + 
+		"	public final int getInclusiveEnd() {\n" + 
+		"		return fOffset + fLength - 1;\n" + 
+		"	}\n" + 
+		"}\n";
+	formatSource(source,
+		"public class X01 {\n" + 
+		"\n" + 
+		"	private int fLength;\n" + 
+		"	private int fOffset;\n" + 
+		"\n" + 
+		"	/**\n" + 
+		"	 * Returns the inclusive end position of this edit. The inclusive end\n" + 
+		"	 * position denotes the last character of the region manipulated by this\n" + 
+		"	 * edit. The returned value is the result of the following calculation:\n" + 
+		"	 * \n" + 
+		"	 * 
\n" + 
+		"	 * getOffset() + getLength() - 1;\n" + 
+		"	 * \n" + 
+		"	 * 
\n" + 
+		"	 * \n" + 
+		"	 * @return the inclusive end position\n" + 
+		"	 */\n" + 
+		"	public final int getInclusiveEnd() {\n" + 
+		"		return fOffset + fLength - 1;\n" + 
+		"	}\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:12:38 -0000
@@ -371,9 +371,20 @@
  * @see org.eclipse.jdt.internal.compiler.parser.JavadocParser#parseTag(int)
  */
 protected boolean parseTag(int previousPosition) throws InvalidInputException {
-	int ptr = this.astPtr;
-	
+
+	// Do not parse javadoc tag inside 
...
tags + if (this.htmlTagsPtr >= 0) { + int ptr = this.htmlTagsPtr; + while (ptr >= 0) { + if (getHtmlTagIndex(this.htmlTags[ptr--]) == JAVADOC_CODE_TAGS_ID) { + if (this.textStart == -1) this.textStart = previousPosition; + return true; + } + } + } + // Read tag name + int ptr = this.astPtr; this.tagSourceStart = previousPosition; this.scanner.startPosition = this.index; this.scanner.currentCharacter = readChar();