public void execute(final SNode node, final EditorContext editorContext) {
   Iterable<SNode> nodes =
       ListSequence.fromList(SNodeOperations.getChildren(SNodeOperations.getParent(node)))
           .where(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return SNodeOperations.isInstanceOf(
                       it, "jetbrains.mps.lang.generator.structure.NodeMacro");
                 }
               });
   boolean seen = false;
   for (SNode n : nodes) {
     if (seen) {
       if (SNodeOperations.isInstanceOf(
           n, "jetbrains.mps.lang.generator.structure.CopySrcNodeMacro")) {
         SNodeOperations.deleteNode(n);
         SNodeFactoryOperations.replaceWithNewChild(
             node, "jetbrains.mps.lang.generator.structure.CopySrcListMacro");
       }
       return;
     } else if (n == node) {
       seen = true;
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * Uncomments the node which is under the comment node specified in constructor
  *
  * <p>Also if containment link of the commented node is singular and non optional comments or
  * deletes the existing child whether it is instance of abstract concept or not respectively
  *
  * @throws IllegalStateException if node to uncomment does not have parent
  * @return node which was under the comment
  */
 public SNode uncomment() {
   if (!(isValid())) {
     throw new IllegalStateException(
         "Node uncommenter has invalid state. Comment attribute has no parent. Attribute "
             + myComment.getPresentation()
             + " Attribute id: "
             + myComment.getNodeId());
   }
   SNode commentedNode =
       SLinkOperations.getTarget(
           myComment,
           MetaAdapterFactory.getContainmentLink(
               0xceab519525ea4f22L,
               0x9b92103b95ca8c0cL,
               0x3dcc194340c24debL,
               0x2ab99f0d2248e89dL,
               "commentedNode"));
   if (getContainmentLink() != null && commentedNode != null) {
     removeOrCommentChildInSingleRole();
     myComment.removeChild(commentedNode);
     getParent().insertChildAfter(getContainmentLink(), commentedNode, myComment);
   }
   SNodeOperations.deleteNode(myComment);
   return commentedNode;
 }
 private void removeAttributes(SNode node) {
   if (SNodeOperations.isAttribute(node)) {
     SNodeOperations.deleteNode(node);
   } else {
     for (SNode child : SNodeOperations.getChildren(node)) {
       removeAttributes(child);
     }
   }
 }
 public SNode execute(final SModule m) {
   {
     final SearchScope scope = CommandUtil.createScope(m);
     QueryExecutionContext context =
         new QueryExecutionContext() {
           public SearchScope getDefaultSearchScope() {
             return scope;
           }
         };
     Iterable<SNode> cellModels =
         CollectionSequence.fromCollection(
                 CommandUtil.instances(
                     CommandUtil.createConsoleScope(null, false, context),
                     MetaAdapterFactory.getConcept(
                         0x18bc659203a64e29L,
                         0xa83a7ff23bde13baL,
                         0xf9eb05cdc7L,
                         "jetbrains.mps.lang.editor.structure.CellModel_RefNode")))
             .where(
                 new IWhereFilter<SNode>() {
                   public boolean accept(SNode it) {
                     return needToMigrate(it);
                   }
                 });
     for (SNode cellModel : Sequence.fromIterable(cellModels)) {
       SNodeOperations.deleteNode(
           SLinkOperations.getTarget(
               cellModel,
               MetaAdapterFactory.getContainmentLink(
                   0x18bc659203a64e29L,
                   0xa83a7ff23bde13baL,
                   0xf9eafb9a39L,
                   0x10a19696199L,
                   "renderingCondition")));
       SPropertyOperations.set(
           cellModel,
           MetaAdapterFactory.getProperty(
               0x18bc659203a64e29L,
               0xa83a7ff23bde13baL,
               0xf9eb05cdc7L,
               0x3a4d559b401214L,
               "customizeEmptyCell"),
           "" + (true));
       SLinkOperations.setTarget(
           cellModel,
           MetaAdapterFactory.getContainmentLink(
               0x18bc659203a64e29L,
               0xa83a7ff23bde13baL,
               0xf9eb05cdc7L,
               0x3a4d559b42e5cbL,
               "emptyCellModel"),
           _quotation_createNode_i6fkmm_a0c0b0a0h());
     }
   }
   return null;
 }
Ejemplo n.º 5
0
 public void handleAction(
     SNode node, SModel model, IOperationContext operationContext, EditorContext editorContext) {
   SNodeOperations.deleteNode(
       SLinkOperations.getTarget(
           node,
           MetaAdapterFactory.getContainmentLink(
               0x22e72e4c0f6946ceL,
               0x84036750153aa615L,
               0x6c55c13f5bc8e1ecL,
               0x5d457621242d8208L,
               "debuggerConfiguration")));
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   List<SNode> TFs =
       SNodeOperations.getDescendants(
           SLinkOperations.getTarget(
               SLinkOperations.getTarget(node, "template", false), "contentNode", true),
           "jetbrains.mps.lang.generator.structure.TemplateFragment",
           true,
           new String[] {});
   if ((int) ListSequence.fromList(TFs).count() == 0) {
     JOptionPane.showMessageDialog(null, "No fragments found");
     return;
   }
   if (ListSequence.fromList(TFs).count() > 1) {
     JOptionPane.showMessageDialog(null, "Too many fragments");
     return;
   }
   // ------
   SNode oldTemplate = SLinkOperations.getTarget(node, "template", false);
   SNode fragmentToSet =
       SNodeOperations.copyNode(SNodeOperations.getParent(ListSequence.fromList(TFs).first()));
   SNode TFtoDelete =
       AttributeOperations.getAttribute(
           fragmentToSet,
           new IAttributeDescriptor.NodeAttribute(
               SConceptOperations.findConceptDeclaration(
                   "jetbrains.mps.lang.generator.structure.TemplateFragment")));
   SNodeOperations.deleteNode(TFtoDelete);
   SNode inlineTemplate =
       SNodeFactoryOperations.replaceWithNewChild(
           node, "jetbrains.mps.lang.generator.structure.InlineTemplate_RuleConsequence");
   SLinkOperations.setTarget(inlineTemplate, "templateNode", fragmentToSet, true);
   // ------
   int option =
       JOptionPane.showConfirmDialog(
           null, "Delete old template?", "", JOptionPane.YES_NO_OPTION);
   if (option == JOptionPane.YES_OPTION) {
     SNodeOperations.deleteNode(oldTemplate);
   }
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   if ((SLinkOperations.getTarget(
           node, AttributesRolesUtil.childRoleFromAttributeRole("blankLineBeforeAnn"), true)
       != null)) {
     SNodeOperations.deleteNode(
         SLinkOperations.getTarget(
             node, AttributesRolesUtil.childRoleFromAttributeRole("blankLineBeforeAnn"), true));
   } else {
     SNodeFactoryOperations.setNewChild(
         node,
         AttributesRolesUtil.childRoleFromAttributeRole("blankLineBeforeAnn"),
         "de.voelter.mps.textshape.structure.NeedsBlankLink");
   }
 }
Ejemplo n.º 8
0
 private void removeOrCommentChildInSingleRole() {
   if (!(getContainmentLink().isMultiple())) {
     SNode firstChild =
         ListSequence.fromList(SNodeOperations.getChildren(getParent(), getContainmentLink()))
             .first();
     if ((firstChild != null)) {
       if (firstChild.getConcept().isAbstract()) {
         SNodeOperations.deleteNode(firstChild);
       } else {
         new NodeCommenter(firstChild).commentOut(false);
       }
     }
   }
 }
 public void execute_internal(EditorContext editorContext, SNode node) {
   if ((int)
           ListSequence.fromList(SLinkOperations.getTargets(node, "alternatives", true)).count()
       == 1) {
     List<SNode> parts =
         ListSequence.fromList(
                 SLinkOperations.getTargets(
                     ListSequence.fromList(
                             SLinkOperations.getTargets(node, "alternatives", true))
                         .first(),
                     "parts",
                     true))
             .toListSequence();
     if ((int) ListSequence.fromList(parts).count() == 1) {
       SNodeOperations.replaceWithAnother(node, ListSequence.fromList(parts).first());
     } else if ((int) ListSequence.fromList(parts).count() == 0) {
       SNodeOperations.deleteNode(node);
     } else if (!(LinkDeclaration_Behavior.call_isSingular_1213877254557(
         SNodeOperations.getContainingLinkDeclaration(node)))) {
       SNodeOperations.replaceWithAnother(node, ListSequence.fromList(parts).first());
       final Wrappers._T<SNode> anchor =
           new Wrappers._T<SNode>(ListSequence.fromList(parts).removeElementAt(0));
       ListSequence.fromList(parts)
           .visitAll(
               new IVisitor<SNode>() {
                 public void visit(SNode it) {
                   SNodeOperations.insertNextSiblingChild(anchor.value, it);
                   anchor.value = it;
                 }
               });
     }
   } else if ((int)
           ListSequence.fromList(SLinkOperations.getTargets(node, "alternatives", true)).count()
       == 0) {
     SNodeOperations.deleteNode(node);
   }
 }
Ejemplo n.º 10
0
 public void execute(SNode node) {
   SNodeOperations.deleteNode(
       AttributeOperations.getAttribute(
           SNodeOperations.cast(
               node,
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x101d9d3ca30L,
                   "jetbrains.mps.baseLanguage.structure.Classifier")),
           new IAttributeDescriptor.NodeAttribute(
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x53f7c33f069862f2L,
                   "jetbrains.mps.baseLanguage.structure.JavaImports"))));
 }
