@Override public void startInclude(String name, List<LexicalUnitImpl> args) { MixinNode node = new MixinNode(name, args); nodeStack.peek().appendChild(node); nodeStack.push(node); }
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(); builder.append("More parameters than expected, in Mixin ").append( mixinNode.getName()); if (fileName != null) { builder.append(", in file ").append(fileName); } throw new RuntimeException(builder.toString()); } }
@Override public void traverse() { try { // limit variable scope to the mixin Map<String, VariableNode> variableScope = ScssStylesheet .openVariableScope(); replaceVariables(ScssStylesheet.getVariables()); replaceVariablesForChildren(); MixinNodeHandler.traverse(this); ScssStylesheet.closeVariableScope(variableScope); } catch (Exception e) { e.printStackTrace(); } }
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); }
protected void replaceVariablesForChildren() { for (Node child : getChildren()) { if (child instanceof IVariableNode) { ((IVariableNode) child).replaceVariables(ScssStylesheet .getVariables()); } } }
if (mixinNode.getArglist().size() > 0) { ArrayList<VariableNode> remainingNodes = new ArrayList<VariableNode>( def.getArglist()); ArrayList<LexicalUnitImpl> remainingUnits = new ArrayList<LexicalUnitImpl>( mixinNode.getArglist()); for (final LexicalUnitImpl unit : mixinNode.getArglist()) { if (unit.getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE && unit.getNextLexicalUnit() != null) {
public MixinDefNode replaceContentNode(ContentNode contentNode, MixinNode mixinNode) { if (contentNode != null) { contentNode.getParentNode().appendChildrenAfter( DeepCopy.copy(mixinNode.getChildren()), contentNode); contentNode.getParentNode().removeChild(contentNode); } return this; } }