summaryrefslogtreecommitdiffstats
path: root/sass
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2012-08-30 10:17:16 +0300
committerMarc Englund <marc@vaadin.com>2012-08-30 10:17:16 +0300
commite71794ee177e309a4cba15ebd6b65d5950721dd7 (patch)
tree52df34791e76325c0c1f4ac5385d394610c3e288 /sass
parent269746aa7843e41a7aa4dd3cf9da731dc18a7d43 (diff)
parent3d757bddfc2a07a77879fb3310e6dbbc49a1a079 (diff)
downloadvaadin-framework-e71794ee177e309a4cba15ebd6b65d5950721dd7.tar.gz
vaadin-framework-e71794ee177e309a4cba15ebd6b65d5950721dd7.zip
Merge branch 'sass'
Diffstat (limited to 'sass')
-rw-r--r--sass/README11
-rw-r--r--sass/src/com/vaadin/sass/parser/LexicalUnitImpl.java2
-rw-r--r--sass/src/com/vaadin/sass/visitor/VariableVisitor.java31
3 files changed, 34 insertions, 10 deletions
diff --git a/sass/README b/sass/README
new file mode 100644
index 0000000000..4d9482763f
--- /dev/null
+++ b/sass/README
@@ -0,0 +1,11 @@
+This project compiles SCSS into CSS.
+It parses the SCSS into a tree.
+
+Classes
+=======
+SassCompiler: This is the main class that can be run from command line. First parameter is for a scss file to be compiled. Second parameter is optional and is a reference to a file where you want the compiled css. If file doesn't exist, it will be deleted. If file exists, it will be deleted and recreated. If second argument is left out, the css will be printed into standard out.
+ScssStylesheet: When Scss/Css is parsed in, it will be represented in memory as this file. Reference is got through static get(File file) where file is input.
+Parser: A JavaCC compiled java class that parses the input and notifies the DocumentHandler on what nodes it encounters.
+Parser.jj: Source for the Parser class.
+SCSSDocumentHandlerImpl: Class that takes in calls from parser and creates nodes into ScssStylesheet based on those calls.
+Node package: All the nodes representing the Scss/Css in tree format \ No newline at end of file
diff --git a/sass/src/com/vaadin/sass/parser/LexicalUnitImpl.java b/sass/src/com/vaadin/sass/parser/LexicalUnitImpl.java
index e268da8ed5..a6b03a864c 100644
--- a/sass/src/com/vaadin/sass/parser/LexicalUnitImpl.java
+++ b/sass/src/com/vaadin/sass/parser/LexicalUnitImpl.java
@@ -357,7 +357,7 @@ public class LexicalUnitImpl implements LexicalUnit, SCSSLexicalUnit,
dimension = another.getDimension();
sdimension = another.getSdimension();
s = another.getStringValue();
- fname = getFunctionName();
+ fname = another.getFunctionName();
params = another.getParameters();
prev = another.getPreviousLexicalUnit();
LexicalUnit finalNextInAnother = another;
diff --git a/sass/src/com/vaadin/sass/visitor/VariableVisitor.java b/sass/src/com/vaadin/sass/visitor/VariableVisitor.java
index e8fb2fccc3..7fa62bd20f 100644
--- a/sass/src/com/vaadin/sass/visitor/VariableVisitor.java
+++ b/sass/src/com/vaadin/sass/visitor/VariableVisitor.java
@@ -40,13 +40,20 @@ public class VariableVisitor implements Visitor {
private void traverse(Node node, Map<String, LexicalUnitImpl> variables) {
if (node instanceof RuleNode) {
LexicalUnit value = ((RuleNode) node).getValue();
- updateValue(value, variables);
+ while (updateValue(value, variables)) {
+ ;
+ }
} else {
Set<Node> toBeDeleted = new HashSet<Node>();
for (Node child : node.getChildren()) {
if (child instanceof VariableNode) {
- variables.put(((VariableNode) child).getName(),
- (LexicalUnitImpl) ((VariableNode) child).getExpr());
+ VariableNode varChild = (VariableNode) child;
+ if (!varChild.isGuarded() || varChild.isGuarded()
+ && variables.get(varChild.getName()) == null) {
+ variables.put(((VariableNode) child).getName(),
+ (LexicalUnitImpl) ((VariableNode) child)
+ .getExpr());
+ }
toBeDeleted.add(child);
} else {
traverse(child, new HashMap<String, LexicalUnitImpl>(
@@ -59,17 +66,22 @@ public class VariableVisitor implements Visitor {
}
}
- private void updateValue(LexicalUnit value,
+ private boolean updateValue(LexicalUnit value,
Map<String, LexicalUnitImpl> variables) {
+ boolean onceMore = false;
if (value == null) {
- return;
+ return false;
}
if (value.getLexicalUnitType() == SCSSLexicalUnit.SCSS_VARIABLE) {
- LexicalUnitImpl variableValue = variables.get(
- value.getStringValue()).clone();
+ LexicalUnitImpl variableValue = variables.get(value
+ .getStringValue());
if (variableValue != null) {
- LexicalUnitImpl lexVal = (LexicalUnitImpl) value;
- lexVal.replaceValue(variableValue);
+ LexicalUnitImpl variableValueCloned = variableValue.clone();
+ if (variableValueCloned != null) {
+ LexicalUnitImpl lexVal = (LexicalUnitImpl) value;
+ lexVal.replaceValue(variableValueCloned);
+ onceMore = true;
+ }
}
} else if (value.getLexicalUnitType() == SCSSLexicalUnit.SAC_FUNCTION) {
LexicalUnit params = value.getParameters();
@@ -77,5 +89,6 @@ public class VariableVisitor implements Visitor {
}
LexicalUnit next = value.getNextLexicalUnit();
updateValue(next, variables);
+ return onceMore;
}
}