Method IDEA, comments configuration class

Method IDEA, comments configuration class

1. Notes template configuration file

File-> Settings-> Editor-> File And Code Templates-> Includes-> File Header FIG:
Template $ {Description} codes can be entered when creating configuration files File Description

/**
 * ${Description}     
 * @创建者:    ${USER}
 * @创建时间:  ${DATE}  ${TIME}
 * @类名:     ${NAME}
 * @包名:     ${PACKAGE_NAME}
 * @项目名:  ${PROJECT_NAME}
 */

Here Insert Picture Description

Notes configuration template method

1、File–>Settings–>Editor–>Live Templates
Here Insert Picture Description

(1) New group: named userDefine
Here Insert Picture Description


(2) New template: name *

* Because IDEA generate comments of default is: / * + template name + shortcut key (for example, if set template named add shortcuts with Tab, the way to generate / add the Tab +), if you do not generate such a way in IDEA no method of content will not be available, for example, a method for obtaining parameters methodParameters (), return value acquisition method methodReturnType ()

(3) set the shortcut keys generated annotations
Here Insert Picture Description

(4) set the template: template follows
Note that the first row, only instead of a * / * must be used when setting the parameter name Ginseng number name {parameter name} way, otherwise the fifth step you can not read the name of the parameter set

*
 * $end$ 
// * @作者 $USER$
 * @时间  $date$ $time$
 $param$
 * @返回 $return$
 *   @throws   $throws$ 
 */ 
 

param value

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

(5) set the template application scenarios
Here Insert Picture Description
Here Insert Picture Description
click on the warning template bottom of the page, set the template used in those scenes, you can generally choose EveryWhere-Java (if ever modified, it appears as change rather than define)

Here Insert Picture Description
(6) setting parameter acquisition mode

Select Edit variables button on the right
Here Insert Picture Description
P S : The first Fives \ Color {# FF0000} {PS: Steps 5 and sixth order can not be reversed, otherwise it will get less than a sixth step method}

When selecting each parameter corresponding to the acquisition method (you can choose in the drop-down selection box), there are many online tutorials Way to use scripts getting param, I tried to use the script way not only cumbersome and can only be used within the method comments in order to obtain the parameters

(7) renderings
creation method, write in the above methods: / * + template name + Enter -> / ** + Enter
Here Insert Picture Description

Published 30 original articles · won praise 0 · Views 6653

Guess you like

Origin blog.csdn.net/qq_37710756/article/details/103258090