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 {
private static final HashSet<IfElseDefNode> ifElseDefNodes = new HashSet<IfElseDefNode>();
+ private static HashMap<Node, Node> lastNodeAdded = new HashMap<Node, Node>();
+
private String fileName;
/**
mixinDefs.clear();
variables.clear();
ifElseDefNodes.clear();
- ParentSelectorHandler.clear();
+ lastNodeAdded.clear();
importOtherFiles(this);
populateDefinitions(this);
traverse(this);
return fileName;
}
+ public static HashMap<Node, Node> getLastNodeAdded() {
+ return lastNodeAdded;
+ }
+
}
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();
}
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));
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) {
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();
- }
}
text-decoration: none;
}
+a .sub {
+ color: blue;
+}
+
a:hover {
text-decoration: underline;
}
a {
font-weight: bold;
text-decoration: none;
+ .sub {
+ color: blue;
+ }
&:hover { text-decoration: underline; }
body.firefox & { font-weight: normal; }
}
parser.parseStyleSheet(getClass().getResource(scss).getPath());
ScssStylesheet root = handler.getStyleSheet();
BlockNode blockNode = (BlockNode) root.getChildren().get(0);
- Assert.assertEquals(4, blockNode.getChildren().size());
- BlockNode nestedBlock1 = (BlockNode) blockNode.getChildren().get(2);
+ Assert.assertEquals(5, blockNode.getChildren().size());
+ BlockNode nestedBlock1 = (BlockNode) blockNode.getChildren().get(3);
Assert.assertEquals("&:hover", nestedBlock1.getSelectorList().get(0));
- BlockNode nestedBlock2 = (BlockNode) blockNode.getChildren().get(3);
+ BlockNode nestedBlock2 = (BlockNode) blockNode.getChildren().get(4);
Assert.assertEquals("body.firefox &", nestedBlock2.getSelectorList()
.get(0));
}