Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eclipse refactoring: move multiple static methods and/or fields

Is it possible to move mutliple static methods and/or multiples static fields on one shot ?

public final class ClassA { 
    public static final String CONSTANTE_A = "CONSTANTE_A";
    public static final String CONSTANTE_B = "CONSTANTE_B";

    public static void methodA() {
        // statements....
    }

    public static void methodB() {
        // statements....
    }
}

public final class ClassB { 
// empty class
}

I would like to be able to select methodA, methodB, CONSTANTE_A and CONSTANTE_B, and do a "move..." to ClassB

like image 680
airdump Avatar asked Oct 08 '13 12:10

airdump


2 Answers

Expand until you see the static methods or varibles. Select all that you want to move. Right click. Select Refactor. Then choose the class where you want to move. Click OK. That will not just copy and paste but will refactor (update references to those methods and variables).

like image 103
ptntialunrlsd Avatar answered Sep 19 '22 22:09

ptntialunrlsd


The easiest way to do this is to drag and drop the variables in Eclipse's package explorer. Expand ClassA until you see your static variables listed under your class and select both of them -- control + click (pc) or command + click (mac). Then just drag them to the desired destination class.

like image 21
Farlan Avatar answered Sep 17 '22 22:09

Farlan