Author: dda
Date: 2007-12-19 12:39:03 -0800 (Wed, 19 Dec 2007)
New Revision: 7622

Modified:
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
Log:
Change 20071219-dda-U by [EMAIL PROTECTED] on 2007-12-19 15:30:44 EST
    in /Users/dda/laszlo/src/svn/openlaszlo/branches/devildog
    for http://svn.openlaszlo.org/openlaszlo/branches/devildog

Summary: Better treatment of error messages

New Features:

Bugs Fixed: LPP-5234

Technical Reviewer: ptw (pending)
QA Reviewer: hminsky (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
    The errors from the third party compiler have file/line numbers that may
    not make sense to the end user (since we create lots of files to compile
    behind their back), so there is a translation of these line numbers back
    to the lines from the original source files.  However, when compiling
    LFC or other system software, we would like access to the error file/lines
    actually produced, since we do have access to the temp files for debugging.

    Three changes made related to this: 
    - when the error line produced was '0' before, now always show the
      'actual' file/linenumbers.
    - even if there is a valid source line number, always show the
      'actual' file/linenumber in brackets [].  When we hook
      this up in the browser environment, we may choose to elide this.
    - some minor refactoring in the source to get greater sharing.

Tests:
   Verified that errors now produced have information that line
   up with tmp files used in compilation.



Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
    2007-12-19 20:38:45 UTC (rev 7621)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9Generator.java
    2007-12-19 20:39:03 UTC (rev 7622)
@@ -552,12 +552,17 @@
           TranslationUnit tunit = err.getTranslationUnit();
           String srcLineStr;
           int srcLine;
+
+          // actualSrcLine is the name/linenumber of the actual files
+          // used in compilation, not the original sources.
+          String actualSrcLine = tunit.getSourceFileName() + ": " + 
err.getLineNumber();
           if (tunit == null || 
-              ((srcLine = tunit.originalLineNumber(err.getLineNumber())) < 0)) 
{
-            srcLineStr = "unknown [" + err.getLineNumber() + "]";
+              ((srcLine = tunit.originalLineNumber(err.getLineNumber())) <= 
0)) {
+            srcLineStr = actualSrcLine;
           }
           else {
-            srcLineStr = String.valueOf(srcLine);
+            // For now, we also show the actual source file/line
+            srcLineStr = String.valueOf(srcLine) + " [" + actualSrcLine + "]";
           }
           System.err.println("Compiler error: at " + srcLineStr + ": " +
                              err.getErrorString() +
@@ -629,13 +634,15 @@
 
     execCompileCommand(cmd, tempdir, tunits, swcfilename);
 
-    writeOutputFile("_stubapp", DEFAULT_FILE_PREAMBLE,
-                    "  import flash.display.Sprite\n" +
-                    "  public class _stubapp extends Sprite {\n" +
-                    "    public function _stubapp() {\n" +
-                    "      var app:LzApplication = new " + apptype + "();\n" +
-                    "    }\n" +
-                    "  }\n", DEFAULT_FILE_EPILOG);
+    TranslationUnit stubtunit = new TranslationUnit();
+    stubtunit.setName("_stubapp");
+    stubtunit.addText("  import flash.display.Sprite\n" +
+                      "  public class _stubapp extends Sprite {\n" +
+                      "    public function _stubapp() {\n" +
+                      "      var app:LzApplication = new " + apptype + "();\n" 
+
+                      "    }\n" +
+                      "  }\n");
+    writeOutputFile(stubtunit, DEFAULT_FILE_PREAMBLE, DEFAULT_FILE_EPILOG);
 
     String appBuilderCmd = getLPSPathname("compiler.swf9.lib.builder");
     cmd = appBuilderCmd;
@@ -667,8 +674,12 @@
     return (new SWF9ParseTreePrinter(compress, 
obfuscate)).makeTranslationUnits(translatedNode);
   }
 
-  public void writeOutputFile(String name, String pre, String body, String 
post) {
+  public void writeOutputFile(TranslationUnit tunit, String pre, String post) {
+    String name = tunit.getName();
+    String body = tunit.getContents();
     String infilename = tempdir + File.separator + name + ".as";
+    tunit.setSourceFileName(infilename);
+
     if (options.getBoolean(Compiler.PROGRESS)) {
       System.err.println("Creating: " + infilename);
     }
@@ -791,7 +802,7 @@
 
         addGlobalVar("lzApplicationInstance", name, null);
       }
-      writeOutputFile(name, preamble, tunit.getContents(), epilog);
+      writeOutputFile(tunit, preamble, epilog);
     }
 
     // For each global variable defined in programVars,
@@ -820,8 +831,7 @@
 
     for (Iterator iter = glotunits.iterator(); iter.hasNext(); ) {
       TranslationUnit tunit = (TranslationUnit)iter.next();
-      writeOutputFile(tunit.getName(), DEFAULT_FILE_PREAMBLE,
-                      tunit.getContents(), DEFAULT_FILE_EPILOG);
+      writeOutputFile(tunit, DEFAULT_FILE_PREAMBLE, DEFAULT_FILE_EPILOG);
       tunits.add(tunit);
     }
 

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
  2007-12-19 20:38:45 UTC (rev 7621)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/sc/TranslationUnit.java
  2007-12-19 20:39:03 UTC (rev 7622)
@@ -47,6 +47,14 @@
     this.name = name;
   }
 
+  public String getSourceFileName() {
+    return srcFilename;
+  }
+
+  public void setSourceFileName(String srcname) {
+    this.srcFilename = srcname;
+  }
+
   public String getContents() {
     return contents.toString();
   }


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to