private static void replace(@NotNull PatternDefinition patternDefinition,
                                @NotNull ComponentContext context) {
      PsiForeachStatementBase foreachStatementBase = context.base;
      StringBuilder newStatementWithPattern = new StringBuilder();
      CommentTracker commentTracker = new CommentTracker();
      for (PsiElement element : foreachStatementBase.getChildren()) {
        if (PsiTreeUtil.isAncestor(element, context.currentParameter, false)) {
          addPatternToString(element, context.currentParameter, newStatementWithPattern, patternDefinition, commentTracker);
        }
        else {
          newStatementWithPattern.append(element.getText());
          commentTracker.markUnchanged(element);
        }
      }
      PsiReplacementUtil.replaceStatementAndShortenClassNames(context.base, newStatementWithPattern.toString(), commentTracker);
    }
private static void replace(@NotNull PatternDefinition patternDefinition,
                                @NotNull ComponentContext context)