package jetbrains.mps.baseLanguage.overloadedOperators.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.baseLanguage.overloadedOperators.util.BinaryOperationUtil;
import jetbrains.mps.typesystem.inference.TypeChecker;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.generator.template.PropertyMacroContext;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations;
import jetbrains.mps.baseLanguage.overloadedOperators.behavior.OverloadedBinaryOperator__BehaviorDescriptor;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.lang.core.behavior.INamedConcept__BehaviorDescriptor;
import jetbrains.mps.generator.template.SourceSubstituteMacroNodeContext;
import jetbrains.mps.generator.template.SourceSubstituteMacroNodesContext;
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;
@Generated
public class QueriesGenerated extends QueryProviderBase {
public QueriesGenerated() {
super(1);
}
public static boolean baseMappingRule_Condition_3100399657864717070(final BaseMappingRuleContext _context) {
return new BinaryOperationUtil(_context.getInputModel()).hasOverloadedOperators(_context.getNode(), TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11cL, "leftExpression"))), TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11bL, "rightExpression"))));
}
public static Object propertyMacro_GetPropertyValue_6677452554240269754(final PropertyMacroContext _context) {
return SPropertyOperations.getString(_context.getNode(), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"));
}
public static Object propertyMacro_GetPropertyValue_6677452554240291185(final PropertyMacroContext _context) {
return (String) OverloadedBinaryOperator__BehaviorDescriptor.getFunctionName_id5MF4VwG2rD2.invoke(_context.getNode());
}
public static Object propertyMacro_GetPropertyValue_3524394717035465437(final PropertyMacroContext _context) {
SNode op = new BinaryOperationUtil(SNodeOperations.getModel(_context.getNode())).getNearestOverloaded(_context.getNode(), TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11cL, "leftExpression"))), TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11bL, "rightExpression"))));
return (String) INamedConcept__BehaviorDescriptor.getFqName_idhEwIO9y.invoke(SNodeOperations.cast(SNodeOperations.getParent(op), MetaAdapterFactory.getConcept(0xfc8d557e5de64dd8L, 0xb749aab2fb23aefcL, 0x6b6f5c413011207L, "jetbrains.mps.baseLanguage.overloadedOperators.structure.OverloadedOperatorContainer")));
}
public static Object propertyMacro_GetPropertyValue_3524394717035465440(final PropertyMacroContext _context) {
SNode op = new BinaryOperationUtil(SNodeOperations.getModel(_context.getNode())).getNearestOverloaded(_context.getNode(), TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11cL, "leftExpression"))), TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11bL, "rightExpression"))));
return (String) OverloadedBinaryOperator__BehaviorDescriptor.getFunctionName_id5MF4VwG2rD2.invoke(op);
}
public static SNode sourceNodeQuery_6677452554240291133(final SourceSubstituteMacroNodeContext _context) {
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xfc8d557e5de64dd8L, 0xb749aab2fb23aefcL, 0x6b6f5c41300f84dL, 0x5cab13b82be03a0dL, "returnType"));
}
public static SNode sourceNodeQuery_6677452554240291100(final SourceSubstituteMacroNodeContext _context) {
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x108bbca0f48L, 0x108bbd29b4aL, "body"));
}
public static SNode sourceNodeQuery_6677452554240291154(final SourceSubstituteMacroNodeContext _context) {
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xfc8d557e5de64dd8L, 0xb749aab2fb23aefcL, 0x6b6f5c41300f84dL, 0x5cab13b82bf359b1L, "leftType"));
}
public static SNode sourceNodeQuery_6677452554240291170(final SourceSubstituteMacroNodeContext _context) {
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xfc8d557e5de64dd8L, 0xb749aab2fb23aefcL, 0x6b6f5c41300f84dL, 0x5cab13b82bf359b2L, "rightType"));
}
public static SNode sourceNodeQuery_3524394717035465527(final SourceSubstituteMacroNodeContext _context) {
new BinaryOperationUtil(SNodeOperations.getModel(_context.getNode())).getNearestOverloaded(_context.getNode(), TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11cL, "leftExpression"))), TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11bL, "rightExpression"))));
if ((Boolean) (_context.getNode().getUserObject("reversed"))) {
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11bL, "rightExpression"));
}
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11cL, "leftExpression"));
}
public static SNode sourceNodeQuery_3524394717035465536(final SourceSubstituteMacroNodeContext _context) {
new BinaryOperationUtil(SNodeOperations.getModel(_context.getNode())).getNearestOverloaded(_context.getNode(), TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11cL, "leftExpression"))), TypeChecker.getInstance().getTypeOf(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11bL, "rightExpression"))));
if ((Boolean) (_context.getNode().getUserObject("reversed"))) {
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11cL, "leftExpression"));
}
return SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbdeb6fecfL, 0xfbdeb7a11bL, "rightExpression"));
}
public static Iterable<SNode> sourceNodesQuery_6677452554240291112(final SourceSubstituteMacroNodesContext _context) {
return SLinkOperations.getChildren(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xfc8d557e5de64dd8L, 0xb749aab2fb23aefcL, 0x6b6f5c413011207L, 0x6b6f5c413011208L, "operators"));
}
private final Map<String, ReductionRuleCondition> rrcMethods = new HashMap<String, ReductionRuleCondition>();
{
int i = 0;
rrcMethods.put("3100399657864692789", 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_3100399657864717070(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("6677452554240291133", new QueriesGenerated.SNQ(i++));
snqMethods.put("6677452554240291100", new QueriesGenerated.SNQ(i++));
snqMethods.put("6677452554240291154", new QueriesGenerated.SNQ(i++));
snqMethods.put("6677452554240291170", new QueriesGenerated.SNQ(i++));
snqMethods.put("3524394717035465527", new QueriesGenerated.SNQ(i++));
snqMethods.put("3524394717035465536", 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_6677452554240291133(ctx);
case 1:
return QueriesGenerated.sourceNodeQuery_6677452554240291100(ctx);
case 2:
return QueriesGenerated.sourceNodeQuery_6677452554240291154(ctx);
case 3:
return QueriesGenerated.sourceNodeQuery_6677452554240291170(ctx);
case 4:
return QueriesGenerated.sourceNodeQuery_3524394717035465527(ctx);
case 5:
return QueriesGenerated.sourceNodeQuery_3524394717035465536(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("6677452554240291112", 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_6677452554240291112(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("6677452554240269753", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "OverloadedOperatorContainerImpl"));
pvqMethods.put("6677452554240291184", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "f"));
pvqMethods.put("3524394717035465436", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xdf345b11b8c74213L, 0xac6648d2a9b75d88L, 0x1115749abe3L, 0x1115767a8eeL, "fqClassName"), "classFQName"));
pvqMethods.put("3524394717035465439", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0xdf345b11b8c74213L, 0xac6648d2a9b75d88L, 0x1115749abe3L, 0x111576710b3L, "methodName"), "methodName"));
}
@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_6677452554240269754(ctx);
case 1:
return QueriesGenerated.propertyMacro_GetPropertyValue_6677452554240291185(ctx);
case 2:
return QueriesGenerated.propertyMacro_GetPropertyValue_3524394717035465437(ctx);
case 3:
return QueriesGenerated.propertyMacro_GetPropertyValue_3524394717035465440(ctx);
default:
throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no method for query %s (key: #%d)", ctx.getTemplateReference(), methodKey));
}
}
}
}