public void execute(SNode node) {
   SNode expr =
       SNodeOperations.cast(
           node,
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xf8c37f506fL,
               "jetbrains.mps.baseLanguage.structure.Expression"));
   Object value =
       Expression__BehaviorDescriptor.getCompileTimeConstantValue_idi1LP2xI.invoke(
           expr, SNodeOperations.getModel(expr).getModule());
   if (value instanceof Boolean) {
     SNode v =
         SNodeFactoryOperations.replaceWithNewChild(
             expr,
             SNodeFactoryOperations.asInstanceConcept(
                 MetaAdapterFactory.getConcept(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0xf8cc56b201L,
                     "jetbrains.mps.baseLanguage.structure.BooleanConstant")));
     SPropertyOperations.set(
         v,
         MetaAdapterFactory.getProperty(
             0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b201L, 0xf8cc56b202L, "value"),
         "" + (((Boolean) value).booleanValue()));
   }
 }
 @Override
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode newLine =
       SNodeFactoryOperations.createNewNode(
           SNodeFactoryOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0x18bc659203a64e29L,
                   0xa83a7ff23bde13baL,
                   0x120154df6f3L,
                   "jetbrains.mps.lang.editor.structure.IndentLayoutNewLineStyleClassItem")),
           null);
   SPropertyOperations.set(
       newLine,
       MetaAdapterFactory.getProperty(
           0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x1143bd1283bL, 0x1143bd161dbL, "flag"),
       "" + (true));
   ListSequence.fromList(
           SLinkOperations.getChildren(
               node,
               MetaAdapterFactory.getContainmentLink(
                   0x18bc659203a64e29L,
                   0xa83a7ff23bde13baL,
                   0x11beb039542L,
                   0x11beb040d06L,
                   "styleItem")))
       .addElement(newLine);
 }
Exemple #3
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;
 }
 public SNode nodeFactory(SNode node, EditorContext editorContext) {
   return SNodeFactoryOperations.createNewNode(
       SNodeFactoryOperations.asInstanceConcept(
           MetaAdapterFactory.getConcept(
               0xf280165065d5424eL,
               0xbb1b463a8781b786L,
               0x44ac82392ce5c6b0L,
               "jetbrains.mps.baseLanguage.javadoc.structure.EmptyBlockDocTag")),
       null);
 }
Exemple #5
0
 @Override
 public void execute(@NotNull String pattern) {
   SNodeOperations.insertPrevSiblingChild(
       _context.getNode(),
       SNodeFactoryOperations.createNewNode(
           SNodeFactoryOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0x49a08c51fe543ccL,
                   0xbd998b46d641d7f5L,
                   0x58e59ea713f79f27L,
                   "jetbrains.mps.samples.Kaja.structure.Drop")),
           null));
 }
 public void handleAction(
     SNode node, SModel model, IOperationContext operationContext, EditorContext editorContext) {
   SNodeFactoryOperations.setNewChild(
       node,
       MetaAdapterFactory.getContainmentLink(
           0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x1143bd837d7L, 0x11c5653e86eL, "query"),
       SNodeFactoryOperations.asInstanceConcept(
           MetaAdapterFactory.getConcept(
               0x18bc659203a64e29L,
               0xa83a7ff23bde13baL,
               0x11c4d022befL,
               "jetbrains.mps.lang.editor.structure.QueryFunction_Underlined")));
 }
 @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);
 }
Exemple #8
0
 @Override
 public void execute(@NotNull String pattern) {
   SNode inserted =
       SNodeOperations.insertPrevSiblingChild(
           _context.getNode(),
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0x49a08c51fe543ccL,
                       0xbd998b46d641d7f5L,
                       0x3cfcda239f1a1049L,
                       "jetbrains.mps.samples.Kaja.structure.Require")),
               null));
   _context.getEditorContext().selectWRTFocusPolicy(inserted);
 }
 public void setup(SNode newNode, SNode sampleNode, SNode enclosingNode, SModel model) {
   SNodeFactoryOperations.addNewChild(
       newNode,
       MetaAdapterFactory.getContainmentLink(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x57d533a7af15ed3aL,
           0x57d533a7af16ff73L,
           "commentPart"),
       SNodeFactoryOperations.asInstanceConcept(
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x57d533a7af15ed3dL,
               "jetbrains.mps.baseLanguage.structure.TextCommentPart")));
 }
