package org.jetbrains.mps.samples.ParallelFor.generator.template.generator.template.main; /*Generated by MPS */ import jetbrains.mps.generator.runtime.Generated; import jetbrains.mps.generator.impl.query.QueryProviderBase; import jetbrains.mps.generator.template.BaseMappingRuleContext; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.baseLanguage.behavior.ContinueStatement__BehaviorDescriptor; import jetbrains.mps.typesystem.inference.TypeChecker; import jetbrains.mps.lang.typesystem.runtime.HUtil; import jetbrains.mps.generator.template.PropertyMacroContext; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.generator.template.ReferenceMacroContext; import jetbrains.mps.generator.template.IfMacroContext; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.generator.template.SourceSubstituteMacroNodeContext; import jetbrains.mps.generator.template.SourceSubstituteMacroNodesContext; import jetbrains.mps.internal.collections.runtime.SetSequence; import jetbrains.mps.baseLanguage.behavior.StatementList__BehaviorDescriptor; import jetbrains.mps.internal.collections.runtime.IWhereFilter; import java.util.Map; import jetbrains.mps.generator.impl.query.ReductionRuleCondition; import java.util.HashMap; import org.jetbrains.annotations.NotNull; import jetbrains.mps.generator.impl.query.QueryKey; import jetbrains.mps.generator.template.ReductionRuleQueryContext; import jetbrains.mps.generator.impl.GenerationFailureException; import jetbrains.mps.generator.impl.query.SourceNodeQuery; import jetbrains.mps.generator.impl.query.QueryKeyImpl; import org.jetbrains.annotations.Nullable; import jetbrains.mps.generator.impl.query.SourceNodesQuery; import java.util.Collection; import jetbrains.mps.util.IterableUtil; import jetbrains.mps.generator.impl.query.PropertyValueQuery; import org.jetbrains.mps.openapi.language.SProperty; import jetbrains.mps.generator.impl.query.IfMacroCondition; import jetbrains.mps.generator.impl.query.ReferenceTargetQuery; @Generated public class QueriesGenerated extends QueryProviderBase { public QueriesGenerated() { super(1); } public static boolean baseMappingRule_Condition_8923957828369629274(final BaseMappingRuleContext _context) { return SNodeOperations.isInstanceOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c77f1e98L, 0xf8cc6bf960L, "variableDeclaration")), MetaAdapterFactory.getConcept(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770abL, "org.jetbrains.mps.samples.ParallelFor.structure.ParallelLoopVariable")); } public static boolean baseMappingRule_Condition_4697196167065973042(final BaseMappingRuleContext _context) { return SNodeOperations.isInstanceOf(ContinueStatement__BehaviorDescriptor.getLoop_idhEwIA0E.invoke(_context.getNode()), MetaAdapterFactory.getConcept(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, "org.jetbrains.mps.samples.ParallelFor.structure.ParallelFor")); } public static boolean baseMappingRule_Condition_7865129668867016083(final BaseMappingRuleContext _context) { return TypeChecker.getInstance().getRuntimeSupport().coerce_(TypeChecker.getInstance().getTypeOf(_context.getNode()), HUtil.createMatchingPatternByConcept(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf940d819f7L, "jetbrains.mps.baseLanguage.structure.ArrayType")), true) != null; } public static Object propertyMacro_GetPropertyValue_5337045848190803509(final PropertyMacroContext _context) { return _context.createUniqueName("latch", null); } public static Object propertyMacro_GetPropertyValue_5337045848190803543(final PropertyMacroContext _context) { return _context.createUniqueName("exceptions", null); } public static Object propertyMacro_GetPropertyValue_633195941006880942(final PropertyMacroContext _context) { if (!(SPropertyOperations.getBoolean(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x7bd8445d1e8810c2L, "loopVariable")), MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c37a7f6eL, 0x111f9e9f00cL, "isFinal")))) { _context.showErrorMessage(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x7bd8445d1e8810c2L, "loopVariable")), "The loop variable must be final"); } return SPropertyOperations.getString(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x7bd8445d1e8810c2L, "loopVariable")), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")); } public static Object propertyMacro_GetPropertyValue_633195941006945119(final PropertyMacroContext _context) { return SPropertyOperations.getInteger(_context.getNode(), MetaAdapterFactory.getProperty(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x8c9905a80efd03cL, 0x8c9905a80efd045L, "numberOfThreads")); } public static Object referenceMacro_GetReferent_7865129668867189303(final ReferenceMacroContext _context) { return _context.getNode(); } public static Object referenceMacro_GetReferent_7793246093815939787(final ReferenceMacroContext _context) { return "localA"; } public static boolean ifMacro_Condition_8374756414439004441(final IfMacroContext _context) { return !(SPropertyOperations.getBoolean(_context.getNode(), MetaAdapterFactory.getProperty(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x74391c966b0f1304L, "nowait"))); } public static boolean ifMacro_Condition_8374756414439004406(final IfMacroContext _context) { return !(SPropertyOperations.getBoolean(_context.getNode(), MetaAdapterFactory.getProperty(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x74391c966b0f1304L, "nowait"))); } public static boolean ifMacro_Condition_633195941006966360(final IfMacroContext _context) { return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x40a8d217b6d881feL, "threadPool")) == null; } public static boolean ifMacro_Condition_633195941006966388(final IfMacroContext _context) { return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x40a8d217b6d881feL, "threadPool")) != null; } public static boolean ifMacro_Condition_8374756414438972401(final IfMacroContext _context) { return !(SPropertyOperations.getBoolean(_context.getNode(), MetaAdapterFactory.getProperty(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x74391c966b0f1304L, "nowait"))); } public static SNode sourceNodeQuery_7865129668866947390(final SourceSubstituteMacroNodeContext _context) { return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x7bd8445d1e888c7eL, "inputSequence")); } public static SNode sourceNodeQuery_633195941006833439(final SourceSubstituteMacroNodeContext _context) { return TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x7bd8445d1e8810c2L, "loopVariable"))); } public static SNode sourceNodeQuery_4659204813808539958(final SourceSubstituteMacroNodeContext _context) { return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x40a8d217b6d881feL, "threadPool")); } public static SNode sourceNodeQuery_633195941006880920(final SourceSubstituteMacroNodeContext _context) { return TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x7bd8445d1e8810c2L, "loopVariable"))); } public static SNode sourceNodeQuery_7865129668866947450(final SourceSubstituteMacroNodeContext _context) { return SNodeOperations.copyNode(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xcb7388e8f1824cdaL, 0xbd839796e8634856L, 0x7bd8445d1e8770aaL, 0x7bd8445d1e888c7eL, "inputSequence"))); } public static Iterable<SNode> sourceNodesQuery_633195941006921760(final SourceSubstituteMacroNodesContext _context) { return SLinkOperations.getChildren(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body")), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, 0xf8cc6bf961L, "statement")); } public static Iterable<SNode> sourceNodesQuery_5337045848190669725(final SourceSubstituteMacroNodesContext _context) { return SetSequence.fromSet(StatementList__BehaviorDescriptor.uncaughtThrowables_id2SVUfbZ9Qq1.invoke(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body")), ((boolean) false))).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return it != SNodeOperations.getNode("6354ebe7-c22a-4a0f-ac54-50b52ab9b065/java:java.lang(JDK/)", "~RuntimeException"); } }); } private final Map<String, ReductionRuleCondition> rrcMethods = new HashMap<String, ReductionRuleCondition>(); { int i = 0; rrcMethods.put("8923957828369629223", new QueriesGenerated.RRC(i++)); rrcMethods.put("4697196167065973040", new QueriesGenerated.RRC(i++)); rrcMethods.put("7865129668867016081", new QueriesGenerated.RRC(i++)); } @Override @NotNull public ReductionRuleCondition getReductionRuleCondition(@NotNull QueryKey identity) { final String id = identity.getTemplateNode().getNodeId().toString(); if (!(rrcMethods.containsKey(id))) { return super.getReductionRuleCondition(identity); } return rrcMethods.get(id); } private static class RRC implements ReductionRuleCondition { private final int methodKey; public RRC(int methodKey) { this.methodKey = methodKey; } @Override public boolean check(ReductionRuleQueryContext ctx) throws GenerationFailureException { switch (methodKey) { case 0: return QueriesGenerated.baseMappingRule_Condition_8923957828369629274(ctx); case 1: return QueriesGenerated.baseMappingRule_Condition_4697196167065973042(ctx); case 2: return QueriesGenerated.baseMappingRule_Condition_7865129668867016083(ctx); default: throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no condition method for rule %s (key: #%d)", ctx.getTemplateReference(), methodKey)); } } } private final Map<String, SourceNodeQuery> snqMethods = new HashMap<String, SourceNodeQuery>(); { int i = 0; snqMethods.put("7865129668866947390", new QueriesGenerated.SNQ(i++)); snqMethods.put("633195941006833439", new QueriesGenerated.SNQ(i++)); snqMethods.put("4659204813808539958", new QueriesGenerated.SNQ(i++)); snqMethods.put("633195941006880920", new QueriesGenerated.SNQ(i++)); snqMethods.put("7865129668866947450", new QueriesGenerated.SNQ(i++)); } @NotNull @Override public SourceNodeQuery getSourceNodeQuery(@NotNull QueryKey identity) { final String id = ((QueryKeyImpl) identity).getQueryNodeId().toString(); if (!(snqMethods.containsKey(id))) { return super.getSourceNodeQuery(identity); } return snqMethods.get(id); } private static class SNQ implements SourceNodeQuery { private final int methodKey; public SNQ(int methodKey) { this.methodKey = methodKey; } @Nullable public SNode evaluate(@NotNull SourceSubstituteMacroNodeContext ctx) throws GenerationFailureException { switch (methodKey) { case 0: return QueriesGenerated.sourceNodeQuery_7865129668866947390(ctx); case 1: return QueriesGenerated.sourceNodeQuery_633195941006833439(ctx); case 2: return QueriesGenerated.sourceNodeQuery_4659204813808539958(ctx); case 3: return QueriesGenerated.sourceNodeQuery_633195941006880920(ctx); case 4: return QueriesGenerated.sourceNodeQuery_7865129668866947450(ctx); default: throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no method for query %s (key: #%d)", ctx.getTemplateReference(), methodKey)); } } } private final Map<String, SourceNodesQuery> snsqMethods = new HashMap<String, SourceNodesQuery>(); { int i = 0; snsqMethods.put("633195941006921760", new QueriesGenerated.SNsQ(i++)); snsqMethods.put("5337045848190669725", new QueriesGenerated.SNsQ(i++)); } @NotNull @Override public SourceNodesQuery getSourceNodesQuery(@NotNull QueryKey identity) { final String id = ((QueryKeyImpl) identity).getQueryNodeId().toString(); if (!(snsqMethods.containsKey(id))) { return super.getSourceNodesQuery(identity); } return snsqMethods.get(id); } private static class SNsQ implements SourceNodesQuery { private final int methodKey; public SNsQ(int methodKey) { this.methodKey = methodKey; } @NotNull public Collection<SNode> evaluate(@NotNull SourceSubstituteMacroNodesContext ctx) throws GenerationFailureException { switch (methodKey) { case 0: return IterableUtil.asCollection(QueriesGenerated.sourceNodesQuery_633195941006921760(ctx)); case 1: return IterableUtil.asCollection(QueriesGenerated.sourceNodesQuery_5337045848190669725(ctx)); default: throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no method for query %s (key: #%d)", ctx.getTemplateReference(), methodKey)); } } } private final Map<String, PropertyValueQuery> pvqMethods = new HashMap<String, PropertyValueQuery>(); { int i = 0; pvqMethods.put("5337045848190803508", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "latch")); pvqMethods.put("5337045848190803542", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "exceptions")); pvqMethods.put("633195941006880939", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "a")); pvqMethods.put("633195941006945116", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc59b314L, 0xf8cc59b315L, "value"), "1")); } @NotNull @Override public PropertyValueQuery getPropertyValueQuery(@NotNull QueryKey identity) { final String id = identity.getTemplateNode().getNodeId().toString(); if (!(pvqMethods.containsKey(id))) { return super.getPropertyValueQuery(identity); } return pvqMethods.get(id); } private static class PVQ extends PropertyValueQuery.Base { private final int methodKey; /*package*/ PVQ(int methodKey, SProperty property, String templateValue) { super(property, templateValue); this.methodKey = methodKey; } @Nullable public Object evaluate(@NotNull PropertyMacroContext ctx) throws GenerationFailureException { switch (methodKey) { case 0: return QueriesGenerated.propertyMacro_GetPropertyValue_5337045848190803509(ctx); case 1: return QueriesGenerated.propertyMacro_GetPropertyValue_5337045848190803543(ctx); case 2: return QueriesGenerated.propertyMacro_GetPropertyValue_633195941006880942(ctx); case 3: return QueriesGenerated.propertyMacro_GetPropertyValue_633195941006945119(ctx); default: throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no method for query %s (key: #%d)", ctx.getTemplateReference(), methodKey)); } } } private final Map<String, IfMacroCondition> imcMethods = new HashMap<String, IfMacroCondition>(); { int i = 0; imcMethods.put("8374756414439004440", new QueriesGenerated.IfMC(i++)); imcMethods.put("8374756414439004405", new QueriesGenerated.IfMC(i++)); imcMethods.put("633195941006966359", new QueriesGenerated.IfMC(i++)); imcMethods.put("633195941006966387", new QueriesGenerated.IfMC(i++)); imcMethods.put("8374756414438972400", new QueriesGenerated.IfMC(i++)); } @NotNull @Override public IfMacroCondition getIfMacroCondition(@NotNull QueryKey identity) { final String id = identity.getTemplateNode().getNodeId().toString(); if (!(imcMethods.containsKey(id))) { return super.getIfMacroCondition(identity); } return imcMethods.get(id); } private static class IfMC implements IfMacroCondition { private final int methodKey; public IfMC(int methodKey) { this.methodKey = methodKey; } @Override public boolean check(@NotNull IfMacroContext ctx) throws GenerationFailureException { switch (methodKey) { case 0: return QueriesGenerated.ifMacro_Condition_8374756414439004441(ctx); case 1: return QueriesGenerated.ifMacro_Condition_8374756414439004406(ctx); case 2: return QueriesGenerated.ifMacro_Condition_633195941006966360(ctx); case 3: return QueriesGenerated.ifMacro_Condition_633195941006966388(ctx); case 4: return QueriesGenerated.ifMacro_Condition_8374756414438972401(ctx); default: throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no condition method for if macro %s (key: #%d)", ctx.getTemplateReference(), methodKey)); } } } private final Map<String, ReferenceTargetQuery> rtqMethods = new HashMap<String, ReferenceTargetQuery>(); { rtqMethods.put("7865129668867189302", new QueriesGenerated.RTQ(0, "Exception")); rtqMethods.put("7793246093815939786", new QueriesGenerated.RTQ(1, "localA")); } @NotNull @Override public ReferenceTargetQuery getReferenceTargetQuery(@NotNull QueryKey queryKey) { final String id = queryKey.getTemplateNode().getNodeId().toString(); if (!(rtqMethods.containsKey(id))) { return super.getReferenceTargetQuery(queryKey); } return rtqMethods.get(id); } private static class RTQ extends ReferenceTargetQuery.Base { private final int methodKey; /*package*/ RTQ(int methodKey, String templateValue) { super(templateValue); this.methodKey = methodKey; } @Nullable public Object evaluate(@NotNull ReferenceMacroContext ctx) throws GenerationFailureException { switch (methodKey) { case 0: return QueriesGenerated.referenceMacro_GetReferent_7865129668867189303(ctx); case 1: return QueriesGenerated.referenceMacro_GetReferent_7793246093815939787(ctx); default: throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no method for query %s (key: #%d)", ctx.getTemplateReference(), methodKey)); } } } }