Bug 49481

Summary: New Code Formatter; if/else without curly braces; guardian clause (1)
Product: [Eclipse Project] JDT Reporter: Sebastian Davids <sdavids>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.0 M7   
Hardware: PC   
OS: All   
Whiteboard:

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.