diff options
author | Haijian Wang <haijian@vaadin.com> | 2012-08-21 12:41:52 +0300 |
---|---|---|
committer | Haijian Wang <haijian@vaadin.com> | 2012-08-21 12:41:52 +0300 |
commit | 3d757bddfc2a07a77879fb3310e6dbbc49a1a079 (patch) | |
tree | 260122b3b511a238f6975c19d06fbed2d213c8d5 /sass | |
parent | cc13349d7c0526cfda81fb846b4565a2e7af5d76 (diff) | |
download | vaadin-framework-3d757bddfc2a07a77879fb3310e6dbbc49a1a079.tar.gz vaadin-framework-3d757bddfc2a07a77879fb3310e6dbbc49a1a079.zip |
fixed the hsl bug reported by Jouni, it is caused by the LexicalUnitImpl replace function and the updateVaule function in VariableVisitor
Diffstat (limited to 'sass')
-rw-r--r-- | sass/src/com/vaadin/sass/parser/LexicalUnitImpl.java | 2 | ||||
-rw-r--r-- | sass/src/com/vaadin/sass/visitor/VariableVisitor.java | 31 |
2 files changed, 23 insertions, 10 deletions
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 bb790a0aee..eb2e6a0b83 100644 --- a/sass/src/com/vaadin/sass/visitor/VariableVisitor.java +++ b/sass/src/com/vaadin/sass/visitor/VariableVisitor.java @@ -28,13 +28,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>( @@ -47,17 +54,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(); @@ -65,5 +77,6 @@ public class VariableVisitor implements Visitor { } LexicalUnit next = value.getNextLexicalUnit(); updateValue(next, variables); + return onceMore; } } |