private void removeAttributes(SNode node) { if (SNodeOperations.isAttribute(node)) { SNodeOperations.deleteNode(node); } else { for (SNode child : SNodeOperations.getChildren(node)) { removeAttributes(child); } } }
public static SNode parent(SNode n) { if (SNodeOperations.isAttribute(n)) { if (SNodeOperations.isInstanceOf(n, "jetbrains.mps.lang.core.structure.NodeAttribute")) { SNode next = SNodeOperations.getPrevSibling(n); while (next != null) { if (SNodeOperations.isInstanceOf( next, "jetbrains.mps.lang.core.structure.NodeAttribute")) { return next; } next = SNodeOperations.getPrevSibling(next); } n = SNodeOperations.getParent(n); return (n == null ? null : SNodeOperations.getParent(n)); } return SNodeOperations.getParent(n); } SNode lastAttr = ListSequence.fromList( SLinkOperations.getTargets( SNodeOperations.cast(n, "jetbrains.mps.lang.core.structure.BaseConcept"), "smodelAttribute", true)) .where( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return SNodeOperations.isInstanceOf( it, "jetbrains.mps.lang.core.structure.NodeAttribute"); } }) .last(); if ((lastAttr != null)) { return lastAttr; } return SNodeOperations.getParent(n); }