Eclipse Auto-complete feature and auto-generate author, date comment and other feature settings

Source: Internet
Author: User

Previously wanted to implement the addition of code author information, but do not know how to achieve, today finally on the Internet inadvertently find a solution


Eclipse automatically generates feature settings such as author, date comment, and more

when using Eclipse when you write Java code, the automatically generated comment information is generated in a pre-set format.

Modify author, date comment format: Open windows->preferences->java->code style->code Templates, click Comments in the right window, you can see a lot of options, We can edit this comment information template.

If we want to set the author information and date information at the beginning of a Java file.

Select types, click Edit, and

/**

  * @author ${user}

 * ${tags}

Span style= "Color:rgb (51,51,51)" >

 */  

Delete the ${user}, change it to the name you want to display, delete ${tags}, click Insert Variable, select Date, and the date information will be generated automatically. When you need to add a comment, click Sources->ganarate Element Comment, or use the shortcut key Alt+shift+j, Eclipse automatically adds a comment before the class.

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:LTGames</p>

* @author LINRZ

* @date ${date}

* @version 1.0

*/

Type Comment Label (note for Class):

/**

* <p>title: ${type_name}</p>

* <p>description: </p>

* <p>Company:LTGames</p>

* @author LINRZ

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

*/


Eclipse Auto-complete feature settings , the default is type "." There will be code hints, otherwise only press the "alt+/" key combination. The following settings allow you to display code hints as you want .

1), Direct settings

Open Eclipse, Window, perferences->java->editor->content Assist, the option that appears on the right, has an auto activation T Riggersor for Java, you'll see only one "." in the text box . Exist. Indicates: Only input "." Then there will be code hints, this is the place to modify, we are directly in the "." In the back of the abcdefghigklmnopqrstuvwxyz, so just type "." Or any letter will have a code hint. If you're not enjoying it, you can then enter "0123456789" or

"_" or something that might be used, and then click "OK".

2), through the import and export file features of Eclipse

Open File--export-> general->Preferences, click "Next", tick "Export all" and select Save Path, "Finish" to complete. Use Notepad to open the file that you just exported with the ". epf" suffix.

[HTML]View Plaincopy
  1. / instance/com.android.ide.eclipse.ddms/ emulatorcontrol.track.name = 141 &NBSP;&NBSP;
  2. /instance/com.android.ide.eclipse.ddms/threadpanel.stack.col4 = 51 &NBSP;&NBSP;
  3. /instance/org.eclipse.jdt.ui/content_assist_autoactivation_triggers_java =.&NBSP;&NBSP;
  4. /instance/com.android.ide.eclipse.ddms/threadpanel.stack.col3 = 49 &NBSP;&NBSP;
  5. /instance/com.android.ide.eclipse.ddms/threadpanel.stack.col2 = 350 &NBSP;&NBSP;
  6. /instance/com.android.ide.eclipse.ddms/threadPanel.stack.col1=121

At the end of the third line is "." is to modify the place, as long as in the "." Enter the characters you want to enter. Save after you have changed, open File-- import-> general-

> Preferences, select the file you just modified tick "Import all", click "Finish" to complete.

Of course, you can also set some other parameters as needed


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.