Set the entry for the comment template: Window->preference->java->code style->code template and then expand the Comments node is all the elements that need to be annotated. This article is now on each element to introduce you to each one.
Files Note Tags:
/*** @Title: ${file_name}* @Package ${package_name}* @Description: ${todo} (describe the file in a word) * @author ${user}* @date ${date} * @version v1.0*/
Type (Types) Comment Label (note for Class):
/*** @ClassName: ${type_name}* @Description: ${todo} (here is a word describing the role of this class) * @author ${user}* @date ${date}** ${tags}*/
Field Comment Label:
/*** @Fields ${field}: ${todo} (describe what this variable means in a word) */
Constructor (Constructor) Tags:
/*** Create a new instance ${enclosing_type}.** ${tags}*/
Method (Methods) Label:
/*** @Title: ${enclosing_method}* @Description: ${todo} (here is a word describing the function of this method) * @param ${tags} parameter * @return ${return_type } return type * @throws */
Override method (overriding Methods) Label:
< P > Title: ${enclosing_method}</p><p> </ P > * ${tags}* ${see_to_overridden}*/
Proxy method (Delegate Methods) Tags:
/*** ${tags}* ${see_to_target}*/
Getter Method Tags:
/*** @return ${bare_field_name}*/
Setter Method Tags:
/*** @param ${param} The ${bare_field_name} to set*/
To implement the above comment template, this requires the following configuration file to be imported:
<?XML version= "1.0" encoding= "UTF-8"?><Templates> <TemplateAutoInsert= "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: ${todo} (describe the file in a word) * @autho R ${user} * @date ${date} * @version V1.0 * *</Template> <TemplateAutoInsert= "false"Context= "Typecomment_context"deleted= "false"Description= "Comment for created types"enabled= "true"ID= "Org.eclipse.jdt.ui.text.codetemplates.typecomment"name= "Typecomment">/** * @ClassName: ${type_name} * @Description: ${todo} (here is a word describing the role of this class) * @author ${user} * @date ${dat e} * * ${tags} */</Template> <TemplateAutoInsert= "false"Context= "Fieldcomment_context"deleted= "false"Description= "Comment for Fields"enabled= "true"ID= "Org.eclipse.jdt.ui.text.codetemplates.fieldcomment"name= "Fieldcomment">/** * @Fields ${field}: ${todo} (describe what this variable means in a word) */</Template> <TemplateAutoInsert= "false"Context= "Constructorcomment_context"deleted= "false"Description= "Comment for created constructors"enabled= "true"ID= "Org.eclipse.jdt.ui.text.codetemplates.constructorcomment"name= "Constructorcomment">/** * Create a new instance of ${enclosing_type}. * * ${tags} */</Template> <TemplateAutoInsert= "false"Context= "Methodcomment_context"deleted= "false"Description= "Comment for non-overriding methods"enabled= "true"ID= "Org.eclipse.jdt.ui.text.codetemplates.methodcomment"name= "Methodcomment">/** * @Title: ${enclosing_method} * @Description: ${todo} (here is a word describing the function of this method) * @param ${tags} parameter * @r Eturn ${return_type} return type * @throws * /</Template> <TemplateAutoInsert= "true"Context= "Overridecomment_context"deleted= "false"Description= "Comment for overriding methods"enabled= "true"ID= "Org.eclipse.jdt.ui.text.codetemplates.overridecomment"name= "Overridecomment">/* (not Javadoc) *<P>Title: ${enclosing_method}</P> * <P>Description:</P>* ${tags} * ${see_to_overridden} */</Template> <TemplateAutoInsert= "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> <TemplateAutoInsert= "false"Context= "Gettercomment_context"deleted= "false"Description= "Comment for getter Method"enabled= "true"ID= "Org.eclipse.jdt.ui.text.codetemplates.gettercomment"name= "Gettercomment">/** * @return ${bare_field_name} * *</Template> <TemplateAutoInsert= "true"Context= "Settercomment_context"deleted= "false"Description= "Comment for setter Method"enabled= "true"ID= "Org.eclipse.jdt.ui.text.codetemplates.settercomment"name= "Settercomment">/** * @param ${param} The ${bare_field_name} to set */</Template> </Templates>
Eclipse Comment template settings in detail