Bug 291270 - [formatter] the @literal tag breaks selected column width
Summary: [formatter] the @literal tag breaks selected column width
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-03 05:23 EDT by Simon Gronlund CLA
Modified: 2009-10-27 15:14 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Gronlund CLA 2009-10-03 05:23:24 EDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; sv-SE; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)
Build Identifier: I20090611-1540

In Javadoc: The @literal tag itself is not considered when computing the length of the line, thus each long line with such a tag exceeds the selected column width.

Reproducible: Always

Steps to Reproduce:
1. In a Javadoc comment, type a line just long enough not to exceed the selected column width. Format to be sure.
2. Add a @literal tag around anything in the previous line. Format again. The line did not reformat but exceeds the columns width.
3.
Comment 1 Frederic Fusier CLA 2009-10-05 03:54:06 EDT
It's often clearer and helpful for us to reproduce when a simple test case shows the problem.

Considering the following test case:
public interface Test {

	/**
	 * This a test for bug 291720: {@literal 3<4}
	 */
	void foo();
}

When formatting it using Eclipse built-in + max line width = 40, I get:
public interface Test {

	/**
	 * This a test for bug 291720:
	 * {@literal 3<4}
	 */
	void foo();
}

So, it sounds to work properly...

However, if your test case was:
public interface Test {

	/**
	 * This a test for bug 291720: @literal
	 */
	void foo();
}

Then I agree that formatting it does not break the line although you could expect it. But this is intentional and not limited to @literal tag. If the formatter detects that breaking a line would imply to have a block tag at the beginning then it skips the tag and brakes the line after it.

The reason of this behavior is because if the line would have been broken before the block tag then another formatting would have formatted the comment differently, hence would have made the formatter output unstable.

Again a sample would be better to understand this. Formatting the test case above would have produced the following output:
public interface Test {

	/**
	 * This a test for bug 291720:
	 * @literal
	 */
	void foo();
}

But formatting this output again would have given a different output:
public interface Test {

	/**
	 * This a test for bug 291720:
	 * 
	 * @literal
	 */
	void foo();
}

As block tags written in a line are often users mistakes (typically in your case, I guess it is as @literal is an inline tag...), we have chosen to accept characters over the max line width instead of making the formatter unstable...

So, close as WONTFIX. Reopen in case my assumption on your test case was totally wrong, thanks
Comment 2 Olivier Thomann CLA 2009-10-27 15:14:08 EDT
Agree with comment 1.
Verified for 3.6M3 using I20091027-0100