Skip to main content

Javadoc Hints

Posted by gsporar on August 30, 2007 at 3:34 PM PDT

I've been browsing some open source projects lately and have been
seeing a fair amount of source code without Javadoc comments. One of
my favorite features in
NetBeans IDE 6.0 is that it provides an editor
hint that will create a Javadoc comment. That hint, however, is turned
off by default.

This is best shown through examples. The file below is from the source
for javac:

none.png

The IDE would be happy to add a Javadoc comment above line 56. And to
repair the Javadoc comments above lines 69 and 78. But there are no
hint icons in the margin to indicate that until I turn on that
option:

hoptions.png

Notice the dropdown list is set to Warning on Current Line
which means the cursor has to be on the line that needs the Javadoc
before the hint icon is displayed.
So if I put the cursor on line 56 the icon appears:

56.png

If I click that icon with the mouse or press the Alt-Enter key on the keyboard
the IDE will offer to insert the appropriate Javadoc comment. An option to reduce visual clutter by limiting the
display of the hint to only when the cursor is on the line is very handy
(not all tools are this flexible).

If, on the other hand, I want to see all Javadoc hints that are available
regardless of the cursor position I can change the option to either Warning:

allW.png

Or Error:

allE.png