一、类注释配置
File -> Settings->Editor->File and Code Template
模板如下:
/**
* //TODO 记得写注释
*
* @author yangjf
* @date ${YEAR}.${MONTH}.${DAY} ${TIME}
*/
新建类之后对应注释出现,效果如下:
二、方法注释配置
File -> Settings->Editor->Live Templates
模板如下:
**
* // TODO XX
*
$param$
$return$
* @author yangjf
* @date $date$$time$
*/
方法参数脚本
groovyScript("def result = '';def params = \"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList();for(i = 0; i < params.size(); i++) {if(params[i] != '')result+=' * @param ' + params[i] + ' ' + params[i] + ((i < params.size() - 1) ? '\\r\\n' : '')}; return result == '' ? null : result", methodParameters())
返回值参数脚本
groovyScript("def returnType = \"${_1}\"; def result ='';if(returnType=='null'||returnType=='void'){return;}else{result += ' * @return {@link ';cls = returnType.split('<');for(i = 0; i < cls.size(); i++){temp = cls[i].tokenize('.');result += temp[temp.size() - 1] + ((i < cls.size() - 1) ? '<' : '');};return result + '} ';}", methodReturnType());
在方法上输入/**
,按Tab补全,效果如下