Class DeleteStatement<P>

java.lang.Object
org.openrewrite.TreeVisitor<org.openrewrite.java.tree.J,P>
org.openrewrite.java.JavaVisitor<P>
org.openrewrite.java.JavaIsoVisitor<P>
org.openrewrite.java.DeleteStatement<P>

public class DeleteStatement<P> extends JavaIsoVisitor<P>
Deletes standalone statements.

Does not include deletion of:

  • control statements present in for loops.
  • control statements present in while loops.
  • control statements present in do while loops.
  • control statements present in if statements.
  • control statements present in switch statements.
  • statements that would render the closest parent non J.Block statement unable to be compiled

For example, the statement isPotato() would not be removed from any of the following code:

 
     if (isPotato()) { }
     while (isPotato()) { }
     do { } while (isPotato());
     boolean potato = isPotato();
     boolean notPotato = !isPotato();
 
 
  • Constructor Details

    • DeleteStatement

      public DeleteStatement(Statement statement)
  • Method Details

    • visitStatement

      @Nullable public @Nullable Statement visitStatement(Statement statement, P p)
      Overrides:
      visitStatement in class JavaIsoVisitor<P>
    • visitIf

      public org.openrewrite.java.tree.J.If visitIf(org.openrewrite.java.tree.J.If iff, P p)
      Overrides:
      visitIf in class JavaIsoVisitor<P>
    • visitForLoop

      public org.openrewrite.java.tree.J.ForLoop visitForLoop(org.openrewrite.java.tree.J.ForLoop forLoop, P p)
      Overrides:
      visitForLoop in class JavaIsoVisitor<P>
    • visitForControl

      public org.openrewrite.java.tree.J.ForLoop.Control visitForControl(org.openrewrite.java.tree.J.ForLoop.Control control, P p)
      Overrides:
      visitForControl in class JavaIsoVisitor<P>
    • visitForEachLoop

      public org.openrewrite.java.tree.J.ForEachLoop visitForEachLoop(org.openrewrite.java.tree.J.ForEachLoop forEachLoop, P p)
      Overrides:
      visitForEachLoop in class JavaIsoVisitor<P>
    • visitForEachControl

      public org.openrewrite.java.tree.J.ForEachLoop.Control visitForEachControl(org.openrewrite.java.tree.J.ForEachLoop.Control control, P p)
      Overrides:
      visitForEachControl in class JavaIsoVisitor<P>
    • visitWhileLoop

      public org.openrewrite.java.tree.J.WhileLoop visitWhileLoop(org.openrewrite.java.tree.J.WhileLoop whileLoop, P p)
      Overrides:
      visitWhileLoop in class JavaIsoVisitor<P>
    • visitDoWhileLoop

      public org.openrewrite.java.tree.J.DoWhileLoop visitDoWhileLoop(org.openrewrite.java.tree.J.DoWhileLoop doWhileLoop, P p)
      Overrides:
      visitDoWhileLoop in class JavaIsoVisitor<P>
    • visitBlock

      public org.openrewrite.java.tree.J.Block visitBlock(org.openrewrite.java.tree.J.Block block, P p)
      Overrides:
      visitBlock in class JavaIsoVisitor<P>
    • preVisit

      public org.openrewrite.java.tree.J preVisit(org.openrewrite.java.tree.J tree, P p)
      Overrides:
      preVisit in class org.openrewrite.TreeVisitor<org.openrewrite.java.tree.J,P>