public void execute(final SNode node, final EditorContext editorContext) {
   // produce throw statement
   SNode throwStatement =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.baseLanguage.structure.ThrowStatement", null);
   SNode newExpr = _quotation_createNode_a1x6vi_a0c0a();
   SLinkOperations.setTarget(throwStatement, "throwable", newExpr, true);
   // produce if statement
   SNode ifStatement =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.baseLanguage.structure.IfStatement", null);
   SNode notExpr =
       SNodeFactoryOperations.setNewChild(
           ifStatement, "condition", "jetbrains.mps.baseLanguage.structure.NotExpression");
   SLinkOperations.setTarget(
       notExpr, "expression", SLinkOperations.getTarget(node, "condition", true), true);
   SNodeFactoryOperations.setNewChild(
       ifStatement, "ifTrue", "jetbrains.mps.baseLanguage.structure.StatementList");
   ListSequence.fromList(
           SLinkOperations.getTargets(
               SLinkOperations.getTarget(ifStatement, "ifTrue", true), "statement", true))
       .insertElement(0, throwStatement);
   // replace assert with if
   SNodeOperations.replaceWithAnother(node, ifStatement);
 }
示例#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;
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode newLine =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.lang.editor.structure.IndentLayoutOnNewLineStyleClassItem", null);
   SPropertyOperations.set(newLine, "flag", "" + (true));
   ListSequence.fromList(SLinkOperations.getTargets(node, "styleItem", true)).addElement(newLine);
 }
 @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);
 }
示例#5
0
 public void execute(final SNode node, final EditorContext editorContext) {
   String name = CreateFromUsageUtil.getText(editorContext);
   if (name == null || name.length() == 0) {
     name = "default_" + SPropertyOperations.getString(node, "name");
   }
   SNode t =
       SNodeFactoryOperations.createNewRootNode(
           SNodeOperations.getModel(node),
           "jetbrains.mps.lang.generator.structure.TemplateDeclaration",
           null);
   SPropertyOperations.set(t, "name", name);
   t.setProperty(
       SModelTreeNode.PACK,
       SPropertyOperations.getString(
           SNodeOperations.cast(
               SNodeOperations.getContainingRoot(node),
               "jetbrains.mps.lang.core.structure.BaseConcept"),
           "virtualPackage"));
   // make reference
   SNode tr =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.lang.generator.structure.TemplateDeclarationReference", null);
   SLinkOperations.setTarget(tr, "template", t, false);
   SLinkOperations.setTarget(node, "defaultConsequence", tr, true);
 }
示例#6
0
 public SNode createReplacementNode_impl(
     SNode parameterObject,
     SNode node,
     SModel model,
     IOperationContext operationContext,
     EditorContext editorContext) {
   return SNodeFactoryOperations.createNewNode(NameUtil.nodeFQName(parameterObject), node);
 }
示例#7
0
 public void execute(final SNode node, final EditorContext editorContext) {
   SLinkOperations.setTarget(
       node,
       "handler",
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.core.xml.sax.structure.XMLSAXAttributeHandler", null),
       true);
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   AttributeOperations.setAttribute(
       node,
       new IAttributeDescriptor.NodeAttribute(
           SConceptOperations.findConceptDeclaration(
               "org.jetbrains.mps.samples.ParallelFor.structure.ThreadSafe")),
       SNodeFactoryOperations.createNewNode(
           "org.jetbrains.mps.samples.ParallelFor.structure.ThreadSafe", null));
 }
 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"));
   }
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode externalProperty =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.buildlanguage.structure.ExternalPropertyDeclaration", null);
   SLinkOperations.setTarget(
       externalProperty, "type", SLinkOperations.getTarget(node, "type", true), true);
   SPropertyOperations.set(
       externalProperty, "name", SPropertyOperations.getString(node, "name"));
   SNodeOperations.replaceWithAnother(node, externalProperty);
 }
 public SNode nodeFactory(SNode node, EditorContext editorContext) {
   return SNodeFactoryOperations.createNewNode(
       SNodeFactoryOperations.asInstanceConcept(
           MetaAdapterFactory.getConcept(
               0xf280165065d5424eL,
               0xbb1b463a8781b786L,
               0x44ac82392ce5c6b0L,
               "jetbrains.mps.baseLanguage.javadoc.structure.EmptyBlockDocTag")),
       null);
 }
