每次突发配置没了,又得重新设置,这次记录下,折腾的可以参考下
类模板设置
/**
* @author :wangcheng
* @date ${DATE}
**/
image-20220118114436649
方法参数模版设置
1.有参数方法模版
2.类中属性字段注释
效果展示
public class Test {
/**
*
**/
private String name;
/**
*
* @author wangcheng
* @date 2022/01/18
* @param name
**/
public void test (String name){
}
/**
*
* @author wangcheng
* @date 2022/01/18
* @param name
* @param age
* @return java.lang.Object
**/
public Object testRes(String name,Integer age) {
return null;
}
}
idea设置里 选择live templates
image-20220118125840361Template text内容
**
* $END$$authorInfo$$params$$return$
**/
进入edit variables,对变量进行设值
image-20220118125946354authorInfo
groovyScript("import java.util.Date;import java.text.DateFormat;import java.text.SimpleDateFormat;SimpleDateFormat sdf = new SimpleDateFormat('yyyy/MM/dd');Calendar lastDate = Calendar.getInstance();String dateStr = sdf.format(lastDate.getTime());if(\"${_1}\".length() == 2) {return '\\n * @author wangcheng\\n * @date ' + dateStr } else {def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList();if('null'==params[0]){return ''} else {return '\\n * @author wangcheng\\n * @date ' + dateStr ;}; return result;}", methodParameters());
Params:
groovyScript("if(\"${_1}\".length() == 2) {return '';} else {def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList();if('null'==params[0]){return ''};for(i = 0; i < params.size(); i++) {if(i==0){result+='\\n * @param ' + params[i]}else{result+='\\n' + ' * @param ' + params[i]};}; return result;}", methodParameters());
Return:
groovyScript("def returnType = \"${_1}\"; if(returnType == 'void' || returnType == 'null'){return '';} else {return '\\n * @return '+returnType;};", methodReturnType());
网友评论