Bug 51035 - [Formatter] endline comment in case of simple if-then statement
Summary: [Formatter] endline comment in case of simple if-then statement
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-02-01 17:25 EST by Sebastian Davids CLA
Modified: 2004-02-12 14:36 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-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.