分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

IDEA使用 live template添加groovy脚本给方法,类,js方法添加注释(转载)

发布时间:2023-09-06 01:44责任编辑:顾先生关键词:js

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;// 固定的时间,默认的是falsedef 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 + " : \n";}def outputReturnType = "";if (methodReturnType != "void") { ???outputReturnType = " * @return : " + methodReturnType + "\n";}def outputMethodName ????????= " * @Method : " + methodName + "\n";def outputDesc ????????????????= " * @Description : \n";def outputAuthor ????????????= " * @author : " + author + "\n";def outputDateTime ???????????= " * @CreateDate : " + date + " " + time + "\n";if (confirmedDateTime) { ???outputDateTime ???????????= " * @CreateDate : " + confirmedDateTimeString + "\n";}def outputProjectName ???????= " * @Project : " + projectName + "\n";def outputPackageName ???????= " * @Package : " + packageName + "\n";def outputClass ???????????????= " * @Class : " + className + "\n";def outputVersion ???????????= " * @version : " + version + "\n";def outputClassOtherInfo ???= " * @Copyright : " + copyright + "\n";outputClassOtherInfo ??????+= " * @Reviewed : " + "\n";outputClassOtherInfo ??????+= " * @UpateLog : ???Name ???Date ???Reason/Contents\n";outputClassOtherInfo ??????+= " * ????????????---------------------------------------\n";outputClassOtherInfo ??????+= " * ???????????????**** ???**** ???**** \n";def outputJsMethodName ???????= " * @Method : " + jsMethodName + "\n";def outputJsParams ???????????= " * @param \n";def outputJsReturnType ???????= " * @return : \n";def result = "";result += "\n";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

IDEA使用 live template添加groovy脚本给方法,类,js方法添加注释(转载)

原文地址:https://www.cnblogs.com/townsend/p/8488283.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved