Bug 260381 - [formatter] Javadoc formatter breaks {@code ...} tags.
Summary: [formatter] Javadoc formatter breaks {@code ...} tags.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-08 07:38 EST by Philippe Maseres CLA
Modified: 2010-03-09 03:54 EST (History)
2 users (show)

See Also:


Attachments
Proposed patch (6.20 KB, patch)
2009-06-23 04:25 EDT, Frederic Fusier CLA
no flags Details | Diff
New complete patch (38.76 KB, patch)
2010-02-09 17:14 EST, Frederic Fusier CLA
no flags Details | Diff
Final patch (195.57 KB, patch)
2010-02-11 07:03 EST, Frederic Fusier CLA
no flags Details | Diff
Final patch (without whitespaces noise...) (42.99 KB, patch)
2010-02-11 07:16 EST, Frederic Fusier CLA
no flags Details | Diff
Released patch (43.02 KB, patch)
2010-02-11 07:21 EST, Frederic Fusier CLA
no flags Details | Diff
Additional patch (32.30 KB, patch)
2010-02-14 10:57 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Maseres CLA 2009-01-08 07:38:57 EST
Build ID: M20080911-1700

Steps To Reproduce:
1. Edit a javadoc comment with tags that contain {@code ...} elements. Example :

/**
 * Comments that can be formated in several lines...
 *
 *  @author Myself
 *
 *  @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 $}
 */

2. Format the code.

3. The version tag value is broken, since the formatter splits the line :

/**
 * Comments that can be formated in several lines...
 * 
 * @author Myself
 * 
 * @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 $}
 */



More information:
Older versions (3.3 Europa, for example) handles the special {@code ...} sequence without splitting the value into multiple lines...
Comment 1 Frederic Fusier CLA 2009-01-08 09:29:07 EST
There's no specification saying that the @version tag should be kept on one line and splitting the @code text in two lines does not really break it.

But I agree that, since 3.3, there's an inconsistency between in-line @code tag and <code>...</code> HTML tags formatting although it is specified that {@code} is equivalent to <code>{@literal}</code>...

However, replacing @code in-line tag by <code> HTML tag is not a possible workaround as this produces the following output:
/**
 * Comments that can be formated in several lines...
 * 
 * @author Myself
 * 
 * @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 $</code>
 */
public class X02 {

}

The formatter should not split the line in this case...
Comment 2 Frederic Fusier CLA 2009-06-23 04:25:27 EDT
Created attachment 139842 [details]
Proposed patch

Add the notion of immutable block based on the tag value (currently only @code).
Comment 3 Olivier Thomann CLA 2010-02-08 15:10:08 EST
You might want to add the same support for @literal.
See http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#{@code}
Comment 4 Frederic Fusier CLA 2010-02-09 17:14:24 EST
Created attachment 158645 [details]
New complete patch

This patch addresses the initial issue but also remove all differences with 3.3 behavior in this area... :-)

It also considers @literal inline tag as immutable.
Comment 5 Frederic Fusier CLA 2010-02-11 07:03:48 EST
Created attachment 158835 [details]
Final patch

Final patch fixing one minor issue when the inline tag closing brace is at max column + 1...
Comment 6 Frederic Fusier CLA 2010-02-11 07:16:06 EST
Created attachment 158838 [details]
Final patch (without whitespaces noise...)

Previous patch wrongly included white spaces cleaning although I didn't want to do it... It seems that something went wrong with the Save Actions...
Comment 7 Frederic Fusier CLA 2010-02-11 07:21:08 EST
Created attachment 158839 [details]
Released patch

One more additional change in a Javadoc comment...
Comment 8 Frederic Fusier CLA 2010-02-11 07:21:45 EST
Released for 3.6M6 in HEAD stream.
Comment 9 Frederic Fusier CLA 2010-02-14 10:57:00 EST
Created attachment 159072 [details]
Additional patch

This additional patch fixes some minor issues with the line length computation while formatting an immutable block.

It also changes the initial tests as the $Revision,  $Date, etc. were meaningful for CVS and was changed at each check-out!
Comment 10 Frederic Fusier CLA 2010-02-14 10:58:37 EST
(In reply to comment #9)
> Created an attachment (id=159072) [details]
> Additional patch
> 
Released for 3.6M6
Comment 11 Srikanth Sankaran CLA 2010-03-09 03:54:16 EST
Verified for 3.6M6 using build I20100305-1011