Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make in Intellij IDEA the generated method to be at the end of the class?

In Intellij IDEA, inside a method, you can write something as:

myNewMethod(someParam);

Then if you go with the cursor on myNewMethod and then Alt+Enter (or Command+Enter on Mac) you can choose Create method 'myNewMethod' which will create the new method with the expected parameters and return type.

The problem is that this new method is created immediately after the method which is in, and not at the end. I would like to generate it at the end of the class.

For example I have a public method and I generate the 3 methods in order:

public methodPublic() {
    myGenerated1();
    myGenerated2();
    myGenerated3();
}

it will end up generating them:

public methodPublic() {
    myGenerated1();
    myGenerated2();
    myGenerated3();
} 

private void myGenerated3() { ... }

private void myGenerated2() { ... }

private void myGenerated1() { ... }
like image 261
Random42 Avatar asked Nov 20 '17 09:11

Random42


1 Answers

As far as I know still there is no option in Intellij Idea to insert generated method to end of the file except getters and setters. But you can sort them in alphabetic order.

Go to File > Setting > Editor > Code Style > Java > Arrangement Tab. Click on the small pencil icon which is placed next to item called method under Matching Rules section. In there select order by name option from Order dropdown.

enter image description here

You can create feature request in https://youtrack.jetbrains.com/issues/IDEA

like image 198
Chathura Buddhika Avatar answered Sep 29 '22 07:09

Chathura Buddhika