aboutsummaryrefslogtreecommitdiffstats
path: root/theme-compiler/src/com/vaadin/sass/tree/controldirective
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2012-09-11 16:27:05 +0300
committerMarc Englund <marc@vaadin.com>2012-09-11 16:27:28 +0300
commitc9e8218799152dd90bacb6c8b92b648a951aca24 (patch)
tree88838e0fdaf1257258d2e3d5eaffd7cb88819ab6 /theme-compiler/src/com/vaadin/sass/tree/controldirective
parent6ccbb9e40ebb160d2bc1a57c5b5293c4f87d0b27 (diff)
downloadvaadin-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/controldirective')
-rw-r--r--theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlChildNode.java6
-rw-r--r--theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlDefNode.java6
-rw-r--r--theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlNode.java5
-rw-r--r--theme-compiler/src/com/vaadin/sass/tree/controldirective/EachDefNode.java2
-rw-r--r--theme-compiler/src/com/vaadin/sass/tree/controldirective/ElseNode.java12
-rw-r--r--theme-compiler/src/com/vaadin/sass/tree/controldirective/IfElseDefNode.java17
-rw-r--r--theme-compiler/src/com/vaadin/sass/tree/controldirective/IfElseNode.java7
-rw-r--r--theme-compiler/src/com/vaadin/sass/tree/controldirective/IfNode.java55
8 files changed, 92 insertions, 18 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlChildNode.java b/theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlChildNode.java
deleted file mode 100644
index a6df1e744b..0000000000
--- a/theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlChildNode.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package com.vaadin.sass.tree.controldirective;
-
-
-public interface ControlChildNode extends ControlNode {
-
-}
diff --git a/theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlDefNode.java b/theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlDefNode.java
deleted file mode 100644
index 4ead42eb0a..0000000000
--- a/theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlDefNode.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package com.vaadin.sass.tree.controldirective;
-
-
-public interface ControlDefNode extends ControlNode {
-
-}
diff --git a/theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlNode.java b/theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlNode.java
deleted file mode 100644
index 453593d4d2..0000000000
--- a/theme-compiler/src/com/vaadin/sass/tree/controldirective/ControlNode.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.vaadin.sass.tree.controldirective;
-
-public interface ControlNode {
-
-}
diff --git a/theme-compiler/src/com/vaadin/sass/tree/controldirective/EachDefNode.java b/theme-compiler/src/com/vaadin/sass/tree/controldirective/EachDefNode.java
index 1dfa5892d9..2cb9aeb1c3 100644
--- a/theme-compiler/src/com/vaadin/sass/tree/controldirective/EachDefNode.java
+++ b/theme-compiler/src/com/vaadin/sass/tree/controldirective/EachDefNode.java
@@ -21,7 +21,7 @@ import java.util.List;
import com.vaadin.sass.tree.Node;
-public class EachDefNode extends Node implements ControlDefNode {
+public class EachDefNode extends Node {
private static final long serialVersionUID = 7943948981204906221L;
private String var;
diff --git a/theme-compiler/src/com/vaadin/sass/tree/controldirective/ElseNode.java b/theme-compiler/src/com/vaadin/sass/tree/controldirective/ElseNode.java
new file mode 100644
index 0000000000..529ce4d76e
--- /dev/null
+++ b/theme-compiler/src/com/vaadin/sass/tree/controldirective/ElseNode.java
@@ -0,0 +1,12 @@
+package com.vaadin.sass.tree.controldirective;
+
+import com.vaadin.sass.tree.Node;
+
+public class ElseNode extends Node implements IfElseNode {
+
+ @Override
+ public String getExpression() {
+ return null;
+ }
+
+}
diff --git a/theme-compiler/src/com/vaadin/sass/tree/controldirective/IfElseDefNode.java b/theme-compiler/src/com/vaadin/sass/tree/controldirective/IfElseDefNode.java
new file mode 100644
index 0000000000..5bd3ba526c
--- /dev/null
+++ b/theme-compiler/src/com/vaadin/sass/tree/controldirective/IfElseDefNode.java
@@ -0,0 +1,17 @@
+package com.vaadin.sass.tree.controldirective;
+
+import com.vaadin.sass.tree.Node;
+
+public class IfElseDefNode extends Node {
+
+ @Override
+ public String toString() {
+ StringBuilder b = new StringBuilder();
+ for (final Node child : getChildren()) {
+ b.append(child.toString());
+ b.append("\n");
+ }
+ return b.toString();
+ }
+
+}
diff --git a/theme-compiler/src/com/vaadin/sass/tree/controldirective/IfElseNode.java b/theme-compiler/src/com/vaadin/sass/tree/controldirective/IfElseNode.java
new file mode 100644
index 0000000000..8f6c09addc
--- /dev/null
+++ b/theme-compiler/src/com/vaadin/sass/tree/controldirective/IfElseNode.java
@@ -0,0 +1,7 @@
+package com.vaadin.sass.tree.controldirective;
+
+public interface IfElseNode {
+
+ String getExpression();
+
+}
diff --git a/theme-compiler/src/com/vaadin/sass/tree/controldirective/IfNode.java b/theme-compiler/src/com/vaadin/sass/tree/controldirective/IfNode.java
new file mode 100644
index 0000000000..2f31f36f0c
--- /dev/null
+++ b/theme-compiler/src/com/vaadin/sass/tree/controldirective/IfNode.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2011 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.sass.tree.controldirective;
+
+import java.util.ArrayList;
+
+import com.vaadin.sass.tree.IVariableNode;
+import com.vaadin.sass.tree.Node;
+import com.vaadin.sass.tree.VariableNode;
+
+public class IfNode extends Node implements IfElseNode, IVariableNode {
+ private String expression;
+
+ public IfNode(String expression) {
+ this.expression = expression;
+ }
+
+ @Override
+ public String getExpression() {
+ if (expression != null) {
+ return expression.trim();
+ } else {
+ return "false";
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "@if" + expression;
+ }
+
+ @Override
+ public void replaceVariables(ArrayList<VariableNode> variables) {
+ for (final VariableNode node : variables) {
+ if (expression.contains(node.getName())) {
+ expression = expression.replaceAll(node.getName(), node
+ .getExpr().toString());
+ }
+ }
+ }
+
+} \ No newline at end of file