public void execute(final SNode node, final EditorContext editorContext) {
      SNode templateNode =
          SNodeFactoryOperations.createNewRootNode(
              SNodeOperations.getModel(node),
              "jetbrains.mps.lang.generator.structure.TemplateDeclaration",
              null);
      SNode ruleNode =
          SNodeOperations.getAncestor(
              node, "jetbrains.mps.lang.generator.structure.BaseMappingRule", false, false);
      SLinkOperations.setTarget(
          templateNode,
          "applicableConcept",
          SLinkOperations.getTarget(ruleNode, "applicableConcept", false),
          false);
      SPropertyOperations.set(templateNode, "name", "template1");
      SLinkOperations.setTarget(
          templateNode, "contentNode", SLinkOperations.getTarget(node, "templateNode", true), true);
      SPropertyOperations.set(
          templateNode,
          "virtualPackage",
          SPropertyOperations.getString(SNodeOperations.getContainingRoot(node), "virtualPackage"));

      SNode templateRefNode =
          SNodeFactoryOperations.replaceWithNewChild(
              node, "jetbrains.mps.lang.generator.structure.TemplateDeclarationReference");
      SLinkOperations.setTarget(templateRefNode, "template", templateNode, false);

      SelectionUtil.selectNode(editorContext, templateNode);
    }
Example #2
0
 @Override
 public void execute(@NotNull String pattern) {
   final SNode result =
       SNodeFactoryOperations.createNewNode(
           SNodeFactoryOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x11adecdb4f0L,
                   "jetbrains.mps.baseLanguage.structure.PostfixIncrementExpression")),
           null);
   SLinkOperations.setTarget(
       result,
       MetaAdapterFactory.getContainmentLink(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x120a4c1f269L,
           0x120a4c433a6L,
           "expression"),
       SNodeOperations.copyNode(_context.getNode()));
   SNodeOperations.replaceWithAnother(_context.getNode(), result);
   SelectionUtil.selectLabelCellAnSetCaret(
       _context.getEditorContext(), result, SelectionManager.LAST_CELL, -1);
   return;
 }
Example #3
0
 @Override
 public void execute(@NotNull String pattern) {
   ListSequence.fromList(
           SLinkOperations.getChildren(
               _context.getNode(),
               MetaAdapterFactory.getContainmentLink(
                   0x698a8d22a10447a0L,
                   0xba8d10e3ec237f13L,
                   0x2670d5989d5a6275L,
                   0x2670d5989d5b4a01L,
                   "after")))
       .addElement(
           SModelOperations.createNewNode(
               _context.getModel(),
               null,
               MetaAdapterFactory.getConcept(
                   0x698a8d22a10447a0L,
                   0xba8d10e3ec237f13L,
                   0x2670d5989d5b49b8L,
                   "jetbrains.mps.build.workflow.structure.BwfSubTaskDependency")));
   SelectionUtil.selectLabelCellAnSetCaret(
       _context.getEditorContext(),
       _context.getNode(),
       SelectionManager.FIRST_ERROR_CELL
           + "|"
           + SelectionManager.FOCUS_POLICY_CELL
           + "|"
           + SelectionManager.FIRST_EDITABLE_CELL
           + "|"
           + SelectionManager.FIRST_CELL,
       -1);
 }
 protected void execute(
     SNode targetNode,
     SubstituteMenuItem item,
     TransformationMenuContext _context,
     String pattern) {
   SNode createdNode = item.createNode(pattern);
   SelectionUtil.selectLabelCellAnSetCaret(
       _context.getEditorContext(),
       PrecedenceUtil.processLeftTransform(
           SNodeOperations.cast(
               targetNode,
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0xf8c37f506fL,
                   "jetbrains.mps.baseLanguage.structure.Expression")),
           createdNode),
       SelectionManager.FIRST_ERROR_CELL
           + "|"
           + SelectionManager.FOCUS_POLICY_CELL
           + "|"
           + SelectionManager.FIRST_EDITABLE_CELL
           + "|"
           + SelectionManager.FIRST_CELL,
       -1);
 }
