Bug 305830

Summary: [formatter] block comment should not be formatted when a non-nls tag is on the same line
Product: [Eclipse Project] JDT Reporter: Frederic Fusier <frederic_fusier>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: jarthana, satyam.kandula
Version: 3.6   
Target Milestone: 3.6 M7   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed patch
none
Proposed patch none

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