Live Template
需要在Live Templates里面创建一个模板组为MyTemplate
触发时机选择java
1、创建一个loge
log.error($content$,$params$);
content
groovyScript("def params = _3.collect {'【'+it+' = {}】'}.join(', '); return '\"' + _1 +'.'+ _2 + '() exception => ' + (params.empty ? '' : params) + '\"'", className(), methodName(), methodParameters())
params
groovyScript("def params = _1.collect {it}.join(', '); return (params.empty ? '' : params) + ',e' ", methodParameters())
2、创建一个logi
log.info($content$,$params$);
content
groovyScript("def params = _3.collect {'【'+it+' = {}】'}.join(', '); return '\"' + _1 +'.'+ _2 + '() parameters => ' + (params.empty ? '' : params) + '\"'", className(),methodName(), methodParameters())
params
groovyScript("def params = _1.collect {it}.join(', '); return (params.empty ? '' : params) ", methodParameters())
3、方法doc
* $params$ $return$* @author: $user$* @date: $date$ $time$*/
params
groovyScript("def result=''; def params=\"${_1}\".replaceAll('[\\\\[|\\\\]|\\\\s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+=' * @param ' + params[i] + ((i < params.size() - 1) ? '\\n':'')}; return result", methodParameters())
return
groovyScript("def returnType = \"${_1}\"; def result ='';if(returnType=='null'||returnType=='void'){return;}else{result += '';cls = returnType.split('<');for(i = 0; i < cls.size(); i++){temp = cls[i].tokenize('.');result += temp[temp.size() - 1] + ((i < cls.size() - 1) ? '<' : '');};return '\\r\\n * @return {@link '+result + '} ';}", methodReturnType());
做一个类似.var快捷键(json)
file-> settings -> editor -> general -> postfix completion