IDEA class and method automatically generated annotations

A generating class comments

1. Open Preferences-->Editor-->File and Code Templatesthe right selection Filestab page, locate Class, Interfaceyou can see the right side of template references a File Header.javatemplate, as shown below:

image

1.1 Variable Description Template


${PACKAGE_NAME}   name of the package in which the new file is created
${USER}   current user system login name
${DATE}   current system date
${TIME}   current system time
${YEAR}   current year
${MONTH}   current month
${MONTH_NAME_SHORT}   first 3 letters of the current month name. Example: Jan, Feb, etc.
${MONTH_NAME_FULL}   full name of the current month. Example: January, February, etc.
${DAY}   current day of the month
${DAY_NAME_SHORT}   first 3 letters of the current day name. Example: Mon, Tue, etc.
${DAY_NAME_FULL}   full name of the current day. Example: Monday, Tuesday, etc.
${HOUR}   current hour
${MINUTE}   current minute
${PROJECT_NAME}   the name of the current project

2. Establish class automatically generated based annotations, as shown in FIG.

image


Second, the method of generating annotated

1.、打开Preferences-->Editor-->Live Templates,为了方便管理,新建一个分组来管理自己添加的Live Template,名为myGroup,

image

2.复制粘贴以下的模板

 
 
**
* @Author: 
* @Description:
* @Date: $date$  $time$
$params$
$return$
**/
3.设置变量
image
3.1 params变量,放在Default value中

groovyScript("if(\"${_1}\".length() == 2) {return '';} else {def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList();for(i = 0; i < params.size(); i++) {if(i==0){result+='* @Param ' + params[i] + ': '}else{result+='\\n' + ' * @Param ' + params[i] + ': '}}; return result;}", methodParameters());

3.2 return变量,放在Default value中
 
 
groovyScript("def returnType = \"${_1}\"; def result = '* @return: ' + returnType; return result;", methodReturnType());
3.3 Settings Shortcuts
image
The range is from 3.4 java
image
3.5 instructions

You need to play yourself out of / *, and then press ENTER generation method comments.

image


Guess you like

Origin www.cnblogs.com/fby698/p/11440637.html