Recently, I have nothing to do and officially switched to the idea tool camp with Eclipse. After all, 70% of developers are using idea development, so its charm can be imagined. I first started working about one day and I knew why it was named Intelli (intelli). It is indeed very intelligent. This is still some small details. Of course, Idea also has its shortcomings, which is the "customized method annotation template" we are going to talk about today. The class annotation template can be set up very simply. I will not repeat it here. Many articles on the Internet about custom method annotation templates are mostly plagiarized and obtained and forwarded, but they have not verified it themselves. This article has been personally verified and validated.
1. File->settings->Editor->Live Templates
2. Click the green + sign in the upper right corner, then select template group, then enter the name of the group, and just enter it: myGroup. Then click OK
3. Select the myGroup you just created, and then click the green + on the right again. This time you select the first 1. Live Template. Name it *, and the name can be casual, but I personally think it is convenient, so you can choose something else.
4. Configure the template. Below is my template. Please read carefully that my template starts with * instead of /*. This is the key.
/* * * @author chenmc * @date $date$ $time$ * @param $params$ * @return $returns$ */
Note that only when the variable is surrounded by $$ is the Edit variables on the right can you click.
5. After editing the template, add only $$ to the parameters and click Editor variables on the right.
6. After finishing, click Apply and click OK. Note, the key point is to enter /* on your method and then add the name of the template*. This is why I didn’t take the letter and named it *. Because it is very fast, press the Tab key again (note that you don’t press the Enter key, but press the Tab key) and the annotation you want will appear. Many tutorials are to directly enter the template name and press the tab key, but @param and @return of this method cannot be obtained. Repeat the correct way: /** and then press the Tab key; if you name it abc, it is /*abc and then press Tab. The effects are as follows:
7. But there is another problem. Careful readers will find that they have reported an error on the @param parameter. This is because of the powerful check function of idea, and there are two solutions:
File->settings->Editor->Inspections->javadoc issues The fourth item below will change the red Error to yellow Warning
The second type is to click on the head image in the lower right corner of the idea, then select the highlight level, and turn it into Syntax mode.
The work has been completed so far, I hope it can help everyone!
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.