@Override
 public void addMethod(SNode method) {
   if (SNodeOperations.getConceptDeclaration(this.getContainerMethod())
       == SNodeOperations.getConceptDeclaration(method)) {
     SNodeOperations.insertNextSiblingChild(this.getContainerMethod(), method);
   } else {
     super.addMethod(method);
   }
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode ifStatement =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.baseLanguage.structure.IfStatement", null);
   List<SNode> selectedNodes = editorContext.getSelectedNodes();
   SNodeOperations.insertNextSiblingChild(
       ListSequence.fromList(selectedNodes).last(), ifStatement);
   for (SNode selectedNode : ListSequence.fromList(selectedNodes)) {
     ListSequence.fromList(
             SLinkOperations.getTargets(
                 SLinkOperations.getTarget(ifStatement, "ifTrue", true), "statement", true))
         .addElement(
             SNodeOperations.getAncestor(
                 selectedNode, "jetbrains.mps.baseLanguage.structure.Statement", true, false));
   }
   editorContext.select(SLinkOperations.getTarget(ifStatement, "condition", true));
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode result =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.lang.editor.structure.CellModel_Collection", null);
   SLinkOperations.setTarget(
       result,
       "cellLayout",
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.lang.editor.structure.CellLayout_Horizontal", null),
       true);
   List<SNode> nodes = editorContext.getSelectedNodes();
   SNodeOperations.insertNextSiblingChild(ListSequence.fromList(nodes).last(), result);
   for (SNode sn : nodes) {
     ListSequence.fromList(SLinkOperations.getTargets(result, "childCellModel", true))
         .addElement(
             SNodeOperations.cast(sn, "jetbrains.mps.lang.editor.structure.EditorCellModel"));
   }
 }
 @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);
  }