Eclipse annotation Template

Source: Internet
Author: User

As a programmer, the readability of the written code is very important! The readable code should not only have a standard format, but also have appropriate annotations. Each class, method, attribute, or important code segment should be annotated so that you can read the code next time or by others. In eclipse, You can automatically generate comments for classes, methods, and attributes. As for what the comment is to be displayed, you can adjust the display according to your own needs, or you can directly import the template, which is easier. The method for importing a template is described here.
First, copy the following content to generate an XML file.

<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="false" context="settercomment_context" deleted="false" description="Comment for setter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.settercomment" name="settercomment">  /**  * @param ${param} : set the property ${bare_field_name}.  * @author ${user}  * @update ${date} ${time}  */       </template><template autoinsert="false" context="methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name="methodcomment">  /**  * ${tags}  * @description   * @version 1.0  * @author ${user}  * @update ${date} ${time}  */       </template><template autoinsert="false" context="gettercomment_context" deleted="false" description="Comment for getter method" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name="gettercomment">  /**  * @author ${user}  * @update ${date} ${time}  * @return ${bare_field_name} : return the property ${bare_field_name}.  */       </template><template autoinsert="false" context="typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.typecomment" name="typecomment">  /**  * @description   * @version 1.0  * @author ${user}  * @update ${date} ${time}  */       </template><template autoinsert="false" context="constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name="constructorcomment">  /**  * Constructor Method  * @author ${user}  * @update ${date} ${time}  * ${tags}  */       </template><template autoinsert="false" context="fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name="fieldcomment">  /**  * @fields ${field}  * @author ${user}  * @update ${date} ${time}  */       </template><template autoinsert="false" context="filecomment_context" deleted="false" description="Comment for created Java files" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.filecomment" name="filecomment">  /**  * @title ${file_name}  * @package ${package_name}  * @description   * @author ${user}  * @update ${date} ${time}  * @version V1.0  */       </template><template autoinsert="false" context="delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name="delegatecomment">  /**  * ${tags}  * ${see_to_target}  * @author ${user}  * @update ${date} ${time}  */       </template><template autoinsert="false" context="overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name="overridecomment">  /**  (non-Javadoc)  * ${see_to_overridden}  * @author ${user}  * @update ${date} ${time}  */       </template></templates>

Then, find the annotation template in WINDOW> preferences> JAVA> code style> code templates.

Finally, click Import to import the generated XML file and then click Apply.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.