package jetbrains.mps.lang.smodel.generator.baseLanguage.util; /*Generated by MPS */ import org.jetbrains.mps.openapi.model.SNode; import org.jetbrains.annotations.NotNull; import jetbrains.mps.lang.smodel.behavior.SNodeOperation__BehaviorDescriptor; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.lang.smodel.behavior.Node_ConceptMethodCall__BehaviorDescriptor; import jetbrains.mps.lang.behavior.behavior.SuperExpression__BehaviorDescriptor; import jetbrains.mps.baseLanguage.behavior.BaseMethodDeclaration__BehaviorDescriptor; public final class ConceptMethodSuperCall { private final SNode myCall; public enum InvokationType { INVOKE("invoke0"), INVOKE_SPECIAL("invokeSpecial"), INVOKE_SUPER("invokeSuper"); InvokationType(@NotNull String methodName) { myMethodName = methodName; } private final String myMethodName; @Override public String toString() { return myMethodName; } } public ConceptMethodSuperCall(SNode superMethodCall) { myCall = superMethodCall; } public static class InvokationTarget { public final SNode targetConcept; public final SNode targetDeclaration; public final ConceptMethodSuperCall.InvokationType type; public InvokationTarget(SNode targetConcept, SNode targetDeclaration, ConceptMethodSuperCall.InvokationType type) { this.targetConcept = targetConcept; this.targetDeclaration = targetDeclaration; this.type = type; } } public ConceptMethodSuperCall.InvokationTarget getMethodCallTarget() { SNode leftExpression = SNodeOperation__BehaviorDescriptor.getLeftExpression_idhEwJdGu.invoke(myCall); assert SNodeOperations.isInstanceOf(leftExpression, MetaAdapterFactory.getInterfaceConcept(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x25076477397f04e3L, "jetbrains.mps.lang.behavior.structure.SuperExpression")); SNode methodDecl = SLinkOperations.getTarget(myCall, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301adL, "baseMethodDeclaration")); if (!((boolean) Node_ConceptMethodCall__BehaviorDescriptor.isVirtualMethodCall_idhEwIWlZ.invoke(myCall))) { return new ConceptMethodSuperCall.InvokationTarget(null, methodDecl, ConceptMethodSuperCall.InvokationType.INVOKE_SPECIAL); } else { SNode specifiedSuperConcept; specifiedSuperConcept = SuperExpression__BehaviorDescriptor.getSpecifiedSuperConcept_id2k7p7sTvKkb.invoke((SNodeOperations.cast(leftExpression, MetaAdapterFactory.getInterfaceConcept(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x25076477397f04e3L, "jetbrains.mps.lang.behavior.structure.SuperExpression")))); if (specifiedSuperConcept != null && !((boolean) BaseMethodDeclaration__BehaviorDescriptor.isAbstract_idhWjv7RO.invoke(methodDecl))) { // if there is no implementation we ignore the specified concept // fixme quickfix for this case return new ConceptMethodSuperCall.InvokationTarget(specifiedSuperConcept, methodDecl, ConceptMethodSuperCall.InvokationType.INVOKE); } else { SNode behavior = SNodeOperations.getNodeAncestor(myCall, MetaAdapterFactory.getConcept(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d43447b1aL, "jetbrains.mps.lang.behavior.structure.ConceptBehavior"), false, true); assert behavior != null; return new ConceptMethodSuperCall.InvokationTarget(SLinkOperations.getTarget(behavior, MetaAdapterFactory.getReferenceLink(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d43447b1aL, 0x11d43447b1fL, "concept")), methodDecl, ConceptMethodSuperCall.InvokationType.INVOKE_SUPER); } } } }