@@ -40,7 +40,7 @@ public class SketchParser {
4040 List <List <Range >> scientificNotations ;
4141
4242 // currently is used to ignore numbers in 'setup' and 'settings' functions
43- List <Range > ignoreFunctions ;
43+ List <List < Range > > ignoreFunctions ;
4444
4545 List <List <Range >> commentBlocks ;
4646 List <int []> curlyScopes ;
@@ -59,11 +59,15 @@ public SketchParser(String[] codeTabs, boolean requiresComment) {
5959 }
6060
6161 // add 'settings' and 'setup' to ignore list (to ignore all numbers there)
62- ignoreFunctions = new ArrayList <Range >();
63- ignoreFunctions .add (new Range (getVoidFunctionStart (codeTabs [0 ], "settings" ),
64- getVoidFunctionEnd (codeTabs [0 ], "settings" )));
65- ignoreFunctions .add (new Range (getVoidFunctionStart (codeTabs [0 ], "setup" ),
66- getVoidFunctionEnd (codeTabs [0 ], "setup" )));
62+ ignoreFunctions = new ArrayList <>();
63+ ignoreFunctions .add (Arrays .asList (new Range (getVoidFunctionStart (codeTabs [0 ], "settings" ),
64+ getVoidFunctionEnd (codeTabs [0 ], "settings" )),
65+ new Range (getVoidFunctionStart (codeTabs [0 ], "setup" ),
66+ getVoidFunctionEnd (codeTabs [0 ], "setup" ))));
67+
68+ //Add empty lists for the other tabs so we do not get an index out of bounds error later
69+ for (int i = 0 ; i < codeTabs .length -1 ; i ++)
70+ ignoreFunctions .add (Collections .EMPTY_LIST );
6771
6872 // build curly scope for every character in the code
6973 curlyScopes = new ArrayList <>();
@@ -102,7 +106,6 @@ private void addAllNumbers() {
102106 }
103107 }
104108
105-
106109 /**
107110 * Get a list of all the numbers in this sketch
108111 * @return
@@ -130,7 +133,7 @@ private void addAllDecimalNumbers() {
130133 continue ;
131134 }
132135
133- if (isInRangeList (start , ignoreFunctions )) {
136+ if (isInRangeList (start , ignoreFunctions . get ( i ) )) {
134137 // ignore numbers in predefined functions
135138 continue ;
136139 }
@@ -222,7 +225,7 @@ private void addAllHexNumbers() {
222225 continue ;
223226 }
224227
225- if (isInRangeList (start , ignoreFunctions )) {
228+ if (isInRangeList (start , ignoreFunctions . get ( i ) )) {
226229 // ignore numbers in predefined functions
227230 continue ;
228231 }
@@ -283,7 +286,7 @@ private void addAllWebColorNumbers() {
283286 continue ;
284287 }
285288
286- if (isInRangeList (start , ignoreFunctions )) {
289+ if (isInRangeList (start , ignoreFunctions . get ( i ) )) {
287290 // ignore numbers in predefined functions
288291 continue ;
289292 }
@@ -387,7 +390,7 @@ private void createColorBoxes() {
387390 continue ;
388391 }
389392
390- if (isInRangeList (m .start (), ignoreFunctions )) {
393+ if (isInRangeList (m .start (), ignoreFunctions . get ( i ) )) {
391394 // ignore numbers in predefined functions
392395 continue ;
393396 }
@@ -471,7 +474,7 @@ private void createColorBoxesForLights() {
471474 continue ;
472475 }
473476
474- if (isInRangeList (m .start (), ignoreFunctions )) {
477+ if (isInRangeList (m .start (), ignoreFunctions . get ( i ) )) {
475478 // ignore numbers in predefined functions
476479 continue ;
477480 }
0 commit comments