Phoenix Brothers Phoenix Brothers - 4 months ago 14
Android Question

How to set JavaDoc to update automatically when I change the method signature in Android Studio or IntelliJ IDEA

Is there a way to make JavaDoc update and add extra corresponding tags when I for example add return value to a method which was void before. This way JavaDoc will be updated as we change the code.

This related question asked 6 years ago for eclipse but no answer to that yet. As it says there too in the comments it's not about refactoring a name.

/**
* Some explanation about method.
*
* @return (I want this tag to be added automatically after I add return type "int" to method)
*/
private int ourMethod() {
int price = quantity * 5;
return price;
}

Answer

As of version 2016.2, there is no feature in IntelliJ IDEA that would add a @return tag for a method when you change its return type.

For parameters, if you use the "Change signature" refactoring, it will add @param tags for new parameters, delete them for parameters you remove, and update them for parameters you rename. The Rename refactoring will also rename @param tags.