When you use Eclipse to write Java code, the automatically generated comment information is generated in a pre-set format, such as a property value such as Author,datetime.
We can set the comment information that we want to display in eclipse.
The operation is as follows: Click Windows->preferences->java->code Style->code Templates, there is a comments option on the right, we can edit the relevant annotation information inside.
For example, we want to set the author's author information and date information at the beginning of a Java file.
Select types, click Edit, and
/**
* @author ${user}
* ${tags}
*/
Replace ${user} with Vkzhang so that the author information becomes Vkzhang, click Insert Variable, select Date, and the date information is automatically generated.
After we have set up the test, the automatically generated comment information is:
/**
* @author Vkzhang
* 2015-2-2
*/
Similarly, under the comments also has the files,methods,delegate Methods and so on the attribute, may let us each set up, the specific annotation specification is as follows:
File Comment Tags:
/**
* <p>title: ${file_name}</p>
* <p>description: </p>
* <p>copyright:copyright (c) 2007</p>
* <p>Company:LTGames</p>
* @author Vkzhang
* @date ${date}
* @version 1.0
*/
Type Comment Label (note for Class):
/**
* <p>title: ${type_name}</p>
* <p>description: </p>
* <p>Company:LTGames</p>
* @author Vkzhang
* @date ${date}
*/
Field Comment Label:
/** ${field}*/
Constructor Tags:
/**
* <p>title: </p>
* <p>description: </p>
* ${tags}
*/
Method Tags:
/**
* <p>title: ${enclosing_method}</p>
* <p>description: </p>
* ${tags}
*/
Override method Label:
/* (non-Javadoc)
* <p>title: ${enclosing_method}</p>
* <p>description: </p>
* ${tags}
* ${see_to_overridden}
*/
Represent method Tags:
/**
* ${tags}
* ${see_to_target}
*/
Getter Method Tags:
/**
* @return ${bare_field_name}
*/
Setter Method Tags:
/**
* @param ${param} to set the ${bare_field_name}
*/
when we want to add a note in a location, click Add Javadoc Comment under source in the menu bar, or use the shortcut key alt+shift+j, Eclipse will automatically add a comment before the method.
Set comments, dates, and more in eclipse