package jetbrains.mps.lang.feedback.problem.constraints;

/*Generated by MPS */

import jetbrains.mps.smodel.runtime.base.BaseConstraintsDescriptor;
import jetbrains.mps.smodel.runtime.ConstraintFunction;
import jetbrains.mps.smodel.runtime.ConstraintContext_CanBeRoot;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.smodel.runtime.CheckingNodeContext;
import org.jetbrains.mps.openapi.model.SModel;
import org.jetbrains.mps.openapi.model.SModelReference;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SModelOperations;
import java.util.Objects;
import org.jetbrains.mps.openapi.persistence.PersistenceFacade;
import jetbrains.mps.smodel.SNodePointer;
import org.jetbrains.mps.openapi.language.SConcept;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;

public class ProblemKind_Constraints extends BaseConstraintsDescriptor {
  public ProblemKind_Constraints() {
    super(CONCEPTS.ProblemKind$fY);
  }

  @Override
  public ConstraintFunction<ConstraintContext_CanBeRoot, Boolean> calculateCanBeRootConstraint() {
    return new ConstraintFunction<ConstraintContext_CanBeRoot, Boolean>() {
      @NotNull
      public Boolean invoke(@NotNull ConstraintContext_CanBeRoot context, @Nullable CheckingNodeContext checkingNodeContext) {
        boolean result = staticCanBeARoot(context.getModel());

        if (!(result) && checkingNodeContext != null) {
          checkingNodeContext.setBreakingNode(canBeRootBreakingPoint);
        }

        return result;
      }
    };
  }
  private static boolean staticCanBeARoot(SModel model) {
    SModelReference pointer = SModelOperations.getPointer(model);
    return Objects.equals(pointer, PersistenceFacade.getInstance().createModelReference("r:9006e6ce-991d-45e3-a20f-0deb45783955(jetbrains.mps.lang.feedback.problem.childAndProp.feedback)")) || Objects.equals(pointer, PersistenceFacade.getInstance().createModelReference("r:63ce0387-25e9-4762-bec1-dac3eb032399(jetbrains.mps.lang.feedback.problem.structural.feedback)")) || Objects.equals(pointer, PersistenceFacade.getInstance().createModelReference("r:b9ce58c5-a751-4b14-8753-25d90bf90204(jetbrains.mps.lang.feedback.problem.scopes.feedback)"));
  }
  private static final SNodePointer canBeRootBreakingPoint = new SNodePointer("r:7a404819-62e4-484e-8389-7ac268c0886e(jetbrains.mps.lang.feedback.problem.constraints)", "24399255755752753");

  private static final class CONCEPTS {
    /*package*/ static final SConcept ProblemKind$fY = MetaAdapterFactory.getConcept(0x33598a476a947e1L, 0xac89a300c0fceab8L, 0x56aefe6c1afdffL, "jetbrains.mps.lang.feedback.problem.structure.ProblemKind");
  }
}
