public void setParentNode(Node node) { parentNode.removeChild(this); node.appendChild(this); }
@Override public void traverse() { try { ExtendNodeHandler.traverse(this); getParentNode().removeChild(this); } catch (Exception e) { e.printStackTrace(); } } }
public void appendAll(Collection<Node> nodes) { if (nodes != null && !nodes.isEmpty()) { children.addAll(nodes); for (final Node n : nodes) { if (n.getParentNode() != null) { n.getParentNode().removeChild(n); } n.setParentNode(this); } } }
public void appendChild(Node node, Node after) { if (node != null) { int index = children.indexOf(after); if (index != -1) { children.add(index + 1, node); if (node.getParentNode() != null) { node.getParentNode().removeChild(node); } node.setParentNode(this); } else { throw new NullPointerException("after-node was not found"); } } }
public void appendChildrenAfter(Collection<Node> childrenNodes, Node after) { if (childrenNodes != null && !childrenNodes.isEmpty()) { int index = children.indexOf(after); if (index != -1) { children.addAll(index, childrenNodes); for (final Node child : childrenNodes) { if (child.getParentNode() != null) { child.getParentNode().removeChild(child); } child.setParentNode(this); } } else { throw new NullPointerException("after-node was not found"); } } }
private void populateDefinitions(Node node) { if (node instanceof MixinDefNode) { mixinDefs.put(((MixinDefNode) node).getName(), (MixinDefNode) node); node.getParentNode().removeChild(node); } else if (node instanceof IfElseDefNode) { ifElseDefNodes.add((IfElseDefNode) node); } for (final Node child : new ArrayList<Node>(node.getChildren())) { populateDefinitions(child); } }
public void appendChild(Node node) { if (node != null) { children.add(node); if (node.getParentNode() != null) { node.getParentNode().removeChild(node); } node.setParentNode(this); } }
public void removeEmptyBlocks(Node node) { // depth first for avoiding re-checking parents of removed nodes for (Node child : new ArrayList<Node>(node.getChildren())) { removeEmptyBlocks(child); } Node parent = node.getParentNode(); if (node instanceof BlockNode && node.getChildren().isEmpty() && parent != null) { // remove empty block parent.removeChild(node); } }
public static void traverse(NestPropertiesNode node) { Node previous = node; for (RuleNode unNested : node.unNesting()) { node.getParentNode().appendChild(unNested, previous); previous = unNested; } node.getParentNode().removeChild(node); } }
public MixinDefNode replaceContentNode(ContentNode contentNode, MixinNode mixinNode) { if (contentNode != null) { contentNode.getParentNode().appendChildrenAfter( DeepCopy.copy(mixinNode.getChildren()), contentNode); contentNode.getParentNode().removeChild(contentNode); } return this; } }
@Override public void traverse() { replaceVariables(ScssStylesheet.getVariables()); ScssStylesheet.addVariable(getModifiedList()); getParentNode().removeChild(this); }
private static void replaceEachDefNode(EachDefNode defNode) { Node last = defNode; for (final String var : defNode.getVariables()) { VariableNode varNode = new VariableNode(defNode.getVariableName() .substring(1), LexicalUnitImpl.createIdent(var), false); ArrayList<VariableNode> variables = new ArrayList<VariableNode>( ScssStylesheet.getVariables()); variables.add(varNode); for (final Node child : defNode.getChildren()) { Node copy = (Node) DeepCopy.copy(child); replaceInterpolation(copy, variables); defNode.getParentNode().appendChild(copy, last); last = copy; } } defNode.setChildren(new ArrayList<Node>()); defNode.getParentNode().removeChild(defNode); }
private static void replaceMixinNode(MixinNode mixinNode, MixinDefNode mixinDef) { MixinDefNode defClone = (MixinDefNode) DeepCopy.copy(mixinDef); defClone.traverse(); defClone.replaceContentDirective(mixinNode); if (mixinDef.getArglist().isEmpty()) { mixinNode.getParentNode().appendChildrenAfter( new ArrayList<Node>(defClone.getChildren()), mixinNode); } else { if (mixinNode.getArglist() != null && !mixinNode.getArglist().isEmpty()) { replacePossibleArguments(mixinNode, defClone); } Node previous = mixinNode; for (final Node child : new ArrayList<Node>(defClone.getChildren())) { replaceChildVariables(defClone, child); mixinNode.getParentNode().appendChild(child, previous); previous = child; } } mixinNode.getParentNode().removeChild(mixinNode); }
new ArrayList<Node>(imported.getChildren()), importNode); node.removeChild(importNode); } catch (CSSException e) { e.printStackTrace();
public static void traverse(VariableNode node) { VariableNode variable = ScssStylesheet.getVariable(node.getName()); if (!node.isGuarded() || variable == null || variable.getExpr() == null || (variable.getExpr().getLexicalUnitType() == SCSSLexicalUnit.SCSS_NULL && variable .getExpr().getNextLexicalUnit() == null)) { ScssStylesheet.addVariable(node); } node.getParentNode().removeChild(node); } }
node.getParentNode().removeChild(node);