Using eclipse find and replace all to swap arguments

后端 未结 5 561
夕颜
夕颜 2021-02-07 20:46

I have about 100 lines that look like the below:

assertEquals(results.get(0).getID(),1);

They all start with assertEquals and contain two arguments. Im looking f

5条回答
  •  孤城傲影
    2021-02-07 21:07

    If you find yourself swapping parameter order in method declarations farily often, I found a plugin that does it for you with a single click.

    This plug-in adds two toolbar buttons to the Eclipse Java editor:

    Swap backward
    Swap forward
    

    enter image description here

    With the caret at | in:

    void process(int age, String |name, boolean member) {...}
    

    clicking the Swap forward button yields:

    void process(int age, boolean member, String |name) {...}
    

    or clicking Swap backward button with the original source yields:

    void process(String |name, int age, boolean member) {...}
    

    Here is the article discussing it.

    Here is the jar to drop into your eclipse plugin directory.

提交回复
热议问题