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.