4
2
Currently, IntelliJ (specifically Android Studio) chops down long conditionals like this:
if (valueWithALongNameA || valueWithALongNameB && valueWithALongNameC) {
}
// becomes
if (valueWithALongNameA ||
valueWithALongNameB &&
valueWithALongNameC) {
}
But our coding conventions has us format them like this:
if (valueWithALongNameA || valueWithALongNameB && valueWithALongNameC) {
}
// becomes
if (valueWithALongNameA
|| valueWithALongNameB
&& valueWithALongNameC) {
}
Note that the ||
and &&
are after the newline in our style. Is there any way to have IntelliJ do this with its autoformat?
The main problem is that I use autoformat to ensure my code is formatted to our standards, but this causes properly-formatted conditionals to be unnecessarily changed, mucking up diffs.
I couldn't find anything that was relevant in preferences:
I tried to get all of the preferences on-screen at once, but I had to cut off some, so I excluded the "Keep when reformatting" options and "Ensure right margin not exceeded". They're all checked aside from "Line breaks", "Control statement in one line", and "Multiple expressions in one line". The cut-off section title is "Braces placement".