package jetbrains.mps.checkers;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.errors.item.ReportItem;
import org.jetbrains.mps.openapi.module.SRepository;
import org.jetbrains.mps.openapi.util.Consumer;
import org.jetbrains.mps.openapi.util.ProgressMonitor;
import org.jetbrains.annotations.ApiStatus;
import jetbrains.mps.progress.ProgressTask;

/**
 * A misnomer composite checker.
 * <p>
 * An instance of this interface is never a "concrete" (a.k.a. "specific") checker, rather it is always composed
 * of other checkers, abstract or otherwise. 
 * 
 */
@GeneratedClass(node = "r:ba41e9c6-15ca-4a47-95f2-6a81c2318547(jetbrains.mps.checkers)/4057642946561766034", model = "r:ba41e9c6-15ca-4a47-95f2-6a81c2318547(jetbrains.mps.checkers)")
public interface IAbstractChecker<O, I extends ReportItem> {

  void check(O toCheck, SRepository repository, Consumer<? super I> errorCollector, ProgressMonitor monitor);

  /**
   * Alternative way to construct a composite checker: instead of running all aggregated checkers in sequence
   * one may choose to construct a batch job with optionally launching a certain "branch" in background. 
   * <p>
   * See {@link jetbrains.mps.progress.ProgressTask }.<br>
   * See {@link jetbrains.mps.progress.TaskScheduler }.<br>
   */
  @ApiStatus.Experimental
  default ProgressTask checkTask(final O toCheck, final SRepository repository, final Consumer<? super I> errorCollector) {
    return new ProgressTask.SimpleTask(String.format("check(%s)", toCheck)) {
      @Override
      protected void run() {
        check(toCheck, repository, errorCollector, myMonitor);
      }
    };
  }

}
