package jetbrains.mps.java.platform.highlighters.methodcallsfixer;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.smodel.event.SModelEventVisitorAdapter;
import jetbrains.mps.smodel.event.SModelChildEvent;
import org.jetbrains.mps.openapi.model.SNode;
import org.jetbrains.mps.openapi.model.SModel;
import jetbrains.mps.smodel.event.SModelReferenceEvent;
import org.jetbrains.mps.openapi.model.SReference;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.smodel.event.SModelPropertyEvent;
import jetbrains.mps.smodel.event.SModelReplacedEvent;
import org.jetbrains.mps.openapi.language.SReferenceLink;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.language.SInterfaceConcept;
import org.jetbrains.mps.openapi.language.SConcept;
import org.jetbrains.mps.openapi.language.SProperty;

/**
 * Updates {@link jetbrains.mps.java.platform.highlighters.methodcallsfixer.MethodCallsUpdateSession } according to visited events.
 */
@GeneratedClass(node = "r:4133014c-7275-4ce9-a7b8-ec59b3bf11b3(jetbrains.mps.java.platform.highlighters.methodcallsfixer)/3584380880170728349", model = "r:4133014c-7275-4ce9-a7b8-ec59b3bf11b3(jetbrains.mps.java.platform.highlighters.methodcallsfixer)")
/*package*/ class UpdateSessionEventVisitor extends SModelEventVisitorAdapter {
  private final MethodCallsUpdateSession mySession;

  /*package*/ UpdateSessionEventVisitor(MethodCallsUpdateSession session) {
    mySession = session;
  }
  @Override
  public void visitChildEvent(SModelChildEvent event) {
    SNode child = event.getChild();
    if (event.isAdded() && child.getModel() != null) {
      mySession.nodeAdded(child);
    } else {
      SNode formerParent = event.getParent();
      SModel m = event.getModel();
      mySession.nodeRemoved(child, formerParent, m);
    }
  }
  @Override
  public void visitReferenceEvent(SModelReferenceEvent event) {
    SReference reference = event.getReference();
    SNode sourceNode = reference.getSourceNode();
    if (SNodeOperations.isInstanceOf(sourceNode, CONCEPTS.IMethodCall$M9) && LINKS.baseMethodDeclaration$pyYw.equals(reference.getLink())) {
      SNode methodCall = SNodeOperations.cast(sourceNode, CONCEPTS.IMethodCall$M9);
      mySession.methodCallChanged(methodCall);
    }
  }
  @Override
  public void visitPropertyEvent(SModelPropertyEvent event) {
    SNode node = event.getNode();
    SNodeOperations.isInstanceOf(node, CONCEPTS.BaseMethodDeclaration$kD);
    if (SNodeOperations.isInstanceOf(node, CONCEPTS.BaseMethodDeclaration$kD) && PROPS.name$MnvL.getName().equals(event.getPropertyName())) {
      mySession.methodDeclarationNameChanged(node);
      mySession.methodDeclarationSignatureChanged(node);
    }
  }
  @Override
  public void visitReplacedEvent(SModelReplacedEvent event) {
    throw new IllegalArgumentException("SModelReplacedEvent should have been handled by the caller");
  }

  private static final class LINKS {
    /*package*/ static final SReferenceLink baseMethodDeclaration$pyYw = MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301adL, "baseMethodDeclaration");
  }

  private static final class CONCEPTS {
    /*package*/ static final SInterfaceConcept IMethodCall$M9 = MetaAdapterFactory.getInterfaceConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, "jetbrains.mps.baseLanguage.structure.IMethodCall");
    /*package*/ static final SConcept BaseMethodDeclaration$kD = MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b1fcL, "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration");
  }

  private static final class PROPS {
    /*package*/ static final SProperty name$MnvL = MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name");
  }
}
