This is a follow up question to: What does $NON-NLS-1$ mean?
I've noticed that the comment tag will be recognized as a NLS tag when you use any number. However, only the number 1 seems to correctly fixed the warning. (Silenced warning vs. unsilenced warning + unnecessary nls tag)
What is the purpose of this?
Non-externalized strings (missing/unused $NON-NLS$ tag)
@Documented@Retention(value=CLASS)@Target(value={METHOD,FIELD,PARAMETER,LOCAL_VARIABLE,TYPE,PACKAGE})public @interface NonNls. Specifies that an element of the program is not a user-visible string which needs to be localized, or does not contain such strings.
The number after $NON-NLS-
signifies which string on the tagged line the tag is for. The number 1 works for you, likely because there is only 1 string on the line you are trying to tag.
If you had 2 strings on the same line, you can, for example, tag only the second string using $NON-NLS-2$
.
//Warning on "baz"
foo("bar","baz"); //$NON-NLS-1$
//Warning on "bar"
foo("bar","baz"); //$NON-NLS-2$
//No warnings
foo("bar","baz"); //$NON-NLS-1$ //$NON-NLS-2$
//Warning on "baz" (apparently the slashes are required even with multiple tags)
foo("bar","baz"); //$NON-NLS-1$ $NON-NLS-2$
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With