示例#12
0
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode executor =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.execution.configurations.structure.RunConfigurationExecutor", null);
   SLinkOperations.setTarget(executor, "configuration", node, false);
   SPropertyOperations.set(
       executor, "virtualPackage", SPropertyOperations.getString(node, "virtualPackage"));
   SModelOperations.addRootNode(SNodeOperations.getModel(node), executor);
   NavigationSupport.getInstance()
       .openNode(editorContext.getOperationContext(), executor, true, false);
 }
示例#13
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();
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode cl =
       (SNodeOperations.getConceptDeclaration(node)
               == SConceptOperations.findConceptDeclaration(
                   "jetbrains.mps.baseLanguage.closures.structure.ClosureLiteral")
           ? SNodeFactoryOperations.createNewNode(
               "jetbrains.mps.baseLanguage.closures.structure.UnrestrictedClosureLiteral", null)
           : SNodeFactoryOperations.createNewNode(
               "jetbrains.mps.baseLanguage.closures.structure.ClosureLiteral", null));
   SNodeOperations.replaceWithAnother(node, cl);
   List<SNode> params = SLinkOperations.getTargets(node, "parameter", true);
   for (SNode p : params) {
     ListSequence.fromList(SLinkOperations.getTargets(cl, "parameter", true))
         .addElement(SNodeOperations.detachNode(p));
   }
   SLinkOperations.setTarget(
       cl,
       "body",
       SNodeOperations.detachNode(SLinkOperations.getTarget(node, "body", true)),
       true);
 }
 public void handleAction(
     SNode node,
     SModel model,
     IScope scope,
     IOperationContext operationContext,
     EditorContext editorContext) {
   SLinkOperations.setTarget(
       node,
       "query",
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.lang.editor.structure.QueryFunction_Boolean", null),
       true);
 }
示例#16
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));
 }
示例#17
0
 public void handleAction_impl(
     SNode parameterObject,
     SNode node,
     SModel model,
     IScope scope,
     IOperationContext operationContext,
     EditorContext editorContext) {
   SNode macro =
       SNodeFactoryOperations.createNewNode(NameUtil.nodeFQName(parameterObject), node);
   SNodeOperations.replaceWithAnother(node, macro);
   editorContext.selectAndSetCaret(macro, 1);
   editorContext.openInspector();
 }
 public void handleAction(
     SNode node,
     SModel model,
     IScope scope,
     IOperationContext operationContext,
     EditorContext editorContext) {
   SNode tagWrapper =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.lang.editor.structure.RightTransformAnchorTagWrapper", null);
   SPropertyOperations.set(
       tagWrapper, "tag", SPropertyOperations.getString_def(node, "tag", null));
   ListSequence.fromList(SLinkOperations.getTargets(node, "tags", true)).addElement(tagWrapper);
   SPropertyOperations.set(node, "tag", null);
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode project =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.buildlanguage.structure.Project", null);
   List<String> externalProps =
       ListSequence.fromListAndArray(
           new ArrayList<String>(), "input.dir", "output.dir", "deploy.dir");
   for (String prop : ListSequence.fromList(externalProps)) {
     SNode property =
         SNodeFactoryOperations.createNewNode(
             "jetbrains.mps.buildlanguage.structure.ExternalPropertyDeclaration", null);
     SPropertyOperations.set(property, "name", prop);
     SLinkOperations.setTarget(
         property,
         "type",
         SNodeFactoryOperations.createNewNode(
             "jetbrains.mps.buildlanguage.structure.FileType", null),
         true);
     ListSequence.fromList(SLinkOperations.getTargets(project, "property", true))
         .addElement(property);
   }
   SModel model = editorContext.getModel();
   model.addRoot(project);
   SLinkOperations.setTarget(node, "project", project, false);
   SLinkOperations.setTarget(
       node,
       "targetDeclaration",
       SLinkOperations.getTarget(
           SLinkOperations.getTarget(project, "default", true), "targetDeclaration", false),
       false);
   NavigationSupport.getInstance()
       .openNode(
           editorContext.getOperationContext(),
           project,
           true,
           !(SNodeOperations.isRoot(project)));
 }
