IDEA添加Live Template:
File->Setting->Editor->Live Templates
Abbreviation:
*
Template text:
** *$context$ */
设置context内容:
Edit variables ->Default value
groovyScript("C:\IDEACommentLiveTemplate.groovy", currentPackage(), className(), methodName(), jsMethodName(), methodParameters(), methodReturnType(), date("yyyy-MM-dd"), time("HH:mm:ss"))
IDEACommentLiveTemplate.groovy脚本内容:
def packageName = _1; def className = _2; def methodName = _3; def jsMethodName = _4; def methodParameters = _5; def methodReturnType = _6; def date = _7; def time = _8; // 固定的时间,默认的是false def confirmedDateTime = false; def confirmedDateTimeString = "2017-06-15 12:20:40"; // 可以修改成自己的相关信息 def author = "yz"; def projectName = ""; def version = "V1.0.0"; def copyright = "yz All rights reserved."; def outputParams = ""; for(param in methodParameters) { outputParams += " * @param " + param + " : "; } def outputReturnType = ""; if (methodReturnType != "void") { outputReturnType = " * @return : " + methodReturnType + " "; } def outputMethodName = " * @Method : " + methodName + " "; def outputDesc = " * @Description : "; def outputAuthor = " * @author : " + author + " "; def outputDateTime = " * @CreateDate : " + date + " " + time + " "; if (confirmedDateTime) { outputDateTime = " * @CreateDate : " + confirmedDateTimeString + " "; } def outputProjectName = " * @Project : " + projectName + " "; def outputPackageName = " * @Package : " + packageName + " "; def outputClass = " * @Class : " + className + " "; def outputVersion = " * @version : " + version + " "; def outputClassOtherInfo = " * @Copyright : " + copyright + " "; outputClassOtherInfo += " * @Reviewed : " + " "; outputClassOtherInfo += " * @UpateLog : Name Date Reason/Contents "; outputClassOtherInfo += " * --------------------------------------- "; outputClassOtherInfo += " * **** **** **** "; def outputJsMethodName = " * @Method : " + jsMethodName + " "; def outputJsParams = " * @param "; def outputJsReturnType = " * @return : "; def result = ""; result += " "; if (methodName) { result += outputMethodName; result += outputDesc; result += outputParams; result += outputReturnType; result += outputAuthor; result += outputDateTime; } else if (jsMethodName) { result += outputJsMethodName; result += outputDesc; result += outputJsParams; result += outputJsReturnType; result += outputAuthor; result += outputDateTime; } else { result += outputProjectName; result += outputPackageName; result += outputClass; result += outputDesc; result += outputAuthor; result += outputDateTime; result += outputVersion; result += outputClassOtherInfo; } result += " *"; return result;
设置应用
内容转载自:http://www.cnblogs.com/xzjxylophone/p/7060035.html