package jetbrains.mps.lang.smodel.generator.baseLanguage.template.main; /*Generated by MPS */ import jetbrains.mps.generator.runtime.Generated; import jetbrains.mps.generator.runtime.TemplateDeclarationBase; import org.jetbrains.mps.openapi.model.SNodeReference; import jetbrains.mps.smodel.SNodePointer; import org.jetbrains.mps.openapi.model.SNode; import org.jetbrains.annotations.NotNull; import jetbrains.mps.generator.runtime.TemplateContext; import jetbrains.mps.generator.runtime.GenerationException; import jetbrains.mps.generator.runtime.TemplateExecutionEnvironment; import java.util.Collection; import org.jetbrains.mps.openapi.model.SNodeAccessUtil; import jetbrains.mps.generator.runtime.TemplateUtil; import jetbrains.mps.generator.template.PropertyMacroContext; import jetbrains.mps.smodel.SReference; import org.jetbrains.mps.openapi.persistence.PersistenceFacade; import jetbrains.mps.generator.template.SourceSubstituteMacroNodeContext; import jetbrains.mps.generator.template.IfMacroContext; import java.util.List; import java.util.ArrayList; import jetbrains.mps.generator.template.SourceSubstituteMacroNodesContext; import jetbrains.mps.generator.impl.reference.RefResolver; import jetbrains.mps.generator.runtime.NodeWeaveFacility; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import org.jetbrains.mps.openapi.language.SConcept; import org.jetbrains.mps.openapi.language.SProperty; import org.jetbrains.mps.openapi.language.SReferenceLink; import org.jetbrains.mps.openapi.language.SContainmentLink; @Generated public class Template_reduce_ConceptSwitch extends TemplateDeclarationBase { public Template_reduce_ConceptSwitch() { } public SNodeReference getTemplateNode() { return new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "7723526804945925517"); } protected SNode applyPart0(@NotNull final TemplateContext context) throws GenerationException { final TemplateExecutionEnvironment environment = context.getEnvironment(); final SNode tnode1 = environment.createOutputNode(myConcepts[0]); try { TemplateContext context1 = context.subContext(); { Collection<SNode> tlist2 = null; TemplateContext context2 = context1.subContext("switchVar"); final SNode tnode3 = environment.createOutputNode(myConcepts[1]); try { environment.nodeCopied(context2, tnode3, "tpl/r:00000000-0000-4000-0000-011c89590303/6039268229364247709"); SNodeAccessUtil.setProperty(tnode3, myProperties[0], TemplateUtil.asString(QueriesGenerated.propertyMacro_GetPropertyValue_8528048620384778058(new PropertyMacroContext(context2, "cncpt", propertyMacro_j8e1z8_c0a0c0b0d0b0c0e)))); TemplateContext context3 = context2.subContext(); { final SNode tnode4 = environment.createOutputNode(myConcepts[2]); try { tnode4.setReference(myAssociationLinks[0], SReference.create(myAssociationLinks[0], tnode4, PersistenceFacade.getInstance().createModelReference("8865b7a8-5271-43d3-884c-6fd1d9cfdd34/java:org.jetbrains.mps.openapi.language(MPS.OpenAPI/)"), PersistenceFacade.getInstance().createNodeId("~SAbstractConcept"))); } finally { } tnode3.addChild(myAggregationLinks[0], tnode4); // TODO validate child } { Collection<SNode> tlist5 = null; final SNode copySrcInput5 = QueriesGenerated.sourceNodeQuery_6039268229364247724(new SourceSubstituteMacroNodeContext(context3, copySrcMacro_j8e1z8_b0a0c0e0d0b0c0e)); tlist5 = environment.copyNodes(TemplateUtil.singletonList(copySrcInput5), copySrcMacro_j8e1z8_b0a0c0e0d0b0c0e, "tpl/r:00000000-0000-4000-0000-011c89590303/6039268229364247722", context3); for (SNode child6 : TemplateUtil.asNotNull(tlist5)) { tnode3.addChild(myAggregationLinks[1], child6); } // TODO validate child } } finally { } tlist2 = TemplateUtil.singletonList(tnode3); environment.registerLabel(context1.getInput(), tnode3, "switchVar"); for (SNode child7 : TemplateUtil.asNotNull(tlist2)) { tnode1.addChild(myAggregationLinks[2], child7); } // TODO validate child } } finally { } return tnode1; } protected Collection<SNode> applyPart1(@NotNull final TemplateContext context) throws GenerationException { final TemplateExecutionEnvironment environment = context.getEnvironment(); Collection<SNode> tlist1 = null; if (QueriesGenerated.ifMacro_Condition_75056552358381014(new IfMacroContext(context, ifMacroRef_j8e1z8_b0a0c0f))) { final SNode tnode2 = environment.createOutputNode(myConcepts[3]); try { TemplateContext context1 = context.subContext(); { final SNode tnode3 = environment.createOutputNode(myConcepts[4]); try { TemplateContext context2 = context1.subContext(); { Collection<SNode> tlist4 = null; tlist4 = new Template_reduce_ConceptSwitch_SubconceptCases(false).apply(environment, context2); for (SNode child5 : TemplateUtil.asNotNull(tlist4)) { tnode3.addChild(myAggregationLinks[3], child5); } // TODO validate child } } finally { } tnode2.addChild(myAggregationLinks[4], tnode3); // TODO validate child } { final List<SNode> tlist6 = new ArrayList<SNode>(); final Iterable<SNode> loopList6 = QueriesGenerated.sourceNodesQuery_7723526804946013064(new SourceSubstituteMacroNodesContext(context1, loopMacroRef_j8e1z8_b0a0a1a2a1a2a5)); int loopIndex_i_6 = 0; for (SNode itnode6 : loopList6) { if (itnode6 == null) { continue; } TemplateContext context3 = context1.subContext(itnode6); context3 = context3.withVariable("cv:i", loopIndex_i_6++); final SNode tnode7 = environment.createOutputNode(myConcepts[5]); try { TemplateContext context4 = context3.subContext(); { final SNode tnode8 = environment.createOutputNode(myConcepts[6]); try { SNodeAccessUtil.setProperty(tnode8, myProperties[1], TemplateUtil.asString(QueriesGenerated.propertyMacro_GetPropertyValue_7723526804946032580(new PropertyMacroContext(context4, "0", propertyMacro_j8e1z8_c0a0c0a0b0b0e0d0c0b0c0f)))); } finally { } tnode7.addChild(myAggregationLinks[5], tnode8); // TODO validate child } { final SNode tnode9 = environment.createOutputNode(myConcepts[4]); try { TemplateContext context5 = context4.subContext(); { Collection<SNode> tlist10 = null; if (QueriesGenerated.ifMacro_Condition_8098116031887267635(new IfMacroContext(context5, ifMacroRef_j8e1z8_b0a0b0b0b0c0e0d0c0b0c0f))) { Collection<SNode> tlist11 = null; final Iterable<SNode> copyListInput11 = QueriesGenerated.sourceNodesQuery_8098116031887331079(new SourceSubstituteMacroNodesContext(context5, copySrcListMacro_j8e1z8_b0a0a1a1a1a1a2a4a3a2a1a2a5)); tlist11 = environment.copyNodes(copyListInput11, copySrcListMacro_j8e1z8_b0a0a1a1a1a1a2a4a3a2a1a2a5, "tpl/r:00000000-0000-4000-0000-011c89590303/8098116031887261567", context5); tlist10 = tlist11; } else { Collection<SNode> tlist12 = new Template_reduce_ConceptCaseBody_Hack1().apply(environment, context5); tlist10 = tlist12; } for (SNode child13 : TemplateUtil.asNotNull(tlist10)) { tnode9.addChild(myAggregationLinks[3], child13); } // TODO validate child } } finally { } tnode7.addChild(myAggregationLinks[6], tnode9); // TODO validate child } } finally { } if (tnode7 != null) { tlist6.add(tnode7); } } for (SNode child14 : TemplateUtil.asNotNull(tlist6)) { tnode2.addChild(myAggregationLinks[7], child14); } // TODO validate child } { final SNode tnode15 = environment.createOutputNode(myConcepts[7]); try { TemplateContext context6 = context1.subContext(); { final SNode tnode16 = environment.createOutputNode(myConcepts[8]); try { tnode16.setReference(myAssociationLinks[1], SReference.create(myAssociationLinks[1], tnode16, PersistenceFacade.getInstance().createModelReference("6ed54515-acc8-4d1e-a16c-9fd6cfe951ea/java:jetbrains.mps.lang.smodel(MPS.Core/)"), PersistenceFacade.getInstance().createNodeId("~ConceptIndex.index(org.jetbrains.mps.openapi.language.SAbstractConcept):int"))); TemplateContext context7 = context6.subContext(); { final SNode tnode17 = environment.createOutputNode(myConcepts[9]); try { environment.resolveInTemplateLater(tnode17, myAssociationLinks[2], templateNode_j8e1z8_c0a0a1a2a1a1a1a3a1a2a5, "tpl/r:00000000-0000-4000-0000-011c89590303/6039268229364247709", "cncpt", context7); } finally { } tnode16.addChild(myAggregationLinks[8], tnode17); // TODO validate child } } finally { } tnode15.addChild(myAggregationLinks[9], tnode16); // TODO validate child } { final SNode tnode18 = environment.createOutputNode(myConcepts[9]); try { environment.resolve(new RefResolver(tnode18, myAssociationLinks[2], context6, new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "4454796803413438135"), "index") { @Override public Object resolve() { return QueriesGenerated.referenceMacro_GetReferent_4454796803413438136(createQueryContext()); } }); } finally { } tnode15.addChild(myAggregationLinks[10], tnode18); // TODO validate child } } finally { } tnode2.addChild(myAggregationLinks[11], tnode15); // TODO validate child } } finally { } tlist1 = TemplateUtil.singletonList(tnode2); } else { Collection<SNode> tlist19 = new Template_reduce_ConceptSwitch_SubconceptCases(true).apply(environment, context); tlist1 = tlist19; } return tlist1; } @Override public Collection<SNode> apply(@NotNull TemplateExecutionEnvironment environment, @NotNull TemplateContext context) throws GenerationException { return TemplateUtil.asList(applyPart0(context), applyPart1(context)); } @Override public Collection<SNode> weave(@NotNull NodeWeaveFacility.WeaveContext weaveContext, @NotNull NodeWeaveFacility weaveSupport) throws GenerationException { final TemplateContext templateContext = weaveSupport.getTemplateContext(); SNode tnodepart0 = applyPart0(templateContext); weaveSupport.weaveNode(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"), tnodepart0); Collection<SNode> tlistpart1 = applyPart1(templateContext); for (SNode nodeToWeave : TemplateUtil.asNotNull(tlistpart1)) { weaveSupport.weaveNode(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"), nodeToWeave); } return TemplateUtil.asList(tnodepart0, tlistpart1); } @Override protected SConcept[] initConcepts() { SConcept[] rv = new SConcept[10]; rv[0] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc67c7f0L, "LocalVariableDeclarationStatement"); rv[1] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc67c7efL, "LocalVariableDeclaration"); rv[2] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0x101de48bf9eL, "ClassifierType"); rv[3] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0x10ef02a8c6aL, "SwitchStatement"); rv[4] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc56b200L, "StatementList"); rv[5] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0x10ef02cdd1bL, "SwitchCase"); rv[6] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc59b314L, "IntegerConstant"); rv[7] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0x116b46a08c4L, "DotExpression"); rv[8] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0x118154a6332L, "InstanceMethodCallOperation"); rv[9] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8c77f1e98L, "VariableReference"); return rv; } @Override protected SProperty[] initProperties() { SProperty[] rv = new SProperty[2]; rv[0] = MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"); rv[1] = MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc59b314L, 0xf8cc59b315L, "value"); return rv; } @Override protected SReferenceLink[] initAssociationLinks() { SReferenceLink[] rv = new SReferenceLink[3]; rv[0] = MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier"); rv[1] = MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301adL, "baseMethodDeclaration"); rv[2] = MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c77f1e98L, 0xf8cc6bf960L, "variableDeclaration"); return rv; } @Override protected SContainmentLink[] initAggregationLinks() { SContainmentLink[] rv = new SContainmentLink[12]; rv[0] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type"); rv[1] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c37a7f6eL, 0xf8c37f506eL, "initializer"); rv[2] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc67c7f0L, 0xf8cc67c7f1L, "localVariableDeclaration"); rv[3] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"); rv[4] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, 0x10ef02c1b6eL, "defaultBlock"); rv[5] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02cdd1bL, 0x10ef02d67cfL, "expression"); rv[6] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02cdd1bL, 0x10ef02d8048L, "body"); rv[7] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, 0x10ef02edcafL, "case"); rv[8] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301aeL, "actualArgument"); rv[9] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, 0x116b46b36c4L, "operation"); rv[10] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, 0x116b46a4416L, "operand"); rv[11] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10ef02a8c6aL, 0x10ef02ec241L, "expression"); return rv; } private static SNodePointer propertyMacro_j8e1z8_c0a0c0b0d0b0c0e = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "8528048620384778057"); private static SNodePointer copySrcMacro_j8e1z8_b0a0c0e0d0b0c0e = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "6039268229364247723"); private static SNodePointer loopMacroRef_j8e1z8_b0a0a1a2a1a2a5 = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "7723526804946013062"); private static SNodePointer propertyMacro_j8e1z8_c0a0c0a0b0b0e0d0c0b0c0f = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "7723526804946032579"); private static SNodePointer copySrcListMacro_j8e1z8_b0a0a1a1a1a1a2a4a3a2a1a2a5 = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "8098116031887331077"); private static SNodePointer ifMacroRef_j8e1z8_b0a0b0b0b0c0e0d0c0b0c0f = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "8098116031887267633"); private static SNodePointer templateNode_j8e1z8_c0a0a1a2a1a1a1a3a1a2a5 = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "4454796803413404081"); private static SNodePointer ifMacroRef_j8e1z8_b0a0c0f = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "75056552358381012"); }