Back in my C# days, I loved using a Visual Studio extension called "GhostDoc". Now that I'm a being used as a Java developer I'm using Eclipse. I can live without being able to have inferred documentation, but something that I'd like to do is to intelligently "fix" my documentation. For example, let's assume I have the following method:
/**
* Gets a collection of {@link Foo} objects
* @param bar The bar level
* @param baz The bazziness
*/
public Collection<Foo> getFoos(int bar, int baz)
{
// Do something cool
}
Later on in development I realize that it would be useful to allow the consumers of my method to pass in a qux value. Not only that, but it makes the most sense to have it as the first parameter. Also I'm going to have the method throw my super useful FooBarException. So now my method looks like this:
/**
* Gets a collection of {@link Foo} objects
* @param bar The bar level
* @param baz The bazziness
*/
public Collection<Foo> getFoos(String qux, int bar, int baz) throws FooBarException
{
// Do something cool
}
Being a good developer, I want my changes reflected in my JavaDoc. In GhostDoc I could hit my document shortcut key and it would add in the new stuff without disturbing the old stuff. In Eclipse, it renders a whole new set of JavaDoc and I have to do a bunch of copy pasta-ing. How can I automatically put in the new @param
, @exception
, and the missing @returns
parameter into my JavaDoc without losing the JavaDoc that I currently have?
Not sure if the following is what you ment, but since eclipse has its own JavaDoc Validator, you can configure compile Warnings/Errors under
Window -> Preferences -> Java -> Compiler -> JavaDoc.
With activating missing javadoc tags on your own needs and setting warning level to "warning", the compiler will notice your changes and give you a warning, as soon as your javadoc differs from your methods signature. To fix it, it offers a quickfix (STRG+1) and you can choose add all missing tags. This operation will add the missing tags even in the right place without messing with your old comment.