Method IDEA, comments configuration class
1. Notes template configuration file
File-> Settings-> Editor-> File And Code Templates-> Includes-> File Header FIG:
Template $ {Description} codes can be entered when creating configuration files File Description
/**
* ${Description}
* @创建者: ${USER}
* @创建时间: ${DATE} ${TIME}
* @类名: ${NAME}
* @包名: ${PACKAGE_NAME}
* @项目名: ${PROJECT_NAME}
*/
Notes configuration template method
1、File–>Settings–>Editor–>Live Templates
(1) New group: named userDefine
(2) New template: name *
* Because IDEA generate comments of default is: / * + template name + shortcut key (for example, if set template named add shortcuts with Tab, the way to generate / add the Tab +), if you do not generate such a way in IDEA no method of content will not be available, for example, a method for obtaining parameters methodParameters (), return value acquisition method methodReturnType ()
(3) set the shortcut keys generated annotations
(4) set the template: template follows
Note that the first row, only instead of a * / * must be used when setting the parameter name
way, otherwise the fifth step you can not read the name of the parameter set
*
* $end$
// * @作者 $USER$
* @时间 $date$ $time$
$param$
* @返回 $return$
* @throws $throws$
*/
param value
groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {if(i==0){result+='* @param ' + params[i] + ((i < params.size() - 1) ? '\\n' : '')}else{result+=' * @param ' + params[i] + ((i < params.size() - 1) ? '\\n' : '')}}; return result", methodParameters())
(5) set the template application scenarios
click on the warning template bottom of the page, set the template used in those scenes, you can generally choose EveryWhere-Java (if ever modified, it appears as change rather than define)
(6) setting parameter acquisition mode
Select Edit variables button on the right
When selecting each parameter corresponding to the acquisition method (you can choose in the drop-down selection box), there are many online tutorials Way to use scripts getting param, I tried to use the script way not only cumbersome and can only be used within the method comments in order to obtain the parameters
(7) renderings
creation method, write in the above methods: / * + template name + Enter -> / ** + Enter