package jetbrains.mps.checkers;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.errors.item.NodeReportItem;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import org.jetbrains.mps.openapi.module.SRepository;
import org.jetbrains.mps.openapi.util.Consumer;
import org.jetbrains.mps.openapi.util.ProgressMonitor;
import org.jetbrains.mps.openapi.language.SInterfaceConcept;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;

/**
 * Redefines the API for checkers that are expected to be run from within an editor context. 
 * <p>
 * See {@link jetbrains.mps.checkers.LanguageErrorsCollector }
 */
@GeneratedClass(node = "r:ba41e9c6-15ca-4a47-95f2-6a81c2318547(jetbrains.mps.checkers)/7390982340086720780", model = "r:ba41e9c6-15ca-4a47-95f2-6a81c2318547(jetbrains.mps.checkers)")
public abstract class AbstractNodeCheckerInEditor extends IChecker.AbstractNodeChecker<NodeReportItem> {
  public static final IChecker.AbstractNodeChecker.ErrorSkipCondition SKIP_CONSTRAINTS_CONDITION = new IChecker.AbstractNodeChecker.ErrorSkipCondition() {
    public boolean skipSingleNode(SNode node) {
      return false;
    }
    public boolean skipSubtree(SNode root) {
      return SNodeOperations.isInstanceOf(root, CONCEPTS.ISkipConstraintsChecking$8j);
    }
  };
  protected abstract void checkNodeInEditor(SNode node, LanguageErrorsCollector errorsCollector, SRepository repository);

  @Override
  public final void check(SNode toCheck, SRepository repository, final Consumer<? super NodeReportItem> errorCollector, ProgressMonitor monitor) {
    checkNodeInEditor(toCheck, new LanguageErrorsCollector() {
      protected void addErrorInternal(NodeReportItem reportItem) {
        errorCollector.consume(reportItem);
      }
    }, repository);
  }

  private static final class CONCEPTS {
    /*package*/ static final SInterfaceConcept ISkipConstraintsChecking$8j = MetaAdapterFactory.getInterfaceConcept(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x50ef06e32fec9043L, "jetbrains.mps.lang.core.structure.ISkipConstraintsChecking");
  }
}
