Community
Participate
Working Groups
The java code conventions suggest various methods of indenting wrapped lines. I like the 8 space rule - <quote> Line wrapping for if statements should generally use the 8-space rule, since conventional (4 space) indentation makes seeing the body difficult. For example: //DON'T USE THIS INDENTATION if ((condition1 && condition2) || (condition3 && condition4) ||!(condition5 && condition6)) { //BAD WRAPS doSomethingAboutIt(); //MAKE THIS LINE EASY TO MISS } //USE THIS INDENTATION INSTEAD if ((condition1 && condition2) || (condition3 && condition4) ||!(condition5 && condition6)) { doSomethingAboutIt(); } </quote> I think this is relevant for any code that defines a braced code block. ie for loops, while loops, if conditions, method declaration. Could an option be added to the code formater to request use of the double indent rule for such wrapped statements.
This should be done if you use the new formatter. This formatter is available in latest integration 3.0 builds. It can be optionally turn on in M6 and it is on by default in the latest integration build.
I have a developer next to me with M6 already installed. Can you tell us how to turn this feature on as I can't see it in the preferences. I was also hoping for another formatting rule "Do not wrap condition and unbraced statement on same line" I would want this to then for relevant lines ignore the max width setting. This is so that for log4j I can save screen depth real-estate. eg. if (log.isDebugEnabled()) log.debug("This is useful logging but I want it all on one line so that it does not obfuscate the surrounding code") This breaks Sun Conventions so should not be turned on by default. Any chance of something like this? Would you prefer I put this in a seperate issue? Regards Bob.
To turn it on, you simply need to select the new code formatter in the Work in progress of the Java settings. Then you apply the change and you select the code formatter preference page. Open a feature request for your last comment. I am not sure if we will have time to do it. I have other things to do than just the code formatter.
This is already done. Closing as FIXED.
There is another bug report for this bug. I change the resolution of this one to WORKSFORME
Change resolution to WORKSFORME