IDEA类或方法设置注释

开启设置快捷键CRL+ALT+S

一:全局设置(File and code Templates-->includes)

IDEA类或方法设置注释

二:局部设置(File and code Templates-Files)

IDEA类或方法设置注释

三:自定义方法注解(Live Templates)
新建一个模板,通过definde选择应用的地方,此处或是java文件一般只要选择java
IDEA类或方法设置注释
添加内容如下:

IDEA类或方法设置注释

Edit Variables设置表达式及默认值
params设置为methodParameters()
return 设置为methodReturnType()
date设置为date()
IDEA类或方法设置注释
expand with Tab将其设置Enter,否则用"/**"+Enter还是默认的模块,
必须使用"/**"+Tab快捷键
IDEA类或方法设置注释

优化:将@param变量不存数组,分开如下图如示:
IDEA类或方法设置注释
解决方法:设置默认值使用groovyScript函数
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());

IDEA类或方法设置注释

猜你喜欢

转载自blog.51cto.com/1929297/2531728
今日推荐