-
Notifications
You must be signed in to change notification settings - Fork 356
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
ChangeType does not work on J.ClassDeclaration #4670
Conversation
Test results (updated) Failed:
Passed:
|
As also detailed in Slack, we're exploring if this is perhaps due to the way this is tested, as a test like this passes: @Issue("https://github.com/openrewrite/rewrite/issues/775")
@Test
void changeTypeInTypeDeclaration() {
rewriteRun(
spec -> spec.recipe(new ChangeType("de.Class2", "de.Class1", false)),
java(
"""
package de;
public class Class2 {}
""",
"""
package de;
public class Class1 {}
""",
spec -> spec.afterRecipe(cu -> {
String simpleName = cu.getClasses().get(0).getSimpleName();
assertThat(simpleName).isEqualTo("Class1");
})
)
);
} |
Thanks for the runnable reproducer! We do however think this is an unintentional use of the |
@Laurens-W Thanks for the fix here! We have two general use cases in which we call
|
* Add test * Added compilation unit test * Swap expected and actual * Restore previous behavior --------- Co-authored-by: Laurens Westerlaken <[email protected]>
What's changed?
A test case was added to demonstrate an issue with using the
ChangeType
recipe on aJ.ClassDeclaration
object.What's your motivation?
ChangeType
fails to change the class name for aJ.ClassDeclaration
object. This may be related toChangeType
andChangePackage
to work withSourceFileWithReference
#4648since we noticed this new regression in a local recipe today.
Anyone you would like to review specifically?
@timtebeek
Checklist