aboutsummaryrefslogtreecommitdiffstats
path: root/theme-compiler/src/com/vaadin/sass/tree/RuleNode.java
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2012-09-27 09:56:49 +0300
committerMarc Englund <marc@vaadin.com>2012-09-27 09:56:49 +0300
commitabea9d1ce0fdcad2e344cfa2417a09c29d903648 (patch)
treefaa69c865e4e9a859c82a6b54046cecc618906cf /theme-compiler/src/com/vaadin/sass/tree/RuleNode.java
parentaf67b3056eabb6428aa2a5e736d5a19e6cca9564 (diff)
downloadvaadin-framework-abea9d1ce0fdcad2e344cfa2417a09c29d903648.tar.gz
vaadin-framework-abea9d1ce0fdcad2e344cfa2417a09c29d903648.zip
Fixes #9492 so that interpolation of mixin parameters works as expected
Diffstat (limited to 'theme-compiler/src/com/vaadin/sass/tree/RuleNode.java')
-rw-r--r--theme-compiler/src/com/vaadin/sass/tree/RuleNode.java38
1 files changed, 35 insertions, 3 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/tree/RuleNode.java b/theme-compiler/src/com/vaadin/sass/tree/RuleNode.java
index ee8d8145f1..aad4509616 100644
--- a/theme-compiler/src/com/vaadin/sass/tree/RuleNode.java
+++ b/theme-compiler/src/com/vaadin/sass/tree/RuleNode.java
@@ -17,10 +17,11 @@
package com.vaadin.sass.tree;
import java.util.ArrayList;
+import java.util.regex.Pattern;
import com.vaadin.sass.parser.LexicalUnitImpl;
-public class RuleNode extends Node implements IVariableNode {
+public class RuleNode extends Node implements IVariableNode, InterpolationNode {
private static final long serialVersionUID = 6653493127869037022L;
String variable;
@@ -83,10 +84,11 @@ public class RuleNode extends Node implements IVariableNode {
public void replaceVariables(ArrayList<VariableNode> variables) {
for (final VariableNode node : variables) {
if (value.getLexicalUnitType() == LexicalUnitImpl.SAC_FUNCTION) {
- if (value.getParameters().toString().contains(node.getName())) {
+ if (value.getParameters().toString()
+ .contains("$" + node.getName())) {
if (value.getParameters() != null) {
if (value.getParameters().toString()
- .contains("$" + node.getName())) {
+ .contains(node.getName())) {
LexicalUnitImpl param = value.getParameters();
while (param != null) {
@@ -125,4 +127,34 @@ public class RuleNode extends Node implements IVariableNode {
}
}
}
+
+ @Override
+ public void replaceInterpolation(String variableName, String variable) {
+ if (this.variable.contains(variableName)) {
+ this.variable = this.variable.replaceAll(variableName, variable);
+ }
+
+ if (value.toString().contains(variableName)) {
+
+ LexicalUnitImpl current = value;
+ while (current != null) {
+ if (current.getValue().toString().contains(variableName)) {
+ current.setStringValue(current
+ .getValue()
+ .toString()
+ .replaceAll(
+ Pattern.quote("#{" + variableName + "}"),
+ variable));
+ }
+
+ current = value.getNextLexicalUnit();
+ }
+ }
+ }
+
+ @Override
+ public boolean containsInterpolationVariable(String variable) {
+ return value.toString().contains(variable)
+ || this.variable.contains(variable);
+ }
}