idea类注释模版以及方法模版
类注释
/**
* ${NAME}
*
* @author zzzz
* @since ${DATE} on ${TIME}
*/
新建分组:
缩写*,适用于升成/** */ 注释
**
*
*/
方法注释,缩写**,/** Enter即可;
**
* $methodName$
*
* @author
* @since $DATE$ on $TIME$$param$ $return$
*/
param表达式:
groovyScript("def result = '';def params = \"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {if(params[i] != '')result+='* @param ' + params[i] + ((i < params.size() - 1) ? '\\r\\n ' : '')}; return result == '' ? null : '\\r\\n ' + result", methodParameters())
return表达式:
groovyScript("return \"${_1}\" == 'void' ? null : '\\r\\n * @return ' + \"${_1}\".substring(\"${_1}\".lastIndexOf('.') + 1)", methodReturnType())
下面生成图:
/**
* test
*
* @author zzz
* @since 2024/4/25 on 上午10:00
*/
void test();
/**
* test1
*
* @author zzz
* @since 2024/4/25 on 上午10:15
* @return Integer
*/
Integer test1();
/**
* test2
*
* @author zzz
* @since 2024/4/25 on 上午10:16
* @param a
*/
void test2(String a);
/**
* test3
*
* @author zzz
* @since 2024/4/25 on 上午10:16
* @param a
* @param b
*/
void test3(String a, String b);
/**
* test4
*
* @author zzz
* @since 2024/4/25 on 上午10:16
* @param a
* @return Integer
*/
Integer test4(String a);
/**
* test5
*
* @author zzz
* @since 2024/4/25 on 上午9:58
* @param a
* @param b
* @return Integer
*/
Integer test5(String a, String b);
参考:IDEA这样配置注释模板,让你高出一个逼格!!-腾讯云开发者社区-腾讯云 (tencent.com)
修改了:return返回值,直接返回类型,不再需要包名
2024年6月11日10:42:59优化:
方法模版注释:【return 有List时会有问题,显示包名。param增加javadoc 警告注释名】
param:
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 : '\\r\\n ' + result", methodParameters())
return
groovyScript("def returnType = \"${_1}\"; return returnType == 'void' ? null : '\\r\\n * @return ' + returnType", methodReturnType())
/**
* getEmployeesNum
*
* @author xxx
* @since 2024/6/11 on 10:38
* @return java.util.List<java.lang.String>
*/
List<String> getEmployeesNum();
/**
* importExcel
*
* @author xxx
* @since 2024/6/11 on 10:38
* @param file file
*/
void importExcel(MultipartFile file);