### 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.25 diff -u -r1.25 FormatterCommentParser.java --- formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 24 Mar 2009 08:51:02 -0000 1.25 +++ formatter/org/eclipse/jdt/internal/formatter/FormatterCommentParser.java 22 Jun 2009 16:37:22 -0000 @@ -355,6 +355,7 @@ this.scanner.resetTo(this.index, this.javadocEnd); return true; } + this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value return false; } @@ -381,6 +382,7 @@ } this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd); } + this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value } return valid; } @@ -393,6 +395,7 @@ if (!valid) { this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd); this.index = this.tagSourceEnd+1; + this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value } return valid; } @@ -504,7 +507,7 @@ if (length == TAG_LINK_LENGTH && CharOperation.equals(TAG_LINK, tagName)) { this.tagValue = TAG_LINK_VALUE; if (this.inlineTagStarted || (this.kind & COMPLETION_PARSER) != 0) { - valid= parseReference(); + valid = parseReference(); } else { // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=53290 // Cannot have @link outside inline comment @@ -603,7 +606,6 @@ } else if (this.invalidTagName) { this.textStart = previousPosition; } else if (this.astPtr == ptr) { - this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value createTag(); } return true; @@ -618,6 +620,7 @@ // If invalid, restart from the end tag position this.scanner.resetTo(this.tagSourceEnd+1, this.javadocEnd); this.index = this.tagSourceEnd+1; + this.tagValue = TAG_OTHERS_VALUE; // tag is invalid, do not keep the parsed tag value } return valid; } 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.167 diff -u -r1.167 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 22 Jun 2009 11:10:30 -0000 1.167 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 22 Jun 2009 16:37:23 -0000 @@ -2548,6 +2548,14 @@ } else { printJavadocHtmlTag(text, block, newLines>0); } + } else if (block.isImmutable()){ + // Indent if new line was added + if (newLines > 0 && this.commentIndentation != null) { + addInsertEdit(node.sourceStart, this.commentIndentation); + this.column += this.commentIndentation.length(); + } + printJavadocHtmlImmutableTag(text, block, newLines > 0); + this.column += getTextLength(block, text); } else { printJavadocText(text, block, newLines>0); } Index: formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java,v retrieving revision 1.8 diff -u -r1.8 FormatJavadocBlock.java --- formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java 27 Jun 2008 16:04:08 -0000 1.8 +++ formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java 22 Jun 2009 16:37:22 -0000 @@ -31,6 +31,7 @@ final static int PARAM_TAG = 0x0020; final static int IN_PARAM_TAG = 0x0040; final static int IN_DESCRIPTION = 0x0080; + final static int IMMUTABLE = 0x0100; // constants final static int MAX_TAG_HIERARCHY = 10; @@ -53,6 +54,10 @@ case TAG_THROWS_VALUE: case TAG_EXCEPTION_VALUE: this.flags |= PARAM_TAG; + break; + case TAG_CODE_VALUE: + this.flags |= IMMUTABLE; + break; } } @@ -322,6 +327,16 @@ return (this.flags & PARAM_TAG) == PARAM_TAG; } +/** + * Returns whether the block is immutable or not. + * + * @return true if the block is immutable, + * false otherwise. + */ +public boolean isImmutable() { + return (this.flags & IMMUTABLE) == IMMUTABLE; +} + void setHeaderLine(int javadocLineStart) { if (javadocLineStart == this.lineStart) { this.flags |= ON_HEADER_LINE; #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.46 diff -u -r1.46 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 22 Jun 2009 11:10:32 -0000 1.46 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 22 Jun 2009 16:37:24 -0000 @@ -4396,6 +4396,25 @@ } /** + * @bug 260381: [formatter] Javadoc formatter breaks {@code ...} tags. + * @test Ensure that the @code tag is similar to HTML tag + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260381" + */ +public void testBug260381() throws JavaModelException { + this.formatterPrefs.join_wrapped_lines = false; + String source = + "/**\n" + + " * Comments that can be formated in several lines...\n" + + " * \n" + + " * @author Myself\n" + + " * @version {@code $Revision: 1.2 $ $Date: 2009/01/07 12:27:50 $ $Author:myself $ $Source: /projects/cvs/module/project/src/com/foo/Main.java,v $}\n" + + " */\n" + + "public class X01 {\n" + + "}\n"; + formatSource(source); +} + +/** * @bug 260798: [formatter] Strange behavior of never join lines * @test Ensure that the formatter indents lines correctly when never join lines pref is activated * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=260798"