Ultra-detailed settings for Idea class annotation templates and method annotation templates

Set class annotation template

1.选择File–>Settings–>Editor–>File and Code Templates–>Includes–>File Header. 
write picture description here

2. In the blank space on the right, you can write your own template. Note that Scheme is the effective scope of the template. The optional variables are introduced in the description. ).

/**
 * @Auther: ${USER}
 * @Date: ${DATE} ${HOUR}:${MINUTE}
 * @Description: 
 */
  • 1
  • 2
  • 3
  • 4
  • 5

3. After the setting is completed, the annotation will be automatically generated when the class is created, and the effect is as follows. 
write picture description here

Set method annotation template

Idea does not have a place where you can directly set the method annotation template. You can use Live Templates for basic implementation. The steps are as follows. 
1. Select File–>Settings–>Editor–>Live Templates, first select the green plus sign on the right to create a new template group of your own, named myGroup as shown in the figure. 
write picture description here

2. Select the created group and select the green plus sign on the right to create a new template, as shown below. 
write picture description here

3. Fill in Abbreviation (quick input), Description (description) and template content (the template in the figure is as follows)

/**
 *
 * 功能描述: 
 *
 * @param: $param$
 * @return: $return$
 * @auther: $user$
 * @date: $date$ $time$
 */
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

4. Click Define and check Java 
write picture description here

5. Click Edit variables to edit variables, set as follows, click Ok->Apply to complete the settings. 
write picture description here

6. Enter "/**", and then press the Tab key to generate a comment, as shown below. Note that this method has a disadvantage, it needs to be generated inside the method, otherwise @param is null. 
write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325769818&siteId=291194637