package jetbrains.mps.lang.behavior.constraints;

/*Generated by MPS */

import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations;
import org.jetbrains.mps.openapi.language.SConcept;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.language.SProperty;

public class ConstraintsUtil {
  private ConstraintsUtil() {
  }

  public static boolean isInsideOfBehavior(SNode node) {
    return (SNodeOperations.getNodeAncestor(node, CONCEPTS.ConceptBehavior$2, true, false) != null);
  }

  public static boolean isInsideOfBehavior(SNode node, final boolean isStatic) {
    if (!(isInsideOfBehavior(node))) {
      return false;
    }
    if ((SNodeOperations.getNodeAncestor(node, CONCEPTS.ConceptConstructorDeclaration$nv, true, false) != null)) {
      return !(isStatic);
    }
    return ListSequence.fromList(SNodeOperations.getNodeAncestors(node, CONCEPTS.ConceptMethodDeclaration$N0, true)).any((it) -> SPropertyOperations.getBoolean(it, PROPS.isStatic$JhJe) == isStatic);
  }

  private static final class CONCEPTS {
    /*package*/ static final SConcept ConceptBehavior$2 = MetaAdapterFactory.getConcept(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d43447b1aL, "jetbrains.mps.lang.behavior.structure.ConceptBehavior");
    /*package*/ static final SConcept ConceptConstructorDeclaration$nv = MetaAdapterFactory.getConcept(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d43471eedL, "jetbrains.mps.lang.behavior.structure.ConceptConstructorDeclaration");
    /*package*/ static final SConcept ConceptMethodDeclaration$N0 = MetaAdapterFactory.getConcept(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d4348057eL, "jetbrains.mps.lang.behavior.structure.ConceptMethodDeclaration");
  }

  private static final class PROPS {
    /*package*/ static final SProperty isStatic$JhJe = MetaAdapterFactory.getProperty(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d4348057eL, 0x51613f7fe129b24dL, "isStatic");
  }
}
