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.
Please sign in to leave a comment.
Please see https://intellij-support.jetbrains.com/hc/en-us/community/posts/206545369-Intellij-Idea-15-disable-import-statement-re-arrangement.
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.
Disable the options to rearrange the code and to optimize the imports in the reformat code dialog:
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.
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!
Not sure, but rearrange code option may still use IntelliJ IDEA rearranger.
I just found the settings for this:
Under Editor > Code Style > Java.