I won’t say much about the power of IntelJ Idea. I believe everyone who has used it will understand it, but we will also be confused by its complexity, especially the children’s shoes that just turned from eclipse. I believe that the first experience was unbearable to look back on, and I also came through it step by step.
A topic I will talk about today is how to implement functions like eclipse's Code Templates to implement file-level method-level annotation.
There are still some differences in the annotation of idea and eclipse.
idea:
Class header comment: Open file->setting->Editor->Filr and Code Templates->Includes->File Header
Edit the things you said you need comments directly in the file box on the right, and then after the application is saved, the comments will be automatically generated when you create the class.
Method comment: Open file->setting->Editor->LiveTemplates Click the green + sign on the top of the right, select Template Group and double-click, and then a window pops up, add a name at will. I added MyGroup here and click OK
Or click the name you just added (I'm MyGroup), then click the green + sign on the top of the right, select LiveTemplate double-click, fill in the box on the picture below
Then click
Then choose Everywhere
Finally, click the Edit variables button in the lower right corner, and a window pops up, as follows:
If you want to use @param: each parameter can be like this
Write the parameter values yourself
The code copy is as follows:
groovyScript("def result=''; def params=/"${_1}/".replaceAll('[////[|////]|////s]', '').split(',').toList(); for(i = 0; i < params.size(); i++) {result+=' * @param ' + params[i] + ((i < params.size() - 1) ? '//n//b' : '')}; return result", methodParameters())
Add this in, but also note one thing:
Click OK to select the corresponding parameters in the drop-down box in the red circle below.
Click apply and click Ok.
Then before writing the method, click add (fill in just now) and press tab, and the comment will come out.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.