@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); }
public void execute_internal(EditorContext editorContext, SNode node) { SingleLineCommentUtil.divideSingleLineCommentText(node, editorContext); editorContext.selectWRTFocusPolicy(node); }
public void execute_internal(EditorContext editorContext, SNode node) { if (SNodeOperations.isInstanceOf( node, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, "jetbrains.mps.baseLanguage.structure.IfStatement"))) { SNodeOperations.deleteNode( SLinkOperations.getTarget( SNodeOperations.cast( node, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, "jetbrains.mps.baseLanguage.structure.IfStatement")), MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b217L, 0xf8cc56b218L, "condition"))); } else if (SNodeOperations.isInstanceOf( node, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfaa4bf0f2fL, "jetbrains.mps.baseLanguage.structure.WhileStatement"))) { SNodeOperations.deleteNode( SLinkOperations.getTarget( SNodeOperations.cast( node, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfaa4bf0f2fL, "jetbrains.mps.baseLanguage.structure.WhileStatement")), MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfaa4bf0f2fL, 0xfaa4bf0f30L, "condition"))); } else if (SNodeOperations.isInstanceOf( node, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11232674988L, "jetbrains.mps.baseLanguage.structure.DoWhileStatement"))) { SNodeOperations.deleteNode( SLinkOperations.getTarget( SNodeOperations.cast( node, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11232674988L, "jetbrains.mps.baseLanguage.structure.DoWhileStatement")), MetaAdapterFactory.getContainmentLink( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11232674988L, 0x11232679422L, "condition"))); } else { return; } editorContext.selectWRTFocusPolicy(node); }