Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 122914

Summary: [formatter] Formating java file breaks NLS (//$NON-NLS-1$) comments
Product: [Eclipse Project] JDT Reporter: Sébastien Gandon <sgandon>
Component: CoreAssignee: Mateusz Matela <mateusz.matela>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P5 CC: manoj.palat, mateusz.matela
Version: 3.1.1   
Target Milestone: 4.7 M6   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Seb's formated pref file for this bug none

Description Sébastien Gandon CLA 2006-01-06 10:11:16 EST
the pb : 
when long lines with //$NON-NLS-1$ comment in the gets formatted this comment can go to the next line a therefore brings the famous warning (Non-externalized string literal; it should be followed by //$NON-NLS-<n>$) everywhere.

proposed solution :  
There should be a property in the formater profile for comments not to break NLS comments from the line they are on.
Comment 1 Olivier Thomann CLA 2006-01-06 10:15:05 EST
Could you please provide a test case? This is supposed to be handled.
Comment 2 Sébastien Gandon CLA 2006-01-06 10:23:47 EST
Created attachment 32586 [details]
Seb's  formated pref file for this bug

just create a new java class and add the following line
displayNamelbl.setText(SignalingMessages.getString("AitPropertiesCompositeControlProvider.0")); // Generated //$NON-NLS-1$

(this is only one line)

import the attached pref and do Ctrl+Shif+F and you'll see the //$NON-NLS-1$ go to the next line.
Comment 3 Olivier Thomann CLA 2006-01-06 10:25:51 EST
What happens if you remove // Generated ?
Comment 4 Sébastien Gandon CLA 2006-01-06 10:29:04 EST
it works perfectly, so indeed this is a bug (side effect) of the // generated comment.
shall I rename the bug, create a new one or leave this one (I'd rather)

SeB.
Comment 5 Olivier Thomann CLA 2006-01-06 10:35:13 EST
Leave this one open. This is a bug on our side.
Looking at the code this should also be supported. We simply check if the line comment contains //$NON-NLS-.
I'll investigate, but not immediately.
Comment 6 Olivier Thomann CLA 2006-01-11 21:36:30 EST
This is a bug in the comment formatter.
If you disable comment formatting for now, it should work.
I'll work later on the comment formatter.
Comment 7 Olivier Thomann CLA 2007-02-13 15:41:42 EST
The comment formatter should not format line comment that contains NLS tags.
Since 3.3M5, you can disable the line comment formatting from other comment formatting (block or javadoc).
Comment 8 Frederic Fusier CLA 2008-08-18 08:07:14 EDT
Ownership has changed for the formatter, but I surely will not have enough time to fix your bug during the 3.5 development process, hence set its priority to P5.
Please provide a patch if you definitely need the bug to be fixed in this version and I'll have a look at it...
TIA
Comment 9 Mateusz Matela CLA 2017-02-10 09:18:43 EST
This bug no longer occurs after the formatter redesign.

*** This bug has been marked as a duplicate of bug 303519 ***
Comment 10 Manoj N Palat CLA 2017-03-07 09:21:54 EST
Verified for Eclipse Oxygen 4.7 M6 Build id: I20170305-2000