Bug 49481 - New Code Formatter; if/else without curly braces; guardian clause (1)
Summary: New Code Formatter; if/else without curly braces; guardian clause (1)
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.0 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-01-03 03:46 EST by Sebastian Davids CLA
Modified: 2004-02-11 12:46 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Davids CLA 2004-01-03 03:46:10 EST
void a() {
    if (true)
        System.out.println("a");
    else
        System.out.println("b");
}

@@@@

Java Code Conventions:

void a() {
    if (true) System.out.println("a");
    else
        System.out.println("b");
}

@@@@

The snipped should not have been formatted.

Apparently the first "if" is considered a guardian clause -- which it is not.
Comment 1 Sebastian Davids CLA 2004-01-03 03:50:43 EST
bug 49482 is similar
Comment 2 Olivier Thomann CLA 2004-01-05 10:59:01 EST
No, this is not a guardian clause, but the option keep then statement on the
same line is checked by default in the Java conventions settings.
I will change it to false.
Comment 3 Olivier Thomann CLA 2004-01-05 11:15:30 EST
Changing this settings to false fixed the problem.
Fixed and released in HEAD.
Regression test added.
Comment 4 Frederic Fusier CLA 2004-02-11 12:46:15 EST
Verified for 3.0-M7 with build I200402102000.