Bug 14387 - Formatter isn't //$NON-NLS-1$ aware
Summary: Formatter isn't //$NON-NLS-1$ aware
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 critical (vote)
Target Milestone: 2.0 M6   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-23 05:01 EDT by Erich Gamma CLA
Modified: 2002-04-25 15:01 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erich Gamma CLA 2002-04-23 05:01:11 EDT
The //$NON-NLS comments should never be broken on a new line by the formatter 
since this changes the run-time behaviour of a program.
Comment 1 Philipe Mulet CLA 2002-04-23 08:54:57 EDT
Olivier - would it be hard to address ?
Comment 2 Olivier Thomann CLA 2002-04-23 10:06:41 EDT
There is nothing easy when it is about changing the formatter.
Comment 3 Olivier Thomann CLA 2002-04-23 14:45:56 EDT
I can easily change the fact that a line is split when too long if it contains //$NON-NLS. Is this what 
we want?

For example if I 
have:
		System.out.println("lnzlkjnzlkjnklndflnafl;nfl;sknfl;" + 
"skfnl;kfnsl;knfkl;sdnfl " + ";ksnfl;knfs"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
It 
would remain on a single line.
If I remove the NON-NLS tags, I 
get:
		System.out.println(
			"lnzlkjnzlkjnklndflnafl;nfl;sknfl;"
				+ 
"skfnl;kfnsl;knfkl;sdnfl "
				+ ";ksnfl;knfs");

If we 
want:
		System.out.println(
			"lnzlkjnzlkjnklndflnafl;nfl;sknfl;"//$NON-NLS-1$ 

				+ "skfnl;kfnsl;knfkl;sdnfl "//$NON-NLS-2$ 
				+ ";ksnfl;knfs");//$NON-NLS-3$ 


Then it is really difficult to get this with the actual implementation. Let me know if the 
first solution is sufficient.
Comment 4 Olivier Thomann CLA 2002-04-25 14:02:17 EDT
Please update the PR if you want to see the code released.
Comment 5 Olivier Thomann CLA 2002-04-25 15:01:32 EDT
I added a special case for $NON-NLS$ comment in the formatter. Lines containing such a comment are 
not formatted anymore. If this doesn't work as expected, reopen this PR.