Bug 315577

Summary: [formatter] No line break after <br> if followed by {@link when formatting java source file
Product: [Eclipse Project] JDT Reporter: Ludovic WALLE <walle>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: daniel_megert, Olivier_Thomann, srikanth_sankaran, walle
Version: 3.6   
Target Milestone: 3.7 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Ludovic WALLE CLA 2010-06-03 09:07:13 EDT
Build Identifier: M20100211-1343

Formatting the following java source file

package fr.inist.refdoc.dtdNotice;

public class C {

	/**
	 * aaaa aaa aaa.<br>  
	 * {@link C}: aaaa.<br>
	 * {@link C}: aaaa.<br>
	 * aaa {@link C}: aaaa.<br>
	 * {@link C}: aaaa<br>
	 * {@link C}: aaaa.<br>
	 */
    public C() {
    }
}

is wrong. There is no new line after the <br> tag if it is followed by a {@link. The formatted source file is:
package fr.inist.refdoc.dtdNotice;

public class C {
	/**
	 * aaaa aaa aaa.<br> {@link C}: aaaa.<br> {@link C}: aaaa.<br>
	 * aaa {@link C}: aaaa.<br> {@link C}: aaaa<br> {@link C}: aaaa.<br>
	 */
	public C() {
	}
}

The only line break is after the <br> followed by aaa. I would have expected the format command to do nothing in this example.

 



Reproducible: Always

Steps to Reproduce:
1.Create a java class as:
package fr.inist.refdoc.dtdNotice;

public class C {
	/**
	 * aaaa aaa aaa.<br>  
	 * {@link C}: aaaa.<br>
	 * {@link C}: aaaa.<br>
	 * aaa {@link C}: aaaa.<br>
	 * {@link C}: aaaa<br>
	 * {@link C}: aaaa.<br>
	 */
    public C() {
    }
}

2. Format the source file.
Comment 1 Frederic Fusier CLA 2010-06-04 07:48:43 EDT
Reproduced using 3.6RC3.

Note that you have a simple workaround, put the lines inside a paragraph:

public class X02 {

	/**
	 * <p>
	 * aaaa aaa aaa.<br>
	 * {@link X02}: aaaa.<br>
	 * {@link X02}: aaaa.<br>
	 * aaa {@link X02}: aaaa.<br>
	 * {@link X02}: aaaa<br>
	 * {@link X02}: aaaa.<br>
	 * </p>
	 */
	public X02() {
	}
}

Then, the formatter will let the lines untouched as expected...
Comment 2 Ludovic WALLE CLA 2010-06-04 08:31:27 EDT
I didn't thought of that. I tried, and yes, formatting worked as I expected. 

But I won't apply it because I don't want to spend time doing that (manually) in all in my sources files, having to undo it once fixed, and not being sure that it works in all cases. As it is just an annoyance, I prefer doing nothing and wait for a real solution.
Comment 3 Frederic Fusier CLA 2010-06-23 09:50:52 EDT
Created attachment 172503 [details]
Proposed patch

Specifying that the formatter javadoc html tag needs to be followed by a new line was missing in some cases (typically when followed by a inline block).

This patch fixes this and the output will be correct now...
Comment 4 Frederic Fusier CLA 2010-06-23 10:02:29 EDT
(In reply to comment #3)
> Created an attachment (id=172503) [details]
> Proposed patch
> 
Released for 3.7M1 in HEAD stream.
Comment 5 Srikanth Sankaran CLA 2010-08-04 02:16:18 EDT
Verified for 3.7 M1 using build I20100802-1800