Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 79065

Summary: add feature to insert braces for simple if statements
Product: [Eclipse Project] JDT Reporter: Mark Drew <eclipse>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3 CC: daniel_megert, rhauser
Version: 3.1Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Mark Drew CLA 2004-11-19 08:25:31 EST
[formatting] add option to insert braces for simple if statements (and other
appropriate control statements)

For example, it would be great if there was an option in the formatter that
would format code that looks like this

    while (someTest)
      someTest = ...;
    if (test)
      return x;
    else
      return y;

into this

    while (someTest) {
      someTest = ...;
    }
    if (test) {
      return x;
    } else {
      return y;
    }
Comment 1 Dani Megert CLA 2004-11-22 04:45:07 EST
Formatting only touches white spacing.

There's a Quick Assist (Change then statement to block).

Martin:
- what about the while?
- I found it strange that I didn't get that Quick Assist while caret is in the
  statement
Comment 2 Martin Aeschlimann CLA 2004-11-22 06:01:25 EST
- the same quick assist exists for while (and for and do)
- Quick assists inside the sytatement would mix with other assist and make the 
list too long. 
Comment 3 Mark Drew CLA 2004-11-22 08:17:58 EST
This enhancement request is not about quick assists, it's about the Java code
formatter.
Comment 4 Dani Megert CLA 2004-11-22 08:26:45 EST
see comment 1: formatter only touches whitespacing
Comment 5 Mark Drew CLA 2004-11-22 08:45:59 EST
Quick assists are fine for some things, but for formatting/transforming large
sections of code, they are not practical.

It doesn't matter to me if this feature is added to the code formatter, or
elsewhere, but quick assists are not--IMHO--a satisfactory solution.  Maybe this
feature could be added in a way that is similar to the organize imports feature.
 (Would it help if I filed a new enhancement request along these lines?)

Please reconsider, or consider some other feature to allow bulk changes.  Thanks!
Comment 6 Mark Drew CLA 2004-11-22 15:21:30 EST
Sorry if I'm making a pest of myself, but could this feature be added in a way
that is similar to the organize imports feature? (Would it help if I filed a new
enhancement request along these lines?)  Please see comment 5.
Comment 7 Martin Aeschlimann CLA 2004-11-23 03:36:53 EST
Yes that could be done, but is currently not planed. Help is definitly welcome.
Comment 8 Benno Baumgartner CLA 2006-01-12 11:46:53 EST

*** This bug has been marked as a duplicate of 87537 ***