diff options
Diffstat (limited to 'theme-compiler/src/com/vaadin')
6 files changed, 29 insertions, 18 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/SassCompiler.java b/theme-compiler/src/com/vaadin/sass/SassCompiler.java index e6ac31b865..07d6eb01f1 100644 --- a/theme-compiler/src/com/vaadin/sass/SassCompiler.java +++ b/theme-compiler/src/com/vaadin/sass/SassCompiler.java @@ -25,14 +25,20 @@ public class SassCompiler { public static void main(String[] args) throws Exception { String input = null; String output = null; - if (args.length == 0) { + if (args.length < 1 || args.length > 2) { System.out .println("usage: SassCompile <scss file to compile> <css file to write>"); return; - } else if (args.length == 1) { - input = args[0]; - } else { - input = args[0]; + } + + File in = new File(args[0]); + if (!in.canRead()) { + System.err.println(in.getCanonicalPath() + " could not be read!"); + return; + } + input = in.getCanonicalPath(); + + if (args.length == 2) { output = args[1]; } diff --git a/theme-compiler/src/com/vaadin/sass/ScssStylesheet.java b/theme-compiler/src/com/vaadin/sass/ScssStylesheet.java index 45578deb19..5f46844641 100644 --- a/theme-compiler/src/com/vaadin/sass/ScssStylesheet.java +++ b/theme-compiler/src/com/vaadin/sass/ScssStylesheet.java @@ -38,7 +38,6 @@ import com.vaadin.sass.tree.Node; import com.vaadin.sass.tree.VariableNode; import com.vaadin.sass.tree.controldirective.IfElseDefNode; import com.vaadin.sass.visitor.ImportNodeHandler; -import com.vaadin.sass.visitor.ParentSelectorHandler; public class ScssStylesheet extends Node { @@ -52,6 +51,8 @@ public class ScssStylesheet extends Node { private static final HashSet<IfElseDefNode> ifElseDefNodes = new HashSet<IfElseDefNode>(); + private static HashMap<Node, Node> lastNodeAdded = new HashMap<Node, Node>(); + private String fileName; /** @@ -130,7 +131,7 @@ public class ScssStylesheet extends Node { mixinDefs.clear(); variables.clear(); ifElseDefNodes.clear(); - ParentSelectorHandler.clear(); + lastNodeAdded.clear(); importOtherFiles(this); populateDefinitions(this); traverse(this); @@ -245,4 +246,8 @@ public class ScssStylesheet extends Node { return fileName; } + public static HashMap<Node, Node> getLastNodeAdded() { + return lastNodeAdded; + } + } diff --git a/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java b/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java index 3ea8379829..89cab33129 100644 --- a/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java +++ b/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java @@ -77,6 +77,8 @@ public class VariableNode extends Node implements IVariableNode { && expr.getParameters().toString() .contains("$" + node.getName())) { replaceValues(expr.getParameters(), node); + } else if (expr.getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE) { + replaceValues(expr, node); } } } diff --git a/theme-compiler/src/com/vaadin/sass/visitor/BlockNodeHandler.java b/theme-compiler/src/com/vaadin/sass/visitor/BlockNodeHandler.java index d338cb0843..0d00fd2d0c 100644 --- a/theme-compiler/src/com/vaadin/sass/visitor/BlockNodeHandler.java +++ b/theme-compiler/src/com/vaadin/sass/visitor/BlockNodeHandler.java @@ -19,13 +19,12 @@ package com.vaadin.sass.visitor; import java.util.ArrayList; import java.util.HashMap; +import com.vaadin.sass.ScssStylesheet; import com.vaadin.sass.tree.BlockNode; import com.vaadin.sass.tree.Node; public class BlockNodeHandler { - private static HashMap<Node, Node> lastNodeAdded = new HashMap<Node, Node>(); - public static void traverse(BlockNode node) { Node parent = node.getParentNode(); @@ -61,6 +60,7 @@ public class BlockNodeHandler { } node.setSelectorList(newList); Node oldParent = node.getParentNode(); + HashMap<Node, Node> lastNodeAdded = ScssStylesheet.getLastNodeAdded(); if (lastNodeAdded.get(oldParent) != null) { node.getParentNode().getParentNode() .appendChild(node, lastNodeAdded.get(oldParent)); diff --git a/theme-compiler/src/com/vaadin/sass/visitor/MixinNodeHandler.java b/theme-compiler/src/com/vaadin/sass/visitor/MixinNodeHandler.java index 3c31ee1073..4875a39b1d 100644 --- a/theme-compiler/src/com/vaadin/sass/visitor/MixinNodeHandler.java +++ b/theme-compiler/src/com/vaadin/sass/visitor/MixinNodeHandler.java @@ -48,6 +48,7 @@ public class MixinNodeHandler { Node pre = mixinNode; MixinDefNode defClone = (MixinDefNode) DeepCopy.copy(mixinDef); + defClone.traverse(); if (mixinDef.getArglist().isEmpty()) { for (Node child : new ArrayList<Node>(defClone.getChildren())) { diff --git a/theme-compiler/src/com/vaadin/sass/visitor/ParentSelectorHandler.java b/theme-compiler/src/com/vaadin/sass/visitor/ParentSelectorHandler.java index 4098cc7cad..cb7b0ac8a8 100644 --- a/theme-compiler/src/com/vaadin/sass/visitor/ParentSelectorHandler.java +++ b/theme-compiler/src/com/vaadin/sass/visitor/ParentSelectorHandler.java @@ -19,13 +19,12 @@ package com.vaadin.sass.visitor; import java.util.ArrayList; import java.util.HashMap; +import com.vaadin.sass.ScssStylesheet; import com.vaadin.sass.tree.BlockNode; import com.vaadin.sass.tree.Node; public class ParentSelectorHandler { - private static HashMap<Node, Node> parentSelectors = new HashMap<Node, Node>(); - public static void traverse(BlockNode block) throws Exception { Node parentNode = block.getParentNode(); if (parentNode instanceof BlockNode) { @@ -48,22 +47,20 @@ public class ParentSelectorHandler { if (isParentSelector) { block.setSelectorList(newList); Node oldparent = block.getParentNode(); - if (parentSelectors.containsKey(block.getParentNode())) { + HashMap<Node, Node> lastNodeAdded = ScssStylesheet + .getLastNodeAdded(); + if (lastNodeAdded.containsKey(block.getParentNode())) { block.getParentNode() .getParentNode() .appendChild(block, - parentSelectors.get(block.getParentNode())); + lastNodeAdded.get(block.getParentNode())); } else { block.getParentNode().getParentNode() .appendChild(block, block.getParentNode()); } - parentSelectors.put(oldparent, block); + lastNodeAdded.put(oldparent, block); } } } - - public static void clear() { - parentSelectors.clear(); - } } |