Ejemplo n.º 11
0
 public void execute_internal(EditorContext editorContext, SNode node) {
   if (ListSequence.fromList(
           SLinkOperations.getChildren(
               node,
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x10a698082feL,
                   0xe5318742b9d1411L,
                   "additionalVar")))
       .isEmpty()) {
     SNodeOperations.deleteNode(
         SLinkOperations.getTarget(
             node,
             MetaAdapterFactory.getContainmentLink(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0x10a697996feL,
                 0x10a6979f36bL,
                 "variable")));
   } else {
     SNode var =
         ListSequence.fromList(
                 SLinkOperations.getChildren(
                     node,
                     MetaAdapterFactory.getContainmentLink(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0x10a698082feL,
                         0xe5318742b9d1411L,
                         "additionalVar")))
             .removeElementAt(0);
     SNodeOperations.replaceWithAnother(
         SLinkOperations.getTarget(
             node,
             MetaAdapterFactory.getContainmentLink(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0x10a697996feL,
                 0x10a6979f36bL,
                 "variable")),
         var);
   }
 }
 public void execute_internal(EditorContext editorContext, final SNode node) {
   if (ListSequence.fromList(
               SLinkOperations.getChildren(
                   node,
                   MetaAdapterFactory.getContainmentLink(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x10cacebf556L,
                       0x10f39abd97cL,
                       "catchClause")))
           .count()
       >= 1) {
     ListSequence.fromList(
             SLinkOperations.getChildren(
                 node,
                 MetaAdapterFactory.getContainmentLink(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0x10cacebf556L,
                     0x10f39abd97cL,
                     "catchClause")))
         .removeElementAt(0);
   } else {
     List<SNode> statements =
         SLinkOperations.getChildren(
             IContainsStatementList_Behavior.call_getStatementList_1237545932619(node),
             MetaAdapterFactory.getContainmentLink(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0xf8cc56b200L,
                 0xf8cc6bf961L,
                 "statement"));
     ListSequence.fromList(statements)
         .visitAll(
             new IVisitor<SNode>() {
               public void visit(SNode it) {
                 SNodeOperations.insertPrevSiblingChild(node, it);
               }
             });
     SNodeOperations.deleteNode(node);
   }
 }
