Bug 58999 - Code formatter doesn't handle //$NON-NLS-x$ very well
Summary: Code formatter doesn't handle //$NON-NLS-x$ very well
Status: RESOLVED DUPLICATE of bug 50989
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-17 20:57 EDT by Ian Brown CLA
Modified: 2004-04-19 14:46 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 Ian Brown CLA 2004-04-17 20:57:43 EDT
I've noticed that in situations where the code formatter splits lines, it 
tends to do so such that quoted strings are placed on a different line to 
the //$NON-NLS-x$ tags that would let software know that the strings were not 
for internationalisation.

Whilst this is because the code formatter is correctly trying to observe line 
length settings, it does mean that the compiler then starts whining about 
there being non-externalized string literals in the code because the //$NON-
NLS-x$ is no longer on the same line as the hard-coded strings.

The downside of this, of course, is that every time the code gets formatted, 
this will recur and need to be manually corrected which, in the case of a 
ListResourceBundle, could be a massive undertaking.

Any suggestions?
Comment 1 Ian Brown CLA 2004-04-17 21:07:56 EDT
For example I have some code thus:

   Identity[] toolsItems = new Identity[]
      {
         new TextualIdentity( "toolsMenu" ), //$NON-NLS-1$ 
         new TextualIdentity( "toolsToolbar" ) //$NON-NLS-1$
      };

but when this gets formatted, I am left with

   Identity[] toolsItems = new Identity[]
      {
         new TextualIdentity( "toolsMenu" ), //$NON-NLS-1$ 
         new TextualIdentity( "toolsToolbar" )
      //$NON-NLS-1$
      };


Conversely (and using exactly the same code formatter settings), if I arrange 
the code thus:

   Identity[] toolsItems = new Identity[]
      {
         new TextualIdentity( "toolsMenu" ), new TextualIdentity
( "toolsToolbar" ) //$NON-NLS-1$ //$NON-NLS-2$ 
      };

and format it, I get:

   Identity[] toolsItems = new Identity[]
      {
         new TextualIdentity( "toolsMenu" ), new TextualIdentity
( "toolsToolbar" )
      //$NON-NLS-1$ //$NON-NLS-2$ 
      };

This was probably obvious from my original write-up, but I thought that while 
I had an example to hand, I'd paste one in :)
Comment 2 Ian Brown CLA 2004-04-17 21:26:02 EDT
See also bug 59000

May not be related, but have a similarity in that they both deal with end-of-
line comments and the code formatter

Although I am looking, in 58999 for specialised //$NON-NLS-x$ handling, and in 
59000 I am highlighting a potential flaw in the "line wrapping" code formatter 
stuff
Comment 3 Dani Megert CLA 2004-04-19 03:50:15 EDT
which build?
Comment 4 Philipe Mulet CLA 2004-04-19 06:26:56 EDT

*** This bug has been marked as a duplicate of 50989 ***
Comment 5 Ian Brown CLA 2004-04-19 14:46:06 EDT
This is in M8, with no third-party plugins