package jetbrains.mps.lang.textGen.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.model.SModel; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SModuleOperations; import jetbrains.mps.smodel.SModelStereotype; import jetbrains.mps.smodel.SNodePointer; public class ConceptTextGenDeclaration_Constraints extends BaseConstraintsDescriptor { public ConceptTextGenDeclaration_Constraints() { super(MetaAdapterFactory.getConcept(0xb83431fe5c8f40bcL, 0x8a3665e25f4dd253L, 0x11f3c776369L, "jetbrains.mps.lang.textGen.structure.ConceptTextGenDeclaration")); } @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(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), new BasePropertyConstraintsDescriptor(MetaIdFactory.propId(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L), this) { @Override public boolean hasOwnGetter() { return true; } @Override public Object getValue(SNode node) { String propertyName = "name"; return SPropertyOperations.getString(SLinkOperations.getTarget(node, MetaAdapterFactory.getReferenceLink(0xb83431fe5c8f40bcL, 0x8a3665e25f4dd253L, 0x11f3c776369L, 0x11f3c7a3d4dL, "conceptDeclaration")), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")) + "_TextGen"; } }); return properties; } private static boolean staticCanBeARoot(SModel model) { return SModuleOperations.isAspect(model, "textGen") || SModelStereotype.isGeneratorModel(model); } private static SNodePointer canBeRootBreakingPoint = new SNodePointer("r:472e3702-e789-4c3f-b300-132c65ad44f1(jetbrains.mps.lang.textGen.constraints)", "1233758188295"); }