Set comments, dates, and more in eclipse

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 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

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.