static @Nullable LoopModel from(@NotNull ActionContext context) {
      PsiFile file = context.file();
      if (!(file instanceof PsiJavaFile) || !PsiUtil.isAvailable(JavaFeature.FOR_EACH, file)) return null;
      TextRange range = context.selection();
      boolean mayTrimTail;
      List<PsiStatement> statements;
      if (!range.isEmpty()) {
        mayTrimTail = false;
        statements = extractStatements(file, range);
      } else {
        mayTrimTail = true;
        statements = extractStatements(file, context.offset());
      }
      int size = statements.size();
      if (size <= 1 || size > (mayTrimTail ? 100 : 1000)) return null;
      if (!(statements.get(0).getParent() instanceof PsiCodeBlock)) return null;
      for (int count = 1; count <= size / 2; count++) {
        if (!mayTrimTail && size % count != 0) continue;
        LoopModel model = from(statements, count, mayTrimTail);
        if (model != null) {
          return model;
        }
      }
      return null;
    }
static @Nullable LoopModel from(@NotNull ActionContext context)