Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NON-NLS tag ignored for specific method references targeting a string literal #3025

Closed
HannesWell opened this issue Sep 27, 2024 · 5 comments · Fixed by #3044
Closed

NON-NLS tag ignored for specific method references targeting a string literal #3025

HannesWell opened this issue Sep 27, 2024 · 5 comments · Fixed by #3044
Assignees

Comments

@HannesWell
Copy link
Contributor

In the following code the compiler issues a warning in the second line and does not consider NON-NLS tag.
Non-externalized string literal; it should be followed by //$NON-NLS-<n>$

List<String> list = List.<String>of();
list.removeIf("."::equals); //$NON-NLS-1$
list.removeIf(e -> ".".equals(e)); //$NON-NLS-1$
list.removeIf((Predicate<String>) "."::equals); //$NON-NLS-1$

In the third and fourth line no such warnings are emitted.

@srikanth-sankaran
Copy link
Contributor

srikanth-sankaran commented Sep 30, 2024

Please always supply full class that can be pasted (with class headers, method headers, imports etc) - the committers will thank you :)

@srikanth-sankaran srikanth-sankaran self-assigned this Sep 30, 2024
@srikanth-sankaran
Copy link
Contributor

I'll take a look.

@HannesWell
Copy link
Contributor Author

Please always supply full class that can be pasted (with class headers, method headers, imports etc) - the committers will thank you :)

Sure, no problem. Assumed you would prefer a minimal snippet, but can of course also make it complete.

I'll take a look.

Thanks.

@srikanth-sankaran
Copy link
Contributor

Please always supply full class that can be pasted (with class headers, method headers, imports etc) - the committers will thank you :)

Sure, no problem. Assumed you would prefer a minimal snippet, but can of course also make it complete.

A minimal snippet is minimal not only in terms of amount of code in it - but also minimal in how much work is needed in addition to reproduce the problem or write a junit test. So in that sense a complete but minimal snippet is best. Thanks.

I'll take a look.

Thanks.

@srikanth-sankaran srikanth-sankaran changed the title NON-NLS tag ignored for specifc method references targeting a string literal NON-NLS tag ignored for specific method references targeting a string literal Oct 2, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Oct 2, 2024
@srikanth-sankaran
Copy link
Contributor

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=443456 - Unfortunately that considered only lambda expressions and the bug has stayed dormant in the case of reference expressions for some ten years !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants