开发者

How to place $NON-NLS-1$ kind of comments in eclipse

I have realized that through eclipse source code there are a lot of comments like this one, I know they are for instructing eclipse开发者_高级运维 that the strings in these lines aren´t supposed to be internationalizable, and I would like if I can place that kind of single line comments using eclipse code completion assistant.

private String toolTip = ""; //$NON-NLS-1$


The Externalize Strings process can take care of that. Select Source → Externalize Strings. Now, select which Strings you wish to externalize. If you wish to Externalize some of the strings, go ahead. Those which will be marked as "Ignore" will automatically get the //$NON-NLS-1$ comment.

You can quickly add these comments by typing nls and clicking Ctrl+Space (code completion, could be different on your platform). There's a template for NLS with a number you need to enter. You can create a template without a number under the Preferences → Java / Editor / Templates.

You can set Eclipse to automatically remove unnecessary $NON-NLS-1$ comments. See under Preferences → Java / Editor / Save Actions → Enable additional actions → Configure → under Unnecessary code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