In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
In the process of using IDEA development, we can set the code annotation template to realize the automatic completion of the annotation information and improve the coding efficiency.
I am using a Mac computer, so let's use the Mac environment to explain it.
Configure the code comment template of IDEA on Mac, which mainly consists of two parts: one is the File Head file header comment, which is used to describe the information of the class file, and the other is the method header comment, which is used to describe the information of the class method. The specific configuration process is as follows.
I. configuration class file header comment template
Click the "IntelliJ IDEA" button in the upper left corner of the IDEA compiler, select "Preferences...", in the pop-up window, select "Editor-- > File and Code Templates", select "Default" in the "Schema" drop-down bar on the right side of the window, and then click the "Includes" tab to fill in the comment template in the right template bar. Finally, click the OK button in the lower right corner to take effect.
The reference content is as follows:
/ * Project name: ${PROJECT_NAME} * Class name: ${NAME} * Class description: TODO * creation time: ${DATE} ${TIME} * founder: ${USER} * /
Among them, ${.} is filled in with tags that automatically fill in the content. There is a list of tags currently supported by IDEA in the lower right corner of the window.
Second, configuration method header annotation template
Click the "IntelliJ IDEA" button in the upper left corner of the IDEA compiler, select "Preferences...", and in the pop-up window, select "Editor-- > Live Templates" to enter the method header comment template editing interface, as shown in the following figure.
To add a comment for the method header, you need to take the following steps:
(1) first, create a group of annotation templates by clicking the "+" sign in step 2 of the figure. For example, we name it: MethodGroup.
(2) add the instruction keyword that needs to be entered when filling comments in the "Abbreviation" input box in step 4, here we use "add" as the keyword, and add the instruction description in step 5. After this step, the instruction keyword appears in the comment group MethodGroup created in the previous step, as shown in the third step in the figure.
(3) to edit the comment content template, refer to the following (Note: it is not necessary to start with / *, because we will enter it manually when we add comments):
* * @ name: $enclosing_method$ * @ description: TODO $param$ * @ return: $return$ * @ date: $date$ $time$ * @ auther: $user$ * /
(4) Click the step 7 button to specify the value of the parameters in the comment code in the pop-up window.
It should be noted that if the param parameter defaults to the system's methodParam (), then in the comment statement, it will use "@ param: [pa1, pa2...]" The form shows. We use the groovyScript script to format the comment statement for param so that each parameter is on a line.
The content of the script is:
GroovyScript ("def result=''; def params=\" ${1}\ ".replaceAll) ('[[\ [|\] |\] |\ s]','). Split (',') .toList (); for (I = 0; I
< params.size(); i++) {if(params[i] == '') return result;if(i==0) result += '\\n'; result+=' * @param ' + params[i] + ((i < params.size() - 1) ? '\\n' : '')}; return result", methodParameters()) (5)接下来指定填充注释语句的提示字符,通过窗口中的"Expand with"来指定。"Space"表示空格,"Tab"表示 Tab键。 (6)最后是指定注释的使用范围,通过点击窗口下面的"...Change"来完成。Third, use code to annotate templates
When the above is done, you can use the annotation template. You can create a new class, and the class file header comments are automatically generated.
Create a new method in the class, then type / * add on top of the method, and press Space (spacebar) to automatically complete the entire comment code.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.