java自动生成函数注释_IDEA类和方法注释自动生成(2019-08-31 21:47写)

1. 生成类注释

打开Preferences-->Editor-->File and Code Templates,右侧选择Filestab页,找到Class、Interface,可以看到右侧模板里引用了一个File Header.java模板,如下图:

f8976cb72808747dad36a7f854a15070.png

模板变量说明

${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

建立类自动生成类注释,如下图所示

99c7f4d1a888bfc99c4147ec50d5764f.png

2. 生成方法注释

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

e0b59e42d9974139940a3de852dc4c28.png

复制粘贴以下的模板

**

* @Author:

* @Description:

* @Date: $date$ $time$

$params$

$return$

**/

设置变量

df4031a48af70693f69ad9d297938302.png

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());

return变量,放在Default value中

groovyScript("def returnType = \"${_1}\"; def result = ‘* @return: ‘ + returnType; return result;", methodReturnType());

设置快捷键

1e2a6d6c85dc8b006810c550f685f442.png

设置范围为java

e700ce31e2e8263b205ece0e5110fe80.png

使用说明

需要自己打出来/*,然后按回车生成方法注释。

8e2d7ad2ef92847e1b088604cbf1f27a.png

原文:https://www.cnblogs.com/fby698/p/12670781.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值