package testDefaultEditor.constraints; /*Generated by MPS */ import jetbrains.mps.smodel.runtime.base.BaseConstraintsDescriptor; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import java.util.Map; import org.jetbrains.mps.openapi.language.SReferenceLink; import jetbrains.mps.smodel.runtime.ReferenceConstraintsDescriptor; import java.util.HashMap; import jetbrains.mps.smodel.runtime.base.BaseReferenceConstraintsDescriptor; import jetbrains.mps.smodel.adapter.ids.MetaIdFactory; import org.jetbrains.annotations.Nullable; import jetbrains.mps.smodel.runtime.ReferenceScopeProvider; import jetbrains.mps.smodel.runtime.base.BaseScopeProvider; import org.jetbrains.mps.openapi.model.SNodeReference; import jetbrains.mps.scope.Scope; import jetbrains.mps.smodel.IOperationContext; import jetbrains.mps.smodel.runtime.ReferenceConstraintsContext; import org.jetbrains.mps.openapi.model.SNode; import java.util.List; import jetbrains.mps.internal.collections.runtime.ListSequence; import java.util.ArrayList; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import org.jetbrains.annotations.NotNull; import jetbrains.mps.smodel.SNodePointer; public class Developer_Constraints extends BaseConstraintsDescriptor { public Developer_Constraints() { super(MetaAdapterFactory.getConcept(0xb5734616c4b04639L, 0x9c6af3a1cf5dc4dbL, 0xd0768d7cf132939L, "testDefaultEditor.structure.Developer")); } @Override protected Map<SReferenceLink, ReferenceConstraintsDescriptor> getSpecifiedReferences() { Map<SReferenceLink, ReferenceConstraintsDescriptor> references = new HashMap<SReferenceLink, ReferenceConstraintsDescriptor>(); references.put(MetaAdapterFactory.getReferenceLink(0xb5734616c4b04639L, 0x9c6af3a1cf5dc4dbL, 0xd0768d7cf132939L, 0xd0768d7cf132953L, "bestFriend"), new BaseReferenceConstraintsDescriptor(MetaIdFactory.refId(0xb5734616c4b04639L, 0x9c6af3a1cf5dc4dbL, 0xd0768d7cf132939L, 0xd0768d7cf132953L), this) { @Override public boolean hasOwnScopeProvider() { return true; } @Nullable @Override public ReferenceScopeProvider getScopeProvider() { return new BaseScopeProvider() { @Override public SNodeReference getSearchScopeValidatorNode() { return breakingNode_f3ukjk_a0a0a0a0a1a0b0a1a2; } @Override public Scope createScope(final IOperationContext operationContext, final ReferenceConstraintsContext _context) { return new Scope() { /** * Returns all available elements in the scope. * * @param prefix (if not null) filters out elements whose reference text doesn't start with prefix * @return list of nodes in the scope */ public Iterable<SNode> getAvailableElements(@Nullable String prefix) { List<SNode> result = ListSequence.fromList(new ArrayList<SNode>()); SNode developer = _context.getReferenceNode(); if (SNodeOperations.isInstanceOf(developer, MetaAdapterFactory.getConcept(0xb5734616c4b04639L, 0x9c6af3a1cf5dc4dbL, 0xd0768d7cf132939L, "testDefaultEditor.structure.Developer"))) { SNode devnode = SNodeOperations.cast(developer, MetaAdapterFactory.getConcept(0xb5734616c4b04639L, 0x9c6af3a1cf5dc4dbL, 0xd0768d7cf132939L, "testDefaultEditor.structure.Developer")); SNode team = SNodeOperations.getParent(devnode); if (SNodeOperations.isInstanceOf(team, MetaAdapterFactory.getConcept(0xb5734616c4b04639L, 0x9c6af3a1cf5dc4dbL, 0xd0768d7cf12f792L, "testDefaultEditor.structure.Team"))) { SNode teamNode = SNodeOperations.cast(team, MetaAdapterFactory.getConcept(0xb5734616c4b04639L, 0x9c6af3a1cf5dc4dbL, 0xd0768d7cf12f792L, "testDefaultEditor.structure.Team")); ListSequence.fromList(result).addSequence(ListSequence.fromList(SLinkOperations.getChildren(teamNode, MetaAdapterFactory.getContainmentLink(0xb5734616c4b04639L, 0x9c6af3a1cf5dc4dbL, 0xd0768d7cf12f792L, 0xd0768d7cf132937L, "developer")))); } else { ListSequence.fromList(result).addElement(devnode); } } return result; } /** * Resolves element by reference text. * * Invariant: getReferenceText(contextNode, resolve(contextNode, refText)) == refText * * @param refText reference text * @param contextNode source node for the reference, or its nearest parent node (if source node is unavailable) * @return resolved element when reference text unambiguously identifies element, null otherwise */ @Nullable public SNode resolve(SNode contextNode, @NotNull String refText) { return null; } /** * Creates textual reference for scope element. If element has no textual representation * for the reference, returns null. * * Invariant: resolve(contextNode, getReferenceText(contextNode, node)) == node * * @param node element from the current scope (contains(node) == true) * @param contextNode source node for the reference, or its nearest parent node (if source node is unavailable) * @return reference text for the node element in the current scope */ @Nullable public String getReferenceText(SNode contextNode, @NotNull SNode node) { return null; } }; } }; } }); return references; } private static SNodePointer breakingNode_f3ukjk_a0a0a0a0a1a0b0a1a2 = new SNodePointer("r:4903a1be-5d28-4ffe-9f02-a773c7ca3a1a(testDefaultEditor.constraints)", "6836281137582852533"); }