package jetbrains.mps.kotlin.behavior;

/*Generated by MPS */

import jetbrains.mps.core.aspects.behaviour.BaseBHDescriptor;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.core.aspects.behaviour.api.SMethod;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.core.aspects.behaviour.SMethodBuilder;
import jetbrains.mps.core.aspects.behaviour.SJavaCompoundTypeImpl;
import jetbrains.mps.core.aspects.behaviour.AccessPrivileges;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import java.util.List;
import java.util.Arrays;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.typechecking.TypecheckingFacade;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
import jetbrains.mps.core.aspects.behaviour.api.SConstructor;
import jetbrains.mps.core.aspects.behaviour.api.BHMethodNotFoundException;
import org.jetbrains.mps.openapi.language.SInterfaceConcept;
import org.jetbrains.mps.openapi.language.SConcept;

public final class NavigationOperation__BehaviorDescriptor extends BaseBHDescriptor {
  private static final SAbstractConcept CONCEPT = MetaAdapterFactory.getConcept(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x28bef6d7551af450L, "jetbrains.mps.kotlin.structure.NavigationOperation");

  public static final SMethod<SNode> getContextType_id7ubb0gUcL0j = new SMethodBuilder<SNode>(new SJavaCompoundTypeImpl((Class<SNode>) ((Class) Object.class))).name("getContextType").modifiers(0, AccessPrivileges.PUBLIC).concept(CONCEPT).baseMethodId(8614027108944121875L).languageId(0x8baff8e6c33ed689L, 0x6b3888c1980244d8L).build2();
  public static final SMethod<Boolean> isResolved_id4MvRlgZCbFz = new SMethodBuilder<Boolean>(new SJavaCompoundTypeImpl(Boolean.TYPE)).name("isResolved").modifiers(8, AccessPrivileges.PUBLIC).concept(CONCEPT).baseMethodId(5521375022094007011L).languageId(0x8baff8e6c33ed689L, 0x6b3888c1980244d8L).build2();
  public static final SMethod<SNode> tryResolve_id4MvRlgZCbFB = new SMethodBuilder<SNode>(new SJavaCompoundTypeImpl((Class<SNode>) ((Class) Object.class))).name("tryResolve").modifiers(8, AccessPrivileges.PUBLIC).concept(CONCEPT).baseMethodId(5521375022094007015L).languageId(0x8baff8e6c33ed689L, 0x6b3888c1980244d8L).build2();
  public static final SMethod<Boolean> isLeftExpressionTarget_id69RFwVHPwd9 = new SMethodBuilder<Boolean>(new SJavaCompoundTypeImpl(Boolean.TYPE)).name("isLeftExpressionTarget").modifiers(8, AccessPrivileges.PUBLIC).concept(CONCEPT).baseMethodId(7095331117088506697L).languageId(0x8baff8e6c33ed689L, 0x6b3888c1980244d8L).build2(SMethodBuilder.createJavaParameter((Class<SContainmentLink>) ((Class) Object.class), ""));
  public static final SMethod<Assignable> assignableState_idCy8Bus9niD = new SMethodBuilder<Assignable>(new SJavaCompoundTypeImpl(Assignable.class)).name("assignableState").modifiers(8, AccessPrivileges.PUBLIC).concept(CONCEPT).baseMethodId(730183986703594665L).languageId(0x8baff8e6c33ed689L, 0x6b3888c1980244d8L).build2();
  public static final SMethod<Boolean> showParenthesis_id3PNJzGvypf4 = new SMethodBuilder<Boolean>(new SJavaCompoundTypeImpl(Boolean.TYPE)).name("showParenthesis").modifiers(0, AccessPrivileges.PUBLIC).concept(CONCEPT).baseMethodId(4428092019776787396L).languageId(0x8baff8e6c33ed689L, 0x6b3888c1980244d8L).build2();

  private static final List<SMethod<?>> BH_METHODS = Arrays.<SMethod<?>>asList(getContextType_id7ubb0gUcL0j, isResolved_id4MvRlgZCbFz, tryResolve_id4MvRlgZCbFB, isLeftExpressionTarget_id69RFwVHPwd9, assignableState_idCy8Bus9niD, showParenthesis_id3PNJzGvypf4);

  private static void ___init___(@NotNull SNode __thisNode__) {
  }

