Code reformat moves static methods at the top of the class

Answered

Hello, 

When refactoring my class (Ctrl+Alt+L), IDEA automatically moves static methods at the top.
Is it possible to turn it off?

 

Situation before formater applied: 

public void setX(..) 

public X getX() 

public static XYZ(){....}


After code format: 

public static XYZ(){....}

public void setX(..) 

public X getX() 


I work in environment where most guys use eclipse. We use the same formater. But I experience problems with static methods rearrangement.

 

0
7 comments

Optimize imports on the fly is disabled by default. 
Version of IDEA I use is: 2017.2.6 (Build #UI-172.4574.11,  Built on November 12, 2017).
Problem still occurs.

0

Disable the options to rearrange the code and to optimize the imports in the reformat code dialog:

0

Or, a better solution for you would be to switch to Eclipse Code Formatter. It will replace built-in IntelliJ IDEA code formatter with exactly the same as is available in Eclipse, this way you will never have conflicts with your teammates.

0

I'm already using Eclipse Code Formater. Nonetheless there are some minor problems (like the one I mentioned above).
I disabled 'Rearrange code' option and it works OK now. 

The version of eclipse code formater I use is: 17.2.132.637.0.Eclipse_4.7

Thanks for help! 

0

Not sure, but rearrange code option may still use IntelliJ IDEA rearranger.

0
Avatar
Permanently deleted user

I just found the settings for this:

Under Editor > Code Style > Java.

0

Please sign in to leave a comment.