Eclipse Automatic completion function and Automatic Generation of author, date annotation and other function settings

Source: Internet
Author: User

Eclipse Automatic completion function and Automatic Generation of author, date annotation and other function settings

I used to add code author information, but I don't know how to implement it. Today I finally found a solution on the Internet.


Eclipse automatically generates author, date comments, and other function settings

When you use Eclipse to write Java code, the automatically generated annotation information is generated according to the preset format.

Modify author and date annotation formats: choose Windows> Preferences> Java> Code Style> Code Templates, and click Comments in the window on the right. You can see many options, you can edit the annotation template.

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

Select Types and click Edit to set

/**

* @ Author $ {user}

* $ {Tags}

*/

Change $ {user} to the name you want to display. Delete $ {tags}, click Insert Variable, and select Date. The Date information is automatically generated. Click Sources-> Ganarate Element Comment where you want to add comments, or use the shortcut key Alt + Shift + J, eclipse automatically adds comments to the class.

The annotations are as follows:

File annotation Tag:

/**

*

Title: $ {file_name}

*

Description:

*

Copyright: Copyright (c) 2007

*

Company: LTGames

* @ Author linrz

* @ Date $ {date}

* @ Version 1.0

*/

Type annotation label (class annotation ):

/**

*

Title: $ {type_name}

*

Description:

*

Company: LTGames

* @ Author linrz

* @ Date $ {date}

*/

Field annotation label:

/** $ {Field }*/

Constructor Tag:

/**

*

Title:

*

Description:

* $ {Tags}

*/

Method label:

/**

*

Title: $ {enclosing_method}

*

Description:

* $ {Tags}

*/

Override method label:

/* (Non-Javadoc)

*

Title: $ {enclosing_method}

*

Description:

* $ {Tags}

* $ {See_to_overridden}

*/

Method label:

/**

* $ {Tags}

* $ {See_to_target}

*/

Getter method label:

/**

* @ Return $ {bare_field_name}

*/

Setter method label:

/**

* @ Param $ {param} the $ {bare_field_name} To be set}

*/


Eclipse auto-completion full-function settingsBy default, a code prompt is displayed when you type ".". Otherwise, you can only press "Alt +. You can use the following settings to display code prompts as needed.

1) directly set

Open Eclipse-> Window-> Perferences-> Java-> Editor-> Content Assist. An Auto activation triggersor for Java option appears on the right, only one ". "exists. Indicates that only the input ". "Then there will be code prompts, this is the place to modify, we directly in". ", enter" abcdefghigklmnopqrstuvwxyz ". "or any letter will prompt the code. If you are not addicted, enter "0123456789" or

May use characters such as "_", and click "OK.

2) implemented through the Import and Export file functions of Eclipse

Open File-> Export-> General-> Preferences, click "next", check "Export all", select the Save path, and finish. Use NotePad to open the exported file with the suffix ". epf.

[Html]View plaincopy
  1. /Instance/com. android. ide. eclipse. ddms/emulatorControl. track. name = 141
  2. /Instance/com. android. ide. eclipse. ddms/threadPanel. stack. col4 = 51
  3. /Instance/org. eclipse. jdt. ui/content_assist_autoactivation_triggers_java =.
  4. /Instance/com. android. ide. eclipse. ddms/threadPanel. stack. col3 = 49
  5. /Instance/com. android. ide. eclipse. ddms/threadPanel. stack. col2 = 350
  6. /Instance/com. android. ide. eclipse. ddms/threadPanel. stack. col1 = 121

    The last "." In the third line above is the place to be modified. You only need to enter the characters you want to enter after. Save the changes and Open File> Import> General-

    > Preferences: select the file you modified and check "Import all", and click "finish.

    You can also set 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.