@@ -60,14 +60,14 @@ public SketchParser(String[] codeTabs, boolean requiresComment) {
6060
6161 // add 'settings' and 'setup' to ignore list (to ignore all numbers there)
6262 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-
63+ Range settingsRange = getVoidFunctionRange (codeTabs [0 ], "settings" );
64+ Range setupRange = getVoidFunctionRange (codeTabs [0 ], "setup" );
65+ ignoreFunctions .add (Arrays .asList (settingsRange , setupRange ));
66+
6867 //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 );
68+ for (int i = 0 ; i < codeTabs .length -1 ; i ++) {
69+ ignoreFunctions .add (new ArrayList <SketchParser .Range >());
70+ }
7171
7272 // build curly scope for every character in the code
7373 curlyScopes = new ArrayList <>();
@@ -839,6 +839,11 @@ else if (readObject) {
839839 return obj ;
840840 }
841841
842+ static public Range getVoidFunctionRange (String code , String functionName ) {
843+ return new Range (getVoidFunctionStart (code , functionName ),
844+ getVoidFunctionEnd (code , functionName ));
845+ }
846+
842847 static public int getVoidFunctionStart (String code , String functionName ) {
843848 Pattern p = Pattern .compile ("void[\\ s\\ t\\ r\\ n]*" +functionName +"[\\ s\\ t]*\\ (\\ )[\\ s\\ t\\ r\\ n]*\\ {" );
844849 Matcher m = p .matcher (code );
0 commit comments