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 bug in InstanceOfPatternMatch getting the variable name from the name of a nested class #291

Merged
merged 1 commit into from
May 10, 2024

Conversation

nguyenhoan
Copy link
Contributor

@nguyenhoan nguyenhoan commented May 9, 2024

What's changed?

Fix bug in InstanceOfPatternMatch getting the variable name from the name of a nested class.

What's your motivation?

Fixes #290

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

@timtebeek

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Thanks a lot for reporting, replicating, debugging and fixing this issue!

if (className.indexOf('.') > 0) {
className = className.substring(className.lastIndexOf('.'));
}
className = className.substring(className.lastIndexOf('.') + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Subtle using last index of being -1 here and adding 1; unless it's found in which case you skip. Smart. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you!

@timtebeek timtebeek merged commit 989faff into openrewrite:main May 10, 2024
2 checks passed
@nguyenhoan
Copy link
Contributor Author

Thank you for reviewing and merging the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Bug in InstanceOfPatternMatch getting the variable name from the name of a nested class
2 participants