示例#20
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 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);
 }
 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 List<SNode> insertMethods(List<SNode> baseMethods) {
   boolean insertion =
       myContextMethod != null && SNodeOperations.getParent(myContextMethod) == myClassConcept;
   List<SNode> result = new ArrayList<SNode>();
   for (SNode m : baseMethods) {
     SNode baseMethod =
         SNodeOperations.cast(m, "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration");
     SNode method =
         SNodeOperations.cast(
             BehaviorReflection.invokeNonVirtual(
                 (Class<SNode>) ((Class) Object.class),
                 baseMethod,
                 "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration",
                 "call_getMethodToImplement_69709522611978987",
                 new Object[] {myClassConcept}),
             "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration");
     SPropertyOperations.set(method, "isAbstract", "" + (false));
     SLinkOperations.setTarget(
         method,
         "body",
         SNodeFactoryOperations.createNewNode(
             SNodeOperations.getModel(myClassConcept),
             "jetbrains.mps.baseLanguage.structure.StatementList",
             null),
         true);
     if (insertion) {
       int index =
           ListSequence.fromList(SLinkOperations.getTargets(myClassConcept, "member", true))
               .indexOf(myContextMethod);
       if (index == -1) {
         ListSequence.fromList(SLinkOperations.getTargets(myClassConcept, "member", true))
             .addElement(method);
       } else {
         ListSequence.fromList(SLinkOperations.getTargets(myClassConcept, "member", true))
             .insertElement(index, method);
       }
     } else {
       ListSequence.fromList(SLinkOperations.getTargets(myClassConcept, "member", true))
           .addElement(method);
     }
     update(method, baseMethod);
     ListSequence.fromList(result).addElement(method);
   }
   return result;
 }
 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;
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode castVariable =
       SNodeFactoryOperations.createNewNode(
           "jetbrains.mps.baseLanguage.structure.LocalVariableDeclarationStatement", null);
   SNode instanceOfExpression =
       SNodeOperations.cast(
           SLinkOperations.getTarget(node, "condition", true),
           "jetbrains.mps.baseLanguage.structure.InstanceOfExpression");
   SNode declaration = SLinkOperations.getTarget(castVariable, "localVariableDeclaration", true);
   SLinkOperations.setTarget(
       declaration,
       "type",
       SNodeOperations.copyNode(
           SLinkOperations.getTarget(instanceOfExpression, "classType", true)),
       true);
   List<String> variableSuffixes =
       BehaviorReflection.invokeVirtual(
           (Class<List<String>>) ((Class) Object.class),
           SLinkOperations.getTarget(instanceOfExpression, "classType", true),
           "virtual_getVariableSuffixes_1213877337304",
           new Object[] {});
   SPropertyOperations.set(declaration, "name", ListSequence.fromList(variableSuffixes).first());
   SNode castExpression =
       SNodeFactoryOperations.setNewChild(
           declaration, "initializer", "jetbrains.mps.baseLanguage.structure.CastExpression");
   SLinkOperations.setTarget(
       castExpression,
       "type",
       SNodeOperations.copyNode(
           SLinkOperations.getTarget(instanceOfExpression, "classType", true)),
       true);
   SLinkOperations.setTarget(
       castExpression,
       "expression",
       SNodeOperations.copyNode(
           SLinkOperations.getTarget(instanceOfExpression, "leftExpression", true)),
       true);
   ListSequence.fromList(
           SLinkOperations.getTargets(
               SLinkOperations.getTarget(node, "ifTrue", true), "statement", true))
       .insertElement(0, castVariable);
 }
 public void execute_internal(EditorContext editorContext, SNode node) {
   SNode statement;
   SNode ifFalseStatement = SLinkOperations.getTarget(node, "ifFalseStatement", true);
   List<SNode> statements =
       SLinkOperations.getTargets(
           SLinkOperations.getTarget(
               SNodeOperations.cast(
                   ifFalseStatement, "jetbrains.mps.baseLanguage.structure.BlockStatement"),
               "statements",
               true),
           "statement",
           true);
   if (ListSequence.fromList(statements).isEmpty()) {
     statement =
         SNodeFactoryOperations.createNewNode(
             SNodeOperations.getModel(node),
             "jetbrains.mps.baseLanguage.structure.Statement",
             null);
   } else {
     statement = ListSequence.fromList(statements).first();
   }
   SNodeOperations.replaceWithAnother(ifFalseStatement, statement);
 }
