How configure Intellij Idea javadoc templates?

Cherry picture Cherry · Jul 12, 2013 · Viewed 27.7k times · Source

I have some method:

public int getSomeField()

I want to generate javadoc like this:

/**
* Gets {someField}
*
* @return value of {someField}
*/

Where {someField} is placeholder for field name. It is possible to create this templates for Intellij Idea (may be as live template)?

Answer

Will Humphreys picture Will Humphreys · Jun 29, 2016

Bring up the Generate menu (Cmd+N on Mac, Alt+Insert on Windows)

Generate menu

Click the ellipsis in the top right hand corner.

Generate Getters menu

Click the plus in the top left corner and create a new template. Create new template dialog

Copy the contents of the old template into the new template and add the following lines to the top of it.

/**
* Gets $field.name
*
* @return value of $field.name
*/

enter image description here

Now when you generate the getter use the 'New Template' and you should get your getter with the JavaDoc.

Select New Template

enter image description here