import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.logging.Logger;
import org.w3c.css.sac.CSSException;
import org.w3c.css.sac.InputSource;
return lastNodeAdded;
}
+ public static final void warning(String msg) {
+ Logger.getLogger(ScssStylesheet.class.getName()).warning(msg);
+ }
}
if (parent instanceof BlockNode) {
combineParentSelectorListToChild(node);
+
+ } else if (node.getSelectors().contains("&")) {
+ ScssStylesheet.warning("Base-level rule contains"
+ + " the parent-selector-referencing character '&';"
+ + " the character will be removed:\n" + node);
+ removeParentReference(node);
}
}
+ /**
+ * Goes through the selector list of the given BlockNode and removes the '&'
+ * character from the selectors.
+ *
+ * @param node
+ */
+ private static void removeParentReference(BlockNode node) {
+ ArrayList<String> newList = new ArrayList<String>();
+ for (String childSelector : node.getSelectorList()) {
+ // remove parent selector
+ if (childSelector.contains("&")) {
+ newList.add(childSelector.replace("&", ""));
+ } else {
+ newList.add(childSelector);
+ }
+ }
+ node.setSelectorList(newList);
+ }
+
private static void combineParentSelectorListToChild(BlockNode node) {
ArrayList<String> newList = new ArrayList<String>();
BlockNode parentBlock = (BlockNode) node.getParentNode();