Bug 394350 - Add option to restrict auto-remove braces (save action) to really simple statements only
Summary: Add option to restrict auto-remove braces (save action) to really simple sta...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8.1   Edit
Hardware: PC Mac OS X
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-14 19:49 EST by Robin Rosenberg CLA
Modified: 2012-11-15 00:07 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Rosenberg CLA 2012-11-14 19:49:22 EST
When a statement has a nested statement which spans multiple lines we want to keep the braces at the "complex" levels, i.e. only remove simple caes.

// remove braces
if (a)
    B;



// Add braces
if (a) {
     try {
     }
}

// Add braces at outer level, remove at inner
if (a) {
     if (b)
         c
}

If a statement's nested statements cover multiple lines (short of wrapped lines) it should have braces. One could add a depth parameter to get. 

if (a)
     if (b)
         c

but
if (a) {
     if (b)
         if (c)
             d
}

Yet another option could be to consider comments when counting lines

if (a) {
     // c
     b
}

or 

if (a)
     // c


Default should be to count comment lines and add braces.
Comment 1 Jay Arthanareeswaran CLA 2012-11-15 00:07:35 EST
Thanks for raising this. However, it might be a while before we can even look at it.