Understanding the Issue: Eclipse Code Formatter and Javadoc @see Tags

If you’re using Eclipse 3.4 and find yourself frustrated by the Javadoc @see tags breaking during code formatting, you are not alone. Many developers encounter this peculiar issue that disrupts the seamless use of HTML in their documentation comments. Specifically, the issue arises when the Eclipse code formatter incorrectly inserts a space in the closing HTML tag of an anchor element, which looks something like this:

* @see <a href="test.html">test</a>

Becomes:

* @see <a href="test.html">test< /a>

Identifying the Problem

The core of the problem lies within the configuration of the Java code formatter in Eclipse. Despite having all options under the Comments tab configured, the formatting still introduces this inconsistency. Even disabling options like Format HTML tags does not resolve the issue.

Why Does This Happen?

  • Possible Bug: Based on user experiences and observations, this seems to be more of a bug within Eclipse, particularly affecting Javadoc @see tags.
  • Formatter Settings: The issue persists across all built-in code formatter settings, suggesting a systematic flaw in how the formatter processes these tags.

Seeking Solutions: How to Fix This Issue

While there is currently no perfect solution to this bug, users have reported several workarounds that can help manage or circumvent the issue.

Workarounds

  1. Disable Javadoc Formatting:

    • As a temporary fix, you can disable Javadoc comment formatting entirely by unchecking both the Enable Javadoc comment formatting and Enable block comment formatting options in your Eclipse settings. However, this means you will need to manage formatting your comment blocks manually, which can be tedious.
  2. Manual Correction:

    • Although it may not be the most efficient method, another approach is to format your comments normally and then once the formatting is applied, manually correct any broken tags.
  3. Check for Updates:

    • Always ensure you are using the latest version of Eclipse. Sometimes, bugs are addressed in newer releases, and upgrading can potentially resolve persistent issues.
  4. Report the Bug:

    • If you have not done so already, consider reporting the bug to the Eclipse Bugzilla page. You can check out existing reports related to @see tags and monitor any updates or solutions offered by the Eclipse development team.

Conclusion

While the issue of the Eclipse code formatter breaking your Javadoc @see tags can be frustrating, understanding its origins allows you to implement effective workarounds. By disabling certain formatting options or manually correcting tags, you can continue to create clear and informative documentation within your Java projects. Stay tuned for Eclipse updates, as they may eventually resolve this pesky bug, enhancing your coding experience further.

For a deeper dive into bugs and to keep an eye on related issues, visit Eclipse Bugzilla.