package jetbrains.mps.samples.highlevel.simpleEditor.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.SLinkOperations; import jetbrains.mps.generator.template.ReferenceMacroContext; import jetbrains.mps.internal.collections.runtime.ListSequence; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.internal.collections.runtime.IWhereFilter; import jetbrains.mps.generator.template.SourceSubstituteMacroNodesContext; import jetbrains.mps.generator.template.TemplateVarContext; import java.util.Map; import jetbrains.mps.generator.impl.query.SourceNodesQuery; import java.util.HashMap; import org.jetbrains.annotations.NotNull; import jetbrains.mps.generator.impl.query.QueryKey; import jetbrains.mps.generator.impl.query.QueryKeyImpl; import java.util.Collection; import jetbrains.mps.generator.impl.GenerationFailureException; import jetbrains.mps.util.IterableUtil; import jetbrains.mps.generator.impl.query.PropertyValueQuery; import org.jetbrains.mps.openapi.language.SProperty; import org.jetbrains.annotations.Nullable; import jetbrains.mps.generator.impl.query.ReferenceTargetQuery; import jetbrains.mps.generator.impl.query.VariableValueQuery; @Generated public class QueriesGenerated extends QueryProviderBase { public QueriesGenerated() { super(1); } public static Object propertyMacro_GetPropertyValue_3778147542048436871(final PropertyMacroContext _context) { return SPropertyOperations.getString(_context.getNode(), MetaAdapterFactory.getProperty(0xc457c5de60274104L, 0xab9ca31c5404ae8bL, 0x346ead2c08ccf6ffL, 0x346ead2c08ccfa54L, "caption")); } public static Object propertyMacro_GetPropertyValue_3778147542048447048(final PropertyMacroContext _context) { return SPropertyOperations.getString(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getReferenceLink(0xc457c5de60274104L, 0xab9ca31c5404ae8bL, 0x346ead2c08ccfa10L, 0x346ead2c08ccfa1fL, "prop")), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")); } public static Object referenceMacro_GetReferent_3778147542048540958(final ReferenceMacroContext _context) { return ListSequence.fromList(SLinkOperations.getChildren(((SNode) _context.getVariable("var:expConcept")), MetaAdapterFactory.getContainmentLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x1103553c5ffL, 0xf979c3ba6cL, "propertyDeclaration"))).findFirst(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return eq_x583g4_a0a0a0a0a0a0d(SPropertyOperations.getString(it, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")), SPropertyOperations.getString(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getReferenceLink(0xc457c5de60274104L, 0xab9ca31c5404ae8bL, 0x346ead2c08ccfa10L, 0x346ead2c08ccfa1fL, "prop")), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"))); } }); } public static Object referenceMacro_GetReferent_3778147542048541256(final ReferenceMacroContext _context) { return ((SNode) _context.getVariable("var:expConcept")); } public static Iterable<SNode> sourceNodesQuery_3778147542048439085(final SourceSubstituteMacroNodesContext _context) { return SLinkOperations.getChildren(_context.getNode(), MetaAdapterFactory.getContainmentLink(0xc457c5de60274104L, 0xab9ca31c5404ae8bL, 0x346ead2c08ccf6ffL, 0x346ead2c08ccfa0dL, "visibleProperties")); } public static Object insertMacro_varValue_3778147542048562258(final TemplateVarContext _context) { return _context.getOutputNodeProxy(SLinkOperations.getTarget(_context.getNode(), MetaAdapterFactory.getReferenceLink(0xc457c5de60274104L, 0xab9ca31c5404ae8bL, 0x346ead2c08ccf6ffL, 0x346ead2c08ccf9f3L, "cncpt")), "concept"); } private final Map<String, SourceNodesQuery> snsqMethods = new HashMap<String, SourceNodesQuery>(); { int i = 0; snsqMethods.put("3778147542048439085", 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_3778147542048439085(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("3778147542048436870", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0xf9eb01232eL, 0xf9eb01232fL, "text"), "alias")); pvqMethods.put("3778147542048447047", new QueriesGenerated.PVQ(i++, MetaAdapterFactory.getProperty(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0xf9eb01232eL, 0xf9eb01232fL, "text"), "propertyName")); } @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_3778147542048436871(ctx); case 1: return QueriesGenerated.propertyMacro_GetPropertyValue_3778147542048447048(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("3778147542048540957", new QueriesGenerated.RTQ(0, "alias")); rtqMethods.put("3778147542048541255", new QueriesGenerated.RTQ(1, "BaseConcept")); } @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_3778147542048540958(ctx); case 1: return QueriesGenerated.referenceMacro_GetReferent_3778147542048541256(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, VariableValueQuery> vvqMethods = new HashMap<String, VariableValueQuery>(); { vvqMethods.put("3778147542048562256", new QueriesGenerated.VVQ(0)); } @NotNull @Override public VariableValueQuery getVariableValueQuery(@NotNull QueryKey queryKey) { final String id = queryKey.getTemplateNode().getNodeId().toString(); if (!(vvqMethods.containsKey(id))) { return super.getVariableValueQuery(queryKey); } return vvqMethods.get(id); } private static class VVQ implements VariableValueQuery { private final int methodKey; /*package*/ VVQ(int methodKey) { this.methodKey = methodKey; } @Nullable public Object evaluate(@NotNull TemplateVarContext ctx) throws GenerationFailureException { switch (methodKey) { case 0: return QueriesGenerated.insertMacro_varValue_3778147542048562258(ctx); default: throw new GenerationFailureException(String.format("Inconsistent QueriesGenerated: there's no method for query %s (key: #%d)", ctx.getTemplateReference(), methodKey)); } } } private static boolean eq_x583g4_a0a0a0a0a0a0d(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } }