package dsl;

import org.eclipse.jdt.core.dom.IfStatement;

import java.util.ArrayList;
import java.util.List;

public class DIfStatement extends DStatement {

    final String node = "DIfStatement";
    final DExpression cond;
    final DStatement thenStmt;
    final DStatement elseStmt;

    public DIfStatement(DExpression cond, DStatement thenStmt, DStatement elseStmt) {
        this.cond = cond;
        this.thenStmt = thenStmt;
        this.elseStmt = elseStmt;
    }

    @Override
    public void updateSequences(List<Sequence> soFar) {
        List<Sequence> copy = new ArrayList<>();
        for (Sequence seq : soFar)
            copy.add(new Sequence(seq.calls));
        thenStmt.updateSequences(soFar);
        elseStmt.updateSequences(copy);
        for (Sequence seq : copy)
            if (! soFar.contains(seq))
                soFar.add(seq);
    }

    public static class Handle extends Handler {
        IfStatement statement;

        public Handle(IfStatement statement, Visitor visitor) {
            super(visitor);
            this.statement = statement;
        }

        @Override
        public DStatement handle() {
            DExpression cond = new DExpression.Handle(statement.getExpression(), visitor).handle();
            DStatement thenStmt = new DStatement.Handle(statement.getThenStatement(), visitor).handle();
            DStatement elseStmt = new DStatement.Handle(statement.getElseStatement(), visitor).handle();

            if (thenStmt != null && elseStmt != null)
                return new DIfStatement(cond, thenStmt, elseStmt);
            if (thenStmt != null)
                return thenStmt;
            if (elseStmt != null)
                return elseStmt;
            return null;
        }
    }
}

@@ -537,24 +537,91 @@
 e%3E soFar) %7B%0A
+        if (cond != null)%0A            cond.updateSequences(soFar);%0A
         List

Fix in sequences through if statement condition