How to automatically rename a Java method in Eclipse?

Viewed 379

I'm trying to rename a method in my Eclipse Java project, but it seems to be renaming every method which has the same name. (Perhaps I'm misunderstanding what this feature is for - maybe it's just using sed?)

Here is a simplified example:

    public class C1 {
        interface Listener {
            void f();
        }

        public C2.Listener c2l = new C2.Listener() {
            public void f() {
            }
        };
    }

    public class C2 {
        interface Listener {
            void f();
        }
    }

If I select the f method in C2, and select "rename" from the "refactor" menu to rename it to g, C1.Listener.f is also renamed, resulting with C1 being changed to this:

    public class C1 {
        interface Listener {
            void g();
        }

        public C2.Listener c2l = new C2.Listener() {
            public void g() {
            }
        };
    }

I expected it to be changed to this:

    public class C1 {
        interface Listener {
            void f();
        }

        public C2.Listener c2l = new C2.Listener() {
            public void g() {
            }
        };
    }

Is there a way to make it only rename C2.Listener.f?

I tried in Eclipse Helios and Android Development Tools 22.3.0.

1 Answers
Related