public static void setBoolean(SNode node, String propertyName, boolean value) {
   if (node != null) {
     SNode conceptProperty = (SNode) findProperty(node, propertyName);
     if (SNodeOperations.isInstanceOf(
             conceptProperty, "jetbrains.mps.lang.structure.structure.BooleanConceptProperty")
         && !(value)) {
       node.removeChild(conceptProperty);
     } else if (conceptProperty == null && value) {
       for (SNode cpd : (List<SNode>) SModelSearchUtil.getConceptPropertyDeclarations(node)) {
         if (SPropertyOperations.getString(cpd, "name").equals(propertyName)) {
           if (SNodeOperations.isInstanceOf(
               cpd, "jetbrains.mps.lang.structure.structure.BooleanConceptPropertyDeclaration")) {
             SNode bcp =
                 SModelOperations.createNewNode(
                     SNodeOperations.getModel(node),
                     null,
                     "jetbrains.mps.lang.structure.structure.BooleanConceptProperty");
             SLinkOperations.setTarget(
                 bcp,
                 "conceptPropertyDeclaration",
                 SNodeOperations.cast(
                     cpd,
                     "jetbrains.mps.lang.structure.structure.BooleanConceptPropertyDeclaration"),
                 false);
             ListSequence.fromList(SLinkOperations.getTargets(node, "conceptProperty", true))
                 .addElement(bcp);
             break;
           }
         }
       }
     }
   }
 }
 public static void setInteger(SNode node, String propertyName, int value) {
   if (node != null) {
     SNode conceptProperty = (SNode) findProperty(node, propertyName);
     if (SNodeOperations.isInstanceOf(
         conceptProperty, "jetbrains.mps.lang.structure.structure.IntegerConceptProperty")) {
       SPropertyOperations.set(
           SNodeOperations.cast(
               conceptProperty, "jetbrains.mps.lang.structure.structure.IntegerConceptProperty"),
           "value",
           "" + (value));
     }
   }
 }
 public static int getInteger(SNode node, String propertyName) {
   if (node == null) {
     return 0;
   }
   SNode conceptProperty = (SNode) findProperty(node, propertyName);
   if (SNodeOperations.isInstanceOf(
       conceptProperty, "jetbrains.mps.lang.structure.structure.IntegerConceptProperty")) {
     return SPropertyOperations.getInteger(
         SNodeOperations.cast(
             conceptProperty, "jetbrains.mps.lang.structure.structure.IntegerConceptProperty"),
         "value");
   }
   return 0;
 }
Example #4
0
 public AttributeList(SNode attributed, IAttributeDescriptor descriptor) {
   super(
       attributed,
       "smodelAttribute",
       (List)
           Sequence.fromIterable(
                   AttributeOperations.getAttributes(
                       SNodeOperations.cast(
                           attributed,
                           MetaAdapterFactory.getConcept(
                               0xceab519525ea4f22L,
                               0x9b92103b95ca8c0cL,
                               0x10802efe25aL,
                               "jetbrains.mps.lang.core.structure.BaseConcept")),
                       descriptor))
               .toListSequence());
   myAttributeDescriptor = descriptor;
 }