Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -94,7 +94,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
if (!FindAnnotations.find(classDecl, "@javax.persistence.Embeddable").isEmpty() &&
acc.isEmbeddableClass(classDecl.getType())) {
// Remove @Id annotation from anything in the class (only found on VariableDeclarations)
classDecl = new RemoveAnnotation( "javax.persistence.Id" ).getVisitor().visit( classDecl, ctx, getCursor().getParentTreeCursor() );
classDecl = (J.ClassDeclaration) new RemoveAnnotation( "javax.persistence.Id" ).getVisitor().visit( classDecl, ctx, getCursor().getParentTreeCursor() );
maybeRemoveImport("javax.persistence.Id");
}
return super.visitClassDeclaration(classDecl, ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
import org.openrewrite.internal.ListUtils;
import org.openrewrite.java.JavaIsoVisitor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
public J visitIf(J.If if_, ExecutionContext ctx) {
J.Switch switch_ = new SwitchCandidate(if_, getCursor()).buildSwitchTemplate();
if (switch_ != null) {
switch_ = new JavaIsoVisitor<ExecutionContext>() {
switch_ = (J.Switch) new JavaIsoVisitor<ExecutionContext>() {
@Override
public J.Case visitCase(J.Case case_, ExecutionContext ctx) {
if (case_.getBody() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public J.Switch visitSwitch(J.Switch sw, ExecutionContext ctx) {
return statement;
})));
if (mappedSwitch != switch_) {
return new JavaIsoVisitor<ExecutionContext>() {
return (J.Switch) new JavaIsoVisitor<ExecutionContext>() {
@Override
public J.Case visitCase(J.Case case_, ExecutionContext ctx) {
// Remove any trailing new line in empty case body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration cd, Execution
List<Statement> bodyStatements = new ArrayList<>(classDeclaration.getBody().getStatements());
bodyStatements.removeAll(memberVariables);

classDeclaration = new RemoveAnnotationVisitor( LOMBOK_VALUE_MATCHER ).visit( classDeclaration, ctx, getCursor().getParentTreeCursor() );
classDeclaration = (J.ClassDeclaration) new RemoveAnnotationVisitor( LOMBOK_VALUE_MATCHER ).visit( classDeclaration, ctx, getCursor().getParentTreeCursor() );
maybeRemoveImport("lombok.Value");

List<J.Modifier> mappedModifiers = ListUtils.map(classDeclaration.getModifiers(), modifier -> {
Expand Down
12 changes: 4 additions & 8 deletions src/main/resources/META-INF/rewrite/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -909,16 +909,14 @@ examples:
import java.lang.reflect.Modifier;

class RemovedModifierAndConstantBootstrapsConstructorsApp {
public void testModifier() throws Exception {
Modifier modifier = new Modifier();
public void testModifier(Modifier modifier) throws Exception {
modifier.classModifiers();
modifier.fieldModifiers();
modifier.isFinal(1);
modifier.isStatic(1);
Modifier.isPublic(0);
}
public void testConstantBootstraps() throws Exception {
ConstantBootstraps constantBootstraps = new ConstantBootstraps();
public void testConstantBootstraps(ConstantBootstraps constantBootstraps) throws Exception {
constantBootstraps.enumConstant(null,null,null);
constantBootstraps.primitiveClass(null,null,null);
ConstantBootstraps.nullConstant(null, null, null);
Expand All @@ -929,16 +927,14 @@ examples:
import java.lang.reflect.Modifier;

class RemovedModifierAndConstantBootstrapsConstructorsApp {
public void testModifier() throws Exception {
Modifier modifier = new Modifier();
public void testModifier(Modifier modifier) throws Exception {
Modifier.classModifiers();
Modifier.fieldModifiers();
Modifier.isFinal(1);
Modifier.isStatic(1);
Modifier.isPublic(0);
}
public void testConstantBootstraps() throws Exception {
ConstantBootstraps constantBootstraps = new ConstantBootstraps();
public void testConstantBootstraps(ConstantBootstraps constantBootstraps) throws Exception {
ConstantBootstraps.enumConstant(null,null,null);
ConstantBootstraps.primitiveClass(null,null,null);
ConstantBootstraps.nullConstant(null, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ void moveToStaticTest() {
import java.lang.reflect.Modifier;

class RemovedModifierAndConstantBootstrapsConstructorsApp {
public void testModifier() throws Exception {
Modifier modifier = new Modifier();
public void testModifier(Modifier modifier) throws Exception {
modifier.classModifiers();
modifier.fieldModifiers();
modifier.isFinal(1);
modifier.isStatic(1);
Modifier.isPublic(0);
}
public void testConstantBootstraps() throws Exception {
ConstantBootstraps constantBootstraps = new ConstantBootstraps();
public void testConstantBootstraps(ConstantBootstraps constantBootstraps) throws Exception {
constantBootstraps.enumConstant(null,null,null);
constantBootstraps.primitiveClass(null,null,null);
ConstantBootstraps.nullConstant(null, null, null);
Expand All @@ -61,16 +59,14 @@ public void testConstantBootstraps() throws Exception {
import java.lang.reflect.Modifier;

class RemovedModifierAndConstantBootstrapsConstructorsApp {
public void testModifier() throws Exception {
Modifier modifier = new Modifier();
public void testModifier(Modifier modifier) throws Exception {
Modifier.classModifiers();
Modifier.fieldModifiers();
Modifier.isFinal(1);
Modifier.isStatic(1);
Modifier.isPublic(0);
}
public void testConstantBootstraps() throws Exception {
ConstantBootstraps constantBootstraps = new ConstantBootstraps();
public void testConstantBootstraps(ConstantBootstraps constantBootstraps) throws Exception {
ConstantBootstraps.enumConstant(null,null,null);
ConstantBootstraps.primitiveClass(null,null,null);
ConstantBootstraps.nullConstant(null, null, null);
Expand Down
Loading