package jetbrains.mps.samples.Kaja.generator.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 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_IfStatement extends TemplateDeclarationBase {
public Template_reduce_IfStatement() {
}
public SNodeReference getTemplateNode() {
return new SNodePointer("r:3ab3501c-2f4b-48e6-9b6c-e31ff8ef3185(jetbrains.mps.samples.Kaja.generator.template.main@generator)", "3308300503039647832");
}
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;
final SNode copySrcInput2 = QueriesGenerated.sourceNodeQuery_3308300503039647895(new SourceSubstituteMacroNodeContext(context1, copySrcMacro_damv7z_b0a0c0b0c0e));
tlist2 = environment.copyNodes(TemplateUtil.singletonList(copySrcInput2), copySrcMacro_damv7z_b0a0c0b0c0e, "tpl/r:3ab3501c-2f4b-48e6-9b6c-e31ff8ef3185/3308300503039647886", context1);
for (SNode child3 : TemplateUtil.asNotNull(tlist2)) {
tnode1.addChild(myAggregationLinks[0], child3);
}
// TODO validate child
}
{
final SNode tnode4 = environment.createOutputNode(myConcepts[1]);
try {
TemplateContext context2 = context1.subContext();
{
Collection<SNode> tlist5 = null;
final SNode copySrcInput5 = QueriesGenerated.sourceNodeQuery_3308300503039939838(new SourceSubstituteMacroNodeContext(context2, copySrcMacro_damv7z_b0a0c0b0b0c0c0e));
tlist5 = environment.copyNodes(TemplateUtil.singletonList(copySrcInput5), copySrcMacro_damv7z_b0a0c0b0b0c0c0e, "tpl/r:3ab3501c-2f4b-48e6-9b6c-e31ff8ef3185/3308300503039939828", context2);
for (SNode child6 : TemplateUtil.asNotNull(tlist5)) {
tnode4.addChild(myAggregationLinks[1], child6);
}
// TODO validate child
}
} finally {
}
tnode1.addChild(myAggregationLinks[2], tnode4);
// TODO validate child
}
{
final SNode tnode7 = environment.createOutputNode(myConcepts[2]);
try {
TemplateContext context3 = context1.subContext();
{
final SNode tnode8 = environment.createOutputNode(myConcepts[1]);
try {
TemplateContext context4 = context3.subContext();
{
Collection<SNode> tlist9 = null;
final SNode copySrcInput9 = QueriesGenerated.sourceNodeQuery_3308300503039939855(new SourceSubstituteMacroNodeContext(context4, copySrcMacro_damv7z_b0a0c0b0b0b0b0d0c0e));
tlist9 = environment.copyNodes(TemplateUtil.singletonList(copySrcInput9), copySrcMacro_damv7z_b0a0c0b0b0b0b0d0c0e, "tpl/r:3ab3501c-2f4b-48e6-9b6c-e31ff8ef3185/3308300503039939845", context4);
for (SNode child10 : TemplateUtil.asNotNull(tlist9)) {
tnode8.addChild(myAggregationLinks[1], child10);
}
// TODO validate child
}
} finally {
}
tnode7.addChild(myAggregationLinks[3], tnode8);
// TODO validate child
}
} finally {
}
tnode1.addChild(myAggregationLinks[4], tnode7);
// TODO validate child
}
} finally {
}
return tnode1;
}
@Override
public Collection<SNode> apply(@NotNull TemplateExecutionEnvironment environment, @NotNull TemplateContext context) throws GenerationException {
return TemplateUtil.singletonList(applyPart0(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);
return TemplateUtil.singletonList(tnodepart0);
}
@Override
protected SConcept[] initConcepts() {
SConcept[] rv = new SConcept[3];
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"), 0xfc092b6b77L, "BlockStatement");
return rv;
}
@Override
protected SContainmentLink[] initAggregationLinks() {
SContainmentLink[] rv = new SContainmentLink[5];
rv[0] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, 0xf8cc56b218L, "condition");
rv[1] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement");
rv[2] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, 0xf8cc56b219L, "ifTrue");
rv[3] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc092b6b77L, 0xfc092b6b78L, "statements");
rv[4] = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, 0xfc092b6b76L, "ifFalseStatement");
return rv;
}
private static SNodePointer copySrcMacro_damv7z_b0a0c0b0c0e = new SNodePointer("r:3ab3501c-2f4b-48e6-9b6c-e31ff8ef3185(jetbrains.mps.samples.Kaja.generator.template.main@generator)", "3308300503039647892");
private static SNodePointer copySrcMacro_damv7z_b0a0c0b0b0c0c0e = new SNodePointer("r:3ab3501c-2f4b-48e6-9b6c-e31ff8ef3185(jetbrains.mps.samples.Kaja.generator.template.main@generator)", "3308300503039939835");
private static SNodePointer copySrcMacro_damv7z_b0a0c0b0b0b0b0d0c0e = new SNodePointer("r:3ab3501c-2f4b-48e6-9b6c-e31ff8ef3185(jetbrains.mps.samples.Kaja.generator.template.main@generator)", "3308300503039939852");
}