summaryrefslogtreecommitdiffstats
path: root/theme-compiler
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2012-10-15 13:51:24 +0300
committerMarc Englund <marc@vaadin.com>2012-10-15 16:02:20 +0300
commit98dd17be57dd4280912a9ede86afaa9fa8ea4c72 (patch)
treec280ca6c27645fecc0e2da6a7a948ee2e8abca52 /theme-compiler
parent16452cbb7fff0441cde4d2d303297e83e8c58ce1 (diff)
downloadvaadin-framework-98dd17be57dd4280912a9ede86afaa9fa8ea4c72.tar.gz
vaadin-framework-98dd17be57dd4280912a9ede86afaa9fa8ea4c72.zip
Fixes Ticket #9408 (orig by Seba)
Change-Id: Idb1cb4babfb712d5bf58f9930220fa18a2865925
Diffstat (limited to 'theme-compiler')
-rw-r--r--theme-compiler/src/com/vaadin/sass/parser/LexicalUnitImpl.java14
-rw-r--r--theme-compiler/src/com/vaadin/sass/tree/VariableNode.java32
-rw-r--r--theme-compiler/src/com/vaadin/sass/visitor/VariableVisitor.java16
3 files changed, 37 insertions, 25 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/parser/LexicalUnitImpl.java b/theme-compiler/src/com/vaadin/sass/parser/LexicalUnitImpl.java
index 0afb95b315..1548538a88 100644
--- a/theme-compiler/src/com/vaadin/sass/parser/LexicalUnitImpl.java
+++ b/theme-compiler/src/com/vaadin/sass/parser/LexicalUnitImpl.java
@@ -632,4 +632,18 @@ public class LexicalUnitImpl implements LexicalUnit, SCSSLexicalUnit,
public static LexicalUnitImpl createIdent(String s) {
return new LexicalUnitImpl(0, 0, null, SAC_IDENT, s);
}
+
+ public static void replaceValues(LexicalUnitImpl unit,
+ LexicalUnitImpl replaceWith) {
+ unit.setLexicalUnitType(replaceWith.getLexicalUnitType());
+ unit.setStringValue(replaceWith.getStringValue());
+ unit.setFloatValue(replaceWith.getFloatValue());
+ unit.setIntegerValue(replaceWith.getIntegerValue());
+ unit.setFunctionName(replaceWith.getFunctionName());
+
+ if (replaceWith.getParameters() != null) {
+ unit.setParameters(replaceWith.getParameters());
+ }
+
+ }
}
diff --git a/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java b/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java
index 8c360c4a56..6ba27ebac5 100644
--- a/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java
+++ b/theme-compiler/src/com/vaadin/sass/tree/VariableNode.java
@@ -18,10 +18,7 @@ package com.vaadin.sass.tree;
import java.util.ArrayList;
-import org.w3c.css.sac.LexicalUnit;
-
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;
@@ -73,23 +70,26 @@ public class VariableNode extends Node implements IVariableNode {
for (final VariableNode node : variables) {
if (!equals(node)) {
- if (name.equals(node.getName())) {
- expr = (LexicalUnitImpl) 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());
+ if (expr.toString().contains("$" + node.getName())) {
+ if (expr.getParameters() != null
+ && expr.getParameters().toString()
+ .contains("$" + node.getName())) {
+ replaceValues(expr.getParameters(), node);
}
-
- current = current.getNextLexicalUnit();
}
+ }
+ }
+ }
+ private void replaceValues(LexicalUnitImpl unit, VariableNode node) {
+ while (unit != null) {
+
+ if (unit.getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE
+ && unit.getValue().toString().equals(node.getName())) {
+ LexicalUnitImpl.replaceValues(unit, node.getExpr());
}
+
+ unit = unit.getNextLexicalUnit();
}
}
}
diff --git a/theme-compiler/src/com/vaadin/sass/visitor/VariableVisitor.java b/theme-compiler/src/com/vaadin/sass/visitor/VariableVisitor.java
index b6963caf1b..c8e28cd9e3 100644
--- a/theme-compiler/src/com/vaadin/sass/visitor/VariableVisitor.java
+++ b/theme-compiler/src/com/vaadin/sass/visitor/VariableVisitor.java
@@ -54,8 +54,14 @@ public class VariableVisitor implements Visitor {
this.variables.values());
for (Node node : children) {
- if (node instanceof VariableNode) {
+ if (node instanceof IVariableNode) {
+ ((IVariableNode) node)
+ .replaceVariables(new ArrayList<VariableNode>(
+ this.variables.values()));
+ }
+
+ if (node instanceof VariableNode) {
VariableNode variableNode = (VariableNode) node;
if (this.variables.containsKey(variableNode.getName())
&& variableNode.isGuarded()) {
@@ -64,10 +70,6 @@ public class VariableVisitor implements Visitor {
this.variables.put(variableNode.getName(), variableNode);
} else if (node instanceof ListModifyNode) {
- ((IVariableNode) node)
- .replaceVariables(new ArrayList<VariableNode>(
- this.variables.values()));
-
ListModifyNode modify = (ListModifyNode) node;
String variable = modify.getNewVariable().substring(1);
@@ -79,10 +81,6 @@ public class VariableVisitor implements Visitor {
} catch (Exception e) {
e.printStackTrace();
}
- } else if (node instanceof IVariableNode) {
- ((IVariableNode) node)
- .replaceVariables(new ArrayList<VariableNode>(
- this.variables.values()));
}
replaceVariables(node, node.getChildren());