Bug 305830 - [formatter] block comment should not be formatted when a non-nls tag is on the same line
Summary: [formatter] block comment should not be formatted when a non-nls tag is on th...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-15 06:35 EDT by Frederic Fusier CLA
Modified: 2010-04-26 08:59 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (8.07 KB, patch)
2010-03-19 05:03 EDT, Frederic Fusier CLA
no flags Details | Diff
Proposed patch (7.08 KB, patch)
2010-03-19 05:28 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2010-03-15 06:35:47 EDT
Using 3.6M6 but I guess this happens since day 1.

Consider the following test case:

public class Test {
void foo() {
	bar("a non-nls string", 0 /* a comment */); //$NON-NLS-1$
}
void bar(String string, int i) {
}
}

Format it using the Eclipse built-in profile + spaces only + max line width=40, then you get:

public class Test {
    void foo() {
        bar("a non-nls string", 0 /*
                                   * a
                                   * comment
                                   */); //$NON-NLS-1$
    }

    void bar(String string, int i) {
    }
}

Unfortunately the formatter, while touching the block comment, breaks the NON-NLS tag effect and may potentially add two warning/errors on the CU if the compiler options has been set to reveal non-nls strings usage...
Comment 1 Frederic Fusier CLA 2010-03-15 07:32:59 EDT
This problem exists since at least 3.0...
Comment 2 Frederic Fusier CLA 2010-03-19 05:03:52 EDT
Created attachment 162501 [details]
Proposed patch

With this patch, the formatter skips the block comments when its formatting will break the line which contains the non-nls tag.
Comment 3 Frederic Fusier CLA 2010-03-19 05:05:08 EDT
Released for 3.6 M7 in HEAD stream.
Comment 4 Frederic Fusier CLA 2010-03-19 05:28:59 EDT
Created attachment 162505 [details]
Proposed patch

This is the real proposed patch, previous one was not up-to-date... :-S
Comment 5 Satyam Kandula CLA 2010-04-26 05:37:13 EDT
Verified for 3.6M7 using build I20100424-2000