public static void setBoolean(SNode node, String propertyName, boolean value) { if (node != null) { SNode conceptProperty = (SNode) findProperty(node, propertyName); if (SNodeOperations.isInstanceOf( conceptProperty, "jetbrains.mps.lang.structure.structure.BooleanConceptProperty") && !(value)) { node.removeChild(conceptProperty); } else if (conceptProperty == null && value) { for (SNode cpd : (List<SNode>) SModelSearchUtil.getConceptPropertyDeclarations(node)) { if (SPropertyOperations.getString(cpd, "name").equals(propertyName)) { if (SNodeOperations.isInstanceOf( cpd, "jetbrains.mps.lang.structure.structure.BooleanConceptPropertyDeclaration")) { SNode bcp = SModelOperations.createNewNode( SNodeOperations.getModel(node), null, "jetbrains.mps.lang.structure.structure.BooleanConceptProperty"); SLinkOperations.setTarget( bcp, "conceptPropertyDeclaration", SNodeOperations.cast( cpd, "jetbrains.mps.lang.structure.structure.BooleanConceptPropertyDeclaration"), false); ListSequence.fromList(SLinkOperations.getTargets(node, "conceptProperty", true)) .addElement(bcp); break; } } } } } }
public static Iterable<SNode> getChildAttributes(SNode node, final SContainmentLink link) { return Sequence.fromIterable( SNodeOperations.ofConcept( SLinkOperations.getChildren( node, MetaAdapterFactory.getContainmentLink( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute")), MetaAdapterFactory.getConcept( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x9d98713f247885aL, "jetbrains.mps.lang.core.structure.ChildAttribute"))) .where( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return eq_b2vkxw_a0a0a0a0a0a0eb( ((SContainmentLink) BHReflection.invoke( it, SMethodTrimmedId.create( "getLink", MetaAdapterFactory.getConcept( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x9d98713f247885aL, "jetbrains.mps.lang.core.structure.ChildAttribute"), "BpxLfMirzf"))), link); } }); }
@Deprecated @ToRemove(version = 3.2) public static Iterable<SNode> getLinkAttributes(SNode node, final String linkRole) { return Sequence.fromIterable( SNodeOperations.ofConcept( SLinkOperations.getChildren( node, MetaAdapterFactory.getContainmentLink( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute")), MetaAdapterFactory.getConcept( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x2eb1ad060897da51L, "jetbrains.mps.lang.core.structure.LinkAttribute"))) .where( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return eq_b2vkxw_a0a0a0a0a0a0cb(getLink(it).getRoleName(), linkRole); } }); }
public static Iterable<SNode> getPropertyAttributes(SNode node, final SProperty property) { return Sequence.fromIterable( SNodeOperations.ofConcept( SLinkOperations.getChildren( node, MetaAdapterFactory.getContainmentLink( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute")), MetaAdapterFactory.getConcept( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x2eb1ad060897da56L, "jetbrains.mps.lang.core.structure.PropertyAttribute"))) .where( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return eq_b2vkxw_a0a0a0a0a0a0bb( ((SProperty) BHReflection.invoke( it, SMethodTrimmedId.create( "getProperty", MetaAdapterFactory.getConcept( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x2eb1ad060897da56L, "jetbrains.mps.lang.core.structure.PropertyAttribute"), "1avfQ4BBzOo"))), property); } }); }
public static SNode setNewChild(SNode node, String role, String childConceptFQName) { if (node != null) { SNode newChild = SModelOperations.createNewNode(node.getModel(), childConceptFQName); SLinkOperations.setTarget(node, role, newChild, true); return newChild; } return null; }
public static List<SNode> getAllAttributes(SNode node) { return SLinkOperations.getChildren( node, MetaAdapterFactory.getContainmentLink( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute")); }
public static SNode addAttribute(SNode node, IAttributeDescriptor descriptor, SNode value) { ListSequence.fromList( SLinkOperations.getChildren( node, MetaAdapterFactory.getContainmentLink( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute"))) .addElement(value); descriptor.update(value); return value; }
public static Iterable<SNode> getNodeAttributes(SNode node) { return SNodeOperations.ofConcept( SLinkOperations.getChildren( node, MetaAdapterFactory.getContainmentLink( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute")), MetaAdapterFactory.getConcept( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x2eb1ad060897da54L, "jetbrains.mps.lang.core.structure.NodeAttribute")); }
public static Iterable<SNode> getAttributes(SNode node, final IAttributeDescriptor descriptor) { return ListSequence.fromList( SLinkOperations.getChildren( node, MetaAdapterFactory.getContainmentLink( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute"))) .where( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return descriptor.match(it); } }); }
public static boolean hasChildAttributes(SNode node) { return Sequence.fromIterable( SNodeOperations.ofConcept( SLinkOperations.getChildren( node, MetaAdapterFactory.getContainmentLink( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute")), MetaAdapterFactory.getConcept( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x9d98713f247885aL, "jetbrains.mps.lang.core.structure.ChildAttribute"))) .isNotEmpty(); }
public static SNode insertAttribute( SNode node, SNode anchor, IAttributeDescriptor descriptor, SNode value) { // shall insert value *after* anchor if (anchor == null || !(ListSequence.fromList( SLinkOperations.getChildren( node, MetaAdapterFactory.getContainmentLink( 0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, 0x47bf8397520e5942L, "smodelAttribute"))) .contains(anchor))) { addAttribute(node, descriptor, value); } else { SNodeOperations.insertNextSiblingChild(anchor, value); } descriptor.update(value); return value; }
public static SNode getModuleStub(SModel model) { final SModule module = model.getModule(); SRepository repo = model.getRepository(); if (repo == null || ProjectStructureModule.getInstance(repo) == null) { return null; } if (module instanceof Generator) { Language lang = ((Generator) module).getSourceLanguage(); SModel m = ProjectStructureModule.getInstance(repo).getModelByModule(lang); if (m == null) { return null; } SNode l = ListSequence.fromList( SModelOperations.roots( m, MetaAdapterFactory.getConcept( 0x86ef829012bb4ca7L, 0x947f093788f263a9L, 0x5869770da61dfe1fL, "jetbrains.mps.lang.project.structure.Language"))) .first(); return (l == null ? null : ListSequence.fromList( SLinkOperations.getChildren( l, MetaAdapterFactory.getContainmentLink( 0x86ef829012bb4ca7L, 0x947f093788f263a9L, 0x5869770da61dfe1fL, 0x5869770da61dfe37L, "generator"))) .findFirst( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return eq_kkj9n5_a0a0a0a0a0a4a3a11( SPropertyOperations.getString( it, MetaAdapterFactory.getProperty( 0x86ef829012bb4ca7L, 0x947f093788f263a9L, 0x5869770da61dfe1eL, 0x5869770da61dfe22L, "uuid")), module.getModuleReference().getModuleId().toString()); } })); } else { SModel m = ProjectStructureModule.getInstance(repo).getModelByModule(module); return (m == null ? null : ListSequence.fromList( SModelOperations.roots( m, MetaAdapterFactory.getConcept( 0x86ef829012bb4ca7L, 0x947f093788f263a9L, 0x5869770da61dfe1eL, "jetbrains.mps.lang.project.structure.Module"))) .first()); } }