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.SNode; 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.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.template.SourceSubstituteMacroNodeContext; import jetbrains.mps.generator.runtime.TemplateUtil; 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.SContainmentLink; @Generated public class Template_reduce_Parameters extends TemplateDeclarationBase { private SNode myMethodDeclaration; public Template_reduce_Parameters(SNode methodDeclaration) { this.myMethodDeclaration = methodDeclaration; } public SNodeReference getTemplateNode() { return new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "4279359955658653877"); } private Map<String, Object> getParametersAsMap() { Map<String, Object> result = MapSequence.fromMap(new HashMap<String, Object>()); MapSequence.fromMap(result).put("methodDeclaration", myMethodDeclaration); 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_4279359955658793405(new SourceSubstituteMacroNodesContext(context, loopMacroRef_f8m1hr_b0a0a2a6)); int loopIndex_argCounter_1 = 0; for (SNode itnode1 : loopList1) { if (itnode1 == null) { continue; } TemplateContext context1 = context.subContext(itnode1); context1 = context1.withVariable("cv:argCounter", loopIndex_argCounter_1++); Collection<SNode> tlist2 = null; if (QueriesGenerated.ifMacro_Condition_4279359955658794670(new IfMacroContext(context1, ifMacroRef_f8m1hr_b0a0e0e0g))) { Collection<SNode> tlist3 = null; final SNode copySrcInput3 = QueriesGenerated.sourceNodeQuery_4279359955658902978(new SourceSubstituteMacroNodeContext(context1, copySrcMacro_f8m1hr_b0a0c0e0e0g)); tlist3 = environment.copyNodes(TemplateUtil.singletonList(copySrcInput3), copySrcMacro_f8m1hr_b0a0c0e0e0g, "tpl/r:00000000-0000-4000-0000-011c89590303/4279359955658789444", context1); tlist2 = tlist3; } else { final SNode tnode4 = environment.createOutputNode(myConcepts[0]); try { TemplateContext context2 = context1.subContext(); { final SNode tnode5 = environment.createOutputNode(myConcepts[1]); try { TemplateContext context3 = context2.subContext(); { Collection<SNode> tlist6 = null; final SNode copySrcInput6 = QueriesGenerated.sourceNodeQuery_4279359955658907090(new SourceSubstituteMacroNodeContext(context3, copySrcMacro_f8m1hr_b0a0c0b0b0b0b0a4a4a6)); tlist6 = environment.copyNodes(TemplateUtil.singletonList(copySrcInput6), copySrcMacro_f8m1hr_b0a0c0b0b0b0b0a4a4a6, "tpl/r:00000000-0000-4000-0000-011c89590303/4279359955658907057", context3); for (SNode child7 : TemplateUtil.asNotNull(tlist6)) { tnode5.addChild(myAggregationLinks[0], child7); } // TODO validate child } { Collection<SNode> tlist8 = null; final SNode copySrcInput8 = QueriesGenerated.sourceNodeQuery_4279359955658914189(new SourceSubstituteMacroNodeContext(context3, copySrcMacro_f8m1hr_b0a0c0c0b0b0b0a4a4a6)); tlist8 = environment.copyNodes(TemplateUtil.singletonList(copySrcInput8), copySrcMacro_f8m1hr_b0a0c0c0b0b0b0a4a4a6, "tpl/r:00000000-0000-4000-0000-011c89590303/4279359955658907051", context3); for (SNode child9 : TemplateUtil.asNotNull(tlist8)) { tnode5.addChild(myAggregationLinks[1], child9); } // TODO validate child } } finally { } tnode4.addChild(myAggregationLinks[2], tnode5); // TODO validate child } } finally { } tlist2 = TemplateUtil.singletonList(tnode4); } if (tlist2 != null) { tlist1.addAll(tlist2); } } return tlist1; } @Override public Collection<SNode> apply(@NotNull TemplateExecutionEnvironment environment, @NotNull TemplateContext context) throws GenerationException { TemplateContext contextWithParams = context.subContext(getParametersAsMap()); return applyPart0(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, 0x11857355952L, 0xf8c78301aeL, "actualArgument"), nodeToWeave); } return tlistpart0; } @Override protected SConcept[] initConcepts() { SConcept[] rv = new SConcept[2]; rv[0] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xfb4ed32b7fL, "ParenthesizedExpression"); rv[1] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0xf940dabe4aL, "CastExpression"); return rv; } @Override protected SContainmentLink[] initAggregationLinks() { SContainmentLink[] rv = new SContainmentLink[3]; rv[0] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf940dabe4aL, 0xf940dabe4cL, "expression"); rv[1] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf940dabe4aL, 0xf940dabe4bL, "type"); rv[2] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfb4ed32b7fL, 0xfb4ed32b80L, "expression"); return rv; } private static SNodePointer loopMacroRef_f8m1hr_b0a0a2a6 = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "4279359955658793402"); private static SNodePointer copySrcMacro_f8m1hr_b0a0c0e0e0g = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "4279359955658901777"); private static SNodePointer ifMacroRef_f8m1hr_b0a0e0e0g = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "4279359955658794668"); private static SNodePointer copySrcMacro_f8m1hr_b0a0c0b0b0b0b0a4a4a6 = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "4279359955658907089"); private static SNodePointer copySrcMacro_f8m1hr_b0a0c0c0b0b0b0a4a4a6 = new SNodePointer("r:00000000-0000-4000-0000-011c89590303(jetbrains.mps.lang.smodel.generator.baseLanguage.template.main@generator)", "4279359955658914093"); }