• IntelliJ IDEA 生成类注释和方法注释


    1.类注释

      settings-> file and code templates-> files(Class) 

     代码:

    #if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
    #parse("File Header.java")
    
    
    /**
     *
     *@author matas
     *@date  ${DATE} ${TIME}
     *@email   mataszhang@163.com
     */
    public class ${NAME} {
    }

    2.方法注释

      settings-> live templates

          

       

     Step

     1.点击+  , 添加一个group 

     2.点击+, 添加一个 templates

     3.abbreviation 设置为 *

     4. template text 添加下面代码

    **
     *
     *
    $params$
     * @return $returns$ 
     * @author matas
     * @date $date$ $time$
     */

     5. 点击 edit variables 编辑变量

       

       

        参数 params 需要通过groovy脚本来循环参数列表生成。 脚本如下

        

    groovyScript("def result=''; def params="${_1}".replaceAll('[\\[|\\]|\\s]','').split(',').toList(); if(null != params && params.size()>0){ for(i = 0; i < params.size(); i++) { if(null == params[i] || 'null'.equals(params[i])) continue; result+=' * @param ' + params[i] + ((i < params.size() - 1) ? '\r\n' : '')}}; return result", methodParameters().trim())

    6 . 设置使用范围,勾选Java

     

     7.使用: 在方法上输入 /*后按TAB =>  (/*+TAB)

    package com.matas;
    
    /**
     *
     *@author matas
     *@date  2018/1/11 0:12
     *@email   mataszhang@163.com
     */
    
    public class Test {
    
        /**
         *
         *
         * @param a
         * @param b
         * @return java.lang.String
         * @author matas
         * @date 2018/1/11 0:12
         */
        public String test (int a ,int b) {
            return null;
        }
    }

    8.再添加一个live templates来生成类的注释

       abbreviation 设置为 cc

       模板内容:

    /**
     *
     *
     * @author matas
     * @date $date$ $time$
      *@email   mataszhang@163.com
     */

     按cc+TAB生成

    Over

  • 相关阅读:
    openpyxl python操作Excel表格,
    ansible剧本
    ansible基础知识(二)
    ansible基础知识
    Flask-Migrate
    Python3-笔记-B-003-数据结构-元组tuple( )
    Python3-笔记-B-002-数据结构-字典dict{ }
    Python3-笔记-B-001-数据结构-列表list[ ]
    Python3-笔记-A-001-基本语法
    cordova 学习链接
  • 原文地址:https://www.cnblogs.com/mataszhang/p/8262462.html
Copyright © 2020-2023  润新知