Eclipse Tips: Renaming field and its setter/getter (Galileo)

The new improvement in Eclipse allows us to refactor variable/field without in dialog-less mode. In fact, in Galileo, we are forced to do that. The problem is… if I want to rename a field, I normally also want to change the setter and getter. This can only be done in dialog mode, since in dialog-less mode we have no control of what Eclipse will do. After several try, I think I get the most efficient way to do this correctly.

So, this is how to force the dialog mode renaming in Galileo that I can found:

1. Put your cursor in the variable name.
2. Alt+Shift+R : this activates the dialog-less renaming mode.
3. One more time Alt+Shift+R : this activates the dialog mode.

2009-08-07_1647

A little bit more work, but at least it can be done. And the best part is, once you set the option to also rename the setter and getter, next time you won’t have to use your mouse anymore.

Related posts:

  1. My top Eclipse keyboard shortcut
  2. Eclipse 3.3 Live Rename Refactoring
  3. Eclipse Tips: Mark Occurrence
  4. Eclipse Tips: Auto generate ‘final’ on your variable, field, and parameter
  5. What are the important improvements on Eclipse Galileo 3.5 (for me)

2 Responses to “Eclipse Tips: Renaming field and its setter/getter (Galileo)”


  • This is a really useful feature. Unfortunately, the refactoring does not include the setter parameter name, so when refactoring “something” to “otherThing” in…

    private String something;
    public void setSomething(String something) {
    this.something = something;
    }

    …it will result in…

    private String otherThing;
    public void setOtherThing(String something) {
    this.otherThing = something;
    }

    … so it’s not quite there yet :-(

  • Agree

Leave a Reply