Package com.vaadin.sass.internal.tree

Examples of com.vaadin.sass.internal.tree.Node


     *            node to traverse
     * @return true if the node was removed (and possibly replaced by others),
     *         false if not
     */
    public boolean traverse(Node node) {
        Node originalParent = node.getParentNode();

        node.traverse();

        Map<String, VariableNode> variableScope = openVariableScope();

        // the size of the child list may change on each iteration: current node
        // may get deleted and possibly other nodes have been inserted where it
        // was or after that position
        for (int i = 0; i < node.getChildren().size(); i++) {
            Node current = node.getChildren().get(i);
            if (traverse(current)) {
                // current has been removed
                --i;
            }
        }
View Full Code Here


    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);
        }
    }
View Full Code Here

        ScssStylesheet styleSheet = null;
        if (node instanceof ScssStylesheet) {
            styleSheet = (ScssStylesheet) node;
        } else {
            // iterate to parents of node, find ScssStylesheet
            Node parent = node.getParentNode();
            while (parent != null && !(parent instanceof ScssStylesheet)) {
                parent = parent.getParentNode();
            }
            if (parent instanceof ScssStylesheet) {
                styleSheet = (ScssStylesheet) parent;
            }
        }
View Full Code Here

            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;
            }
View Full Code Here

    protected static void checkExtraParameters(MixinNode mixinNode,
            int remainingNodesSize, int remainingUnitsSize) {
        if (remainingUnitsSize > remainingNodesSize) {
            String fileName = null;
            Node root = mixinNode.getParentNode();
            while (root != null && !(root instanceof ScssStylesheet)) {
                root = root.getParentNode();
            }
            if (root != null) {
                fileName = ((ScssStylesheet) root).getFileName();
            }
            StringBuilder builder = new StringBuilder();
View Full Code Here

        if (node.getChildren().size() == 0) {
            // empty blocks are removed later
            return;
        }

        Node parent = node.getParentNode();

        if (parent instanceof BlockNode) {
            combineParentSelectorListToChild(node);

        } else if (node.getSelectors().contains("&")) {
View Full Code Here

                    newList.add(parentSelector + " " + childSelector);
                }
            }
        }
        node.setSelectorList(newList);
        Node oldParent = node.getParentNode();

        HashMap<Node, Node> lastNodeAdded = ScssStylesheet.getLastNodeAdded();
        Node lastAdded = lastNodeAdded.get(oldParent.getParentNode());
        if (lastAdded == null) {
            lastAdded = oldParent;
        }

        oldParent.getParentNode().appendChild(node, lastAdded);
View Full Code Here

* {@link BlockNodeHandler}.
*/
public class NestedNodeHandler {

    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);
View Full Code Here

    public static void traverse(EachDefNode node) {
        replaceEachDefNode(node);
    }

    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;
View Full Code Here

                        String prefix = getUrlPrefix(importNode.getUri());
                        if (prefix != null) {
                            updateUrlInImportedSheet(imported, prefix);
                        }

                        Node pre = importNode;
                        for (Node importedChild : new ArrayList<Node>(
                                imported.getChildren())) {
                            node.appendChild(importedChild, pre);
                            pre = importedChild;
                        }
View Full Code Here

TOP

Related Classes of com.vaadin.sass.internal.tree.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.