IDEA類和方法注釋模板設置


1、在類上設置注釋的模板

File-->settings-->Editor-->File and Code Templates-->Files

 

 

選擇CLASS,如果沒有選擇File 下面的+ 進行添加

內容

#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
/**
* @author :
* @date :${DATE} ${TIME}
* @description :
* @modyified By:
*/
public class ${NAME} {
}

 

如果添加右下角的Apply 即可

2、 File-->Settings-->Editor-->Live Templates

 選擇新增分組,

 

然后新增具體的模板

Abbreviation 的值設置為* ,Description 為add comment for method ,

Template text

*
* 功能描述:
* @Param: $param$
* @Return: $return$
* @Author: $author$
* @Date: $date$ $time$
* @Description: 
*/

 

選擇作用的位置

 

 

勾選java

 

下面設置默認值

 

param 設置的Default Value為 

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

return 設置為

methodReturnType()

date 設置為date()

time 位置為time()

 

生成后的

    /**
    * 功能描述:
    * @Param: 
     * @param code
     * @param msgParams
     * @param throwable 
    * @Return: 
    * @Author: 
    * @Date: 2020/11/26 14:44
    * @Description: 
    */
    @Deprecated
    public BusinessException(String code,String [] msgParams,Throwable throwable) {
     }

 

如果嫌棄@Param生成的不好看則設置為 methodParameters()

@return 也可以設置為groovy腳本

groovyScript("def params=\"${_1}\"; if(params=='void'){return '';} else {return '\\n\t * @return ' + params}", methodReturnType())

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM