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

Fix: NON-NLS comments move before + in string concatenations #45

Merged
merged 4 commits into from
Oct 21, 2019

Conversation

dansanduleac
Copy link
Contributor

Before this PR

NON-NLS comments after + in chains of string concatenations are moved such that they don't follow the original string anymore.

After this PR

==COMMIT_MSG==
NON-NLS comments are moved behind + tokens in string concatenations. This is a heuristic that doesn't look at what the thing before the + is, so it might produce confusing results.
==COMMIT_MSG==

Possible downsides?

@changelog-app
Copy link

changelog-app bot commented Oct 21, 2019

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

NON-NLS comments are moved behind + tokens in string concatenations. This is a heuristic that doesn't look at what the thing before the + is, so it might produce confusing results.

Check the box to generate changelog(s)

  • Generate changelog entry

@dansanduleac dansanduleac changed the title FixL NON-NLS comments move before + in string concatenations Fix: NON-NLS comments move before + in string concatenations Oct 21, 2019
+ "field_1," //$NON-NLS-1$
+ "field_2," //$NON-NLS-1$
+ "field_3," //$NON-NLS-1$
+ "field_4"; //$NON-NLS-1$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ 😍

@@ -620,6 +631,10 @@ private static int getI(Input.Token token) {
return newOps.build();
}

private static boolean isNonNlsComment(Input.Tok tokAfter) {
return tokAfter.isSlashSlashComment() && tokAfter.getText().contains("$NON-NLS");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be able to make this more specific, nls comments are required to start with //$NON-NLS-, even subsequent numbers, e.g.

String f() {
  return "a" + "b"; //$NON-NLS-1$ //$NON-NLS-2$
}

Realistically I'm not sure that makes much difference.

@bulldozer-bot bulldozer-bot bot merged commit dfc5cf1 into develop Oct 21, 2019
@bulldozer-bot bulldozer-bot bot deleted the ds/non-nls branch October 21, 2019 21:17
@svc-autorelease
Copy link
Collaborator

Released 0.2.8

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

Successfully merging this pull request may close these issues.

None yet

3 participants