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

Recipe ReplaceAWTGetPeerMethod in Java 11 Migration #524

Merged
merged 24 commits into from
Aug 9, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
61abfb8
getPeer() recipe
AnuRam123 Aug 1, 2024
f60b422
updated with fixes
AnuRam123 Aug 5, 2024
3c0e764
small updates
AnuRam123 Aug 5, 2024
6a4a5fa
Merge branch 'main' into recipe_detectAWTGetPeerMethod
ranuradh Aug 5, 2024
1bb77d2
Apply suggestions from code review
timtebeek Aug 5, 2024
3d1de0a
Apply suggestions from code review
timtebeek Aug 5, 2024
deb96c3
Apply formatter & order imports
timtebeek Aug 6, 2024
4e63d90
Align before and after code blocks again
timtebeek Aug 6, 2024
1d16fc4
updated recipe name, updated tests and formatted code
AnuRam123 Aug 6, 2024
1e26b14
removing extra file commit and test update
AnuRam123 Aug 6, 2024
1883f5d
adding comments, Test file cleanup
AnuRam123 Aug 6, 2024
c30aefb
Demonstrate the need for `super.visitControlParentheses(cp, ctx)`
timtebeek Aug 7, 2024
d1b97da
Only override `visitBinary` and `visitInstanceOf`
timtebeek Aug 7, 2024
6764297
Update src/test/java/org/openrewrite/java/migrate/ReplaceAWTGetPeerMe…
timtebeek Aug 7, 2024
b28d9bb
update to code and adding missing arguments to .yml
AnuRam123 Aug 8, 2024
94bc136
Merge branch 'main' into recipe_detectAWTGetPeerMethod
ranuradh Aug 8, 2024
5679678
right format for java-version.yml
AnuRam123 Aug 8, 2024
46b0c86
Merge branch 'main' into recipe_detectAWTGetPeerMethod
timtebeek Aug 9, 2024
13be5af
Remove import after instanceof replacement
timtebeek Aug 9, 2024
99801ef
Also handle flipped case
timtebeek Aug 9, 2024
694e592
Replace `checkClassNameIsEqualToFQCN` with TypeUtils
timtebeek Aug 9, 2024
e8247db
Remove duplication in arguments
timtebeek Aug 9, 2024
d2cce4f
Document options and shorten description
timtebeek Aug 9, 2024
e00a481
fixed small typo in description
AnuRam123 Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Preconditions;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
import org.openrewrite.*;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.java.ChangeMethodName;
import org.openrewrite.java.JavaVisitor;
Expand All @@ -35,8 +32,14 @@
@EqualsAndHashCode(callSuper = false)
class ReplaceAWTGetPeerMethod extends Recipe {

// Fields configurable for tests
@Option(displayName = "Method pattern to replace",
timtebeek marked this conversation as resolved.
Show resolved Hide resolved
description = "The method pattern to match and replace.",
example = "java.awt.* getPeer()")
String getPeerMethodPattern;

@Option(displayName = "The LightweightPeer interface FQCN",
description = "The fully qualified class name of the LightweightPeer interface to replace in `instanceof`.",
example = "java.awt.peer.LightweightPeer")
String lightweightPeerFQCN;

@Override
Expand All @@ -46,11 +49,9 @@ public String getDisplayName() {

@Override
public String getDescription() {
return "All methods that refer to types defined in the java.awt.peer package are removed in Java 11. " +
"This 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())`.";
return "This recipe replaces the use of `getPeer()` method in `java.awt.*` classes. " +
"`component.getPeer() != nul` is replaced with `component.isDisplayable()` and " +
"`component.getPeer() instanceof LightweightPeer` is replaced with `component.isLightweight()`.";
}

@Override
Expand Down
Loading