private static void replaceDefNodeWithCorrectChild(IfElseDefNode defNode, Node parent, final Node child) { for (final Node n : new ArrayList<Node>(child.getChildren())) { parent.appendChild(n, defNode); } } }
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); } }
private MixinDefNode findAndReplaceContentNodeInChildren(Node node, MixinNode mixinNode) { ContentNode contentNode = null; for (Node child : new ArrayList<Node>(node.getChildren())) { if (child instanceof ContentNode) { contentNode = (ContentNode) child; replaceContentNode(contentNode, mixinNode); } else { findAndReplaceContentNodeInChildren(child, mixinNode); } } return this; }
private static void replaceInterpolation(Node copy, ArrayList<VariableNode> variables) { if (copy instanceof IVariableNode) { IVariableNode n = (IVariableNode) copy; n.replaceVariables(variables); } for (Node c : copy.getChildren()) { replaceInterpolation(c, variables); } }
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); } }
private static void modifyTree(Node node) throws Exception { for (Node child : node.getChildren()) { if (child instanceof BlockNode) { BlockNode blockNode = (BlockNode) child; String selectorString = blockNode.getSelectors(); if (extendsMap.get(selectorString) != null) { for (ArrayList<String> sList : extendsMap .get(selectorString)) { ArrayList<String> clone = (ArrayList<String>) sList .clone(); addAdditionalSelectorListToBlockNode(blockNode, clone, null); } } else { for (Entry<String, List<ArrayList<String>>> entry : extendsMap .entrySet()) { if (StringUtil.containsSubString(selectorString, entry.getKey())) { for (ArrayList<String> sList : entry.getValue()) { ArrayList<String> clone = (ArrayList<String>) sList .clone(); addAdditionalSelectorListToBlockNode(blockNode, clone, entry.getKey()); } } } } } } }
for (int i = 0; i < node.getChildren().size(); i++) { Node current = node.getChildren().get(i); if (traverse(current)) { boolean removed = !originalParent.getChildren().contains(node); return removed; } else {
private static void replaceChildVariables(MixinDefNode mixinDef, Node node) { for (final Node child : node.getChildren()) { replaceChildVariables(mixinDef, child); } if (node instanceof IVariableNode) { ((IVariableNode) node).replaceVariables(mixinDef.getArglist()); } } }
private static void updateUrlInImportedSheet(Node node, String prefix) { for (Node child : node.getChildren()) { if (child instanceof RuleNode) { LexicalUnit value = ((RuleNode) child).getValue(); while (value != null) { if (value.getLexicalUnitType() == LexicalUnit.SAC_URI) { String path = value.getStringValue() .replaceAll("^\"|\"$", "") .replaceAll("^'|'$", ""); if (!path.startsWith("/") && !path.contains(":")) { path = prefix + path; path = StringUtil.cleanPath(path); ((LexicalUnitImpl) value).setStringValue(path); } } value = value.getNextLexicalUnit(); } } updateUrlInImportedSheet(child, prefix); } } }
throw new ParseException("Nested import in an invalid context"); ArrayList<Node> c = new ArrayList<Node>(node.getChildren()); for (Node n : c) { if (n instanceof ImportNode) {