Skip to content

Commit

Permalink
Shorten RemoveExtendsEasyMockSupport
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Nov 18, 2024
1 parent b3e1ba8 commit 1d1c6fc
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.search.UsesType;
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaType;
import org.openrewrite.java.tree.TypeUtils;

public class RemoveExtendsEasyMockSupport extends Recipe {
Expand All @@ -46,13 +45,9 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, ExecutionContext ctx) {
J.ClassDeclaration cd = super.visitClassDeclaration(classDecl, ctx);

maybeRemoveImport(EASYMOCK);

if (cd.getExtends() != null) {
JavaType.FullyQualified fqn = TypeUtils.asFullyQualified(cd.getExtends().getType());
if (fqn != null && fqn.isAssignableTo(EASYMOCK)) {
cd = cd.withExtends(null);
}
if (cd.getExtends() != null && TypeUtils.isAssignableTo(EASYMOCK, cd.getExtends().getType())) {
maybeRemoveImport(EASYMOCK);
cd = cd.withExtends(null);
}
return cd;
}
Expand Down

0 comments on commit 1d1c6fc

Please sign in to comment.