1

In a java project I'm creating a bunch of subclasses of an abstract class.

public abstract class Foo {
    protected String myFoo;
}

public class SubFoo extends Foo {
    public void fooMethod() {
        super.getClass().getDeclaredFields()[0].set(this, "something");
    }
}

because of a nasty habit of renaming variable names all the time I refrain from referring to them by name, which gets tiresome.. Writing this question I'm realizing a better solution would be a setter method in Foo, but I really prefer not to, so my question stands:

Is there a way to refactor variable names in Eclipse such that all references to the old variable, in all classes, are updated? ALT+SHIFT+R only changes in the same class :(

Carl Manaster
  • 39,912
  • 17
  • 102
  • 155
user2651804
  • 1,464
  • 4
  • 22
  • 45
  • see this solved my problem http://stackoverflow.com/questions/9308352/renaming-a-lot-of-variables-in-many-java-classes-at-once – rummykhan Oct 05 '15 at 22:03

1 Answers1

2

ALT+SHIFT+R does rename all instances.

leeor
  • 17,041
  • 6
  • 34
  • 60