Pull up method refactoring extension

Compatible with IntelliJ IDEA
May 18, 2016
940

*** Warning : this is an experimental software, it contains many bugs. ***

Extends Pull Members Up refactoring to consider methods with different types in different classes to be pulled-up as an abstract method with generic types.

Also provides an extension of the Extract Superclass refactoring to support several classes simulteanously.

Download plugin

Recent change notes

  • 0.3e Adapted to IDEA 14.
  • 0.3d Bug fix (pull up interface).
  • 0.3c Improved GUI for extract superclass multi.
  • 0.3b Adapted to IDEA 13. Not supporting IDEA 12.
  • 0.3a Improved GUI for pull-up-gen.
  • 0.2 Introduce new type parameters only if needed.
  • 0.1 First release, with
    • pull-up method with generics and
    • extract superclass for several classes (automatically selects classes with methods that has been specified).

Known bugs (in pull-up-gen v0.2):

  • Fails when incoherent type parameters between a class and its superclass.
  • Fails when several abstract classes in the considered hierarchy.
  • Fails with polymorphic methods (with type parameters attached to the methods).
  • Fails when conflicting method visibilities.
  • Fails when the method to pull up is already abstract in one of the considered classes.
  • Fails when the method to pull up is already in the superclass.
  • Fails when several overloaded methods are pulled up (a same type parameter can be introduced twice).

General usage instructions

EXPECTED BEHAVIOR =================

Consider the following code:

public abstract class S{}

public class A extends S {

Integer m(){ return 1; }

}

public class B extends S {

String m(){ return "foo"; }

}

The pull up extension transforms that code as follows:

public abstract class S {

abstract TmRET m();

}

public class A extends S {

@Override

Integer m(){ return 1; }

}

public class B extends S {

@Override

String m(){ return "foo"; }

}



USAGE =====

This plugin provides a new entry in the Refactor menu : 'Pull up with Generics (abstract)'. Place the cursor in the method you want to pull up; trigger the 'Pull up with Generics (abstract)' operation in the Refactor menu; check the box to indicate you want to pull up an abstract version of the method; then click in the Refactor button.



OTHER FEATURES ==============

This plugin also provides a second operation extension : "Extract Superclass (multi)". This extended operation allows for extracting a superclass for several classes simulteanously. As for the Pull up extension, it can be used with methods that needs to be generified in the superclass. That extension also comes with the limitationss stated above.