zoukankan      html  css  js  c++  java
  • IDEA类和方法注释自动生成(2019-08-31 21:47写)

    1. 生成类注释

    打开Preferences-->Editor-->File and Code Templates,右侧选择Filestab页,找到ClassInterface,可以看到右侧模板里引用了一个File Header.java模板,如下图:

    image

    模板变量说明

    ${PACKAGE_NAME}   name of the package in which the new file is created
    ${USER}   current user system login name
    ${DATE}   current system date
    ${TIME}   current system time
    ${YEAR}   current year
    ${MONTH}   current month
    ${MONTH_NAME_SHORT}   first 3 letters of the current month name. Example: Jan, Feb, etc.
    ${MONTH_NAME_FULL}   full name of the current month. Example: January, February, etc.
    ${DAY}   current day of the month
    ${DAY_NAME_SHORT}   first 3 letters of the current day name. Example: Mon, Tue, etc.
    ${DAY_NAME_FULL}   full name of the current day. Example: Monday, Tuesday, etc.
    ${HOUR}   current hour
    ${MINUTE}   current minute
    ${PROJECT_NAME}   the name of the current project
    

    建立类自动生成类注释,如下图所示

    image

    2. 生成方法注释

    打开Preferences-->Editor-->Live Templates,为了方便管理,新建一个分组来管理自己添加的Live Template,名为myGroup,

    image

    复制粘贴以下的模板

    **
    * @Author: 
    * @Description:
    * @Date: $date$  $time$
    $params$
    $return$
    **/
    

    设置变量

    params变量,放在Default value中

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

    return变量,放在Default value中

    groovyScript("def returnType = "${_1}"; def result = '* @return: ' + returnType; return result;", methodReturnType());
    

    设置快捷键

    设置范围为java

    使用说明

    需要自己打出来/*,然后按回车生成方法注释。

    image

  • 相关阅读:
    实习工作两月
    远程mysql_java.sql.SQLException: null, message from server: "Host 'xxx' is not allowed to connect
    大学毕业后拉开差距的真正原因写给将要毕业的自己
    var nameValue=$("#"+name+"DelFlag_"+id).attr("name"); 中的nameValue是一个字符串!并非boolean值
    装饰模式
    数据结构图(非带权图)(js)
    WPF的逻辑树与视觉树(1)基本概念
    WPF的动画(2)Animation
    集合附加属性(HACK)
    WPF的逻辑树与视觉树(2)Visual容器
  • 原文地址:https://www.cnblogs.com/fby698/p/12670781.html
Copyright © 2011-2022 走看看