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) { EditorCell cell = editorContext.getSelectedCell(); String linkRole = QueriesUtil.getEditedLinkRole(cell); SNode referentNode = QueriesUtil.getEditedLinkReferentNode(cell); SNode result = SNodeFactoryOperations.setNewAttribute( referentNode, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.editor.editorTest.structure.ReferenceAnnotataion"), linkRole), "jetbrains.mps.lang.editor.editorTest.structure.ReferenceAnnotataion"); }
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()); }
@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"))); }