-
Notifications
You must be signed in to change notification settings - Fork 78
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
Recipe ReplaceAWTGetPeerMethod in Java 11 Migration #524
Recipe ReplaceAWTGetPeerMethod in Java 11 Migration #524
Conversation
src/main/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethod.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethodTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethodTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
src/test/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethodTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethod.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethodTest.java
Outdated
Show resolved
Hide resolved
Hi @ranuradh ! Thanks for yet another recipe. I'm working my way through and I'm wondering what IDE settings you're using. You had checked the box above that you applied the formatter, but when I do the same locally I still got quite a bit of changes, as seen in deb96c3 . Additionally, I see quite a bit of warnings in my IDE about nullability handling & casts for instance: Ideally we'd have none of those issues on recipes that we add to our catalog, such that any new issues in the future stand out when we maintain these recipes. Would you mind sharing and perhaps adjusting your settings? We use IntelliJ defaults where possible. |
src/main/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethod.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethod.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethodTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethodTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethodTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethodTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethodTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethod.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethod.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/DetectAWTGetPeerMethod.java
Outdated
Show resolved
Hide resolved
I am not sure what is going on probably have to update my IntelliJ - I use the following - |
Hi @timtebeek am taking a look at ur suggestions and will update the PR |
Hi @timtebeek would like some clarification here:
In the above case neither visitBinary() nor visitInstantOf is called instead we need to override visitMethodDeclaration. |
Hi @ranuradh ; I've pushed a change that will have caused your overridden methods not to be called; now if you set a breakpoint in those other methods they will actually be triggered. As a reminder you are in complete control of the tree traversal, which includes calling |
src/test/java/org/openrewrite/java/migrate/ReplaceAWTGetPeerMethodTest.java
Outdated
Show resolved
Hide resolved
Thanks @timtebeek taking a look now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @ranuradh ; I've applied a last few finishing touches to expand what's matched, and reduce the code to maintain.
@timtebeek love how you have made the recipe more generic and removed duplications will remember for the next recipe. This recipe looks great and we should be able to merge it post Chuka taking a look There are still build errors though. |
Thanks for the kind words! Indeed incremental improvements is what we're going for; glad you're still learning from my feedback. The build issue should be fixed once this change rolls out to a new release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @timtebeek for working so closely with Anu on this.
What's changed?
This PR contains recipe - org.openrewrite.java.migrate.ReplaceAWTGetPeerMethod
Rule:
What's your motivation?
This custom recipe replaces the use of getPeer() method in the java.awt.Component, java.awt.Font, and java.awt.MenuComponent classes and direct known subclasses. The occurrence of
(component.getPeer() != null) { .. }
is replaced with(component.isDisplayable())
and the occurrence of(component.getPeer() instanceof LightweightPeer)
is replaced with(component.isLightweight())
.Anyone you would like to review specifically?
@timtebeek
@cjobinabo
Any additional context
Since I couldn't test the recipe I am attaching the rewrite.patch along with the Test that tests using similar invocations
rewrite.patch
Checklist