@Override
  PsiElement migrate(@NotNull Project project, @NotNull PsiElement body, @NotNull TerminalBlock tb) {
    PsiStatement loopStatement = tb.getStreamSourceStatement();
    CommentTracker ct = new CommentTracker();

    PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);

    PsiExpression mapExpression = tryExtractMapExpression(tb);

    if(mapExpression != null) {
      PsiMethodCallExpression call = tb.getSingleMethodCall();
      LOG.assertTrue(call != null);
      PsiType addedType = getAddedElementType(call);
      if (addedType == null) addedType = call.getType();
      JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(project);
      SuggestedNameInfo suggestedNameInfo =
        codeStyleManager.suggestVariableName(VariableKind.LOCAL_VARIABLE, null, null, addedType, true);
      if (suggestedNameInfo.names.length == 0) {
        suggestedNameInfo = codeStyleManager.suggestVariableName(VariableKind.LOCAL_VARIABLE, "item", null, null, true);
      }
      String varName = codeStyleManager.suggestUniqueVariableName(suggestedNameInfo, call, false).names[0];

      String streamText = tb.add(new StreamApiMigrationInspection.MapOp(mapExpression, tb.getVariable(), addedType)).generate(ct);
      String forEachBody = varName + "->" + ct.text(call.getMethodExpression()) + "(" + varName + ")";
      String callText = streamText + "." + getReplacement() + "(" + forEachBody + ");";
      return ct.replaceAndRestoreComments(loopStatement, callText);
    }

    tb.replaceContinueWithReturn(factory);

    String stream = tb.generate(ct, true) + "." + getReplacement() + "(";
    PsiElement block = tb.convertToElement(ct, factory);

    final String functionalExpressionText = tb.getVariable().getName() + " -> " + wrapInBlock(ct, block);
    PsiExpressionStatement callStatement =
      (PsiExpressionStatement)ct.replaceAndRestoreComments(loopStatement, stream + functionalExpressionText + ");");

    final PsiExpressionList argumentList = ((PsiCallExpression)callStatement.getExpression()).getArgumentList();
    LOG.assertTrue(argumentList != null, callStatement.getText());
    final PsiExpression[] expressions = argumentList.getExpressions();
    LOG.assertTrue(expressions.length == 1);

    if (expressions[0] instanceof PsiFunctionalExpression &&
        ((PsiFunctionalExpression)expressions[0]).getFunctionalInterfaceType() == null) {
      PsiTypeElement typeElement = tb.getVariable().getTypeElement();
      if (typeElement != null) {
        String typedVariable = typeElement.getText() + " " + tb.getVariable().getName();
        ct = new CommentTracker();
        callStatement = (PsiExpressionStatement)ct
          .replaceAndRestoreComments(callStatement, stream + "(" + typedVariable + ") -> " + wrapInBlock(ct, block) + ");");
      }
    }
    return callStatement;
  }
@Override
  PsiElement migrate(@NotNull Project project, @NotNull PsiElement body, @NotNull TerminalBlock tb)