Exemple #10
0
 public void handleAction(
     SNode node, SModel model, IOperationContext operationContext, EditorContext editorContext) {
   SNodeFactoryOperations.setNewChild(
       node,
       MetaAdapterFactory.getContainmentLink(
           0x22e72e4c0f6946ceL,
           0x84036750153aa615L,
           0x6c55c13f5bc8e1ecL,
           0x5d457621242d8208L,
           "debuggerConfiguration"),
       SNodeFactoryOperations.asInstanceConcept(
           MetaAdapterFactory.getConcept(
               0xfbc142795e2a4c87L,
               0xa5d15f7061e6c456L,
               0x5d457621242d16f5L,
               "jetbrains.mps.debugger.api.lang.structure.DebuggerConfiguration")));
 }
 public SNode nodeFactory(SNode node, EditorContext editorContext) {
   SNode result =
       SNodeFactoryOperations.createNewNode(
           SNodeOperations.getModel(node),
           SNodeFactoryOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0xc72da2b97cce4447L,
                   0x8389f407dc1158b7L,
                   0xf979bd086aL,
                   "jetbrains.mps.lang.structure.structure.LinkDeclaration")),
           null);
   SPropertyOperations.set(
       result,
       MetaAdapterFactory.getProperty(
           0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0xf980556927L, "metaClass"),
       "reference");
   return result;
 }
 @Override
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode ifFalse =
       SLinkOperations.getTarget(
           node,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xf8cc56b217L,
               0xfc092b6b76L,
               "ifFalseStatement"));
   SLinkOperations.setTarget(
       node,
       MetaAdapterFactory.getContainmentLink(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0xf8cc56b217L,
           0xfc092b6b76L,
           "ifFalseStatement"),
       null);
   SNodeFactoryOperations.addNewChild(
       node,
       MetaAdapterFactory.getContainmentLink(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0xf8cc56b217L,
           0x118cecf1287L,
           "elsifClauses"),
       SNodeFactoryOperations.asInstanceConcept(
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x118ceceb41aL,
               "jetbrains.mps.baseLanguage.structure.ElsifClause")));
   SLinkOperations.setTarget(
       node,
       MetaAdapterFactory.getContainmentLink(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0xf8cc56b217L,
           0xfc092b6b76L,
           "ifFalseStatement"),
       ifFalse);
 }
 @Override
 public void execute(final SNode node, final EditorContext editorContext) {
   EditorCell_Property cell = (EditorCell_Property) editorContext.getSelectedCell();
   String propertyName = ((PropertyAccessor) cell.getModelAccessor()).getPropertyName();
   SNode cellNode = cell.getSNode();
   SNodeFactoryOperations.setNewAttribute(
       cellNode,
       new IAttributeDescriptor.PropertyAttribute(
           MetaAdapterFactory.getConcept(
               0xd4615e3bd6714ba9L,
               0xaf012b78369b0ba7L,
               0x108a9cb4795L,
               "jetbrains.mps.lang.pattern.structure.PropertyPatternVariableDeclaration"),
           propertyName),
       SNodeFactoryOperations.asInstanceConcept(
           MetaAdapterFactory.getConcept(
               0xd4615e3bd6714ba9L,
               0xaf012b78369b0ba7L,
               0x108a9cb4795L,
               "jetbrains.mps.lang.pattern.structure.PropertyPatternVariableDeclaration")));
 }
 @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);
 }
        @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);
        }
 @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 {
     }
   }
 }
 @Override
 public void execute(final SNode node, final EditorContext editorContext) {
   List<SNode> configs =
       SModelOperations.roots(
           SNodeOperations.getModel(node),
           MetaAdapterFactory.getConcept(
               0xb401a68083254110L,
               0x8fd384331ff25befL,
               0xff0bea0475L,
               "jetbrains.mps.lang.generator.structure.MappingConfiguration"));
   if (ListSequence.fromList(configs).count() > 1) {
     Iterable<SNode> sameVPackConfigs =
         ListSequence.fromList(configs)
             .where(
                 new IWhereFilter<SNode>() {
                   public boolean accept(SNode it) {
                     return EqualUtil.equals(
                         SPropertyOperations.getString(
                             it,
                             MetaAdapterFactory.getProperty(
                                 0xceab519525ea4f22L,
                                 0x9b92103b95ca8c0cL,
                                 0x10802efe25aL,
                                 0x115eca8579fL,
                                 "virtualPackage")),
                         SPropertyOperations.getString(
                             node,
                             MetaAdapterFactory.getProperty(
                                 0xceab519525ea4f22L,
                                 0x9b92103b95ca8c0cL,
                                 0x10802efe25aL,
                                 0x115eca8579fL,
                                 "virtualPackage")));
                   }
                 });
     if (Sequence.fromIterable(sameVPackConfigs).isNotEmpty()) {
       configs = Sequence.fromIterable(sameVPackConfigs).toListSequence();
     }
   }
   if (ListSequence.fromList(configs).count() > 1) {
     // TODO: let user to choose mapping config?
   }
   //  add new rule
   SNode rule =
       SNodeFactoryOperations.addNewChild(
           ListSequence.fromList(configs).first(),
           MetaAdapterFactory.getContainmentLink(
               0xb401a68083254110L,
               0x8fd384331ff25befL,
               0xff0bea0475L,
               0x10fbbe00519L,
               "createRootRule"),
           SNodeFactoryOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0xb401a68083254110L,
                   0x8fd384331ff25befL,
                   0x10fbbd5854aL,
                   "jetbrains.mps.lang.generator.structure.CreateRootRule")));
   SLinkOperations.setTarget(
       rule,
       MetaAdapterFactory.getReferenceLink(
           0xb401a68083254110L,
           0x8fd384331ff25befL,
           0x10fbbd5854aL,
           0x10fbbd5854dL,
           "templateNode"),
       node);
   //  open in editor
   NavigationSupport.getInstance()
       .openNode(editorContext.getOperationContext(), rule, true, true);
 }
 public static void migrate(SRepository repo, SNode node) {
   // todo try to remove duplication here
   SNode movePart =
       SNodeOperations.getNodeAncestor(
           node,
           MetaAdapterFactory.getConcept(
               0x9074634404fd4286L,
               0x97d5b46ae6a81709L,
               0x67236d4a5830221eL,
               "jetbrains.mps.lang.migration.structure.MoveNodeMigrationPart"),
           false,
           false);
   if (SNodeOperations.isInstanceOf(
       node,
       MetaAdapterFactory.getConcept(
           0x9074634404fd4286L,
           0x97d5b46ae6a81709L,
           0x2b3f57492c1741b6L,
           "jetbrains.mps.lang.migration.structure.MoveConcept"))) {
     SNode mc =
         SNodeOperations.cast(
             node,
             MetaAdapterFactory.getConcept(
                 0x9074634404fd4286L,
                 0x97d5b46ae6a81709L,
                 0x2b3f57492c1741b6L,
                 "jetbrains.mps.lang.migration.structure.MoveConcept"));
     SNode from =
         AbstractNodeReference__BehaviorDescriptor.tryToFindNode_id6szrkDoc2K7.invoke(
             SLinkOperations.getTarget(
                 movePart,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x67236d4a5830221eL,
                     0x67236d4a58343d15L,
                     "fromNode")),
             repo);
     SNode to =
         AbstractNodeReference__BehaviorDescriptor.tryToFindNode_id6szrkDoc2K7.invoke(
             SLinkOperations.getTarget(
                 movePart,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x67236d4a5830221eL,
                     0x67236d4a58343d17L,
                     "toNode")),
             repo);
     if ((SLinkOperations.getTarget(
                 mc,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x2b3f57492c1741b6L,
                     0x74cb131f590ad6eaL,
                     "sourceId"))
             == null)
         && (from != null)) {
       SLinkOperations.setTarget(
           mc,
           MetaAdapterFactory.getContainmentLink(
               0x9074634404fd4286L,
               0x97d5b46ae6a81709L,
               0x2b3f57492c1741b6L,
               0x74cb131f590ad6eaL,
               "sourceId"),
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0x7866978ea0f04cc7L,
                       0x81bc4d213d9375e1L,
                       0x5fea1eb9fefb6fe7L,
                       "jetbrains.mps.lang.smodel.structure.ConceptId")),
               null));
       ConceptId__BehaviorDescriptor.setConcept_id5ZE7FBYYR6j.invoke(
           SLinkOperations.getTarget(
               mc,
               MetaAdapterFactory.getContainmentLink(
                   0x9074634404fd4286L,
                   0x97d5b46ae6a81709L,
                   0x2b3f57492c1741b6L,
                   0x74cb131f590ad6eaL,
                   "sourceId")),
           MetaAdapterByDeclaration.getConcept(from));
     }
     if ((SLinkOperations.getTarget(
                 mc,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x2b3f57492c1741b6L,
                     0x74cb131f590ad6edL,
                     "targetId"))
             == null)
         && (to != null)) {
       SLinkOperations.setTarget(
           mc,
           MetaAdapterFactory.getContainmentLink(
               0x9074634404fd4286L,
               0x97d5b46ae6a81709L,
               0x2b3f57492c1741b6L,
               0x74cb131f590ad6edL,
               "targetId"),
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0x7866978ea0f04cc7L,
                       0x81bc4d213d9375e1L,
                       0x5fea1eb9fefb6fe7L,
                       "jetbrains.mps.lang.smodel.structure.ConceptId")),
               null));
       ConceptId__BehaviorDescriptor.setConcept_id5ZE7FBYYR6j.invoke(
           SLinkOperations.getTarget(
               mc,
               MetaAdapterFactory.getContainmentLink(
                   0x9074634404fd4286L,
                   0x97d5b46ae6a81709L,
                   0x2b3f57492c1741b6L,
                   0x74cb131f590ad6edL,
                   "targetId")),
           MetaAdapterByDeclaration.getConcept(to));
     }
     return;
   }
   if (SNodeOperations.isInstanceOf(
       node,
       MetaAdapterFactory.getConcept(
           0x9074634404fd4286L,
           0x97d5b46ae6a81709L,
           0x2b3f57492c1741baL,
           "jetbrains.mps.lang.migration.structure.MoveContainmentLink"))) {
     SNode mcl =
         SNodeOperations.cast(
             node,
             MetaAdapterFactory.getConcept(
                 0x9074634404fd4286L,
                 0x97d5b46ae6a81709L,
                 0x2b3f57492c1741baL,
                 "jetbrains.mps.lang.migration.structure.MoveContainmentLink"));
     SNode from =
         AbstractNodeReference__BehaviorDescriptor.tryToFindNode_id6szrkDoc2K7.invoke(
             SLinkOperations.getTarget(
                 movePart,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x67236d4a5830221eL,
                     0x67236d4a58343d15L,
                     "fromNode")),
             repo);
     SNode to =
         AbstractNodeReference__BehaviorDescriptor.tryToFindNode_id6szrkDoc2K7.invoke(
             SLinkOperations.getTarget(
                 movePart,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x67236d4a5830221eL,
                     0x67236d4a58343d17L,
                     "toNode")),
             repo);
     if ((SLinkOperations.getTarget(
                 mcl,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x2b3f57492c1741baL,
                     0x74cb131f592e8ab5L,
                     "sourceId"))
             == null)
         && (from != null)) {
       SLinkOperations.setTarget(
           mcl,
           MetaAdapterFactory.getContainmentLink(
               0x9074634404fd4286L,
               0x97d5b46ae6a81709L,
               0x2b3f57492c1741baL,
               0x74cb131f592e8ab5L,
               "sourceId"),
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0x7866978ea0f04cc7L,
                       0x81bc4d213d9375e1L,
                       0x74cb131f5923b6e7L,
                       "jetbrains.mps.lang.smodel.structure.ContainmentLinkId")),
               null));
       ContainmentLinkId__BehaviorDescriptor.setLink_id7jb4LXp8VsD.invoke(
           SLinkOperations.getTarget(
               mcl,
               MetaAdapterFactory.getContainmentLink(
                   0x9074634404fd4286L,
                   0x97d5b46ae6a81709L,
                   0x2b3f57492c1741baL,
                   0x74cb131f592e8ab5L,
                   "sourceId")),
           MetaAdapterByDeclaration.getContainmentLink(from));
     }
     if ((SLinkOperations.getTarget(
                 mcl,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x2b3f57492c1741baL,
                     0x74cb131f592e8ab6L,
                     "targetId"))
             == null)
         && (to != null)) {
       SLinkOperations.setTarget(
           mcl,
           MetaAdapterFactory.getContainmentLink(
               0x9074634404fd4286L,
               0x97d5b46ae6a81709L,
               0x2b3f57492c1741baL,
               0x74cb131f592e8ab6L,
               "targetId"),
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0x7866978ea0f04cc7L,
                       0x81bc4d213d9375e1L,
                       0x74cb131f5923b6e7L,
                       "jetbrains.mps.lang.smodel.structure.ContainmentLinkId")),
               null));
       ContainmentLinkId__BehaviorDescriptor.setLink_id7jb4LXp8VsD.invoke(
           SLinkOperations.getTarget(
               mcl,
               MetaAdapterFactory.getContainmentLink(
                   0x9074634404fd4286L,
                   0x97d5b46ae6a81709L,
                   0x2b3f57492c1741baL,
                   0x74cb131f592e8ab6L,
                   "targetId")),
           MetaAdapterByDeclaration.getContainmentLink(to));
     }
     return;
   }
   if (SNodeOperations.isInstanceOf(
       node,
       MetaAdapterFactory.getConcept(
           0x9074634404fd4286L,
           0x97d5b46ae6a81709L,
           0x2b3f57492c1741b7L,
           "jetbrains.mps.lang.migration.structure.MoveReferenceLink"))) {
     SNode mrl =
         SNodeOperations.cast(
             node,
             MetaAdapterFactory.getConcept(
                 0x9074634404fd4286L,
                 0x97d5b46ae6a81709L,
                 0x2b3f57492c1741b7L,
                 "jetbrains.mps.lang.migration.structure.MoveReferenceLink"));
     SNode from =
         AbstractNodeReference__BehaviorDescriptor.tryToFindNode_id6szrkDoc2K7.invoke(
             SLinkOperations.getTarget(
                 movePart,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x67236d4a5830221eL,
                     0x67236d4a58343d15L,
                     "fromNode")),
             repo);
     SNode to =
         AbstractNodeReference__BehaviorDescriptor.tryToFindNode_id6szrkDoc2K7.invoke(
             SLinkOperations.getTarget(
                 movePart,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x67236d4a5830221eL,
                     0x67236d4a58343d17L,
                     "toNode")),
             repo);
     if ((SLinkOperations.getTarget(
                 mrl,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x2b3f57492c1741b7L,
                     0x74cb131f592e8abdL,
                     "sourceId"))
             == null)
         && (from != null)) {
       SLinkOperations.setTarget(
           mrl,
           MetaAdapterFactory.getContainmentLink(
               0x9074634404fd4286L,
               0x97d5b46ae6a81709L,
               0x2b3f57492c1741b7L,
               0x74cb131f592e8abdL,
               "sourceId"),
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0x7866978ea0f04cc7L,
                       0x81bc4d213d9375e1L,
                       0x74cb131f5923b6ecL,
                       "jetbrains.mps.lang.smodel.structure.ReferenceLinkId")),
               null));
       ReferenceLinkId__BehaviorDescriptor.setReference_id7jb4LXp9a6q.invoke(
           SLinkOperations.getTarget(
               mrl,
               MetaAdapterFactory.getContainmentLink(
                   0x9074634404fd4286L,
                   0x97d5b46ae6a81709L,
                   0x2b3f57492c1741b7L,
                   0x74cb131f592e8abdL,
                   "sourceId")),
           MetaAdapterByDeclaration.getReferenceLink(from));
     }
     if ((SLinkOperations.getTarget(
                 mrl,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x2b3f57492c1741b7L,
                     0x74cb131f592e8abeL,
                     "targetId"))
             == null)
         && (to != null)) {
       SLinkOperations.setTarget(
           mrl,
           MetaAdapterFactory.getContainmentLink(
               0x9074634404fd4286L,
               0x97d5b46ae6a81709L,
               0x2b3f57492c1741b7L,
               0x74cb131f592e8abeL,
               "targetId"),
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0x7866978ea0f04cc7L,
                       0x81bc4d213d9375e1L,
                       0x74cb131f5923b6ecL,
                       "jetbrains.mps.lang.smodel.structure.ReferenceLinkId")),
               null));
       ReferenceLinkId__BehaviorDescriptor.setReference_id7jb4LXp9a6q.invoke(
           SLinkOperations.getTarget(
               mrl,
               MetaAdapterFactory.getContainmentLink(
                   0x9074634404fd4286L,
                   0x97d5b46ae6a81709L,
                   0x2b3f57492c1741b7L,
                   0x74cb131f592e8abeL,
                   "targetId")),
           MetaAdapterByDeclaration.getReferenceLink(to));
     }
     return;
   }
   if (SNodeOperations.isInstanceOf(
       node,
       MetaAdapterFactory.getConcept(
           0x9074634404fd4286L,
           0x97d5b46ae6a81709L,
           0x2b3f57492c1741b9L,
           "jetbrains.mps.lang.migration.structure.MoveProperty"))) {
     SNode mp =
         SNodeOperations.cast(
             node,
             MetaAdapterFactory.getConcept(
                 0x9074634404fd4286L,
                 0x97d5b46ae6a81709L,
                 0x2b3f57492c1741b9L,
                 "jetbrains.mps.lang.migration.structure.MoveProperty"));
     SNode from =
         AbstractNodeReference__BehaviorDescriptor.tryToFindNode_id6szrkDoc2K7.invoke(
             SLinkOperations.getTarget(
                 movePart,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x67236d4a5830221eL,
                     0x67236d4a58343d15L,
                     "fromNode")),
             repo);
     SNode to =
         AbstractNodeReference__BehaviorDescriptor.tryToFindNode_id6szrkDoc2K7.invoke(
             SLinkOperations.getTarget(
                 movePart,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x67236d4a5830221eL,
                     0x67236d4a58343d17L,
                     "toNode")),
             repo);
     if ((SLinkOperations.getTarget(
                 mp,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x2b3f57492c1741b9L,
                     0x74cb131f592e8ab9L,
                     "sourceId"))
             == null)
         && (from != null)) {
       SLinkOperations.setTarget(
           mp,
           MetaAdapterFactory.getContainmentLink(
               0x9074634404fd4286L,
               0x97d5b46ae6a81709L,
               0x2b3f57492c1741b9L,
               0x74cb131f592e8ab9L,
               "sourceId"),
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0x7866978ea0f04cc7L,
                       0x81bc4d213d9375e1L,
                       0x5fea1eb9fefc235cL,
                       "jetbrains.mps.lang.smodel.structure.PropertyId")),
               null));
       PropertyId__BehaviorDescriptor.setProperty_id5ZE7FBYZ2jW.invoke(
           SLinkOperations.getTarget(
               mp,
               MetaAdapterFactory.getContainmentLink(
                   0x9074634404fd4286L,
                   0x97d5b46ae6a81709L,
                   0x2b3f57492c1741b9L,
                   0x74cb131f592e8ab9L,
                   "sourceId")),
           MetaAdapterByDeclaration.getProperty(from));
     }
     if ((SLinkOperations.getTarget(
                 mp,
                 MetaAdapterFactory.getContainmentLink(
                     0x9074634404fd4286L,
                     0x97d5b46ae6a81709L,
                     0x2b3f57492c1741b9L,
                     0x74cb131f592e8abaL,
                     "targetId"))
             == null)
         && (to != null)) {
       SLinkOperations.setTarget(
           mp,
           MetaAdapterFactory.getContainmentLink(
               0x9074634404fd4286L,
               0x97d5b46ae6a81709L,
               0x2b3f57492c1741b9L,
               0x74cb131f592e8abaL,
               "targetId"),
           SNodeFactoryOperations.createNewNode(
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0x7866978ea0f04cc7L,
                       0x81bc4d213d9375e1L,
                       0x5fea1eb9fefc235cL,
                       "jetbrains.mps.lang.smodel.structure.PropertyId")),
               null));
       PropertyId__BehaviorDescriptor.setProperty_id5ZE7FBYZ2jW.invoke(
           SLinkOperations.getTarget(
               mp,
               MetaAdapterFactory.getContainmentLink(
                   0x9074634404fd4286L,
                   0x97d5b46ae6a81709L,
                   0x2b3f57492c1741b9L,
                   0x74cb131f592e8abaL,
                   "targetId")),
           MetaAdapterByDeclaration.getProperty(to));
     }
     return;
   }
   throw new IllegalArgumentException(
       "Unknown concept:" + SNodeOperations.getConcept(node).getName());
 }
 @Override
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode routineDefinition =
       SNodeFactoryOperations.createNewNode(
           SNodeFactoryOperations.asInstanceConcept(
               MetaAdapterFactory.getConcept(
                   0x49a08c51fe543ccL,
                   0xbd998b46d641d7f5L,
                   0x2de971c785ed6f79L,
                   "jetbrains.mps.samples.Kaja.structure.RoutineDefinition")),
           null);
   List<SNode> selectedNodes = editorContext.getSelectedNodes();
   ListSequence.fromList(
           SLinkOperations.getChildren(
               SLinkOperations.getTarget(
                   SNodeOperations.getNodeAncestor(
                       node,
                       MetaAdapterFactory.getConcept(
                           0x49a08c51fe543ccL,
                           0xbd998b46d641d7f5L,
                           0x2d523c5e4cc45746L,
                           "jetbrains.mps.samples.Kaja.structure.Script"),
                       true,
                       false),
                   MetaAdapterFactory.getContainmentLink(
                       0x49a08c51fe543ccL,
                       0xbd998b46d641d7f5L,
                       0x2d523c5e4cc45746L,
                       0x2d523c5e4cc4574cL,
                       "body")),
               MetaAdapterFactory.getContainmentLink(
                   0x49a08c51fe543ccL,
                   0xbd998b46d641d7f5L,
                   0x2de971c785f06a3fL,
                   0x2de971c785f06a40L,
                   "commands")))
       .addElement(routineDefinition);
   SNode call =
       SConceptOperations.createNewNode(
           MetaAdapterFactory.getConcept(
               0x49a08c51fe543ccL,
               0xbd998b46d641d7f5L,
               0x2de971c785ed6f92L,
               "jetbrains.mps.samples.Kaja.structure.RoutineCall"));
   SLinkOperations.setTarget(
       call,
       MetaAdapterFactory.getReferenceLink(
           0x49a08c51fe543ccL,
           0xbd998b46d641d7f5L,
           0x2de971c785ed6f92L,
           0x2de971c785ede3ccL,
           "definition"),
       routineDefinition);
   SNodeOperations.insertPrevSiblingChild(ListSequence.fromList(selectedNodes).first(), call);
   for (SNode selectedNode : ListSequence.fromList(selectedNodes)) {
     ListSequence.fromList(
             SLinkOperations.getChildren(
                 SLinkOperations.getTarget(
                     routineDefinition,
                     MetaAdapterFactory.getContainmentLink(
                         0x49a08c51fe543ccL,
                         0xbd998b46d641d7f5L,
                         0x2de971c785ed6f79L,
                         0x2de971c785ed6f7cL,
                         "body")),
                 MetaAdapterFactory.getContainmentLink(
                     0x49a08c51fe543ccL,
                     0xbd998b46d641d7f5L,
                     0x2de971c785f06a3fL,
                     0x2de971c785f06a40L,
                     "commands")))
         .addElement(
             SNodeOperations.getNodeAncestor(
                 selectedNode,
                 MetaAdapterFactory.getConcept(
                     0x49a08c51fe543ccL,
                     0xbd998b46d641d7f5L,
                     0x2d523c5e4cc4574aL,
                     "jetbrains.mps.samples.Kaja.structure.AbstractCommand"),
                 true,
                 false));
   }
   editorContext.selectWRTFocusPolicy(routineDefinition);
 }
