IDEA configures class annotations and method annotations
First show the effect diagram, whenever a class is created, it will automatically add annotations, the author's time in the industry (you need to add it yourself), and the class name information created under which project, author's creation time, author's name, author's email address , project version number, configuration changer version, etc.
1. In File->Setting->Editor→File and Code Templates, select Includes→click to create a new name as "File Top" and
enter the following code in File Top (you can change it according to your own information)
/*
* Copyright (c) 2020, ${YEAR}, keyila All rights reserved.
*
*/
2. Find File Header in Includes (the system will automatically create a blank inside), and enter the following code in the right window. (Change according to your own information)
/**
*
* <p>Project: ${PROJECT_NAME} - ${NAME}
* <p>Powered by keyila On ${YEAR}-${MONTH}-${DAY} ${HOUR}:${MINUTE}:${SECOND}
*
* @author keyila [[email protected]]
* @version 1.0
* @since 17
*/
3. After completing the operation of Includes, click Files next to it and find Class, and add File Top on the left. Because when you complete the acquisition of File Top, the right side of the window will automatically obtain the content you filled in, but it will not obtain the content of File Top, you need to add it yourself. All codes in Class are as follows
#parse("File Top.java")
#if (${
PACKAGE_NAME} && ${
PACKAGE_NAME} != "")package ${
PACKAGE_NAME};#end
#parse("File Header.java")
public class ${
NAME} {
}
4. Test after adding. (It has been tested at the beginning)
5. Method comment, in File->Setting->Editor→ Live Templates, click "+" on the right to select a new group (name yourself)
6. After creating a group, click "+" to create a shortcut Key method annotations. The class annotation code created here is as follows
/**
*
* <p>Description:
* <p>Class:$cname$
* <p>Powered by &user$ on $y$-$m$--$d$ $time$
* @author $user$ [[email protected]]
* @version 1.0
* @since 17
*/
After writing the code, remember to select Applicable to Java in the lower left corner. After completion, click Edit Template on the right
and configure the Edit Template as shown in Figure
7. After the configuration is complete, test it. The shortcut key set here is "cc", you can enter the shortcut key according to your own habits. Press "cc" and then press the Enter key
8. After configuring a commonly used shortcut key, you can quickly add comments by writing a method each time. Also click the "+" on the right in File->Setting->Editor→Live Templates, and then name the shortcut key. After completion, the code is as follows
/**
* Description:
* @date:$Date$ $Time$
* @params:$params$
* @return:$return$
*/
Remember to select change to apply to java, and click Edit Template on the right
9. Test run. The shortcut key set here is "mm" and press Enter