IDEA classes and methods IDEA comment template set of classes and methods Notes template settings (very detailed)

IDEA class and method comments template settings (very detailed)

IDEA comes with comment template is not very good, I am to the Internet to collect a lot of information about the production system is put together a more complete template for everyone to share, I am not a professional play blog, writing this article just to let everyone save.

Notes template set here using Eclipse format, following first comment posted Eclipse template, we will follow the format set:

Class Notes templates: a template method Notes:

I. First, we set the template class IDEA: (IDEA when you create a class to automatically add comments)

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

We select Class file (of course you have to set the interface can also choose Interface file)

(1) $ {NAME}: Set the class name, and the following $ {NAME} in order to get to the same class name created

(2) TODO: dos labeled, generally generated class or method need to add description

(3) $ {USER}, $ {DATE}, $ {TIME}: Set to create a user class, date and time of creation, these things IDEA built-in methods, there are other ways in the green box marked location, For example, you want to add the project name, you can use $ {PROJECT_NAME}

(4) 1.0: set the version number, the newly created classes are generally 1.0 version, here to write on it dead

 

2, showing the effect of FIG.

 

Second, the method set annotated template

IDEA has not yet smart enough to automatically create annotated as we approach this is to manually add comments to our method, we use Eclipse is used to generate comments

/ ** + Enter, here we are in this habit to set the IDEA method comments

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

(1) New Group: name userDefine

 

(2) create a new template: name *

IDEA because the default mode is generated comment: / * + template name + shortcut key (for example, if set template named add shortcuts with Tab, generating way

/ * Add + Tab), if the method does not generate such a content is not available in a manner IDEA, e.g. methodParameters acquisition method parameters (),

The method of obtaining methodReturnType return value ()

 

(3) set the shortcut keys generated annotations

 

(4) set the template: template reads as follows

Note that the first row, only instead of a * / *

You must use $ {parameter name} $ ways, otherwise the fifth step you can not read the name of the parameter set when setting the parameter name

/ *
* @Author chengpunan
* @Description // TODO $ End $
* Time @date $ $ $ $ DATE
* @Param $ param $
* @return $ return $
** /
If you use a template comment / * will be generated the following effects: so we have to get rid of the foremost / *

 

(5) Application of scene setting template

Click on the warning template bottom of the page, set the template used in those scenes, usually selected EveryWhere -> Java to

(If you've modified, it appears as change rather than define)

(6) setting parameter acquisition mode

Select Edit variables button on the right

PS: Steps 5 and sixth order can not be reversed, otherwise it will get less than a sixth step method

 

Select each parameter corresponding to the acquisition method (you can select in the drop-down selection box), there are many online tutorials Way to use scripts getting param, I tried using a script

The only way to get into trouble and only within the parameters of the method when using annotations

(7) Effect of FIG.

Create a method, the method may write: / * + template name + Enter -> / ** + Enter

My life is limited, knowledge has no limits ~~~

IDEA comes with comment template is not very good, I am to the Internet to collect a lot of information about the production system is put together a more complete template for everyone to share, I am not a professional play blog, writing this article just to let everyone save.

Notes template set here using Eclipse format, following first comment posted Eclipse template, we will follow the format set:

Class Notes templates: a template method Notes:

I. First, we set the template class IDEA: (IDEA when you create a class to automatically add comments)

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

We select Class file (of course you have to set the interface can also choose Interface file)

(1) $ {NAME}: Set the class name, and the following $ {NAME} in order to get to the same class name created

(2) TODO: dos labeled, generally generated class or method need to add description

(3) $ {USER}, $ {DATE}, $ {TIME}: Set to create a user class, date and time of creation, these things IDEA built-in methods, there are other ways in the green box marked location, For example, you want to add the project name, you can use $ {PROJECT_NAME}

(4) 1.0: set the version number, the newly created classes are generally 1.0 version, here to write on it dead

 

2, showing the effect of FIG.

 

Second, the method set annotated template

IDEA has not yet smart enough to automatically create annotated as we approach this is to manually add comments to our method, we use Eclipse is used to generate comments

/ ** + Enter, here we are in this habit to set the IDEA method comments

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

(1) New Group: name userDefine

 

(2) create a new template: name *

IDEA because the default mode is generated comment: / * + template name + shortcut key (for example, if set template named add shortcuts with Tab, generating way

/ * Add + Tab), if the method does not generate such a content is not available in a manner IDEA, e.g. methodParameters acquisition method parameters (),

The method of obtaining methodReturnType return value ()

 

(3) set the shortcut keys generated annotations

 

(4) set the template: template reads as follows

Note that the first row, only instead of a * / *

You must use $ {parameter name} $ ways, otherwise the fifth step you can not read the name of the parameter set when setting the parameter name

/ *
* @Author chengpunan
* @Description // TODO $ End $
* Time @date $ $ $ $ DATE
* @Param $ param $
* @return $ return $
** /
If you use a template comment / * will be generated the following effects: so we have to get rid of the foremost / *

 

(5) Application of scene setting template

Click on the warning template bottom of the page, set the template used in those scenes, usually selected EveryWhere -> Java to

(If you've modified, it appears as change rather than define)

(6) setting parameter acquisition mode

Select Edit variables button on the right

PS: Steps 5 and sixth order can not be reversed, otherwise it will get less than a sixth step method

 

Select each parameter corresponding to the acquisition method (you can select in the drop-down selection box), there are many online tutorials Way to use scripts getting param, I tried using a script

The only way to get into trouble and only within the parameters of the method when using annotations

(7) Effect of FIG.

Create a method, the method may write: / * + template name + Enter -> / ** + Enter

Guess you like

Origin www.cnblogs.com/toufajiantuzhongbuhui/p/12587114.html