Eclipse is actively adding Chinese gaze to getter and setter

Source: Internet
Author: User

When we use eclipse for development, we often use the ability to proactively generate getter and setter from Eclipse, and most of the time, the getter and setter that eclipse generates for us are not available in the project. We also need to manually change them.

For example, the following class. I used Eclipse's own initiative to generate getter and setter functions and chose to join the gaze. Finally the class for example the following

public class User {//usernameprivate string name;/** * @return the name */public string GetName () {return name;} /** * @param name the name to set */public void SetName (String name) {this.name = name;}}

But what we want is not such a gaze. Hope can generate such as the following code gaze

public class User {//usernameprivate string name;/** * return username *  * @return username */public string GetName () {RE Turn name;} /** * Set username *  * @param name *            username */public void SetName (String name) {this.name = name;}}

How to do it?

Now I'm going to explain how I changed.

1. The first step is to find the class file that eclipse itself actively generates getter and setter. I'm looking for everybody. In eclipse\plugins\org.eclipse.jdt.ui_xxxxxxxx.jar\org\eclipse\jdt\internal\corext\codemanipulation\ Gettersetterutil.class

2, we change the source code of this class and then compile and replace.

This class source code is generally in the corresponding eclipse\plugins\org.eclipse.jdt.ui.source__xxxxxxxx.jar\org\eclipse\jdt\internal\corext\ Codemanipulation\gettersetterutil.java

My eclipse version number is version:4.3.1

I pass on the files that have been modified and compiled well.

When you use this, remember to back up the original jar first. Lest tragedy.

The replacement process for Class I'll just say it briefly. Lest some students are not clear.

1. Open Eclipse\plugins\org.eclipse.jdt.ui_xxxxxxxx.jar directly with compressed files

2. Find Org\eclipse\jdt\internal\corext\codemanipulation\gettersetterutil.class

3, replace the Gettersetterutil.class with our own modified Gettersetterutil.class (Eclipse does not perform in the state of talent replacement)

Usage

1. window-in Eclipse "Preferences->java->code style->code templates

2. Find comments

3, expand Find getters Click Edit input such as the following content

/** * Return bare_field_comment *  * @return bare_field_comment*/

4, find setters Click Edit input such as the following content

/** * Set Bare_field_comment *  * @param ${param} *            bare_field_comment * *

5. Save


Bare_field_comment: It is replaced with the gaze above our attributes.

Suppose the attribute above is useless to stare at the words. Then it will output bare_field_comment directly.

Use

public class User {//Usernameprivate String name;}


In our own initiative to generate getter and setter when the same check generate method comments Suppose the attribute has a single Gaze then this gaze will be used by us.

Finally generate effects such as the following

public class User {//usernameprivate string name;/** * return username *  * @return username */public string GetName () {RE Turn name;} /** * Set username *  * @param name *            username */public void SetName (String name) {this.name = name;}}


Note that the

MultiRow gaze is not recognized. This is useful for shielding off.

http://download.csdn.net/detail/kongguoan/7694553




Eclipse is actively adding Chinese gaze to getter and setter

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.