Bug 51035

Summary: [Formatter] endline comment in case of simple if-then statement
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-02-01 17:25:35 EST
public class Test {

    void test(String s) {
        if (s == null) s = ""; //$NON-NLS-1$
    }
}

Formatted using Java Conventions:

public class Test {

    void test(String s) {
        if (s == null) s = "";
        //$NON-NLS-1$
    }
}

@@@@

The //$NON-NLS-1$ should be kept on the same line.
Comment 1 Martin Aeschlimann CLA 2004-02-05 16:52:20 EST
Comments on the line of a statement should probably always stay on the line of
the statement. (also for cases like /* protected */ void foo() {..})

We should have the same heuristic in mapping comments to nodes in the AST
rewrite and in the formatting (work in progress)
Comment 2 Olivier Thomann CLA 2004-02-09 13:20:39 EST
This is not a guardian clause, but a simple if-then statement.
Update the title accordingly.
Fixed and released in HEAD.
Regression test added.
Comment 3 Olivier Thomann CLA 2004-02-12 14:36:21 EST
Verified in 200402121200.