  /*package*/ static SNode getContextType_id7ubb0gUcL0j(@NotNull SNode __thisNode__) {
    return SNodeOperations.as(TypecheckingFacade.getFromContext().getTypeOf(SLinkOperations.getTarget(__thisNode__, LINKS.operand$YS5t)), CONCEPTS.IType$Ni);
  }
  /*package*/ static boolean isResolved_id4MvRlgZCbFz(@NotNull SNode __thisNode__) {
    return SNodeOperations.isInstanceOf(SLinkOperations.getTarget(__thisNode__, LINKS.target$C6zp), CONCEPTS.UnresolvedParsedReference$2A);
  }
  /*package*/ static SNode tryResolve_id4MvRlgZCbFB(@NotNull SNode __thisNode__) {
    // TODO try with var scope and fun scope
    return null;
  }
  /*package*/ static boolean isLeftExpressionTarget_id69RFwVHPwd9(@NotNull SNode __thisNode__, @Nullable SContainmentLink childLink) {
    // Self or target propagate (super is not used as it refers to UnaryExpression which we bypass)
    if (!(Objects.equals(childLink, LINKS.operand$YS5t)) && SNodeOperations.isInstanceOf(SNodeOperations.getParent(__thisNode__), CONCEPTS.IStatement$fj)) {
      return (boolean) IStatement__BehaviorDescriptor.isLeftExpressionTarget_id69RFwVHPwd9.invoke(SNodeOperations.as(SNodeOperations.getParent(__thisNode__), CONCEPTS.IStatement$fj), SNodeOperations.getContainingLink(__thisNode__));
    }

    return false;
  }
  /*package*/ static Assignable assignableState_idCy8Bus9niD(@NotNull SNode __thisNode__) {
    return ILeftExpression__BehaviorDescriptor.assignableState_idCy8Bus9niD.invoke(SLinkOperations.getTarget(__thisNode__, LINKS.target$C6zp));
  }
  /*package*/ static boolean showParenthesis_id3PNJzGvypf4(@NotNull SNode __thisNode__) {
    return SNodeOperations.isInstanceOf(SLinkOperations.getTarget(__thisNode__, LINKS.operand$YS5t), CONCEPTS.TypePostFixUnaryExpression$In);
  }

  /*package*/ NavigationOperation__BehaviorDescriptor() {
  }

  @Override
  protected void initNode(@NotNull SNode node, @NotNull SConstructor constructor, @Nullable Object[] parameters) {
    ___init___(node);
  }

  @Override
  protected <T> T invokeSpecial0(@NotNull SNode node, @NotNull SMethod<T> method, @Nullable Object[] parameters) {
    int methodIndex = BH_METHODS.indexOf(method);
    if (methodIndex < 0) {
      throw new BHMethodNotFoundException(this, method);
    }
    switch (methodIndex) {
      case 0:
        return (T) ((SNode) getContextType_id7ubb0gUcL0j(node));
      case 1:
        return (T) ((Boolean) isResolved_id4MvRlgZCbFz(node));
      case 2:
        return (T) ((SNode) tryResolve_id4MvRlgZCbFB(node));
      case 3:
        return (T) ((Boolean) isLeftExpressionTarget_id69RFwVHPwd9(node, (SContainmentLink) parameters[0]));
      case 4:
        return (T) ((Assignable) assignableState_idCy8Bus9niD(node));
      case 5:
        return (T) ((Boolean) showParenthesis_id3PNJzGvypf4(node));
      default:
        throw new BHMethodNotFoundException(this, method);
    }
  }

  @Override
  protected <T> T invokeSpecial0(@NotNull SAbstractConcept concept, @NotNull SMethod<T> method, @Nullable Object[] parameters) {
    int methodIndex = BH_METHODS.indexOf(method);
    if (methodIndex < 0) {
      throw new BHMethodNotFoundException(this, method);
    }
    switch (methodIndex) {
      default:
        throw new BHMethodNotFoundException(this, method);
    }
  }

  @NotNull
  @Override
  public List<SMethod<?>> getDeclaredMethods() {
    return BH_METHODS;
  }

  @NotNull
  @Override
  public SAbstractConcept getConcept() {
    return CONCEPT;
  }

  private static final class LINKS {
    /*package*/ static final SContainmentLink operand$YS5t = MetaAdapterFactory.getContainmentLink(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x11400bb790956f20L, 0x11400bb790956f23L, "operand");
    /*package*/ static final SContainmentLink target$C6zp = MetaAdapterFactory.getContainmentLink(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x28bef6d7551af450L, 0x28bef6d7551af73bL, "target");
  }

  private static final class CONCEPTS {
    /*package*/ static final SInterfaceConcept IType$Ni = MetaAdapterFactory.getInterfaceConcept(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x28bef6d7551af441L, "jetbrains.mps.kotlin.structure.IType");
    /*package*/ static final SConcept UnresolvedParsedReference$2A = MetaAdapterFactory.getConcept(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x430acdda9dcb793eL, "jetbrains.mps.kotlin.structure.UnresolvedParsedReference");
    /*package*/ static final SInterfaceConcept IStatement$fj = MetaAdapterFactory.getInterfaceConcept(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x28bef6d7551af322L, "jetbrains.mps.kotlin.structure.IStatement");
    /*package*/ static final SConcept TypePostFixUnaryExpression$In = MetaAdapterFactory.getConcept(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x6babb2d406575098L, "jetbrains.mps.kotlin.structure.TypePostFixUnaryExpression");
  }
}
