Add annotation template in eclipse

Source: Internet
Author: User

To write code, you must add comments. One is to facilitate your future use, and the other is to facilitate maintenance by others.

Annotations have a certain format. It is also annoying to repeatedly repeat the keyboard or copy.

With the annotation template, you can add the annotation label to automatically complete the annotation format, which is very worry-free.

Save the following code as an XML file:

<? XML version = "1.0" encoding = "UTF-8" standalone = "no"?>
<Templates>
<Template autoinsert = "true" context = "fieldcomment_context" deleted = "false" Description = "comment for fields" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. fieldcomment "name =" fieldcomment ">
/**
*
*/</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 ">
/**
* Class Name: $ {file_name}
* Function:
*
* Modifications:
*
* @ Author Howard datetime $ {date }$ {time}
* @ Version 1.0
* $ {Tags}
*/</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 ">
/**
* Function:
*
* @ Author Howard datetime $ {date }$ {time}
* $ {Tags}
*/</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 "/>
<Template autoinsert = "true" context = "constructorcomment_context" deleted = "false" Description = "comment for created constructors" enabled = "true" id = "org. eclipse. jdt. UI. text. codetemplates. constructorcomment "name =" constructorcomment ">
/**
* $ {Tags}
*/</Template>
<Template autoinsert = "true" 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}
*/</Template>
<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 $ {bare_field_name}
*/</Template>
<Template autoinsert = "true" 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}
*/</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 ">
/**
* @ Return get $ {bare_field_name}
*/</Template>
</Templates>

Open eclipse and click window-------, preference -----, Java ------, code style -------, code templates.

Import your saved files

Note: In the Java source file header, the format is automatically generated by adding a comment label before the function or the field, and then the word is entered.

It must start with/**. Otherwise, no comments will be generated, and no comments will be generated for other class files in eclipse.

Related Article

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.