diff options
author | Marc Englund <marc@vaadin.com> | 2012-09-11 16:27:05 +0300 |
---|---|---|
committer | Marc Englund <marc@vaadin.com> | 2012-09-11 16:27:28 +0300 |
commit | c9e8218799152dd90bacb6c8b92b648a951aca24 (patch) | |
tree | 88838e0fdaf1257258d2e3d5eaffd7cb88819ab6 /theme-compiler/src/com/vaadin/sass/tree/VariableNode.java | |
parent | 6ccbb9e40ebb160d2bc1a57c5b5293c4f87d0b27 (diff) | |
download | vaadin-framework-c9e8218799152dd90bacb6c8b92b648a951aca24.tar.gz vaadin-framework-c9e8218799152dd90bacb6c8b92b648a951aca24.zip |
Applying patch: remak of variable handling in sass (partial for e.g #9492 and others)
Diffstat (limited to 'theme-compiler/src/com/vaadin/sass/tree/VariableNode.java')
-rw-r--r-- | theme-compiler/src/com/vaadin/sass/tree/VariableNode.java | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java b/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java index db014ae616..b7e9a21d51 100644 --- a/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java +++ b/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java @@ -16,9 +16,14 @@ package com.vaadin.sass.tree; +import java.util.ArrayList; + import org.w3c.css.sac.LexicalUnit; -public class VariableNode extends Node { +import com.vaadin.sass.parser.LexicalUnitImpl; +import com.vaadin.sass.util.DeepCopy; + +public class VariableNode extends Node implements IVariableNode { private static final long serialVersionUID = 7003372557547748734L; private String name; @@ -64,4 +69,43 @@ public class VariableNode extends Node { this.guarded = guarded; } + @Override + public void replaceVariables(ArrayList<VariableNode> variables) { + for (final VariableNode node : variables) { + if (!this.equals(node)) { + + if (name.equals(node.getName())) { + expr = (LexicalUnit) DeepCopy.copy(node.getExpr()); + guarded = node.isGuarded(); + continue; + } + + LexicalUnit current = expr; + while (current != null) { + if (current.toString().contains(node.getName())) { + ((LexicalUnitImpl) current) + .replaceValue(node.getExpr()); + } + + current = current.getNextLexicalUnit(); + } + + } + } + } + + public boolean replacePossibleVariables(ArrayList<VariableNode> list) { + list.remove(this); + LexicalUnit oldExpr = (LexicalUnit) DeepCopy.copy(expr); + replaceVariables(list); + + if (!oldExpr.toString().equals(expr.toString())) { + for (VariableNode n : list) { + if (expr.toString().equals(n.getExpr().toString())) { + return true; + } + } + } + return false; + } } |