示例#27
0
 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) {
   {
     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 {
     }
   }
 }
 public void execute(final SNode node, final EditorContext editorContext) {
   SNode applicableConcept = SLinkOperations.getTarget(node, "applicableConcept", false);
   String name = CreateFromUsageUtil.getText(editorContext);
   if (name == null || name.length() == 0) {
     name = "weave_";
     if (applicableConcept != null) {
       name += SPropertyOperations.getString(applicableConcept, "name");
     }
   }
   SNode t =
       SNodeFactoryOperations.createNewRootNode(
           SNodeOperations.getModel(node),
           "jetbrains.mps.lang.generator.structure.TemplateDeclaration",
           null);
   SPropertyOperations.set(t, "name", name);
   SLinkOperations.setTarget(t, "applicableConcept", applicableConcept, false);
   t.setProperty(
       SNodeUtil.property_BaseConcept_virtualPackage,
       SPropertyOperations.getString(
           SNodeOperations.cast(
               SNodeOperations.getContainingRoot(node),
               "jetbrains.mps.lang.core.structure.BaseConcept"),
           "virtualPackage"));
   //  initialize 'content node' in template
   SNode contextNodeType =
       TypeChecker.getInstance()
           .getTypeOf(
               SLinkOperations.getTarget(
                   SNodeOperations.cast(
                       node, "jetbrains.mps.lang.generator.structure.Weaving_MappingRule"),
                   "contextNodeQuery",
                   true));
   if (SNodeOperations.isInstanceOf(
       contextNodeType, "jetbrains.mps.lang.smodel.structure.SNodeType")) {
     SNode contextNodeConcept =
         SLinkOperations.getTarget(
             SNodeOperations.cast(
                 contextNodeType, "jetbrains.mps.lang.smodel.structure.SNodeType"),
             "concept",
             false);
     if (contextNodeConcept
         != SConceptOperations.findConceptDeclaration(
             "jetbrains.mps.lang.core.structure.BaseConcept")) {
       if (!(SNodeOperations.isInstanceOf(
           contextNodeConcept,
           "jetbrains.mps.lang.structure.structure.InterfaceConceptDeclaration"))) {
         SLinkOperations.setTarget(
             t,
             "contentNode",
             SNodeFactoryOperations.createNewNode(NameUtil.nodeFQName(contextNodeConcept), null),
             true);
       }
     }
   }
   // make reference
   SNode tr =
       SNodeFactoryOperations.setNewChild(
           node,
           "ruleConsequence",
           "jetbrains.mps.lang.generator.structure.TemplateDeclarationReference");
   SLinkOperations.setTarget(tr, "template", t, false);
 }
示例#30
0
 @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);
 }