Ejemplo n.º 13
0
 public void execute_internal(EditorContext editorContext, SNode node) {
   SNodeOperations.deleteNode(node);
 }
    @Override
    public void execute(final SNode node, final EditorContext editorContext) {
      SNode declarationStmt;
      SNode initializerStmt;

      if (SNodeOperations.isInstanceOf(
          node,
          MetaAdapterFactory.getConcept(
              0xf3061a5392264cc5L,
              0xa443f952ceaf5816L,
              0xf8cc67c7f0L,
              "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement"))) {
        declarationStmt =
            SNodeOperations.cast(
                node,
                MetaAdapterFactory.getConcept(
                    0xf3061a5392264cc5L,
                    0xa443f952ceaf5816L,
                    0xf8cc67c7f0L,
                    "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement"));
        initializerStmt =
            SNodeOperations.cast(
                SNodeOperations.getNextSibling(node),
                MetaAdapterFactory.getConcept(
                    0xf3061a5392264cc5L,
                    0xa443f952ceaf5816L,
                    0xf8cc56b213L,
                    "jetbrains.mps.baseLanguage.structure.ExpressionStatement"));
      } else {
        declarationStmt =
            SNodeOperations.cast(
                SNodeOperations.getPrevSibling(node),
                MetaAdapterFactory.getConcept(
                    0xf3061a5392264cc5L,
                    0xa443f952ceaf5816L,
                    0xf8cc67c7f0L,
                    "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement"));
        initializerStmt =
            SNodeOperations.cast(
                node,
                MetaAdapterFactory.getConcept(
                    0xf3061a5392264cc5L,
                    0xa443f952ceaf5816L,
                    0xf8cc56b213L,
                    "jetbrains.mps.baseLanguage.structure.ExpressionStatement"));
      }
      SNodeOperations.deleteNode(initializerStmt);
      SLinkOperations.setTarget(
          SLinkOperations.getTarget(
              declarationStmt,
              MetaAdapterFactory.getContainmentLink(
                  0xf3061a5392264cc5L,
                  0xa443f952ceaf5816L,
                  0xf8cc67c7f0L,
                  0xf8cc67c7f1L,
                  "localVariableDeclaration")),
          MetaAdapterFactory.getContainmentLink(
              0xf3061a5392264cc5L,
              0xa443f952ceaf5816L,
              0xf8c37a7f6eL,
              0xf8c37f506eL,
              "initializer"),
          SLinkOperations.getTarget(
              SNodeOperations.cast(
                  SLinkOperations.getTarget(
                      initializerStmt,
                      MetaAdapterFactory.getContainmentLink(
                          0xf3061a5392264cc5L,
                          0xa443f952ceaf5816L,
                          0xf8cc56b213L,
                          0xf8cc56b214L,
                          "expression")),
                  MetaAdapterFactory.getConcept(
                      0xf3061a5392264cc5L,
                      0xa443f952ceaf5816L,
                      0xf8c77f1e96L,
                      "jetbrains.mps.baseLanguage.structure.AssignmentExpression")),
              MetaAdapterFactory.getContainmentLink(
                  0xf3061a5392264cc5L,
                  0xa443f952ceaf5816L,
                  0x11b0d00332cL,
                  0xf8c77f1e99L,
                  "rValue")));
    }
