package jetbrains.mps.lang.structure.constraints; /*Generated by MPS */ import jetbrains.mps.smodel.runtime.base.BaseConstraintsDescriptor; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.smodel.runtime.ConstraintFunction; import jetbrains.mps.smodel.runtime.ConstraintContext_CanBeRoot; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import jetbrains.mps.smodel.runtime.CheckingNodeContext; import java.util.Map; import org.jetbrains.mps.openapi.language.SProperty; import jetbrains.mps.smodel.runtime.PropertyConstraintsDescriptor; import java.util.HashMap; import jetbrains.mps.smodel.runtime.base.BasePropertyConstraintsDescriptor; import jetbrains.mps.smodel.adapter.ids.MetaIdFactory; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import org.jetbrains.mps.openapi.language.SReferenceLink; import jetbrains.mps.smodel.runtime.ReferenceConstraintsDescriptor; import jetbrains.mps.smodel.runtime.base.BaseReferenceConstraintsDescriptor; 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 jetbrains.mps.scope.ListScope; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import org.jetbrains.mps.openapi.language.SAbstractConcept; import org.jetbrains.mps.openapi.model.SModel; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SModuleOperations; import jetbrains.mps.smodel.SModelStereotype; import jetbrains.mps.smodel.SNodePointer; public class EnumerationDataTypeDeclaration_Constraints extends BaseConstraintsDescriptor { public EnumerationDataTypeDeclaration_Constraints() { super(MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xfc26875dfbL, "jetbrains.mps.lang.structure.structure.EnumerationDataTypeDeclaration")); } @Override public ConstraintFunction<ConstraintContext_CanBeRoot, Boolean> calculateCanBeRootConstraint() { return new ConstraintFunction<ConstraintContext_CanBeRoot, Boolean>() { @NotNull public Boolean invoke(@NotNull ConstraintContext_CanBeRoot context, @Nullable CheckingNodeContext checkingNodeContext) { boolean result = staticCanBeARoot(context.getModel()); if (!(result) && checkingNodeContext != null) { checkingNodeContext.setBreakingNode(canBeRootBreakingPoint); } return result; } }; } @Override protected Map<SProperty, PropertyConstraintsDescriptor> getSpecifiedProperties() { Map<SProperty, PropertyConstraintsDescriptor> properties = new HashMap<SProperty, PropertyConstraintsDescriptor>(); properties.put(MetaAdapterFactory.getProperty(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xfc26875dfbL, 0x11a35a5efdaL, "hasNoDefaultMember"), new BasePropertyConstraintsDescriptor(MetaIdFactory.propId(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xfc26875dfbL, 0x11a35a5efdaL), this) { @Override public boolean hasOwnSetter() { return true; } @Override public void setValue(SNode node, String propertyValue) { String propertyName = "hasNoDefaultMember"; SPropertyOperations.set(node, MetaAdapterFactory.getProperty(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xfc26875dfbL, 0x11a35a5efdaL, "hasNoDefaultMember"), "" + ((SPropertyOperations.getBoolean(propertyValue)))); if ((SPropertyOperations.getBoolean(propertyValue)) == true) { SLinkOperations.setTarget(node, MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xfc26875dfbL, 0xfc3640a77dL, "defaultMember"), null); } } }); return properties; } @Override protected Map<SReferenceLink, ReferenceConstraintsDescriptor> getSpecifiedReferences() { Map<SReferenceLink, ReferenceConstraintsDescriptor> references = new HashMap<SReferenceLink, ReferenceConstraintsDescriptor>(); references.put(MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xfc26875dfbL, 0xfc3640a77dL, "defaultMember"), new BaseReferenceConstraintsDescriptor(MetaIdFactory.refId(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xfc26875dfbL, 0xfc3640a77dL), this) { @Override public boolean hasOwnScopeProvider() { return true; } @Nullable @Override public ReferenceScopeProvider getScopeProvider() { return new BaseScopeProvider() { @Override public SNodeReference getSearchScopeValidatorNode() { return breakingNode_8h501v_a0a0a0a0a1a0b0a1a4; } @Override public Scope createScope(final IOperationContext operationContext, final ReferenceConstraintsContext _context) { // members declared here return ListScope.forResolvableElements(SNodeOperations.getNodeDescendants(_context.getReferenceNode(), null, false, new SAbstractConcept[]{})); } }; } }); return references; } private static boolean staticCanBeARoot(SModel model) { return SModuleOperations.isAspect(model, "structure") || SModelStereotype.isGeneratorModel(model); } private static SNodePointer canBeRootBreakingPoint = new SNodePointer("r:00000000-0000-4000-0000-011c8959028c(jetbrains.mps.lang.structure.constraints)", "1227087688291"); private static SNodePointer breakingNode_8h501v_a0a0a0a0a1a0b0a1a4 = new SNodePointer("r:00000000-0000-4000-0000-011c8959028c(jetbrains.mps.lang.structure.constraints)", "6836281137582805030"); }