package jetbrains.mps.transformation.test.inputLang.generator.outputLang.template.test_reduceOneToMany; /*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.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 org.jetbrains.mps.openapi.model.SNodeAccessUtil; 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.SProperty; @Generated public class Template_reduce_InputNode_A extends TemplateDeclarationBase { public Template_reduce_InputNode_A() { } public SNodeReference getTemplateNode() { return new SNodePointer("r:eca8e1c7-93fd-4ddf-9db6-91f9c2320691(jetbrains.mps.transformation.test.inputLang.generator.outputLang.template.test_reduceOneToMany@generator)", "3893401255414100167"); } 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_3893401255414161783(new SourceSubstituteMacroNodesContext(context, loopMacroRef_vff4zh_b0a0a2a4)); for (SNode itnode1 : loopList1) { if (itnode1 == null) { continue; } TemplateContext context1 = context.subContext(itnode1); final SNode tnode2 = environment.createOutputNode(myConcepts[0]); try { SNodeAccessUtil.setProperty(tnode2, myProperties[0], "child #1"); } finally { } if (tnode2 != null) { tlist1.add(tnode2); } } return tlist1; } protected SNode applyPart1(@NotNull final TemplateContext context) throws GenerationException { final TemplateExecutionEnvironment environment = context.getEnvironment(); final SNode tnode1 = environment.createOutputNode(myConcepts[0]); try { SNodeAccessUtil.setProperty(tnode1, myProperties[0], "child #2"); } finally { } return tnode1; } protected Collection<SNode> applyPart2(@NotNull final TemplateContext context) throws GenerationException { final TemplateExecutionEnvironment environment = context.getEnvironment(); Collection<SNode> tlist1 = null; try { try { tlist1 = new Template_reduce_InputNode_A_included().apply(environment, context); } finally { } } finally { } return tlist1; } protected Collection<SNode> applyPart3(@NotNull final TemplateContext context) throws GenerationException { final TemplateExecutionEnvironment environment = context.getEnvironment(); Collection<SNode> tlist1 = null; try { TemplateContext switchContext1; switchContext1 = context; tlist1 = environment.trySwitch(templateSwitchNodeNoInput_vff4zh_a0a0c0c0h, switchContext1); if (tlist1 == null) { final SNode tnode2 = environment.createOutputNode(myConcepts[0]); try { } finally { } if (tnode2 != null) { tlist1 = TemplateUtil.singletonList(tnode2); } } } finally { } return tlist1; } @Override public Collection<SNode> apply(@NotNull TemplateExecutionEnvironment environment, @NotNull TemplateContext context) throws GenerationException { return TemplateUtil.asList(applyPart0(context), applyPart1(context), applyPart2(context), applyPart3(context)); } @Override public Collection<SNode> weave(@NotNull NodeWeaveFacility.WeaveContext weaveContext, @NotNull NodeWeaveFacility weaveSupport) throws GenerationException { final TemplateContext templateContext = weaveSupport.getTemplateContext(); Collection<SNode> tlistpart0 = applyPart0(templateContext); for (SNode nodeToWeave : TemplateUtil.asNotNull(tlistpart0)) { weaveSupport.weaveNode(MetaAdapterFactory.getContainmentLink(0x157a9668bf58417bL, 0x893e53d86388dc56L, 0x116455d922fL, 0x11645a94e4aL, "outputChild"), nodeToWeave); } SNode tnodepart1 = applyPart1(templateContext); weaveSupport.weaveNode(MetaAdapterFactory.getContainmentLink(0x157a9668bf58417bL, 0x893e53d86388dc56L, 0x116455d922fL, 0x11645a94e4aL, "outputChild"), tnodepart1); Collection<SNode> tlistpart2 = applyPart2(templateContext); for (SNode nodeToWeave : TemplateUtil.asNotNull(tlistpart2)) { weaveSupport.weaveNode(MetaAdapterFactory.getContainmentLink(0x157a9668bf58417bL, 0x893e53d86388dc56L, 0x116455d922fL, 0x11645a94e4aL, "outputChild"), nodeToWeave); } Collection<SNode> tlistpart3 = applyPart3(templateContext); for (SNode nodeToWeave : TemplateUtil.asNotNull(tlistpart3)) { weaveSupport.weaveNode(MetaAdapterFactory.getContainmentLink(0x157a9668bf58417bL, 0x893e53d86388dc56L, 0x116455d922fL, 0x11645a94e4aL, "outputChild"), nodeToWeave); } return TemplateUtil.asList(tlistpart0, tnodepart1, tlistpart2, tlistpart3); } @Override protected SConcept[] initConcepts() { SConcept[] rv = new SConcept[1]; rv[0] = MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0x157a9668bf58417bL, 0x893e53d86388dc56L, "jetbrains.mps.transformation.test.outputLang"), 0x1164564a526L, "OutputNode"); return rv; } @Override protected SProperty[] initProperties() { SProperty[] rv = new SProperty[1]; rv[0] = MetaAdapterFactory.getProperty(0x157a9668bf58417bL, 0x893e53d86388dc56L, 0x1164564a526L, 0x11645b5a797L, "text"); return rv; } private static SNodePointer loopMacroRef_vff4zh_b0a0a2a4 = new SNodePointer("r:eca8e1c7-93fd-4ddf-9db6-91f9c2320691(jetbrains.mps.transformation.test.inputLang.generator.outputLang.template.test_reduceOneToMany@generator)", "3893401255414161782"); private static SNodePointer templateSwitchNodeNoInput_vff4zh_a0a0c0c0h = new SNodePointer("r:eca8e1c7-93fd-4ddf-9db6-91f9c2320691(jetbrains.mps.transformation.test.inputLang.generator.outputLang.template.test_reduceOneToMany@generator)", "1892993302480310366"); }