1.在idea的 Live Templates中找到Java分类,新建一个Live Template
Template text:
* * $END$ * @author songmin $param$ * @date $date$ $time$ $return$ */
2.编辑变量属性
param值:
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());
return值:
groovyScript("def returnType = "${_1}"; def result = '* @return: ' + returnType; return result;", methodReturnType());