Search code examples
javaeclipserefactoringmethod-signature

Refactor method header parameter order


I fighting with a refactoring issue in my Eclipse IDE.

I have this interface method:

List<String> evaluateAllPoi(boolean pIsVerified, List<String> pAllNames, List<String> pAllComment);

that method has a high test coverage with Junit (at least 90 tests).

I want to move the first boolean parameter to the end of the method signature via refactoring so I get:

List<String> evaluateAllPoi(List<String> pAllNames, List<String> pAllComment,boolean pIsVerified);

I am pretty sure that Eclipse offers a possibility to do that easily, without change each call by hand, but at the moment I do not find/see it.

Could you give me a hint?


Solution

  • Yes, Eclipse does provide a facility for that.

    1. Highlight the method name
    2. Right-click and go into "Refactor > Change Method Signature..." (alternatively, you can hit Alt+Shift+C)
    3. Change the order of the method parameters by clicking "Up" or "Down". You can also add / remove parameters in this dialog box.
    4. Hit "OK".
    5. Enjoy.

    Picture:

    enter image description here