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")); } } }
private static boolean renderingCondition_1clvom_a0a(SNode node, EditorContext editorContext) { return (SLinkOperations.getTarget(node, "persistentConfiguration", false) == null) || (AttributeOperations.getAttribute( SLinkOperations.getTarget(node, "persistentConfiguration", false), new IAttributeDescriptor.NodeAttribute( "jetbrains.mps.execution.settings.structure.DeprecatedAnnotation")) == null); }
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 String getDescription(final SNode node, final EditorContext editorContext) { return (AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( "jetbrains.mps.lang.editor.figures.structure.FigureParameterAttributeViewProperty")) == null ? "Add figure parameter attribute" : "Remove figure parameter attribute"); }
public String getDescription(final SNode node, final EditorContext editorContext) { return ((AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.baseLanguage.javadoc.structure.FieldDocComment"))) == null) ? "Add Documentation Comment" : "Remove Documentation Comment"); }
public boolean isApplicableToNode(final SNode node, final EditorContext editorContext) { return SNodeOperations.isInstanceOf( SLinkOperations.getTarget(node, "operation", true), "jetbrains.mps.baseLanguage.structure.InstanceMethodCallOperation") && AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "org.jetbrains.mps.samples.ParallelFor.structure.ThreadSafe"))) == null; }
public void execute(SNode node) { SNodeOperations.deleteNode( AttributeOperations.getAttribute( SNodeOperations.cast( node, MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101d9d3ca30L, "jetbrains.mps.baseLanguage.structure.Classifier")), new IAttributeDescriptor.NodeAttribute( MetaAdapterFactory.getConcept( 0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x53f7c33f069862f2L, "jetbrains.mps.baseLanguage.structure.JavaImports")))); }
public static boolean filterIssue(SNode node) { SNode container = AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( "jetbrains.mps.lang.test.structure.NodeOperationsContainer")); if (container == null) { return true; } for (SNode property : SLinkOperations.getTargets(container, "nodeOperations", true)) { if (jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations.isInstanceOf( property, "jetbrains.mps.lang.test.structure.NodeErrorCheckOperation")) { return false; } } return true; }
public static SNode getApplicableConcept_fromEnvironment(SNode node) { SNode ancestor = SNodeOperations.getAncestorWhereConceptInList( node, new String[] { "jetbrains.mps.lang.generator.structure.TemplateDeclaration", "jetbrains.mps.lang.generator.structure.BaseMappingRule", "jetbrains.mps.lang.generator.structure.PatternReduction_MappingRule" }, false, false); if (SNodeOperations.isInstanceOf( ancestor, "jetbrains.mps.lang.generator.structure.TemplateDeclaration")) { return SLinkOperations.getTarget( SNodeOperations.cast( ancestor, "jetbrains.mps.lang.generator.structure.TemplateDeclaration"), "applicableConcept", false); } if (SNodeOperations.isInstanceOf( ancestor, "jetbrains.mps.lang.generator.structure.PatternReduction_MappingRule")) { return PatternReduction_MappingRule_Behavior.call_getConcept_1805153994417064763( SNodeOperations.cast( ancestor, "jetbrains.mps.lang.generator.structure.PatternReduction_MappingRule")); } if (SNodeOperations.isInstanceOf( ancestor, "jetbrains.mps.lang.generator.structure.BaseMappingRule")) { return SLinkOperations.getTarget( SNodeOperations.cast(ancestor, "jetbrains.mps.lang.generator.structure.BaseMappingRule"), "applicableConcept", false); } // ============ SNode rootAnnotation = AttributeOperations.getAttribute( SNodeOperations.getContainingRoot(node), new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation"))); return SLinkOperations.getTarget( SNodeOperations.cast( rootAnnotation, "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation"), "applicableConcept", false); }
public void execute(final SNode node, final EditorContext editorContext) { List<SNode> configs = SModelOperations.getRoots( SNodeOperations.getModel(node), "jetbrains.mps.lang.generator.structure.MappingConfiguration"); if (ListSequence.fromList(configs).count() > 1) { Iterable<SNode> sameVPackConfigs = ListSequence.fromList(configs) .where( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return Comparing.equal( SPropertyOperations.getString(it, "virtualPackage"), SPropertyOperations.getString(node, "virtualPackage")); } }); if (Sequence.fromIterable(sameVPackConfigs).isNotEmpty()) { configs = Sequence.fromIterable(sameVPackConfigs).toListSequence(); } } if (ListSequence.fromList(configs).count() > 1) { // TODO: let user to choose mapping config? } // add new rule SNode rule = SNodeFactoryOperations.addNewChild( ListSequence.fromList(configs).first(), "rootMappingRule", "jetbrains.mps.lang.generator.structure.Root_MappingRule"); SLinkOperations.setTarget( rule, "applicableConcept", SLinkOperations.getTarget( AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation")), "applicableConcept", false), false); SLinkOperations.setTarget(rule, "template", node, false); // open in editor NavigationSupport.getInstance() .openNode(editorContext.getOperationContext(), rule, true, true); }
private static Boolean isApplicable_id4IvydoGviup( @NotNull SAbstractConcept __thisConcept__, SNode node) { return Sequence.fromIterable(SNodeOperations.getReferences(node)).isNotEmpty() && (AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( MetaAdapterFactory.getConcept( 0x8585453e6bfb4d80L, 0x98deb16074f1d86cL, 0x7181d929c720809L, "jetbrains.mps.lang.test.structure.ScopesTest"))) == null) && !(SNodeOperations.isInstanceOf( node, MetaAdapterFactory.getConcept( 0x8585453e6bfb4d80L, 0x98deb16074f1d86cL, 0x7181d929c720809L, "jetbrains.mps.lang.test.structure.ScopesTest"))); }
public static boolean call_isApplicable_5449224527592368025( SAbstractConcept thisConcept, SNode node) { return ListSequence.fromList(SNodeOperations.getReferences(node)).isNotEmpty() && (AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( MetaAdapterFactory.getConcept( 0x8585453e6bfb4d80L, 0x98deb16074f1d86cL, 0x7181d929c720809L, "jetbrains.mps.lang.test.structure.ScopesTest"))) == null) && !(SNodeOperations.isInstanceOf( node, MetaAdapterFactory.getConcept( 0x8585453e6bfb4d80L, 0x98deb16074f1d86cL, 0x7181d929c720809L, "jetbrains.mps.lang.test.structure.ScopesTest"))); }
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) { List<SNode> TFs = SNodeOperations.getDescendants( SLinkOperations.getTarget( SLinkOperations.getTarget(node, "template", false), "contentNode", true), "jetbrains.mps.lang.generator.structure.TemplateFragment", true, new String[] {}); if ((int) ListSequence.fromList(TFs).count() == 0) { JOptionPane.showMessageDialog(null, "No fragments found"); return; } if (ListSequence.fromList(TFs).count() > 1) { JOptionPane.showMessageDialog(null, "Too many fragments"); return; } // ------ SNode oldTemplate = SLinkOperations.getTarget(node, "template", false); SNode fragmentToSet = SNodeOperations.copyNode(SNodeOperations.getParent(ListSequence.fromList(TFs).first())); SNode TFtoDelete = AttributeOperations.getAttribute( fragmentToSet, new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.generator.structure.TemplateFragment"))); SNodeOperations.deleteNode(TFtoDelete); SNode inlineTemplate = SNodeFactoryOperations.replaceWithNewChild( node, "jetbrains.mps.lang.generator.structure.InlineTemplate_RuleConsequence"); SLinkOperations.setTarget(inlineTemplate, "templateNode", fragmentToSet, true); // ------ int option = JOptionPane.showConfirmDialog( null, "Delete old template?", "", JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { SNodeOperations.deleteNode(oldTemplate); } }
private boolean isApplicableToNode(final SNode node, final EditorContext editorContext) { SNode annotation = AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation")); if (annotation == null) { return false; } if (SLinkOperations.getTarget(annotation, "applicableConcept", false) == null) { return false; } List<SNode> configs = SModelOperations.getRoots( SNodeOperations.getModel(node), "jetbrains.mps.lang.generator.structure.MappingConfiguration"); if (ListSequence.fromList(configs).isEmpty()) { return false; } SNode usage = ListSequence.fromList(configs) .findFirst( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return ListSequence.fromList( SLinkOperations.getTargets(it, "rootMappingRule", true)) .findFirst( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return SLinkOperations.getTarget(it, "template", false) == node; } }) != null; } }); // not used in rule yet? return usage == null; }
@Override public List<SearchResult<ModelCheckerIssue>> checkModel( SModel model, ProgressMonitor monitor, final IOperationContext operationContext) { List<SearchResult<ModelCheckerIssue>> results = ListSequence.fromList(new ArrayList<SearchResult<ModelCheckerIssue>>()); String title = "Checking " + SModelOperations.getModelName(model) + " for wrong aspect dependencies..."; monitor.start(title, 1); int modelKind = getModelKind(model, null); if (modelKind == OTHER) { monitor.done(); return results; } for (SNode node : ListSequence.fromList(SModelOperations.getNodes(model, null))) { if (monitor.isCanceled()) { break; } // Check for unresolved references for (final SReference ref : Sequence.fromIterable(SNodeOperations.getReferences(node))) { if ((AttributeOperations.getAttribute( node, new IAttributeDescriptor.LinkAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.generator.structure.ReferenceMacro"), SLinkOperations.getRole(ref))) != null)) { continue; } SNode targetNode = jetbrains.mps.util.SNodeOperations.getTargetNodeSilently(ref); if (targetNode == null) { addIssue( results, node, "Unresolved reference: " + SLinkOperations.getResolveInfo(ref), ModelChecker.SEVERITY_ERROR, "unresolved reference", new IModelCheckerFix() { public boolean doFix() { return ResolverComponent.getInstance().resolve(ref, operationContext); } }); continue; } SModel targetModel = SNodeOperations.getModel(targetNode); int targetKind = getModelKind(targetModel, ref); if (targetKind > modelKind) { addIssue( results, node, "Wrong reference: " + SLinkOperations.getResolveInfo(ref) + ", reference from " + kindToString(modelKind) + " to " + kindToString(targetKind), ModelChecker.SEVERITY_ERROR, "wrong aspect dependency (" + kindToString(modelKind) + ")", null); } } } monitor.done(); return results; }
private boolean isApplicableToNode(final SNode node, final EditorContext editorContext) { SNode annotation = AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( MetaAdapterFactory.getConcept( 0xb401a68083254110L, 0x8fd384331ff25befL, 0x11017244494L, "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation"))); if (annotation == null) { return false; } if (SLinkOperations.getTarget( annotation, MetaAdapterFactory.getReferenceLink( 0xb401a68083254110L, 0x8fd384331ff25befL, 0x11017244494L, 0x11017255ccfL, "applicableConcept")) != null) { return false; } List<SNode> configs = SModelOperations.roots( SNodeOperations.getModel(node), MetaAdapterFactory.getConcept( 0xb401a68083254110L, 0x8fd384331ff25befL, 0xff0bea0475L, "jetbrains.mps.lang.generator.structure.MappingConfiguration")); if (ListSequence.fromList(configs).isEmpty()) { return false; } SNode usage = ListSequence.fromList(configs) .findFirst( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return ListSequence.fromList( SLinkOperations.getChildren( it, MetaAdapterFactory.getContainmentLink( 0xb401a68083254110L, 0x8fd384331ff25befL, 0xff0bea0475L, 0x10fbbe00519L, "createRootRule"))) .findFirst( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return SLinkOperations.getTarget( it, MetaAdapterFactory.getReferenceLink( 0xb401a68083254110L, 0x8fd384331ff25befL, 0x10fbbd5854aL, 0x10fbbd5854dL, "templateNode")) == node; } }) != null; } }); // not used in rule yet? return usage == null; }
public void doGenerateText(SNode node) { if (getBuffer().hasPositionsSupport()) { TraceInfoGenerationUtil.createUnitInfo(this, node); } if ((AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( "jetbrains.mps.baseLanguage.javadoc.structure.ClassifierDocComment")) != null)) { appendNode( AttributeOperations.getAttribute( node, new IAttributeDescriptor.NodeAttribute( "jetbrains.mps.baseLanguage.javadoc.structure.ClassifierDocComment"))); } BaseLanguageTextGen.fileHeader(node, this); BaseLanguageTextGen.annotations(node, this); BaseLanguageTextGen.visibilityWithIndent( SLinkOperations.getTarget(node, "visibility", true), this); if (Classifier_Behavior.call_isInner_521412098689998677(node) && BehaviorReflection.invokeVirtual( Boolean.TYPE, node, "virtual_isStatic_7405920559687241224", new Object[] {})) { this.append("static "); } if (SPropertyOperations.getBoolean(node, "abstractClass")) { this.append("abstract "); } if (SPropertyOperations.getBoolean(node, "isFinal")) { this.append("final "); } this.append("class "); this.append(SPropertyOperations.getString(node, "name")); GenericDeclarationTextGen2.typeDeclarations(node, this); if ((SLinkOperations.getTarget(node, "superclass", true) != null)) { this.append(" extends "); appendNode(SLinkOperations.getTarget(node, "superclass", true)); } if (ListSequence.fromList(SLinkOperations.getTargets(node, "implementedInterface", true)) .isNotEmpty()) { this.append(" implements "); { Iterable<SNode> collection = SLinkOperations.getTargets(node, "implementedInterface", true); final SNode lastItem = Sequence.fromIterable(collection).last(); for (SNode item : collection) { appendNode(item); if (item != lastItem) { append(", "); } } } } this.append(" "); BaseClassConceptTextGen.membersWithBrackets(node, true, this); this.appendNewLine(); if (getBuffer().hasPositionsSupport()) { { String unitName = null; try { unitName = BehaviorReflection.invokeVirtual( String.class, SNodeOperations.cast(node, "jetbrains.mps.lang.traceable.structure.UnitConcept"), "virtual_getUnitName_5067982036267369911", new Object[] {}); } catch (Throwable t) { if (LOG.isEnabledFor(Level.ERROR)) { LOG.error("Can't calculate unit name for a node " + node + ".", t); } } TraceInfoGenerationUtil.fillUnitInfo(this, node, unitName); } } }