From 8d8c286f8ea63f63f0241ca5181a41fc2294ebdc Mon Sep 17 00:00:00 2001 From: erniejunior Date: Sun, 18 Oct 2015 23:58:07 +0200 Subject: [PATCH] Fixed issue #4017 now with even fewer changes. --- .../mode/java/tweak/SketchParser.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/java/src/processing/mode/java/tweak/SketchParser.java b/java/src/processing/mode/java/tweak/SketchParser.java index 9ce2cdd09..487ce8ad2 100644 --- a/java/src/processing/mode/java/tweak/SketchParser.java +++ b/java/src/processing/mode/java/tweak/SketchParser.java @@ -40,7 +40,7 @@ public class SketchParser { List> scientificNotations; // currently is used to ignore numbers in 'setup' and 'settings' functions - List ignoreFunctions; + List> ignoreFunctions; List> commentBlocks; List curlyScopes; @@ -59,11 +59,15 @@ public class SketchParser { } // add 'settings' and 'setup' to ignore list (to ignore all numbers there) - ignoreFunctions = new ArrayList(); - ignoreFunctions.add(new Range(getVoidFunctionStart(codeTabs[0], "settings"), - getVoidFunctionEnd(codeTabs[0], "settings"))); - ignoreFunctions.add(new Range(getVoidFunctionStart(codeTabs[0], "setup"), - getVoidFunctionEnd(codeTabs[0], "setup"))); + ignoreFunctions = new ArrayList<>(); + ignoreFunctions.add(Arrays.asList(new Range(getVoidFunctionStart(codeTabs[0], "settings"), + getVoidFunctionEnd(codeTabs[0], "settings")), + new Range(getVoidFunctionStart(codeTabs[0], "setup"), + getVoidFunctionEnd(codeTabs[0], "setup")))); + + //Add empty lists for the other tabs so we do not get an index out of bounds error later + for(int i = 0; i < codeTabs.length-1; i++) + ignoreFunctions.add(Collections.EMPTY_LIST); // build curly scope for every character in the code curlyScopes = new ArrayList<>(); @@ -102,7 +106,6 @@ public class SketchParser { } } - /** * Get a list of all the numbers in this sketch * @return @@ -130,7 +133,7 @@ public class SketchParser { continue; } - if (isInRangeList(start, ignoreFunctions)) { + if (isInRangeList(start, ignoreFunctions.get(i))) { // ignore numbers in predefined functions continue; } @@ -222,7 +225,7 @@ public class SketchParser { continue; } - if (isInRangeList(start, ignoreFunctions)) { + if (isInRangeList(start, ignoreFunctions.get(i))) { // ignore numbers in predefined functions continue; } @@ -283,7 +286,7 @@ public class SketchParser { continue; } - if (isInRangeList(start, ignoreFunctions)) { + if (isInRangeList(start, ignoreFunctions.get(i))) { // ignore numbers in predefined functions continue; } @@ -387,7 +390,7 @@ public class SketchParser { continue; } - if (isInRangeList(m.start(), ignoreFunctions)) { + if (isInRangeList(m.start(), ignoreFunctions.get(i))) { // ignore numbers in predefined functions continue; } @@ -471,7 +474,7 @@ public class SketchParser { continue; } - if (isInRangeList(m.start(), ignoreFunctions)) { + if (isInRangeList(m.start(), ignoreFunctions.get(i))) { // ignore numbers in predefined functions continue; }