public void execute(final SNode node, final EditorContext editorContext) { SNode statement = SConceptOperations.createNewNode( "org.jetbrains.mps.samples.IfAndUnless.structure.MyIfStatement", null); SLinkOperations.setTarget( statement, "condition", SLinkOperations.getTarget(node, "condition", true), true); SNode ifBody = SConceptOperations.createNewNode( "org.jetbrains.mps.samples.IfAndUnless.structure.TrueFlow", null); ListSequence.fromList(SLinkOperations.getTargets(ifBody, "statement", true)) .addSequence( ListSequence.fromList( SLinkOperations.getTargets( SLinkOperations.getTarget(node, "ifTrue", true), "statement", true))); SLinkOperations.setTarget(statement, "body", ifBody, true); SLinkOperations.setTarget( statement, "alternative", SConceptOperations.createNewNode( "org.jetbrains.mps.samples.IfAndUnless.structure.FalseFlow", null), true); if (SNodeOperations.isInstanceOf( SLinkOperations.getTarget(node, "ifFalseStatement", true), "jetbrains.mps.baseLanguage.structure.BlockStatement")) { ListSequence.fromList( SLinkOperations.getTargets( SLinkOperations.getTarget(statement, "alternative", true), "statement", true)) .addSequence( ListSequence.fromList( SLinkOperations.getTargets( SLinkOperations.getTarget( SNodeOperations.cast( SLinkOperations.getTarget(node, "ifFalseStatement", true), "jetbrains.mps.baseLanguage.structure.BlockStatement"), "statements", true), "statement", true))); } else { ListSequence.fromList( SLinkOperations.getTargets( SLinkOperations.getTarget(statement, "alternative", true), "statement", true)) .addElement(SLinkOperations.getTarget(node, "ifFalseStatement", true)); } SNodeOperations.replaceWithAnother(node, statement); editorContext.select(SLinkOperations.getTarget(statement, "condition", true)); }
public void execute(final SNode node, final EditorContext editorContext) { DocCommentHelper.addJavadocLangIfMissing(node); if ((AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"))) == null)) { SNodeFactoryOperations.setNewAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment")), "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"); SNode line = SNodeFactoryOperations.addNewChild( AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"))), "body", "jetbrains.mps.baseLanguage.javadoc.structure.CommentLine"); SNodeFactoryOperations.addNewChild( line, "part", "jetbrains.mps.baseLanguage.javadoc.structure.TextCommentLinePart"); } else { AttributeOperations.setAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment")), null); } editorContext.select( ListSequence.fromList( SLinkOperations.getTargets( AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"))), "body", true)) .first()); }
public void execute(final SNode node, final EditorContext editorContext) { SNode ifStatement = SNodeFactoryOperations.createNewNode( "jetbrains.mps.baseLanguage.structure.IfStatement", null); List<SNode> selectedNodes = editorContext.getSelectedNodes(); SNodeOperations.insertNextSiblingChild( ListSequence.fromList(selectedNodes).last(), ifStatement); for (SNode selectedNode : ListSequence.fromList(selectedNodes)) { ListSequence.fromList( SLinkOperations.getTargets( SLinkOperations.getTarget(ifStatement, "ifTrue", true), "statement", true)) .addElement( SNodeOperations.getAncestor( selectedNode, "jetbrains.mps.baseLanguage.structure.Statement", true, false)); } editorContext.select(SLinkOperations.getTarget(ifStatement, "condition", true)); }
public void execute_internal(EditorContext editorContext, SNode node) { SNode result = SLinkOperations.getTarget(node, "period", true); SNodeOperations.replaceWithAnother(node, result); editorContext.select(result); }