summaryrefslogtreecommitdiffstats
path: root/theme-compiler/src/com/vaadin/sass
diff options
context:
space:
mode:
authorHaijian Wang <haijian@vaadin.com>2013-02-19 11:17:51 +0200
committerVaadin Code Review <review@vaadin.com>2013-02-19 10:16:38 +0000
commit821ebf49d898ba5f0e2f2e386de242b3dbcbe2e1 (patch)
tree370ee54321db44c581f30401835305534f4845b7 /theme-compiler/src/com/vaadin/sass
parent638bb9263d867f300123acc9023f27ee242e6079 (diff)
downloadvaadin-framework-821ebf49d898ba5f0e2f2e386de242b3dbcbe2e1.tar.gz
vaadin-framework-821ebf49d898ba5f0e2f2e386de242b3dbcbe2e1.zip
more than expected params in mixin throws IOB exception. (Ticket #10988)
Change-Id: I6451c94a4f733b002165983f92c8577dac4904f6
Diffstat (limited to 'theme-compiler/src/com/vaadin/sass')
-rw-r--r--theme-compiler/src/com/vaadin/sass/internal/visitor/MixinNodeHandler.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/internal/visitor/MixinNodeHandler.java b/theme-compiler/src/com/vaadin/sass/internal/visitor/MixinNodeHandler.java
index 8a62e3abf8..5aa90151b9 100644
--- a/theme-compiler/src/com/vaadin/sass/internal/visitor/MixinNodeHandler.java
+++ b/theme-compiler/src/com/vaadin/sass/internal/visitor/MixinNodeHandler.java
@@ -108,18 +108,39 @@ public class MixinNodeHandler {
}
}
}
-
- int i = 0;
- for (final LexicalUnitImpl unit : remainingUnits) {
+ checkExtraParameters(mixinNode, remainingNodes.size(),
+ remainingUnits.size());
+ for (int i = 0; i < remainingNodes.size()
+ && i < remainingUnits.size(); i++) {
+ LexicalUnitImpl unit = remainingUnits.get(i);
remainingNodes.get(i).setExpr(
(LexicalUnitImpl) DeepCopy.copy(unit));
- i++;
}
-
}
}
+ protected static void checkExtraParameters(MixinNode mixinNode,
+ int remainingNodesSize, int remainingUnitsSize) {
+ if (remainingUnitsSize > remainingNodesSize) {
+ String fileName = null;
+ Node root = mixinNode.getParentNode();
+ while (root != null && !(root instanceof ScssStylesheet)) {
+ root = root.getParentNode();
+ }
+ if (root != null) {
+ fileName = ((ScssStylesheet) root).getFileName();
+ }
+ StringBuilder builder = new StringBuilder();
+ builder.append("More parameters than expected, in Mixin ").append(
+ mixinNode.getName());
+ if (fileName != null) {
+ builder.append(", in file ").append(fileName);
+ }
+ throw new RuntimeException(builder.toString());
+ }
+ }
+
private static void replaceChildVariables(MixinDefNode mixinDef, Node node) {
for (final Node child : node.getChildren()) {
replaceChildVariables(mixinDef, child);