package org.jetbrains.mps.samples.DecisionTable.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.PropertyMacroContext;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.generator.template.ReferenceMacroContext;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.generator.template.SourceSubstituteMacroNodeContext;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import jetbrains.mps.generator.template.SourceSubstituteMacroNodesContext;
import jetbrains.mps.internal.collections.runtime.SetSequence;
import org.jetbrains.mps.samples.DecisionTable.behavior.DecisionTable__BehaviorDescriptor;
import java.util.List;
import jetbrains.mps.internal.collections.runtime.IVisitor;
import jetbrains.mps.generator.template.WeavingMappingRuleContext;
import java.util.Map;
import java.util.HashMap;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.generator.impl.query.WeaveRuleCondition;
import jetbrains.mps.generator.impl.query.QueryKey;
import jetbrains.mps.generator.impl.query.WeaveRuleQuery;
import jetbrains.mps.generator.impl.query.WeaveAnchorQuery;
import jetbrains.mps.generator.impl.GenerationFailureException;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.generator.template.WeavingAnchorContext;
import jetbrains.mps.generator.impl.query.SourceNodeQuery;
import jetbrains.mps.generator.impl.query.QueryKeyImpl;
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.ReferenceTargetQuery;
@Generated
public class QueriesGenerated extends QueryProviderBase {
public QueriesGenerated() {
super(1);
}
public static Object propertyMacro_GetPropertyValue_3863300516938156376(final PropertyMacroContext _context) {
return SPropertyOperations.getString(_context.getNode(), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"));
}
public static Object propertyMacro_GetPropertyValue_3863300516938159716(final PropertyMacroContext _context) {
return SPropertyOperations.getString(_context.getNode(), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"));
}
public static Object propertyMacro_GetPropertyValue_3863300516938126188(final PropertyMacroContext _context) {
return _context.createUniqueName("decisionTable", SNodeOperations.getNodeAncestor(_context.getNode(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept"), false, false));
}
public static Object referenceMacro_GetReferent_3863300516938126286(final ReferenceMacroContext _context) {
return _context.getOutputNodeByInputNodeAndMappingLabel(_context.getNode(), "decisionTable2Method");
}
public static Object referenceMacro_GetReferent_3863300516938168935(final ReferenceMacroContext _context) {
return SPropertyOperations.getString(_context.getNode(), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"));
}
public static Object referenceMacro_GetReferent_3863300516938168975(final ReferenceMacroContext _context) {
return SPropertyOperations.getString(_context.getNode(), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"));
}
public static SNode sourceNodeQuery_3863300516938155499(final SourceSubstituteMacroNodeContext _context) {
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type"));
}
public static SNode sourceNodeQuery_3863300516938159701(final SourceSubstituteMacroNodeContext _context) {
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type"));
}
public static SNode sourceNodeQuery_3863300516938171105(final SourceSubstituteMacroNodeContext _context) {
SNode t = SNodeOperations.getNodeAncestor(_context.getNode(), MetaAdapterFactory.getConcept(0x65c13e6709b64695L, 0xaf8852024b7d2027L, 0x1b942309931b1581L, "org.jetbrains.mps.samples.DecisionTable.structure.DecisionTable"), false, false);
SNode rowHeader = _context.getNode();
SNode colHeader = (SNode) _context.getNode().getUserObject("colHeader");
return ListSequence.fromList(SLinkOperations.getChildren(t, MetaAdapterFactory.getContainmentLink(0x65c13e6709b64695L, 0xaf8852024b7d2027L, 0x1b942309931b1581L, 0x1b942309931b1586L, "resultValues"))).getElement(SNodeOperations.getIndexInParent(rowHeader) * ListSequence.fromList(SLinkOperations.getChildren(t, MetaAdapterFactory.getContainmentLink(0x65c13e6709b64695L, 0xaf8852024b7d2027L, 0x1b942309931b1581L, 0x1b942309931b1584L, "colHeaders"))).count() + SNodeOperations.getIndexInParent(colHeader));
}
public static SNode sourceNodeQuery_3863300516938155197(final SourceSubstituteMacroNodeContext _context) {
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0x65c13e6709b64695L, 0xaf8852024b7d2027L, 0x1b942309931b1581L, 0x1b942309931b1583L, "defaultValue"));
}
public static SNode sourceNodeQuery_3863300516938155177(final SourceSubstituteMacroNodeContext _context) {
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0x65c13e6709b64695L, 0xaf8852024b7d2027L, 0x1b942309931b1581L, 0x1b942309931b1582L, "expectedType"));
}
public static Iterable<SNode> sourceNodesQuery_3863300516938168918(final SourceSubstituteMacroNodesContext _context) {
return SetSequence.fromSet(DecisionTable__BehaviorDescriptor.referencedLVDs_id3mtcPBWFCmw.invoke(_context.getNode())).toListSequence();
}
public static Iterable<SNode> sourceNodesQuery_3863300516938168959(final SourceSubstituteMacroNodesContext _context) {
return SetSequence.fromSet(DecisionTable__BehaviorDescriptor.referencedParams_id3mtcPBWFDo3.invoke(_context.getNode())).toListSequence();
}
public static Iterable<SNode> sourceNodesQuery_3863300516938155488(final SourceSubstituteMacroNodesContext _context) {
return SetSequence.fromSet(DecisionTable__BehaviorDescriptor.referencedLVDs_id3mtcPBWFCmw.invoke(_context.getNode())).toListSequence();
}
public static Iterable<SNode> sourceNodesQuery_3863300516938159683(final SourceSubstituteMacroNodesContext _context) {
return SetSequence.fromSet(DecisionTable__BehaviorDescriptor.referencedParams_id3mtcPBWFDo3.invoke(_context.getNode())).toListSequence();
}
public static Iterable<SNode> sourceNodesQuery_3863300516938171067(final SourceSubstituteMacroNodesContext _context) {
List<SNode> rowHeaders = SLinkOperations.getChildren(SNodeOperations.getNodeAncestor(_context.getNode(), MetaAdapterFactory.getConcept(0x65c13e6709b64695L, 0xaf8852024b7d2027L, 0x1b942309931b1581L, "org.jetbrains.mps.samples.DecisionTable.structure.DecisionTable"), false, false), MetaAdapterFactory.getContainmentLink(0x65c13e6709b64695L, 0xaf8852024b7d2027L, 0x1b942309931b1581L, 0x1b942309931b1585L, "rowHeaders"));
ListSequence.fromList(rowHeaders).visitAll(new IVisitor<SNode>() {
public void visit(SNode it) {
it.putUserObject("colHeader", _context.getNode());
}
});
return rowHeaders;
}
public static Iterable<SNode> sourceNodesQuery_3863300516938170992(final SourceSubstituteMacroNodesContext _context) {
return SLinkOperations.getChildren(_context.getNode(), MetaAdapterFactory.getContainmentLink(0x65c13e6709b64695L, 0xaf8852024b7d2027L, 0x1b942309931b1581L, 0x1b942309931b1584L, "colHeaders"));
}
public static SNode weaving_MappingRule_ContextNodeQuery_3863300516938090623(final WeavingMappingRuleContext _context) {
return _context.getCopiedOutputNodeForInputNode(SNodeOperations.getNodeAncestor(_context.getNode(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept"), false, false));
}
private final Map<String, QueriesGenerated.WRQ> wrcnMethods = new HashMap<String, QueriesGenerated.WRQ>();
{
int i = 0;
wrcnMethods.put("3863300516938090621", new QueriesGenerated.WRQ(i++));
}
@Override
@NotNull
public WeaveRuleCondition getWeaveRuleCondition(@NotNull QueryKey identity) {
final String id = identity.getTemplateNode().getNodeId().toString();
if (!(wrcnMethods.containsKey(id))) {
return super.getWeaveRuleCondition(identity);
}
return wrcnMethods.get(id);
}
@Override
@NotNull
public WeaveRuleQuery getWeaveRuleQuery(@NotNull QueryKey identity) {
final String id = identity.getTemplateNode().getNodeId().toString();
if (!(wrcnMethods.containsKey(id))) {
return super.getWeaveRuleQuery(identity);
}
return wrcnMethods.get(id);
}
@NotNull
@Override
public WeaveAnchorQuery getWeaveAnchorQuery(@NotNull QueryKey identity) {
final String id = identity.getTemplateNode().getNodeId().toString();
if (!(wrcnMethods.containsKey(id))) {
return super.getWeaveAnchorQuery(identity);
}
return wrcnMethods.get(id);
}
private static class WRQ implements WeaveRuleQuery, WeaveRuleCondition, WeaveAnchorQuery {
private final int methodKey;
public WRQ(int methodKey) {
this.methodKey = methodKey;
}
@Override
public boolean check(@NotNull WeavingMappingRuleContext ctx) throws GenerationFailureException {
switch (methodKey) {
case 0:
return true;
default:
throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no condition method for rule %s (key: #%d)", ctx.getTemplateReference(), methodKey));
}
}
@Override
public SNode contextNode(WeavingMappingRuleContext ctx) throws GenerationFailureException {
switch (methodKey) {
case 0:
return QueriesGenerated.weaving_MappingRule_ContextNodeQuery_3863300516938090623(ctx);
default:
throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no context node query method for weaving rule %s (key: #%d)", ctx.getTemplateReference(), methodKey));
}
}
@Nullable
@Override
public SNode anchorNode(WeavingAnchorContext ctx) throws GenerationFailureException {
switch (methodKey) {
case 0:
return null;
default:
throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no anchor query method for rule %s (key: #%d)", ctx.getTemplateReference(), methodKey));
}
}
}
private final Map<String, SourceNodeQuery> snqMethods = new HashMap<String, SourceNodeQuery>();
{
int i = 0;
snqMethods.put("3863300516938155499", new QueriesGenerated.SNQ(i++));
snqMethods.put("3863300516938159701", new QueriesGenerated.SNQ(i++));
snqMethods.put("3863300516938171105", new QueriesGenerated.SNQ(i++));
snqMethods.put("3863300516938155197", new QueriesGenerated.SNQ(i++));
snqMethods.put("3863300516938155177", 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_3863300516938155499(ctx);
case 1:
return QueriesGenerated.sourceNodeQuery_3863300516938159701(ctx);
case 2:
return QueriesGenerated.sourceNodeQuery_3863300516938171105(ctx);
case 3:
return QueriesGenerated.sourceNodeQuery_3863300516938155197(ctx);
case 4:
return QueriesGenerated.sourceNodeQuery_3863300516938155177(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("3863300516938168918", new QueriesGenerated.SNsQ(i++));
snsqMethods.put("3863300516938168959", new QueriesGenerated.SNsQ(i++));
snsqMethods.put("3863300516938155488", new QueriesGenerated.SNsQ(i++));
snsqMethods.put("3863300516938159683", new QueriesGenerated.SNsQ(i++));
snsqMethods.put("3863300516938171067", new QueriesGenerated.SNsQ(i++));
snsqMethods.put("3863300516938170992", 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_3863300516938168918(ctx));
case 1:
return IterableUtil.asCollection(QueriesGenerated.sourceNodesQuery_3863300516938168959(ctx));
case 2:
return IterableUtil.asCollection(QueriesGenerated.sourceNodesQuery_3863300516938155488(ctx));
case 3:
return IterableUtil.asCollection(QueriesGenerated.sourceNodesQuery_3863300516938159683(ctx));
case 4:
return IterableUtil.asCollection(QueriesGenerated.sourceNodesQuery_3863300516938171067(ctx));
case 5:
return IterableUtil.asCollection(QueriesGenerated.sourceNodesQuery_3863300516938170992(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("3863300516938156375", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "localVarArg"));
pvqMethods.put("3863300516938159713", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "paramsArg"));
pvqMethods.put("3863300516938126187", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "tableImplementationMethod"));
}
@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_3863300516938156376(ctx);
case 1:
return QueriesGenerated.propertyMacro_GetPropertyValue_3863300516938159716(ctx);
case 2:
return QueriesGenerated.propertyMacro_GetPropertyValue_3863300516938126188(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, ReferenceTargetQuery> rtqMethods = new HashMap<String, ReferenceTargetQuery>();
{
rtqMethods.put("3863300516938126285", new QueriesGenerated.RTQ(0, "generateDecTableMethod"));
rtqMethods.put("3863300516938168934", new QueriesGenerated.RTQ(1, "aLocalVar"));
rtqMethods.put("3863300516938168974", new QueriesGenerated.RTQ(2, "param"));
}
@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_3863300516938126286(ctx);
case 1:
return QueriesGenerated.referenceMacro_GetReferent_3863300516938168935(ctx);
case 2:
return QueriesGenerated.referenceMacro_GetReferent_3863300516938168975(ctx);
default:
throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no method for query %s (key: #%d)", ctx.getTemplateReference(), methodKey));
}
}
}
}