This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new e298761  report filename and location for unexpected exceptions in the 
block walkers
e298761 is described below

commit e298761538b0b9f124ddc046381685414c35630b
Author: Alex Harui <[email protected]>
AuthorDate: Fri Mar 16 09:42:07 2018 -0700

    report filename and location for unexpected exceptions in the block walkers
---
 .../royale/compiler/clients/MXMLJSCRoyale.java     |  9 ++++++---
 .../internal/codegen/as/ASBlockWalker.java         | 16 +++++++++++++++-
 .../internal/codegen/mxml/MXMLBlockWalker.java     | 22 ++++++++++++++++++----
 3 files changed, 39 insertions(+), 8 deletions(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java
index 13c8994..c4619f1 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java
@@ -353,12 +353,12 @@ public class MXMLJSCRoyale implements 
JSCompilerEntryPoint, ProblemQueryProvider
                                if (cuType == ICompilationUnit.UnitType.AS_UNIT)
                                {
                                    writer = (IJSWriter) 
project.getBackend().createWriter(project,
-                                           errors, unit, false);
+                                           problems.getProblems(), unit, 
false);
                                }
                                else
                                {
                                    writer = (IJSWriter) 
project.getBackend().createMXMLWriter(
-                                           project, errors, unit, false);
+                                           project, problems.getProblems(), 
unit, false);
                                }
        
                                BufferedOutputStream out = new 
BufferedOutputStream(
@@ -394,8 +394,11 @@ public class MXMLJSCRoyale implements 
JSCompilerEntryPoint, ProblemQueryProvider
             final ICompilerProblem problem = new InternalCompilerProblem(e);
             problems.add(problem);
         }
+        List<ICompilerProblem> errs = new ArrayList<ICompilerProblem>();
+        List<ICompilerProblem> warns = new ArrayList<ICompilerProblem>();
+        problems.getErrorsAndWarnings(errs, warns);
 
-        return compilationSuccess;
+        return compilationSuccess && (errs.size() == 0);
     }
 
     /**
diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/as/ASBlockWalker.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/as/ASBlockWalker.java
index 208ccd7..d8f26ab 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/as/ASBlockWalker.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/as/ASBlockWalker.java
@@ -26,6 +26,7 @@ import 
org.apache.royale.compiler.definitions.IPackageDefinition;
 import org.apache.royale.compiler.internal.semantics.SemanticUtils;
 import org.apache.royale.compiler.internal.tree.as.LabeledStatementNode;
 import org.apache.royale.compiler.problems.ICompilerProblem;
+import org.apache.royale.compiler.problems.InternalCompilerProblem2;
 import org.apache.royale.compiler.projects.IASProject;
 import org.apache.royale.compiler.tree.ASTNodeID;
 import org.apache.royale.compiler.tree.as.IASNode;
@@ -154,7 +155,20 @@ public class ASBlockWalker implements IASBlockVisitor, 
IASBlockWalker
     @Override
     public void walk(IASNode node)
     {
-        getStrategy().handle(node);
+       try {
+               getStrategy().handle(node);
+       }
+       catch (Exception e)
+       {
+               String sp = String.format("%s line %d column %d", 
node.getSourcePath(), node.getLine() + 1, node.getColumn());
+               if (node.getSourcePath() == null)
+               {
+                       IASNode parent = node.getParent();
+                       sp = String.format("%s line %d column %d", 
parent.getSourcePath(), parent.getLine() + 1, parent.getColumn());
+               }
+               InternalCompilerProblem2 problem = new 
InternalCompilerProblem2(sp, e, "ASBlockWalker");
+               errors.add(problem);
+       }
     }
 
     @Override
diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/MXMLBlockWalker.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/MXMLBlockWalker.java
index 7527811..b6d9af0 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/MXMLBlockWalker.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/MXMLBlockWalker.java
@@ -24,6 +24,7 @@ import java.util.List;
 import org.apache.royale.compiler.codegen.as.IASEmitter;
 import org.apache.royale.compiler.codegen.mxml.IMXMLEmitter;
 import org.apache.royale.compiler.problems.ICompilerProblem;
+import org.apache.royale.compiler.problems.InternalCompilerProblem2;
 import org.apache.royale.compiler.projects.IASProject;
 import org.apache.royale.compiler.tree.as.IASNode;
 import org.apache.royale.compiler.tree.as.IFileNode;
@@ -145,10 +146,23 @@ public class MXMLBlockWalker implements 
IMXMLBlockVisitor, IMXMLBlockWalker
     @Override
     public void walk(IASNode node)
     {
-        if (node instanceof IMXMLNode)
-            mxmlStrategy.handle(node);
-        else
-            asStrategy.handle(node);
+       try {
+               if (node instanceof IMXMLNode)
+                   mxmlStrategy.handle(node);
+               else
+                   asStrategy.handle(node);
+       }
+       catch (Exception e)
+       {
+               String sp = String.format("%s line %d column %d", 
node.getSourcePath(), node.getLine() + 1, node.getColumn());
+               if (node.getSourcePath() == null)
+               {
+                       IASNode parent = node.getParent();
+                       sp = String.format("%s line %d column %d", 
parent.getSourcePath(), parent.getLine() + 1, parent.getColumn());
+               }
+               InternalCompilerProblem2 problem = new 
InternalCompilerProblem2(sp, e, "ASBlockWalker");
+               errors.add(problem);
+       }
     }
 
     @Override

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to