Exemple #20
0
 public static SNode parenthesiseIfNecessary(@NotNull SNode contextNode) {
   if (SNodeOperations.isInstanceOf(
       SNodeOperations.getParent(contextNode),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0xfbdeb6fecfL,
           "jetbrains.mps.baseLanguage.structure.BinaryOperation"))) {
     SNode parentBinaryOperation =
         SNodeOperations.cast(
             SNodeOperations.getParent(contextNode),
             MetaAdapterFactory.getConcept(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0xfbdeb6fecfL,
                 "jetbrains.mps.baseLanguage.structure.BinaryOperation"));
     if (SNodeOperations.getContainingLinkDeclaration(contextNode)
             == SLinkOperations.findLinkDeclaration(
                 MetaAdapterFactory.getContainmentLink(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0xfbdeb6fecfL,
                     0xfbdeb7a11bL,
                     "rightExpression"))
         && isHigherPriority(parentBinaryOperation, contextNode)) {
       SNode result =
           SNodeFactoryOperations.replaceWithNewChild(
               contextNode,
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xfb4ed32b7fL,
                       "jetbrains.mps.baseLanguage.structure.ParenthesizedExpression")));
       SLinkOperations.setTarget(
           result,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xfb4ed32b7fL,
               0xfb4ed32b80L,
               "expression"),
           contextNode);
       return result;
     }
   } else if (SNodeOperations.isInstanceOf(
       SNodeOperations.getParent(contextNode),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0xf940dabe4aL,
           "jetbrains.mps.baseLanguage.structure.CastExpression"))) {
     SNode parentCastExpression =
         SNodeOperations.cast(
             SNodeOperations.getParent(contextNode),
             MetaAdapterFactory.getConcept(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0xf940dabe4aL,
                 "jetbrains.mps.baseLanguage.structure.CastExpression"));
     if (PrecedenceUtil.needsParensAroundCastExpression(parentCastExpression)) {
       SNode result =
           SNodeFactoryOperations.replaceWithNewChild(
               contextNode,
               SNodeFactoryOperations.asInstanceConcept(
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xfb4ed32b7fL,
                       "jetbrains.mps.baseLanguage.structure.ParenthesizedExpression")));
       SLinkOperations.setTarget(
           result,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xfb4ed32b7fL,
               0xfb4ed32b80L,
               "expression"),
           contextNode);
       return result;
     }
   }
   return contextNode;
 }