Пример #1
0
 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;
           }
         }
       }
     }
   }
 }
Пример #2
0
 public static SNode setNewChild(SNode node, String role, String childConceptFQName) {
   if (node != null) {
     SNode newChild = SModelOperations.createNewNode(node.getModel(), childConceptFQName);
     SLinkOperations.setTarget(node, role, newChild, true);
     return newChild;
   }
   return null;
 }
Пример #3
0
 public static SNode addNewChild(SNode node, String role, String childConceptFQName) {
   if (node != null) {
     SNode newChild = SModelOperations.createNewNode(node.getModel(), childConceptFQName);
     node.addChild(role, newChild);
     return newChild;
   }
   return null;
 }
Пример #4
0
 public static SNode getModuleStub(SModel model) {
   final SModule module = model.getModule();
   SRepository repo = model.getRepository();
   if (repo == null || ProjectStructureModule.getInstance(repo) == null) {
     return null;
   }
   if (module instanceof Generator) {
     Language lang = ((Generator) module).getSourceLanguage();
     SModel m = ProjectStructureModule.getInstance(repo).getModelByModule(lang);
     if (m == null) {
       return null;
     }
     SNode l =
         ListSequence.fromList(
                 SModelOperations.roots(
                     m,
                     MetaAdapterFactory.getConcept(
                         0x86ef829012bb4ca7L,
                         0x947f093788f263a9L,
                         0x5869770da61dfe1fL,
                         "jetbrains.mps.lang.project.structure.Language")))
             .first();
     return (l == null
         ? null
         : ListSequence.fromList(
                 SLinkOperations.getChildren(
                     l,
                     MetaAdapterFactory.getContainmentLink(
                         0x86ef829012bb4ca7L,
                         0x947f093788f263a9L,
                         0x5869770da61dfe1fL,
                         0x5869770da61dfe37L,
                         "generator")))
             .findFirst(
                 new IWhereFilter<SNode>() {
                   public boolean accept(SNode it) {
                     return eq_kkj9n5_a0a0a0a0a0a4a3a11(
                         SPropertyOperations.getString(
                             it,
                             MetaAdapterFactory.getProperty(
                                 0x86ef829012bb4ca7L,
                                 0x947f093788f263a9L,
                                 0x5869770da61dfe1eL,
                                 0x5869770da61dfe22L,
                                 "uuid")),
                         module.getModuleReference().getModuleId().toString());
                   }
                 }));
   } else {
     SModel m = ProjectStructureModule.getInstance(repo).getModelByModule(module);
     return (m == null
         ? null
         : ListSequence.fromList(
                 SModelOperations.roots(
                     m,
                     MetaAdapterFactory.getConcept(
                         0x86ef829012bb4ca7L,
                         0x947f093788f263a9L,
                         0x5869770da61dfe1eL,
                         "jetbrains.mps.lang.project.structure.Module")))
             .first());
   }
 }
Пример #5
0
 public static SNode createAndAddAttribute(
     SNode node, IAttributeDescriptor descriptor, SConcept newConceptFqname) {
   SModel model = SNodeOperations.getModel(node);
   return addAttribute(
       node, descriptor, (SNode) SModelOperations.createNewNode(model, null, newConceptFqname));
 }