private void handleForeach(@NotNull PsiForeachStatementBase statement) {
    startElement(statement);
    final PsiStatement body = statement.getBody();
    myStartStatementStack.pushStatement(body == null ? statement : body, false);
    myEndStatementStack.pushStatement(statement, false);
    final PsiExpression iteratedValue = statement.getIteratedValue();
    if (iteratedValue != null) {
      iteratedValue.accept(this);
    }

    final int gotoTarget = myCurrentFlow.getSize();
    Instruction instruction = new ConditionalGoToInstruction(0, statement.getIteratedValue());
    myCurrentFlow.addInstruction(instruction);
    addElementOffsetLater(statement, false);

    if (statement instanceof PsiForeachStatement) {
      final PsiParameter iterationParameter = ((PsiForeachStatement)statement).getIterationParameter();
      if (myPolicy.isParameterAccepted(iterationParameter)) {
        generateWriteInstruction(iterationParameter);
      }
    } else if (statement instanceof PsiForeachPatternStatement) {
      PsiPattern pattern = ((PsiForeachPatternStatement)statement).getIterationPattern();
      processPattern(pattern);
    }
    if (body != null) {
      body.accept(this);
    }

    final GoToInstruction gotoInstruction = new GoToInstruction(gotoTarget);
    myCurrentFlow.addInstruction(gotoInstruction);
    myStartStatementStack.popStatement();
    myEndStatementStack.popStatement();
    finishElement(statement);
  }
private void handleForeach(@NotNull PsiForeachStatementBase statement)