Ejemplo n.º 15
0
  @Override
  public SModel loadSModel(IModule module, SModelDescriptor descriptor) {
    SModel model = new SModel(descriptor.getSModelReference(), new ForeignNodeIdMap());
    ModuleReference lang =
        MPSModuleRepository.getInstance()
            .getModuleById(ModuleId.fromString("32d0a39c-772f-4490-8142-e50f9a9f19d4"))
            .getModuleReference();
    model.addLanguage(lang);

    String pkg = model.getSModelFqName().getLongName();
    List<Tuples._4<String, String, SNode, PathItem>> doclst =
        ListSequence.fromList(new ArrayList<Tuples._4<String, String, SNode, PathItem>>());
    SNode sample =
        SConceptOperations.createNewNode(
            "jetbrains.mps.platform.conf.structure.ConfigurationXmlDocument", null);
    for (String path : roots) {
      PathItem pi = ConfPathItem.getPathItem(path);
      for (String docres : ListSequence.fromList(pi.resources(pkg))) {
        SNodeId id = ConfReader.createForeignId(pi.baseName(docres));
        SNode doc = (SNode) model.getNodeById(id);
        if ((doc == null)) {
          doc =
              SConceptOperations.createNewNode(
                  NameUtil.nodeFQName(
                      SConceptOperations.findConceptDeclaration(
                          "jetbrains.mps.platform.conf.structure.ConfigurationXmlDocument")),
                  sample);
          ((jetbrains.mps.smodel.SNode) doc).setId(id);
          SPropertyOperations.set(doc, "name", pi.baseName(docres));
          SModelOperations.addRootNode(((SModel) model), doc);
          ListSequence.fromList(doclst)
              .addElement(MultiTuple.<String, String, SNode, PathItem>from(pkg, docres, doc, pi));
        }
      }
    }
    final StubModelDescriptors descs =
        new StubModelDescriptors(SModelStereotype.getStubStereotypeForId("conf"), roots, module) {
          @Override
          public StubModelDataSource createStubsSource(String path) {
            return new ConfStubSource(path);
          }
        };
    ConfReader reader =
        new ConfReader(
            new ConfReader.Resolver() {
              public SModelReference stubModelReference(String pk) {
                return descs.javaStubRef(pk);
              }
            },
            new ConfReader.Resolver() {
              public SModelReference stubModelReference(String pk) {
                return descs.smodelRefWithId(pk);
              }
            });
    for (Tuples._4<String, String, SNode, PathItem> doctuple : ListSequence.fromList(doclst)) {
      InputStream is = null;
      try {
        is = doctuple._3().openResource(doctuple._0(), doctuple._1());
        reader.read(doctuple._2(), new SAXBuilder().build(is));
      } catch (IOException e) {
        e.printStackTrace();
      } catch (JDOMException e) {
        e.printStackTrace();
      }
      if (is != null) {
        try {
          is.close();
        } catch (IOException e) {
        }
      }
    }
    SNodeOperations.deleteNode(sample);
    return model;
  }
Ejemplo n.º 16
0
 public void execute_internal(EditorContext editorContext, SNode node) {
   if (SNodeOperations.isInstanceOf(
       node,
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0xf8cc56b217L,
           "jetbrains.mps.baseLanguage.structure.IfStatement"))) {
     SNodeOperations.deleteNode(
         SLinkOperations.getTarget(
             SNodeOperations.cast(
                 node,
                 MetaAdapterFactory.getConcept(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0xf8cc56b217L,
                     "jetbrains.mps.baseLanguage.structure.IfStatement")),
             MetaAdapterFactory.getContainmentLink(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0xf8cc56b217L,
                 0xf8cc56b218L,
                 "condition")));
   } else if (SNodeOperations.isInstanceOf(
       node,
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0xfaa4bf0f2fL,
           "jetbrains.mps.baseLanguage.structure.WhileStatement"))) {
     SNodeOperations.deleteNode(
         SLinkOperations.getTarget(
             SNodeOperations.cast(
                 node,
                 MetaAdapterFactory.getConcept(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0xfaa4bf0f2fL,
                     "jetbrains.mps.baseLanguage.structure.WhileStatement")),
             MetaAdapterFactory.getContainmentLink(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0xfaa4bf0f2fL,
                 0xfaa4bf0f30L,
                 "condition")));
   } else if (SNodeOperations.isInstanceOf(
       node,
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x11232674988L,
           "jetbrains.mps.baseLanguage.structure.DoWhileStatement"))) {
     SNodeOperations.deleteNode(
         SLinkOperations.getTarget(
             SNodeOperations.cast(
                 node,
                 MetaAdapterFactory.getConcept(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0x11232674988L,
                     "jetbrains.mps.baseLanguage.structure.DoWhileStatement")),
             MetaAdapterFactory.getContainmentLink(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0x11232674988L,
                 0x11232679422L,
                 "condition")));
   } else {
     return;
   }
   editorContext.selectWRTFocusPolicy(node);
 }
 public void execute(SNode node) {
   SNode fieldDeclaration =
       SConceptOperations.createNewNode(
           "jetbrains.mps.baseLanguage.structure.FieldDeclaration", null);
   SPropertyOperations.set(
       fieldDeclaration,
       "name",
       SPropertyOperations.getString(
           ((SNode) MakeStaticFieldNotStatic_QuickFix.this.getField("staticField")[0]), "name"));
   SLinkOperations.setTarget(
       fieldDeclaration,
       "type",
       SLinkOperations.getTarget(
           ((SNode) MakeStaticFieldNotStatic_QuickFix.this.getField("staticField")[0]),
           "type",
           true),
       true);
   SPropertyOperations.set(
       fieldDeclaration,
       "isFinal",
       ""
           + SPropertyOperations.getBoolean(
               ((SNode) MakeStaticFieldNotStatic_QuickFix.this.getField("staticField")[0]),
               "isFinal"));
   SLinkOperations.setTarget(
       fieldDeclaration,
       "initializer",
       SLinkOperations.getTarget(
           ((SNode) MakeStaticFieldNotStatic_QuickFix.this.getField("staticField")[0]),
           "initializer",
           true),
       true);
   ListSequence.fromList(SLinkOperations.getTargets(fieldDeclaration, "annotation", true))
       .addSequence(
           ListSequence.fromList(
               SLinkOperations.getTargets(
                   ((SNode) MakeStaticFieldNotStatic_QuickFix.this.getField("staticField")[0]),
                   "annotation",
                   true)));
   SLinkOperations.setTarget(
       fieldDeclaration,
       "visibility",
       SLinkOperations.getTarget(
           ((SNode) MakeStaticFieldNotStatic_QuickFix.this.getField("staticField")[0]),
           "visibility",
           true),
       true);
   SPropertyOperations.set(
       fieldDeclaration,
       "isDeprecated",
       ""
           + SPropertyOperations.getBoolean(
               ((SNode) MakeStaticFieldNotStatic_QuickFix.this.getField("staticField")[0]),
               "isDeprecated"));
   ListSequence.fromList(
           SLinkOperations.getTargets(
               ((SNode) MakeStaticFieldNotStatic_QuickFix.this.getField("containingClass")[0]),
               "field",
               true))
       .addElement(fieldDeclaration);
   SNodeOperations.detachNode(
       ((SNode) MakeStaticFieldNotStatic_QuickFix.this.getField("staticField")[0]));
   SNodeOperations.deleteNode(
       ((SNode) MakeStaticFieldNotStatic_QuickFix.this.getField("staticField")[0]));
 }
