From 91d18620a5d141773b8f3c86070a5a3d4a796a3d Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Wed, 23 Oct 2024 12:15:00 +0200 Subject: [PATCH] Add withSideEffects:null to RemoveUnusedLocalVariables --- .../java/org/openrewrite/featureflags/RemoveBooleanFlag.java | 2 +- .../java/org/openrewrite/featureflags/RemoveStringFlag.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/openrewrite/featureflags/RemoveBooleanFlag.java b/src/main/java/org/openrewrite/featureflags/RemoveBooleanFlag.java index a6a8dc2..2b3109d 100644 --- a/src/main/java/org/openrewrite/featureflags/RemoveBooleanFlag.java +++ b/src/main/java/org/openrewrite/featureflags/RemoveBooleanFlag.java @@ -70,7 +70,7 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) J.MethodInvocation mi = (J.MethodInvocation) super.visitMethodInvocation(method, ctx); if (methodMatcher.matches(mi) && isFeatureKey(mi.getArguments().get(0))) { doAfterVisit(new SimplifyConstantIfBranchExecution().getVisitor()); - doAfterVisit(new RemoveUnusedLocalVariables(null).getVisitor()); + doAfterVisit(new RemoveUnusedLocalVariables(null, null).getVisitor()); doAfterVisit(new RemoveUnusedPrivateFields().getVisitor()); J.Literal literal = new J.Literal(Tree.randomId(), Space.SINGLE_SPACE, Markers.EMPTY, replacementValue, String.valueOf(replacementValue), null, JavaType.Primitive.Boolean); return literal.withPrefix(mi.getPrefix()); diff --git a/src/main/java/org/openrewrite/featureflags/RemoveStringFlag.java b/src/main/java/org/openrewrite/featureflags/RemoveStringFlag.java index ae1c35d..a3e9aec 100644 --- a/src/main/java/org/openrewrite/featureflags/RemoveStringFlag.java +++ b/src/main/java/org/openrewrite/featureflags/RemoveStringFlag.java @@ -70,7 +70,7 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) J.MethodInvocation mi = (J.MethodInvocation) super.visitMethodInvocation(method, ctx); if (methodMatcher.matches(mi) && isFeatureKey(mi.getArguments().get(0))) { doAfterVisit(new SimplifyConstantIfBranchExecution().getVisitor()); - doAfterVisit(new RemoveUnusedLocalVariables(null).getVisitor()); + doAfterVisit(new RemoveUnusedLocalVariables(null, null).getVisitor()); doAfterVisit(new RemoveUnusedPrivateFields().getVisitor()); J.Literal literal = new J.Literal(Tree.randomId(), Space.SINGLE_SPACE, Markers.EMPTY, replacementValue, '"' + replacementValue + '"', null, JavaType.Primitive.String); return literal.withPrefix(mi.getPrefix());