MKorsch
MKorsch

Reputation: 3831

Is it possible to extract a method to a base class in eclipse?

I have a class B which extends class A. Now I want to refactor class B and extract a method to class A with the Extract Method refactor operation (Alt+Shift+m). Is there any possibility to accomplish this in eclipse?

Thank you :)

Upvotes: 0

Views: 578

Answers (1)

E-Riz
E-Riz

Reputation: 32914

Right-click on the method and select Refactor > Pull Up.... There is no keyboard shortcut for that refactoring by default, but you can assign one via the Preferences dialog if you want.

The Extract method refactoring (Alt+Shift+m) does not support creating the new method directly in a super class, so if that's what you're trying to do you'll have to first do the Extract method in class B and then use Pull Up... refactoring to move it to A.

Upvotes: 3

Related Questions