"Reprint" MyEclipse automatically generate comments

Source: Internet
Author: User

When you use Eclipse to write Java code, the automatically generated comment information is generated in a pre-set format, such as the attribute value of author.

We can set the information we want to display in eclipse.

Now look at how to modify our user name is the author information: Click Windows->preferences->java->code style->code Templates,

Then we can select the comments in the right window, corresponding to the specific comments option, we can edit the specific annotation information to set.

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}
*/

Delete the ${user} and change it to Hanyankai so that the author information becomes Hanyankai; 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 Hanyankai

* 2009-11-27
*/

For the same steps, we can also edit settings for other annotation information such as constructors and so on.

When you use the mouse, place it anywhere inside the method where you want to add the comment. If you click Add Javadoc Comment under source code in the menu bar, or use the shortcut key Alt Shift J, Eclipse automatically adds a comment before the method.

The specification for annotations is as follows:

File Comment Tags:

/**
* <p>title: ${file_name}</p>
* <p>description: </p>
* <p>copyright:copyright (c) 2007</p>
* <p>Company:zkyr</p>
* @author Uu
* @date ${date}
* @version 1.0
*/

Type Comment Label (note for Class):

/**
* <p>title: ${type_name}</p>
* <p>description: </p>
* <p>Company:zkyr</p>
* @author Uu
* @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}
*/

From: http://blog.csdn.net/aaronuu/article/details/7065928

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.