Why does the Eclipse code formatter break </a> in a Javadoc @see tag?
-
09-06-2019 - |
Question
I'm using Eclipse 3.4 and have configured the Java code formatter with all of the options on the Comments tab enabled. The problem is that when I format a document comment that contains:
* @see <a href="test.html">test</a>
the code formatter inserts a space in the closing HTML, breaking it:
* @see <a href="test.html">test< /a>
Why? How do I stop this happening?
This is not fixed by disabling any of the options on the Comments tab, such as Format HTML tags. The only work-around I found is to disable Javadoc formatting completely by disabling both the Enable Javadoc comment formatting and Enable block comment formatting options, which means I then have to format comment blocks manually.
Solution
I can only assume it's a bug in Eclipse. It only happens with @see tags, it happens also for all 3 builtin code formatter settings.
There are some interesting bugs reported already in the neighbourhood, but I couldn't find this specific one. See for example a search for @see in the Eclipse Bugzilla.
OTHER TIPS
Strict XML specifications require that the self closing tags should have a space before the closing slash like so:
<gcServer enabled="true" /> <!-- note the space just after "true" -->
I can only assume, like Bart said, that there is a bug in Eclipse's reformatter that thinks the closing tag is actually a self-closing tag. Another idea: Can you verify that your a tags are balanced (i.e. no unclosed tags higher up in the document)?
This could be a bug in Eclipse 3.4. I'm using 3.3 (M20080221-1800), and do not observe this behavior.