Bug 50334 - Better code format for wrapped lines
Summary: Better code format for wrapped lines
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-21 10:25 EST by csccsccsc CLA
Modified: 2004-05-18 12:30 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description csccsccsc CLA 2004-01-21 10:25:15 EST
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.
Comment 1 Olivier Thomann CLA 2004-01-27 14:32:38 EST
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.
Comment 2 csccsccsc CLA 2004-01-28 05:32:36 EST
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.
Comment 3 Olivier Thomann CLA 2004-02-04 13:56:02 EST
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.
Comment 4 Olivier Thomann CLA 2004-04-30 16:09:36 EDT
This is already done.
Closing as FIXED.
Comment 5 David Audel CLA 2004-05-18 12:29:54 EDT
There is another bug report for this bug.

I change the resolution of this one to WORKSFORME
Comment 6 David Audel CLA 2004-05-18 12:30:29 EDT
Change resolution to WORKSFORME