Recipe ReplaceAWTGetPeerMethod in Java 11 Migration#524
Recipe ReplaceAWTGetPeerMethod in Java 11 Migration#524timtebeek merged 24 commits intoopenrewrite:mainfrom
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
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. |
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 |
|
Thanks @timtebeek taking a look now |
|
@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. |
cjobinabo
left a comment
There was a problem hiding this comment.
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