List<Runnable> (@NotNull Statement statement, @NotNull Set<IfStatement> usedIfStatements, @NotNull List<TempVarAssignmentItem> tempVarAssignments, boolean recordPatternSupport) { ArrayList<Runnable> actions = new ArrayList<>(); if (statement instanceof IfStatement ifStatement && !usedIfStatements.contains(ifStatement)) { FunctionExprent instanceOfExprent = findInstanceofExprent(ifStatement); if (instanceOfExprent == null) return new ArrayList<>(); List<Exprent> operands = instanceOfExprent.getLstOperands(); if (operands.size() != 2 || operands.get(0).type != Exprent.EXPRENT_VAR || operands.get(1).type != Exprent.EXPRENT_CONST) return new ArrayList<>(); VarExprent operand = (VarExprent)operands.get(0); ConstExprent checkType = (ConstExprent)operands.get(1); if (ifStatement.getIfstat() == null) { return new ArrayList<>(); } Statement statementToChange = ifStatement.getIfstat(); PatternVariableCandidate patternVarCandidate = findInitPatternVarCandidate(statementToChange, operand, checkType, recordPatternSupport, statementToChange); if (patternVarCandidate == null && ifStatement.getElsestat() != null) { statementToChange = ifStatement.getElsestat(); patternVarCandidate = findInitPatternVarCandidate(statementToChange, operand, checkType, recordPatternSupport, statementToChange); } if (patternVarCandidate == null) return new ArrayList<>(); tempVarAssignments.addAll(patternVarCandidate.getTempAssignments()); usedIfStatements.add(ifStatement); usedIfStatements.addAll(patternVarCandidate.getUsedIfStatement()); PatternVariableCandidate finalPatternVarCandidate = patternVarCandidate; Runnable action = ()-> { operands.remove(1); operands.add(finalPatternVarCandidate.getVarExprent()); finalPatternVarCandidate.getCleaner().run(); }; actions.add(action); } for (Statement child : statement.getStats()) { actions.addAll(0, replaceAssignmentsWithPatternVariables(child, usedIfStatements, tempVarAssignments, recordPatternSupport)); } return actions; }