public void execute(final SNode node, final EditorContext editorContext) { EditorCell selectedCell = editorContext.getSelectedCell(); if (!(selectedCell.isReferenceCell())) { return; } SNode contextNode = SNodeOperations.cast( selectedCell.getSNode(), "jetbrains.mps.lang.core.structure.BaseConcept"); if (contextNode == null) { return; } String role = selectedCell.getRole(); if (SNodeOperations.isInstanceOf( contextNode, "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation")) { SNode attributedNode = SNodeOperations.cast( SNodeOperations.getParent(contextNode), "jetbrains.mps.lang.core.structure.BaseConcept"); assert attributedNode != null; AttributeOperations.setAttribute( attributedNode, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), role), null); return; } if (AttributeOperations.getAttribute( contextNode, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), role)) != null) { AttributeOperations.setAttribute( contextNode, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), role), null); } else { SNode referenceAntiquotation = SNodeFactoryOperations.setNewAttribute( contextNode, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), role), "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"); if (selectedCell.isSingleNodeCell()) { SPropertyOperations.set( referenceAntiquotation, "label", SPropertyOperations.getString( SNodeOperations.getConceptDeclaration(contextNode), "name")); } } }
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) { if (AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( "jetbrains.mps.lang.editor.figures.structure.FigureParameterAttributeViewProperty")) != null) { AttributeOperations.setAttribute( node, new IAttributeDescriptor.NodeAttribute( "jetbrains.mps.lang.editor.figures.structure.FigureParameterAttributeViewProperty"), null); } else { AttributeOperations.setAttribute( node, new IAttributeDescriptor.NodeAttribute( "jetbrains.mps.lang.editor.figures.structure.FigureParameterAttributeViewProperty"), SConceptOperations.createNewNode( "jetbrains.mps.lang.editor.figures.structure.FigureParameterAttributeViewProperty", null)); } }
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) { 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()); }