• Idea 添加注释:类注释、方法注释(可获取参数)


    Idea 添加注释:类注释、方法注释
    类注释
    方法注释
    类注释
    File–Setting–Editor–File and Code Templates–Class:
    注释模板:

    /**
    *
    *@description: *@author: Andy *@time: ${DATE} ${TIME} * */

    操作截图:

     效果:

     方法注释

    为了获取参数信息,我们需要使用 “ Live Templates” 。

    创建 Live Templates 分组

    File–Setting–Live Templates。

      创建 Template

    我们上一步创建了 Andy 分组,现在我们将在 Andy 分组中创建 Template。

     设置模板内容

    模板缩写(Abbreviation):例如,我们可以把它设置为 “a”。
    模板描述(Description):例如,我们可以设置为 “方法注释”。
    模板内容:

    *
    * @description: 
    $params$
    * @return: $return$
    * @author: Andy
    * @time: $date$ $time$
    */ 

     定义模板的使用范围

     

     定义模板内容中引用的变量

     我们上一步的截图中,点击 Edit variables 按钮可以弹出变量设置窗口。

    这里,我们把参数变量 params 设置为一个自定义函数 groovyScript() 。groovyScript 函数调用 Idea 的 methodParameters() 函数获得参数数组,并进行格式化。
    params 的值(即 groovyScript 函数):

    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())

     其他变量的值,直接使用 Idea 的函数进行赋值。

    date → date()
    time → time()
    return → methodReturnType()

    效果:

     

     

  • 相关阅读:
    第七次作业-正规式到正规文法与自动机
    第六次作业——正规文法与正规式
    作业5 词法分析程序的设计与实现
    作业4—文法和语言总结与梳理
    第三次作业
    第二次作业-语言和文法
    编译原理第一次作业
    记录在腾讯云上搭建Ubuntu服务器
    第八章总结--排序 数据结构课程终章
    第七章-查找
  • 原文地址:https://www.cnblogs.com/wsy0202/p/13032693.html
Copyright © 2020-2023  润新知