-
Notifications
You must be signed in to change notification settings - Fork 275
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
org.openrewrite.java.ChangePackage precise match #4188
Comments
Hi! Thanks for the report; I think this might be a bug we hadn't encountered before. Looking at the implementation quickly it might just be this line that causes trouble:
Slightly further down we don't use
The best way to rule this out would be to add a unit test to ChangePackageTest similar to this one rewrite/rewrite-java-test/src/test/java/org/openrewrite/java/ChangePackageTest.java Lines 114 to 147 in 2122964
That unit test should then contain two Is this something you'd want to help resolve? |
@timtebeek, I think it's a little more complicated than just swapping to equals as it looks like nested packages should be moved as well. rewrite/rewrite-java-test/src/test/java/org/openrewrite/java/ChangePackageTest.java Lines 364 to 400 in 2122964
I suspect that these all should be equals exact and then starts with the package name followed by a dot. That should handle the case of exact package and all subpackages. |
Hi everyone! I'm a user of your project and I'm interested in contributing to it. Can I try to help you in this and maybe some other issues if you don't mind? |
Thanks for your sharp eye as always @shanman190 , and thanks for the offer to help @Dinozavvvr .
All help is welcome! Best to start with a draft pull request that just adds tests to replicate the issue at hand here, and then from there we can see what changes would make the test pass to fix the issue. |
Is something need from me now? I wrote tests and fixed issue @timtebeek |
Thanks a lot! Hadn't seen your PR pop up just yet as drafts don't trigger a notification for me yet. I see it now though: I'm traveling right now, but will be back Thursday for a closer look; great to see you picked this up and worked out how to make the tests pass. |
* Fixed issue [org.openrewrite.java.ChangePackage precise match](#4188) * Added links to issue * Inline `oldRecursivePackageName` --------- Co-authored-by: Tim te Beek <tim@moderne.io>
Thanks a lot @Dinozavvvr ; Change should make it into our next release, and can already be tried out from the latest snapshot version. |
https://docs.openrewrite.org/recipes/java/changepackage
When I use the above recipe to move/rename/change the types in package
com.test.model.staff
tocom.test.model.data.staff
, it picks up the types in packagecom.test.model.staffdetails
too.How can I restrict it to pick up only files from package
.staff
and not from.staffdetails
?The text was updated successfully, but these errors were encountered: