diff options
author | Sebastian Nyholm <sebastian@vaadin.com> | 2012-10-22 11:11:04 +0300 |
---|---|---|
committer | Sebastian Nyholm <sebastian@vaadin.com> | 2012-11-08 17:16:10 +0200 |
commit | a0da163fd5c23f1d961fc5c686efd6ffc50ecd61 (patch) | |
tree | 093e40a12de854d48920335b67b08144b98556bf /theme-compiler/src/com/vaadin/sass/tree/RuleNode.java | |
parent | e8ae9f7d6427f7f6daae300dee7931a6e8394bdb (diff) | |
download | vaadin-framework-a0da163fd5c23f1d961fc5c686efd6ffc50ecd61.tar.gz vaadin-framework-a0da163fd5c23f1d961fc5c686efd6ffc50ecd61.zip |
Fixes #9546, #9974, #10100, #10105
Change-Id: I1baccb5604899707960b1cf06887ada0fe217d08
Diffstat (limited to 'theme-compiler/src/com/vaadin/sass/tree/RuleNode.java')
-rw-r--r-- | theme-compiler/src/com/vaadin/sass/tree/RuleNode.java | 95 |
1 files changed, 43 insertions, 52 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/tree/RuleNode.java b/theme-compiler/src/com/vaadin/sass/tree/RuleNode.java index aad4509616..38c5b1cb4e 100644 --- a/theme-compiler/src/com/vaadin/sass/tree/RuleNode.java +++ b/theme-compiler/src/com/vaadin/sass/tree/RuleNode.java @@ -19,9 +19,10 @@ package com.vaadin.sass.tree; import java.util.ArrayList; import java.util.regex.Pattern; +import com.vaadin.sass.ScssStylesheet; import com.vaadin.sass.parser.LexicalUnitImpl; -public class RuleNode extends Node implements IVariableNode, InterpolationNode { +public class RuleNode extends Node implements IVariableNode { private static final long serialVersionUID = 6653493127869037022L; String variable; @@ -83,36 +84,51 @@ public class RuleNode extends Node implements IVariableNode, InterpolationNode { @Override public void replaceVariables(ArrayList<VariableNode> variables) { for (final VariableNode node : variables) { + + String interpolation = "#{$" + node.getName() + "}"; + if (value.getLexicalUnitType() == LexicalUnitImpl.SAC_FUNCTION) { - if (value.getParameters().toString() - .contains("$" + node.getName())) { - if (value.getParameters() != null) { - if (value.getParameters().toString() - .contains(node.getName())) { - - LexicalUnitImpl param = value.getParameters(); - while (param != null) { - if (param.getValue().toString() - .contains(node.getName())) { - - LexicalUnitImpl expr = node.getExpr(); - - LexicalUnitImpl prev = param - .getPreviousLexicalUnit(); - LexicalUnitImpl next = param - .getNextLexicalUnit(); - - if (param.getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE) { - param.replaceValue(expr); - param.setPrevLexicalUnit(prev); - param.setNextLexicalUnit(next); - } + + if (value.getParameters() != null) { + if (value.getParameters().toString() + .contains(node.getName())) { + + LexicalUnitImpl param = value.getParameters(); + while (param != null) { + if (param.getValue().toString() + .contains(node.getName())) { + + LexicalUnitImpl expr = node.getExpr(); + + LexicalUnitImpl prev = param + .getPreviousLexicalUnit(); + LexicalUnitImpl next = param + .getNextLexicalUnit(); + + if (param.getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE) { + param.replaceValue(expr); + param.setPrevLexicalUnit(prev); + param.setNextLexicalUnit(next); } - param = param.getNextLexicalUnit(); } + param = param.getNextLexicalUnit(); } } } + } else if (value.getStringValue() != null + && value.getStringValue().contains(interpolation)) { + LexicalUnitImpl current = value; + while (current != null) { + if (current.getValue().toString().contains(interpolation)) { + + current.setStringValue(current + .getValue() + .toString() + .replaceAll(Pattern.quote(interpolation), + node.getExpr().toString())); + } + current = current.getNextLexicalUnit(); + } } else { LexicalUnitImpl current = value; while (current != null) { @@ -129,32 +145,7 @@ public class RuleNode extends Node implements IVariableNode, InterpolationNode { } @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); + public void traverse() { + replaceVariables(ScssStylesheet.getVariables()); } } |