Get the App
SLTechnology News&Howtos  ›  Development  › 

How to automatically generate class comments and method comments by idea

Shulou Source: shulou.com Published: 2022-06-03 09:47:53 10月04日 Update

Editor to share with you how idea automatically generate class comments and method comments, I believe that most people do not understand, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Change the computer and reinstall idea, record the method of adding automatic comments, in case you use idea version: 2018.3.1

1. Generate class comments

Open setting-> Editor-> File and Code Templates-> Files-> Class

Generate a class annotation template

/ * * @ program: ${PROJECT_NAME} * @ description: ${description} * @ author ${USER} * @ date ${YEAR}-${MONTH}-${DAY} ${HOUR}: ${MINUTE}: ${SECOND} * /

Effect.

two。 Generate method comments

Open setting-> Editor-> Live Templates-> Click the plus sign on the right to add a Templates Group-> then select the added Group and click the plus sign again to add Live Templates

The added group name can be decided by yourself, but the added live templates name is best *

Generate a class annotation template

* * $VAR1 $$params$ * @ return $returns$ * @ author $user$ * @ describe: * @ date$ date$ $time$ * /

Then click Edit variables to configure variables

The script for VAR1 is as follows:

GroovyScript ("def result=''; def params=\" ${1}\ ".replaceAll ('[\ [|\] |\]]','). Split (','). ToList (); for (I = 0; I < params.size (); replaceAll) {if (iTune0) result+='*' Result+='@param'+ params [I] + ((I < (params.size ()-1))?'\ n' +'\ t':');}; return result ", methodParameters ())

Next, click define to check the desired file format. You can select all or only java.

At this point, the configuration has been completed, enter / * *, and then Tab

The above is all the content of the article "how idea automatically generates class comments and method comments". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Comments generation methods articles automatic generation content plus sign name template annotation configuration next not much again right most effects files more best Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info MySQL Huawei MariaDB Shulou Information