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 java.util.Map; import jetbrains.mps.internal.collections.runtime.MapSequence; import java.util.HashMap; import java.util.Collection; 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.List; import java.util.ArrayList; import jetbrains.mps.generator.template.SourceSubstituteMacroNodesContext; import jetbrains.mps.generator.template.IfMacroContext; import jetbrains.mps.generator.runtime.TemplateUtil; import jetbrains.mps.smodel.SReference; import org.jetbrains.mps.openapi.persistence.PersistenceFacade; import jetbrains.mps.generator.impl.reference.RefResolver; import jetbrains.mps.generator.template.SourceSubstituteMacroNodeContext; 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.SReferenceLink; import org.jetbrains.mps.openapi.language.SContainmentLink; @Generated public class Template_reduce_ConceptSwitch_SubconceptCases extends TemplateDeclarationBase { private boolean myOutsideOfSwitch; public Template_reduce_ConceptSwitch_SubconceptCases(boolean outsideOfSwitch) { this.myOutsideOfSwitch = outsideOfSwitch; } public SNodeReference getTemplateNode() { return new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "75056552358298205"); } private Map<String, Object> getParametersAsMap() { Map<String, Object> result = MapSequence.fromMap(new HashMap<String, Object>()); MapSequence.fromMap(result).put("outsideOfSwitch", myOutsideOfSwitch); return result; } protected Collection<SNode> applyPart0(@NotNull final TemplateContext context) throws GenerationException { final TemplateExecutionEnvironment environment = context.getEnvironment(); final List<SNode> tlist1 = new ArrayList<SNode>(); final Iterable<SNode> loopList1 = QueriesGenerated.sourceNodesQuery_75056552358317729(new SourceSubstituteMacroNodesContext(context, loopMacroRef_nyxx76_b0a0a2a6)); for (SNode itnode1 : loopList1) { if (itnode1 == null) { continue; } TemplateContext context1 = context.subContext(itnode1); final SNode tnode2 = environment.createOutputNode(myConcepts[0]); try { TemplateContext context2 = context1.subContext(); { final SNode tnode3 = environment.createOutputNode(myConcepts[1]); try { TemplateContext context3 = context2.subContext(); { Collection<SNode> tlist4 = null; if (QueriesGenerated.ifMacro_Condition_75056552358317705(new IfMacroContext(context3, ifMacroRef_nyxx76_b0a0b0b0b0b0d0d0g))) { Collection<SNode> tlist5 = null; final Iterable<SNode> copyListInput5 = QueriesGenerated.sourceNodesQuery_75056552358317720(new SourceSubstituteMacroNodesContext(context3, copySrcListMacro_nyxx76_b0a0a1a1a1a1a1a3a3a6)); tlist5 = environment.copyNodes(copyListInput5, copySrcListMacro_nyxx76_b0a0a1a1a1a1a1a3a3a6, "tpl/r:00000000-0000-4000-0000-011c89590303/75056552358317703", context3); tlist4 = tlist5; } else { Collection<SNode> tlist6 = new Template_reduce_ConceptCaseBody_Hack2().apply(environment, context3); tlist4 = tlist6; } for (SNode child7 : TemplateUtil.asNotNull(tlist4)) { tnode3.addChild(myAggregationLinks[0], child7); } // TODO validate child } } finally { } tnode2.addChild(myAggregationLinks[1], tnode3); // TODO validate child } { final SNode tnode8 = environment.createOutputNode(myConcepts[2]); try { tnode8.setReference(myAssociationLinks[0], SReference.create(myAssociationLinks[0], tnode8, PersistenceFacade.getInstance().createModelReference("r:c3548bac-30eb-4a2a-937c-0111d5697309(jetbrains.mps.lang.smodel.generator.smodelAdapter)"), PersistenceFacade.getInstance().createNodeId("1461238478128512590"))); tnode8.setReference(myAssociationLinks[1], SReference.create(myAssociationLinks[1], tnode8, PersistenceFacade.getInstance().createModelReference("r:c3548bac-30eb-4a2a-937c-0111d5697309(jetbrains.mps.lang.smodel.generator.smodelAdapter)"), PersistenceFacade.getInstance().createNodeId("6599163591527270726"))); TemplateContext context4 = context2.subContext(); { final SNode tnode9 = environment.createOutputNode(myConcepts[3]); try { environment.resolve(new RefResolver(tnode9, myAssociationLinks[2], context4, new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "4217968694108143881"), "cncpt") { @Override public Object resolve() { return QueriesGenerated.referenceMacro_GetReferent_4217968694108143882(createQueryContext()); } }); } finally { } tnode8.addChild(myAggregationLinks[2], tnode9); // TODO validate child } { Collection<SNode> tlist10 = null; try { SNode callInputNode10 = QueriesGenerated.sourceNodeQuery_75056552358317757(new SourceSubstituteMacroNodeContext(context4, includeMacro_nyxx76_b0a0a0a1a4a1a2a3a3a6)); TemplateContext context5 = context4.subContext(null, callInputNode10); if (callInputNode10 != null) { try { tlist10 = new Template_reduce_ConceptDeclaration2SAbstractConcept().apply(environment, context5); } finally { } } } finally { } for (SNode child11 : TemplateUtil.asNotNull(tlist10)) { tnode8.addChild(myAggregationLinks[2], child11); } // TODO validate child } } finally { } tnode2.addChild(myAggregationLinks[3], tnode8); // TODO validate child } } finally { } if (tnode2 != null) { tlist1.add(tnode2); } } return tlist1; } protected Collection<SNode> applyPart1(@NotNull final TemplateContext context) throws GenerationException { final TemplateExecutionEnvironment environment = context.getEnvironment(); Collection<SNode> tlist1 = null; if (QueriesGenerated.ifMacro_Condition_75056552358338159(new IfMacroContext(context, ifMacroRef_nyxx76_b0a0c0h))) { Collection<SNode> tlist2 = null; final Iterable<SNode> copyListInput2 = QueriesGenerated.sourceNodesQuery_75056552358330362(new SourceSubstituteMacroNodesContext(context, copySrcListMacro_nyxx76_b0a0a1a2a7)); tlist2 = environment.copyNodes(copyListInput2, copySrcListMacro_nyxx76_b0a0a1a2a7, "tpl/r:00000000-0000-4000-0000-011c89590303/75056552358330360", context); tlist1 = tlist2; } return tlist1; } @Override public Collection<SNode> apply(@NotNull TemplateExecutionEnvironment environment, @NotNull TemplateContext context) throws GenerationException { TemplateContext contextWithParams = context.subContext(getParametersAsMap()); return TemplateUtil.asList(applyPart0(contextWithParams), applyPart1(contextWithParams)); } @Override public Collection<SNode> weave(@NotNull NodeWeaveFacility.WeaveContext weaveContext, @NotNull NodeWeaveFacility weaveSupport) throws GenerationException { final TemplateContext templateContext = weaveSupport.getTemplateContext().subContext(getParametersAsMap()); Collection<SNode> tlistpart0 = applyPart0(templateContext); for (SNode nodeToWeave : TemplateUtil.asNotNull(tlistpart0)) { weaveSupport.weaveNode(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"), nodeToWeave); } Collection<SNode> tlistpart1 = applyPart1(templateContext); for (SNode nodeToWeave : TemplateUtil.asNotNull(tlistpart1)) { weaveSupport.weaveNode(MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"), nodeToWeave); } return TemplateUtil.asList(tlistpart0, tlistpart1); } @Override protected SConcept[] initConcepts() { SConcept[] rv = new SConcept[4]; rv[0] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc56b217L, "IfStatement"); rv[1] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8cc56b200L, "StatementList"); rv[2] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xfbbebabf09L, "StaticMethodCall"); rv[3] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf8c77f1e98L, "VariableReference"); return rv; } @Override protected SReferenceLink[] initAssociationLinks() { SReferenceLink[] rv = new SReferenceLink[3]; rv[0] = MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301adL, "baseMethodDeclaration"); rv[1] = MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbbebabf09L, 0x10a7588b546L, "classConcept"); rv[2] = MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c77f1e98L, 0xf8cc6bf960L, "variableDeclaration"); return rv; } @Override protected SContainmentLink[] initAggregationLinks() { SContainmentLink[] rv = new SContainmentLink[4]; rv[0] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement"); rv[1] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, 0xf8cc56b219L, "ifTrue"); rv[2] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301aeL, "actualArgument"); rv[3] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, 0xf8cc56b218L, "condition"); return rv; } private static SNodePointer loopMacroRef_nyxx76_b0a0a2a6 = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "75056552358317728"); private static SNodePointer copySrcListMacro_nyxx76_b0a0a1a1a1a1a1a3a3a6 = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "75056552358317719"); private static SNodePointer ifMacroRef_nyxx76_b0a0b0b0b0b0d0d0g = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "75056552358317704"); private static SNodePointer includeMacro_nyxx76_b0a0a0a1a4a1a2a3a3a6 = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "75056552358317756"); private static SNodePointer copySrcListMacro_nyxx76_b0a0a1a2a7 = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "75056552358330361"); private static SNodePointer ifMacroRef_nyxx76_b0a0c0h = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "75056552358338157"); }