(Java) formatting: if condition indentation
Answered
Hi everyboy,
I am using Intellij IDEA (ultimate) 2017.3 EAP version.
I am trying to apply java code style according to our company rules (it was not done yet).
One remaining difference is related to if condition and inner operator locations.
Currently, code looks like followed :
if(CAirsConstants.STATUT_VISA_EN_COURS.equalsIgnoreCase(courrier.getStatut()) ||
CAirsConstants.STATUT_PROCEDURE.equalsIgnoreCase(courrier.getStatut())) {
...
}
I would prefer to see the operator || on the next line, as you can see below
if(CAirsConstants.STATUT_VISA_EN_COURS.equalsIgnoreCase(courrier.getStatut())
|| CAirsConstants.STATUT_PROCEDURE.equalsIgnoreCase(courrier.getStatut())) {
...
}
Does anybody have an idea how to set this rule (if it is possible) ?
Thanks for any help.
PS: I apologise for my English, I'm just a French guy ;-)
Nicolas
Please sign in to leave a comment.
Hello Nicolas,
It's possible to set "Binary expressions" = "Wrap always" and "Operation sign on next line" (Settings|Code Style|Java|Wrapping and Braces).
Also I created feature request on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-180404
Feel free to vote for it and leave comments.
Hello Yaroslav,
thank you for this quick response.
I've already tried those options, but unfortunately, even if it works on the previous sample,
it then breaks other simple if conditions, like the following
which then becomes
Currently, my options related to Binary expressions are
I will votefor the feature you opened.
Thanks again for your help !
Nicolas
You are welcome!
old problem, but still there :( have the same problem but a little bit more difficult :
if (("" + Param001).equals(stringToCompare) || ("" + Param002).equals(stringToCompare)
|| ("" + Param003).equals(stringToCompare) || ("" + Param004).equals(stringToCompare)
|| ("" + Param005).equals(stringToCompare) || ("" + Param006).equals(stringToCompare)
|| ("" + Param007).equals(stringToCompare) || ("" + Param008).equals(stringToCompare)) {
------
should look like this
if (("" + Param001).equals(stringToCompare)
|| ("" + Param002).equals(stringToCompare)
|| ("" + Param003).equals(stringToCompare)
|| ("" + Param004).equals(stringToCompare)
|| ("" + Param005).equals(stringToCompare)
|| ("" + Param006).equals(stringToCompare)
|| ("" + Param007).equals(stringToCompare)
|| ("" + Param008).equals(stringToCompare)) {
------
https://youtrack.jetbrains.com/issue/IDEA-180404
is now marked as duplicate of
https://youtrack.jetbrains.com/issue/IDEA-183037
but they are not the same, cause of the option "Keep line breaks" (in 183037 on, in 180404 OFF)