Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a possible Eclipse supported refactoring for removing superclass dependency?

I want to remove the intermediate dependency of class B by moving the code from B to C and inherit directly from A.

generic class A
  |
  ---modified generic class B
       |
       ---current class C

Is there any refactoring from Eclipse to support this?

like image 559
OliverS Avatar asked Oct 24 '11 08:10

OliverS


People also ask

Does Eclipse support refactoring?

Compositional RefactoringThis Eclipse bundle provides new Quick Assist actions to support refactorings in a compositional paradigm. In the compositional paradigm, the tool automates small, predictable steps of a refactorin...

How do you Refactor in Eclipse?

Refactoring using EclipseRight clicking on a Java element in the Package Explorer view and selecting Refactor menu item. Right clicking on a Java element in the Java editor and selecting Refactor menu item. Selecting a Java element in either the Package Explorer view or Java Editor and clicking Shift + Alt + T.

How do I undo refactoring in Eclipse?

Normally you can achieve this by just pressing undo. If this is not possible for any reason Eclipse will warn you. In case of emergency: Revert by using your VCS :-) D.R.


1 Answers

Use Refactoring > Pull up on all the methods of C.

Move all fields and constructors from C to B. Make sure C and B are in the same package.

Delete the class C.

Rename class B to C.

You have to move fields and constructors by hand, but otherwise this should be a fairly safe and painless refactoring.

like image 83
Garrett Hall Avatar answered Sep 30 '22 08:09

Garrett Hall