4646public class Sketch {
4747 static private File tempBuildFolder ;
4848
49+ /**
50+ * Regular expression for parsing the size() method. This should match
51+ * against any uses of the size() function, whether numbers or variables
52+ * or whatever. This way, no warning is shown if size() isn't actually used
53+ * in the sketch, which is the case especially for anyone who is cutting
54+ * and pasting from the reference.
55+ */
56+ public static final String SIZE_REGEX =
57+ "(?:^|\\ s|;)size\\ s*\\ (\\ s*(\\ S+)\\ s*,\\ s*([^\\ s,\\ )]+),?\\ s*([^\\ )]*)\\ s*\\ )\\ s*\\ ;" ;
58+
4959 private Editor editor ;
5060 private boolean foundMain = false ;
5161
@@ -1582,7 +1592,7 @@ protected boolean exportApplet() throws Exception {
15821592 return exportApplet (new File (folder , "applet" ).getAbsolutePath ());
15831593 }
15841594
1585-
1595+
15861596 /**
15871597 * Handle export to applet.
15881598 */
@@ -1625,15 +1635,8 @@ public boolean exportApplet(String appletPath) throws RunnerException, IOExcepti
16251635 int high = PApplet .DEFAULT_HEIGHT ;
16261636 String renderer = "" ;
16271637
1628- // This matches against any uses of the size() function, whether numbers
1629- // or variables or whatever. This way, no warning is shown if size() isn't
1630- // actually used in the applet, which is the case especially for anyone
1631- // who is cutting/pasting from the reference.
1632- String sizeRegex =
1633- "(?:^|\\ s|;)size\\ s*\\ (\\ s*(\\ S+)\\ s*,\\ s*(\\ d+),?\\ s*([^\\ )]*)\\ s*\\ )" ;
1634-
16351638 String scrubbed = scrubComments (code [0 ].getProgram ());
1636- String [] matches = PApplet .match (scrubbed , sizeRegex );
1639+ String [] matches = PApplet .match (scrubbed , SIZE_REGEX );
16371640
16381641 if (matches != null ) {
16391642 try {
@@ -1642,6 +1645,7 @@ public boolean exportApplet(String appletPath) throws RunnerException, IOExcepti
16421645
16431646 // Adding back the trim() for 0136 to handle Bug #769
16441647 if (matches .length == 4 ) renderer = matches [3 ].trim ();
1648+ // Actually, matches.length should always be 4...
16451649
16461650 } catch (NumberFormatException e ) {
16471651 // found a reference to size, but it didn't
0 commit comments