Revision: 15302
          http://gate.svn.sourceforge.net/gate/?rev=15302&view=rev
Author:   valyt
Date:     2012-02-02 10:16:55 +0000 (Thu, 02 Feb 2012)
Log Message:
-----------
Added static final DEBUG flag so that I don't have to keep re-writing the same 
piece of debug code every time Julien finds a problem in J+.

Modified Paths:
--------------
    gate/trunk/plugins/JAPE_Plus/src/gate/jape/plus/SPTBuilder.java

Modified: gate/trunk/plugins/JAPE_Plus/src/gate/jape/plus/SPTBuilder.java
===================================================================
--- gate/trunk/plugins/JAPE_Plus/src/gate/jape/plus/SPTBuilder.java     
2012-02-02 10:15:29 UTC (rev 15301)
+++ gate/trunk/plugins/JAPE_Plus/src/gate/jape/plus/SPTBuilder.java     
2012-02-02 10:16:55 UTC (rev 15302)
@@ -60,6 +60,11 @@
  */
 public class SPTBuilder {
 
+  /**
+   * Flag used when debugging: set to true to enable dumping the generated code
+   * to disk and printing of additional information. 
+   */
+  private static final boolean DEBUG = false;
   
   private static final String[] TABS = new String[]{"", "\t", "\t\t", "\t\t\t",
       "\t\t\t\t", "\t\t\t\t\t", "\t\t\t\t\t\t", "\t\t\t\t\t\t\t", 
@@ -138,16 +143,29 @@
     SPTBase optimisedTransducer = null;
     
     // when debugging, this will dump the generated sources where Eclipse can 
-    // see the.
-//    try {
-//      File srcDir = new File("plugins/JAPE_Plus/test/src/japephases/");
-//      srcDir.mkdirs();
-//      FileWriter writer = new FileWriter(new File(srcDir, className + 
".java"));
-//      writer.write(sptCode.toString());
-//      writer.close();
-//    } catch(IOException e1) {
-//      e1.printStackTrace();
-//    }
+    // see them.
+    if(DEBUG) {
+      try {
+        File srcDir = new File("plugins/JAPE_Plus/test/src/japephases/");
+        srcDir.mkdirs();
+        FileWriter writer = new FileWriter(new File(srcDir, className + 
".java"));
+        writer.write(sptCode.toString());
+        writer.close();
+      } catch(IOException e1) {
+        e1.printStackTrace();
+      }
+      // also print out the predicates used
+      StringBuilder str = new StringBuilder();
+      for(int type = 0; type < predicatesByTypeArray.length; type++) {
+        str.append(annotationTypes.get(type)).append(": ");
+        for(Predicate pred : predicatesByTypeArray[type]) {
+          str.append(pred.toString()).append(" ");
+        }
+        str.append("\n");
+      }
+      str.append("\n\n");
+      System.out.print(str.toString());
+    }
 
     try {
       Map<String, String> classes = new HashMap<String, String>(1);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to