idea通过live template配置方法注释

idea live template config

method comment template

1 template

code
* 
 * $description$$END$
 *$params$$return$
 * @date $date$ $time$
 */
文字解释
  1. 第一行 "星号"顶格
  2. 第二行 空格+"星号"+空格+description参数+END参数
  3. 第三行 空格+"星号"+params参数+return参数
  4. 第四行 @date+空格+date参数+空格+time参数
  5. 第五行 空格+"星号"+反斜杠
截图

2 script

script code:
params: groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList();if(params[0].trim().equals('')) return ''; for(i = 0; i < params.size(); i++) {result+= '\\n * @param ' + params[i] + ' ' + params[i]}; return result", methodParameters())

return: groovyScript("def returnType = \"${_1}\"; if(returnType == 'null' || returnType.length() == 2 || returnType == 'void') {return '';} else{return '\\n * @return {@link '+ returnType +'}';}", methodReturnType())
截图:

3 实际效果

posted @ 2019-11-08 14:15  A_1023  阅读(1220)  评论(0编辑  收藏  举报