@@ -939,6 +939,15 @@ protected void writeFooter(PrintWriter out, String className) {
939939 }
940940
941941 if ((mode == Mode .STATIC ) || (mode == Mode .ACTIVE )) {
942+ // doesn't remove the oriiginal size() method, but calling size()
943+ // again in setup() is harmless.
944+ if (!hasMethod ("settings" ) && sizeStatement != null ) {
945+ out .println (indent + "public void settings() { " + sizeStatement + " }" );
946+ // out.println(indent + "public void settings() {");
947+ // out.println(indent + indent + sizeStatement);
948+ // out.println(indent + "}");
949+ }
950+ /*
942951 if (sketchWidth != null && !hasMethod("sketchWidth")) {
943952 // Only include if it's a number (a variable will be a problem)
944953 if (PApplet.parseInt(sketchWidth, -1) != -1 || sketchWidth.equals("displayWidth")) {
@@ -960,6 +969,7 @@ protected void writeFooter(PrintWriter out, String className) {
960969 if (sketchOutputPath != null && !hasMethod("sketchOutputPath")) {
961970 out.println(indent + "public String sketchOutputPath() { return " + sketchOutputPath + "; }");
962971 }
972+ */
963973
964974 if (!hasMethod ("main" )) {
965975 out .println (indent + "static public void main(String[] passedArgs) {" );
@@ -1036,6 +1046,10 @@ public boolean ignoreImport(String pkg) {
10361046// return pkg.startsWith("processing.xml.");
10371047 }
10381048
1049+
1050+ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1051+
1052+
10391053 /**
10401054 * Find the first CLASS_DEF node in the tree, and return the name of the
10411055 * class in question.
@@ -1049,11 +1063,13 @@ String getFirstClassName(AST ast) {
10491063 return t ;
10501064 }
10511065
1066+
10521067 public void debugAST (final AST ast , final boolean includeHidden ) {
10531068 System .err .println ("------------------" );
10541069 debugAST (ast , includeHidden , 0 );
10551070 }
10561071
1072+
10571073 private void debugAST (final AST ast , final boolean includeHidden ,
10581074 final int indent ) {
10591075 for (int i = 0 ; i < indent ; i ++)
@@ -1073,23 +1089,24 @@ private void debugAST(final AST ast, final boolean includeHidden,
10731089 debugAST (kid , includeHidden , indent + 1 );
10741090 }
10751091
1092+
10761093 private String debugHiddenAfter (AST ast ) {
1077- if (!(ast instanceof antlr .CommonASTWithHiddenTokens ))
1078- return "" ;
1079- return debugHiddenTokens (((antlr .CommonASTWithHiddenTokens ) ast )
1080- .getHiddenAfter ());
1094+ return (ast instanceof antlr .CommonASTWithHiddenTokens ) ?
1095+ debugHiddenTokens (((antlr .CommonASTWithHiddenTokens ) ast ).getHiddenAfter ()) : "" ;
10811096 }
10821097
10831098 private String debugHiddenBefore (AST ast ) {
1084- if (!(ast instanceof antlr .CommonASTWithHiddenTokens ))
1099+ if (!(ast instanceof antlr .CommonASTWithHiddenTokens )) {
10851100 return "" ;
1086- antlr .CommonHiddenStreamToken child = null , parent = ((antlr .CommonASTWithHiddenTokens ) ast )
1087- .getHiddenBefore ();
1101+ }
1102+ antlr .CommonHiddenStreamToken parent =
1103+ ((antlr .CommonASTWithHiddenTokens ) ast ).getHiddenBefore ();
10881104
10891105 if (parent == null ) {
10901106 return "" ;
10911107 }
10921108
1109+ antlr .CommonHiddenStreamToken child = null ;
10931110 do {
10941111 child = parent ;
10951112 parent = child .getHiddenBefore ();
@@ -1098,15 +1115,18 @@ private String debugHiddenBefore(AST ast) {
10981115 return debugHiddenTokens (child );
10991116 }
11001117
1118+
11011119 private String debugHiddenTokens (antlr .CommonHiddenStreamToken t ) {
11021120 final StringBuilder sb = new StringBuilder ();
11031121 for (; t != null ; t = filter .getHiddenAfter (t )) {
1104- if (sb .length () == 0 )
1122+ if (sb .length () == 0 ) {
11051123 sb .append ("[" );
1124+ }
11061125 sb .append (t .getText ().replace ("\n " , "\\ n" ));
11071126 }
1108- if (sb .length () > 0 )
1127+ if (sb .length () > 0 ) {
11091128 sb .append ("]" );
1129+ }
11101130 return sb .toString ();
11111131 }
11121132}
0 commit comments