Ejemplo n.º 18
0
 public void execute_internal(EditorContext editorContext, SNode node) {
   SNode selected = editorContext.getSelectedNode();
   if (SNodeOperations.isInstanceOf(
           selected,
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x57d533a7af15ed3bL,
               "jetbrains.mps.baseLanguage.structure.CommentPart"))
       && SNodeOperations.isInstanceOf(
           SNodeOperations.getParent(selected),
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x57d533a7af15ed3aL,
               "jetbrains.mps.baseLanguage.structure.SingleLineComment"))
       && !(ListSequence.fromList(
               SLinkOperations.getChildren(
                   node,
                   MetaAdapterFactory.getContainmentLink(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x57d533a7af15ed3aL,
                       0x57d533a7af16ff73L,
                       "commentPart")))
           .contains(
               SNodeOperations.cast(
                   selected,
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x57d533a7af15ed3bL,
                       "jetbrains.mps.baseLanguage.structure.CommentPart"))))) {
     SNode prevLine =
         SNodeOperations.cast(
             SNodeOperations.getParent(selected),
             MetaAdapterFactory.getConcept(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0x57d533a7af15ed3aL,
                 "jetbrains.mps.baseLanguage.structure.SingleLineComment"));
     ListSequence.fromList(
             SLinkOperations.getChildren(
                 prevLine,
                 MetaAdapterFactory.getContainmentLink(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0x57d533a7af15ed3aL,
                     0x57d533a7af16ff73L,
                     "commentPart")))
         .addSequence(
             ListSequence.fromList(
                 SLinkOperations.getChildren(
                     node,
                     MetaAdapterFactory.getContainmentLink(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0x57d533a7af15ed3aL,
                         0x57d533a7af16ff73L,
                         "commentPart"))));
     SNodeOperations.deleteNode(node);
     return;
   }
   if (SNodeOperations.isInstanceOf(
       ListSequence.fromList(
               SLinkOperations.getChildren(
                   node,
                   MetaAdapterFactory.getContainmentLink(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x57d533a7af15ed3aL,
                       0x57d533a7af16ff73L,
                       "commentPart")))
           .first(),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x57d533a7af16ff67L,
           "jetbrains.mps.baseLanguage.structure.StatementCommentPart"))) {
     SNodeOperations.replaceWithAnother(
         node,
         SLinkOperations.getTarget(
             SNodeOperations.cast(
                 ListSequence.fromList(
                         SLinkOperations.getChildren(
                             node,
                             MetaAdapterFactory.getContainmentLink(
                                 0xf3061a5392264cc5L,
                                 0xa443f952ceaf5816L,
                                 0x57d533a7af15ed3aL,
                                 0x57d533a7af16ff73L,
                                 "commentPart")))
                     .first(),
                 MetaAdapterFactory.getConcept(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0x57d533a7af16ff67L,
                     "jetbrains.mps.baseLanguage.structure.StatementCommentPart")),
             MetaAdapterFactory.getContainmentLink(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0x57d533a7af16ff67L,
                 0x57d533a7af16ff68L,
                 "commentedStatement")));
     return;
   }
   if (SNodeOperations.isInstanceOf(
           selected,
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x57d533a7af15ed3aL,
               "jetbrains.mps.baseLanguage.structure.SingleLineComment"))
       && SNodeOperations.isInstanceOf(
           SNodeOperations.getPrevSibling(selected),
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x57d533a7af15ed3aL,
               "jetbrains.mps.baseLanguage.structure.SingleLineComment"))) {
     // if we got 'delete' for whole comment (not CommentPart), and this map is attached to
     // double slash
     // constant, it's likely we got 'Del' or 'Backspace' (no way to tell one from another)
     // pressed over
     // double slash constant. Try to join comment lines then.
     SNode prevLine =
         SNodeOperations.cast(
             SNodeOperations.getPrevSibling(selected),
             MetaAdapterFactory.getConcept(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0x57d533a7af15ed3aL,
                 "jetbrains.mps.baseLanguage.structure.SingleLineComment"));
     ListSequence.fromList(
             SLinkOperations.getChildren(
                 prevLine,
                 MetaAdapterFactory.getContainmentLink(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0x57d533a7af15ed3aL,
                     0x57d533a7af16ff73L,
                     "commentPart")))
         .addSequence(
             ListSequence.fromList(
                 SLinkOperations.getChildren(
                     node,
                     MetaAdapterFactory.getContainmentLink(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0x57d533a7af15ed3aL,
                         0x57d533a7af16ff73L,
                         "commentPart"))));
     SNodeOperations.deleteNode(node);
   }
 }
 public void execute(SNode node) {
   SNodeOperations.deleteNode(
       ((SNode) Remove_empty_unless_block_QuickFix.this.getField("node")[0]));
 }
 @Override
 public void execute(final SNode node, final EditorContext editorContext) {
   {
     GeneratedMatchingPattern pattern_6isygg_a0a =
         new IterateOverIterable_Intention.Pattern_w1n2qe_a0a0a0a2h();
     SNode coercedNode_6isygg_a0a =
         TypeChecker.getInstance()
             .getRuntimeSupport()
             .coerce_(
                 TypeChecker.getInstance()
                     .getTypeOf(
                         SLinkOperations.getTarget(
                             node,
                             MetaAdapterFactory.getContainmentLink(
                                 0xf3061a5392264cc5L,
                                 0xa443f952ceaf5816L,
                                 0xf8cc56b213L,
                                 0xf8cc56b214L,
                                 "expression"))),
                 pattern_6isygg_a0a);
     if (coercedNode_6isygg_a0a != null) {
       SNode foreachStatement =
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x10a6933ce33L,
                       "jetbrains.mps.baseLanguage.structure.ForeachStatement")),
               null);
       SNode variableDeclaration =
           SNodeFactoryOperations.setNewChild(
               foreachStatement,
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x10a697996feL,
                   0x10a6979f36bL,
                   "variable"),
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf8cc67c7efL,
                       "jetbrains.mps.baseLanguage.structure.LocalVariableDeclaration")));
       SLinkOperations.setTarget(
           variableDeclaration,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x450368d90ce15bc3L,
               0x4ed4d318133c80ceL,
               "type"),
           SNodeOperations.copyNode(
               ((SNode) pattern_6isygg_a0a.getFieldValue("patternVar_elem"))));
       SPropertyOperations.set(
           variableDeclaration,
           MetaAdapterFactory.getProperty(
               0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"),
           NameUtil.toValidIdentifier(
               BaseConcept_BehaviorDescriptor.getPresentation_idhEwIMiw.invoke(
                   ((SNode) pattern_6isygg_a0a.getFieldValue("patternVar_elem")))));
       SLinkOperations.setTarget(
           foreachStatement,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x10a6933ce33L,
               0x10a6934ab66L,
               "iterable"),
           SNodeOperations.copyNode(
               SLinkOperations.getTarget(
                   node,
                   MetaAdapterFactory.getContainmentLink(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf8cc56b213L,
                       0xf8cc56b214L,
                       "expression"))));
       SNodeOperations.insertNextSiblingChild(node, foreachStatement);
       SNodeOperations.deleteNode(node);
     } else {
     }
   }
 }
  private static NodeCaretPair smartDelete_id7PYAiugbmRz(
      @NotNull SNode __thisNode__, boolean isBeginning) {
    SNode line =
        SNodeOperations.cast(
            SNodeOperations.getParent(__thisNode__),
            MetaAdapterFactory.getConcept(
                0xf280165065d5424eL,
                0xbb1b463a8781b786L,
                0x757ba20a4c87f96cL,
                "jetbrains.mps.baseLanguage.javadoc.structure.CommentLine"));
    int index = SNodeOperations.getIndexInParent(__thisNode__);
    Iterable<SNode> lines =
        SLinkOperations.getChildren(
            __thisNode__,
            MetaAdapterFactory.getContainmentLink(
                0xf280165065d5424eL,
                0xbb1b463a8781b786L,
                0x5bc4aa08e154b399L,
                0x5bc4aa08e154b39bL,
                "line"));

    SNode nodeToSelect = null;
    int caret = -1;

    if (Sequence.fromIterable(lines).isEmpty()) {
      SNode prev = SNodeOperations.getPrevSibling(__thisNode__);
      if (isNotEmptyString(
          SPropertyOperations.getString(
              SNodeOperations.cast(
                  prev,
                  MetaAdapterFactory.getConcept(
                      0xf280165065d5424eL,
                      0xbb1b463a8781b786L,
                      0x7c7f5b2f31990287L,
                      "jetbrains.mps.baseLanguage.javadoc.structure.TextCommentLinePart")),
              MetaAdapterFactory.getProperty(
                  0xf280165065d5424eL,
                  0xbb1b463a8781b786L,
                  0x7c7f5b2f31990287L,
                  0x7c7f5b2f31990288L,
                  "text")))) {
        caret =
            SPropertyOperations.getString(
                    SNodeOperations.cast(
                        prev,
                        MetaAdapterFactory.getConcept(
                            0xf280165065d5424eL,
                            0xbb1b463a8781b786L,
                            0x7c7f5b2f31990287L,
                            "jetbrains.mps.baseLanguage.javadoc.structure.TextCommentLinePart")),
                    MetaAdapterFactory.getProperty(
                        0xf280165065d5424eL,
                        0xbb1b463a8781b786L,
                        0x7c7f5b2f31990287L,
                        0x7c7f5b2f31990288L,
                        "text"))
                .length();
      }
      SNodeOperations.deleteNode(__thisNode__);
      CommentLine_BehaviorDescriptor.tryMergeToRight_idooaTF_3fF3.invoke(line, index - 1);
      return new NodeCaretPair(prev, caret);
    } else {
      //  Merging first line
      for (SNode part :
          ListSequence.fromList(
              SLinkOperations.getChildren(
                  ListSequence.fromList(
                          SLinkOperations.getChildren(
                              __thisNode__,
                              MetaAdapterFactory.getContainmentLink(
                                  0xf280165065d5424eL,
                                  0xbb1b463a8781b786L,
                                  0x5bc4aa08e154b399L,
                                  0x5bc4aa08e154b39bL,
                                  "line")))
                      .first(),
                  MetaAdapterFactory.getContainmentLink(
                      0xf280165065d5424eL,
                      0xbb1b463a8781b786L,
                      0x757ba20a4c87f96cL,
                      0x7c7f5b2f3199028dL,
                      "part")))) {
        SNodeOperations.insertPrevSiblingChild(__thisNode__, part);
      }
      SNodeOperations.deleteNode(
          ListSequence.fromList(
                  SLinkOperations.getChildren(
                      __thisNode__,
                      MetaAdapterFactory.getContainmentLink(
                          0xf280165065d5424eL,
                          0xbb1b463a8781b786L,
                          0x5bc4aa08e154b399L,
                          0x5bc4aa08e154b39bL,
                          "line")))
              .first());
      if (isBeginning) {
        nodeToSelect =
            ListSequence.fromList(
                    SLinkOperations.getChildren(
                        line,
                        MetaAdapterFactory.getContainmentLink(
                            0xf280165065d5424eL,
                            0xbb1b463a8781b786L,
                            0x757ba20a4c87f96cL,
                            0x7c7f5b2f3199028dL,
                            "part")))
                .getElement(index - 1);
        caret =
            SPropertyOperations.getString(
                    SNodeOperations.cast(
                        ListSequence.fromList(
                                SLinkOperations.getChildren(
                                    line,
                                    MetaAdapterFactory.getContainmentLink(
                                        0xf280165065d5424eL,
                                        0xbb1b463a8781b786L,
                                        0x757ba20a4c87f96cL,
                                        0x7c7f5b2f3199028dL,
                                        "part")))
                            .getElement(index - 1),
                        MetaAdapterFactory.getConcept(
                            0xf280165065d5424eL,
                            0xbb1b463a8781b786L,
                            0x7c7f5b2f31990287L,
                            "jetbrains.mps.baseLanguage.javadoc.structure.TextCommentLinePart")),
                    MetaAdapterFactory.getProperty(
                        0xf280165065d5424eL,
                        0xbb1b463a8781b786L,
                        0x7c7f5b2f31990287L,
                        0x7c7f5b2f31990288L,
                        "text"))
                .length();
      }
      CommentLine_BehaviorDescriptor.tryMergeToRight_idooaTF_3fF3.invoke(line, index - 1);

      //  Merging other lines
      SNode lastElementLine =
          ListSequence.fromList(
                  SLinkOperations.getChildren(
                      __thisNode__,
                      MetaAdapterFactory.getContainmentLink(
                          0xf280165065d5424eL,
                          0xbb1b463a8781b786L,
                          0x5bc4aa08e154b399L,
                          0x5bc4aa08e154b39bL,
                          "line")))
              .last();
      for (SNode elementLine :
          ListSequence.fromList(
                  SLinkOperations.getChildren(
                      __thisNode__,
                      MetaAdapterFactory.getContainmentLink(
                          0xf280165065d5424eL,
                          0xbb1b463a8781b786L,
                          0x5bc4aa08e154b399L,
                          0x5bc4aa08e154b39bL,
                          "line")))
              .reversedList()) {
        SNodeOperations.insertNextSiblingChild(line, elementLine);
      }

      if ((lastElementLine == null)) {
        index = SNodeOperations.getIndexInParent(__thisNode__);
        SNodeOperations.deleteNode(__thisNode__);
        if (!(isBeginning)) {
          nodeToSelect =
              ListSequence.fromList(
                      SLinkOperations.getChildren(
                          line,
                          MetaAdapterFactory.getContainmentLink(
                              0xf280165065d5424eL,
                              0xbb1b463a8781b786L,
                              0x757ba20a4c87f96cL,
                              0x7c7f5b2f3199028dL,
                              "part")))
                  .getElement(index - 1);
          caret =
              SPropertyOperations.getString(
                      SNodeOperations.cast(
                          ListSequence.fromList(
                                  SLinkOperations.getChildren(
                                      line,
                                      MetaAdapterFactory.getContainmentLink(
                                          0xf280165065d5424eL,
                                          0xbb1b463a8781b786L,
                                          0x757ba20a4c87f96cL,
                                          0x7c7f5b2f3199028dL,
                                          "part")))
                              .getElement(index - 1),
                          MetaAdapterFactory.getConcept(
                              0xf280165065d5424eL,
                              0xbb1b463a8781b786L,
                              0x7c7f5b2f31990287L,
                              "jetbrains.mps.baseLanguage.javadoc.structure.TextCommentLinePart")),
                      MetaAdapterFactory.getProperty(
                          0xf280165065d5424eL,
                          0xbb1b463a8781b786L,
                          0x7c7f5b2f31990287L,
                          0x7c7f5b2f31990288L,
                          "text"))
                  .length();
        }
        CommentLine_BehaviorDescriptor.tryMergeToRight_idooaTF_3fF3.invoke(line, index - 1);
      } else {
        //  Merging last line parts
        index =
            ListSequence.fromList(
                        SLinkOperations.getChildren(
                            lastElementLine,
                            MetaAdapterFactory.getContainmentLink(
                                0xf280165065d5424eL,
                                0xbb1b463a8781b786L,
                                0x757ba20a4c87f96cL,
                                0x7c7f5b2f3199028dL,
                                "part")))
                    .count()
                - 1;
        for (SNode linePart :
            ListSequence.fromList(SNodeOperations.getNextSiblings(__thisNode__, false))) {
          ListSequence.fromList(
                  SLinkOperations.getChildren(
                      lastElementLine,
                      MetaAdapterFactory.getContainmentLink(
                          0xf280165065d5424eL,
                          0xbb1b463a8781b786L,
                          0x757ba20a4c87f96cL,
                          0x7c7f5b2f3199028dL,
                          "part")))
              .addElement(
                  SNodeOperations.cast(
                      linePart,
                      MetaAdapterFactory.getConcept(
                          0xf280165065d5424eL,
                          0xbb1b463a8781b786L,
                          0x7c7f5b2f31990286L,
                          "jetbrains.mps.baseLanguage.javadoc.structure.CommentLinePart")));
        }
        SNodeOperations.deleteNode(__thisNode__);
        if (!(isBeginning)) {
          nodeToSelect =
              ListSequence.fromList(
                      SLinkOperations.getChildren(
                          lastElementLine,
                          MetaAdapterFactory.getContainmentLink(
                              0xf280165065d5424eL,
                              0xbb1b463a8781b786L,
                              0x757ba20a4c87f96cL,
                              0x7c7f5b2f3199028dL,
                              "part")))
                  .getElement(index);
          caret =
              SPropertyOperations.getString(
                      SNodeOperations.cast(
                          ListSequence.fromList(
                                  SLinkOperations.getChildren(
                                      lastElementLine,
                                      MetaAdapterFactory.getContainmentLink(
                                          0xf280165065d5424eL,
                                          0xbb1b463a8781b786L,
                                          0x757ba20a4c87f96cL,
                                          0x7c7f5b2f3199028dL,
                                          "part")))
                              .getElement(index),
                          MetaAdapterFactory.getConcept(
                              0xf280165065d5424eL,
                              0xbb1b463a8781b786L,
                              0x7c7f5b2f31990287L,
                              "jetbrains.mps.baseLanguage.javadoc.structure.TextCommentLinePart")),
                      MetaAdapterFactory.getProperty(
                          0xf280165065d5424eL,
                          0xbb1b463a8781b786L,
                          0x7c7f5b2f31990287L,
                          0x7c7f5b2f31990288L,
                          "text"))
                  .length();
        }
        CommentLine_BehaviorDescriptor.tryMergeToRight_idooaTF_3fF3.invoke(lastElementLine, index);
      }
    }
    return new NodeCaretPair(nodeToSelect, caret);
  }
Ejemplo n.º 22
0
 public void execute_internal(EditorContext editorContext, SNode node) {
   SNode nodeToSelect = SNodeOperations.getParent(node);
   SNodeOperations.deleteNode(node);
   SelectionUtil.selectCell(editorContext, nodeToSelect, SelectionManager.FIRST_EDITABLE_CELL);
 }