Example #5
0
 public void handleAction_impl(
     SNode parameterObject,
     SNode node,
     SModel model,
     IOperationContext operationContext,
     EditorContext editorContext) {
   SNode macro =
       SNodeFactoryOperations.createNewNode(NameUtil.nodeFQName(parameterObject), node);
   SNodeOperations.replaceWithAnother(node, macro);
   SelectionUtil.selectLabelCellAnSetCaret(editorContext, macro, SelectionManager.FIRST_CELL, 1);
   editorContext.openInspector();
 }
 @Override
 public void execute(@NotNull String pattern) {
   SNodeFactoryOperations.addNewChild(
       SNodeOperations.cast(
           SNodeOperations.getParent(_context.getNode()),
           MetaAdapterFactory.getConcept(
               0xfd3920347849419dL,
               0x907112563d152375L,
               0x1174a4d19ffL,
               "jetbrains.mps.baseLanguage.closures.structure.FunctionType")),
       MetaAdapterFactory.getContainmentLink(
           0xfd3920347849419dL,
           0x907112563d152375L,
           0x1174a4d19ffL,
           0x11ad99d9c36L,
           "throwsType"),
       SNodeFactoryOperations.asInstanceConcept(
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xf8c37f506dL,
               "jetbrains.mps.baseLanguage.structure.Type")));
   SelectionUtil.selectLabelCellAnSetCaret(
       _context.getEditorContext(),
       ListSequence.fromList(
               SLinkOperations.getChildren(
                   SNodeOperations.cast(
                       SNodeOperations.getParent(_context.getNode()),
                       MetaAdapterFactory.getConcept(
                           0xfd3920347849419dL,
                           0x907112563d152375L,
                           0x1174a4d19ffL,
                           "jetbrains.mps.baseLanguage.closures.structure.FunctionType")),
                   MetaAdapterFactory.getContainmentLink(
                       0xfd3920347849419dL,
                       0x907112563d152375L,
                       0x1174a4d19ffL,
                       0x11ad99d9c36L,
                       "throwsType")))
           .first(),
       SelectionManager.FIRST_ERROR_CELL
           + "|"
           + SelectionManager.FOCUS_POLICY_CELL
           + "|"
           + SelectionManager.FIRST_EDITABLE_CELL
           + "|"
           + SelectionManager.FIRST_CELL,
       -1);
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode newAnnotation =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.lang.test.structure.NodeOperationsContainer", null);
   AttributeOperations.setAttribute(
       node,
       new IAttributeDescriptor.NodeAttribute(
           "jetbrains.mps.lang.test.structure.NodeOperationsContainer"),
       newAnnotation);
   SNode warningCheck =
       SConceptOperations.createNewNode(
           "jetbrains.mps.lang.test.structure.NodeWarningCheckOperation", null);
   ListSequence.fromList(SLinkOperations.getTargets(newAnnotation, "nodeOperations", true))
       .addElement(warningCheck);
   SelectionUtil.selectCell(editorContext, warningCheck, SelectionManager.LAST_EDITABLE_CELL);
 }
 @Override
 public void execute(@NotNull String pattern) {
   SelectionUtil.selectLabelCellAnSetCaret(
       _context.getEditorContext(),
       SNodeFactoryOperations.replaceWithNewChild(
           _context.getNode(),
           SNodeFactoryOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0xf3347d8a0e794f35L,
                   0x8ac91574f25c986fL,
                   0x87f99370d7e1ea3L,
                   "jetbrains.mps.execution.commands.structure.CommandProcessType"))),
       SelectionManager.FIRST_ERROR_CELL
           + "|"
           + SelectionManager.FOCUS_POLICY_CELL
           + "|"
           + SelectionManager.FIRST_EDITABLE_CELL
           + "|"
           + SelectionManager.FIRST_CELL,
       -1);
 }
  public void execute(EditorContext editorContext) {
    EditorCell selectedCell = editorContext.getSelectedCell();
    if (selectedCell == null) {
      return;
    }
    final String cellId = selectedCell.getCellId();
    SNode actualSelectedNode = selectedCell.getSNode();
    boolean isLabel = selectedCell instanceof EditorCell_Label;
    int startPosition = (isLabel ? ((EditorCell_Label) selectedCell).getSelectionStart() : -1);
    int endPosition = (isLabel ? ((EditorCell_Label) selectedCell).getSelectionEnd() : -1);
    SNode nodeToSelect = CommentUtil.commentOut(myNode);
    editorContext.flushEvents();
    if (cellId != null) {
      EditorCell newNodeCell = editorContext.getEditorComponent().findNodeCell(actualSelectedNode);
      if (newNodeCell != null) {
        EditorCell cellToSelect =
            CellFinderUtil.findChildByCondition(
                newNodeCell,
                new Condition<EditorCell>() {
                  public boolean met(EditorCell cell) {
                    return eq_9lx3n0_a0a0a0a1a0a0b0j0h(cell.getCellId(), cellId);
                  }
                },
                true,
                true);
        if (cellToSelect != null) {
          if (isLabel) {
            editorContext
                .getSelectionManager()
                .setSelection(actualSelectedNode, cellId, startPosition, endPosition);
          } else {
            editorContext.getSelectionManager().setSelection(actualSelectedNode, cellId);
          }

          return;
        }
      }
    }
    SelectionUtil.selectCell(editorContext, nodeToSelect, SelectionManager.LAST_EDITABLE_CELL);
  }
 @Override
 public void execute(@NotNull String pattern) {
   SNode method =
       SNodeOperations.cast(
           SNodeOperations.getParent(_context.getNode()),
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xf8cc56b21dL,
               "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration"));
   SPropertyOperations.set(
       method,
       MetaAdapterFactory.getProperty(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0xf8cc56b21dL,
           0x1126a8d157dL,
           "isAbstract"),
       "" + (true));
   SelectionUtil.selectLabelCellAnSetCaret(
       _context.getEditorContext(), method, "abstractModifier", -1);
 }
 @Override
 public void execute(@NotNull String pattern) {
   SNode method =
       SNodeOperations.cast(
           SNodeOperations.getParent(_context.getNode()),
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x6c6b6a1e379f9408L,
               "jetbrains.mps.baseLanguage.structure.MethodDeclaration"));
   SPropertyOperations.set(
       method,
       MetaAdapterFactory.getProperty(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x6c6b6a1e379f9408L,
           0x73f30e3df95c0b73L,
           "isNative"),
       "" + (true));
   SelectionUtil.selectLabelCellAnSetCaret(
       _context.getEditorContext(), method, "nativeModifier", -1);
 }
        @Override
        public void execute(@NotNull String pattern) {
          SNode method =
              SNodeOperations.cast(
                  SNodeOperations.getParent(_context.getNode()),
                  MetaAdapterFactory.getConcept(
                      0xf3061a5392264cc5L,
                      0xa443f952ceaf5816L,
                      0xf8cc56b21dL,
                      "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration"));
          SNode staticMethod =
              SNodeFactoryOperations.replaceWithNewChild(
                  method,
                  SNodeFactoryOperations.asInstanceConcept(
                      MetaAdapterFactory.getConcept(
                          0xf3061a5392264cc5L,
                          0xa443f952ceaf5816L,
                          0xfbbebabf0aL,
                          "jetbrains.mps.baseLanguage.structure.StaticMethodDeclaration")));
          MemberDeclarationRefactoringUtil.rewireMethodReferences(method, staticMethod);

          SelectionUtil.selectLabelCellAnSetCaret(
              _context.getEditorContext(), staticMethod, "staticModifier", -1);
        }
 public void execute_internal(EditorContext editorContext, SNode node) {
   SNode nodeToSelect = SNodeOperations.getParent(node);
   SNodeOperations.deleteNode(node);
   SelectionUtil.selectCell(editorContext, nodeToSelect, SelectionManager.FIRST_EDITABLE_CELL);
 }