flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject git commit: [flex-falcon] [refs/heads/develop] - FLEX-35051 more error reporting from ExternC
Date Fri, 18 Nov 2016 20:23:58 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop 7a6ec7227 -> 2b6e4d690


FLEX-35051 more error reporting from ExternC


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/2b6e4d69
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/2b6e4d69
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/2b6e4d69

Branch: refs/heads/develop
Commit: 2b6e4d690f88c9a21d6fff129646e0a3f6ff6850
Parents: 7a6ec72
Author: Alex Harui <aharui@apache.org>
Authored: Fri Nov 18 12:23:48 2016 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Nov 18 12:23:48 2016 -0800

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/EXTERNC.java   |  7 ++--
 .../externals/pass/AbstractCompilerPass.java    | 37 ++++++++++++++++++++
 .../externals/pass/NamespaceResolutionPass.java | 15 ++++++++
 .../externals/reference/ClassReference.java     |  7 ++--
 .../externals/reference/ReferenceModel.java     |  3 ++
 .../codegen/externals/ExternalsTestBase.java    |  2 +-
 .../codegen/externals/TestExternChrome.java     | 13 ++++---
 7 files changed, 70 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2b6e4d69/compiler-jx/src/main/java/org/apache/flex/compiler/clients/EXTERNC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/EXTERNC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/EXTERNC.java
index 8124817..547bae4 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/EXTERNC.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/EXTERNC.java
@@ -56,7 +56,7 @@ public class EXTERNC implements FlexTool
         final int code;
     }
 
-    public static Set<ICompilerProblem> problems;
+    public Set<ICompilerProblem> problems;
     protected Configurator projectConfigurator;
     private ExternCConfiguration configuration;
     private ReferenceModel model;
@@ -138,7 +138,7 @@ public class EXTERNC implements FlexTool
 
         final EXTERNC compiler = new EXTERNC();
         compiler.configure(args);
-        problems = new HashSet<ICompilerProblem>();
+        Set<ICompilerProblem> problems = new HashSet<ICompilerProblem>();
         final int exitCode = compiler.mainNoExit(args, problems, true);
 
         long endTime = System.nanoTime();
@@ -154,6 +154,7 @@ public class EXTERNC implements FlexTool
 
         try
         {
+        	model.problems = problems;
             cleanOutput();
             compile();
             emit();
@@ -169,7 +170,7 @@ public class EXTERNC implements FlexTool
                 if (printProblems)
                 {
                 	for (ICompilerProblem problem : problems)
-                		System.out.println(problem.toString() + " " + problem.getSourcePath() +
" " + problem.getLine());
+                		System.out.println(problem.toString() + " " + problem.getSourcePath() +
" line:" + problem.getLine());
                 	exitCode = ExitCode.FAILED_WITH_PROBLEMS.code;
                 }
             }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2b6e4d69/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/AbstractCompilerPass.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/AbstractCompilerPass.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/AbstractCompilerPass.java
index a9734de..9903fc2 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/AbstractCompilerPass.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/AbstractCompilerPass.java
@@ -19,6 +19,10 @@
 
 package org.apache.flex.compiler.internal.codegen.externals.pass;
 
+import java.util.Collection;
+
+import org.apache.flex.compiler.clients.ExternCConfiguration;
+import org.apache.flex.compiler.internal.codegen.externals.pass.ReferenceCompiler.ExternalFile;
 import org.apache.flex.compiler.internal.codegen.externals.reference.ReferenceModel;
 import org.apache.flex.compiler.internal.codegen.externals.utils.DebugLogUtils;
 
@@ -26,7 +30,9 @@ import com.google.javascript.jscomp.AbstractCompiler;
 import com.google.javascript.jscomp.CompilerPass;
 import com.google.javascript.jscomp.NodeTraversal;
 import com.google.javascript.jscomp.NodeTraversal.Callback;
+import com.google.javascript.jscomp.SourceFile;
 import com.google.javascript.rhino.Node;
+import com.google.javascript.rhino.StaticSourceFile;
 
 public abstract class AbstractCompilerPass implements CompilerPass, Callback
 {
@@ -68,4 +74,35 @@ public abstract class AbstractCompilerPass implements CompilerPass, Callback
     {
         DebugLogUtils.err(message);
     }
+    
+    protected String getSourceCode(StaticSourceFile file, int line)
+    {
+    	if (file instanceof SourceFile)
+    	{
+    		String code = ((SourceFile)file).getLine(line);
+    		return code;
+    	}
+    	return "no source line found";
+    }
+
+    public static String getSourceFileName(String externName, ReferenceModel model)
+    {
+    	if (externName.contains("["))
+    	{
+    		externName = externName.replace("[", "");
+    		externName = externName.replace("]", "");
+        	ExternCConfiguration config = model.getConfiguration();
+        	Collection<ExternalFile> externs = config.getExternals();
+        	for (ExternalFile f : externs)
+        	{
+        		String fn = f.getName();
+        		if (fn.equals(externName))
+        		{
+        			externName = f.getFile().getAbsolutePath();
+        			break;
+        		}
+        	}
+    	}
+    	return externName;
+    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2b6e4d69/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/NamespaceResolutionPass.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/NamespaceResolutionPass.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/NamespaceResolutionPass.java
index 8f5cd95..6270227 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/NamespaceResolutionPass.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/pass/NamespaceResolutionPass.java
@@ -20,11 +20,14 @@
 package org.apache.flex.compiler.internal.codegen.externals.pass;
 
 import org.apache.flex.compiler.internal.codegen.externals.reference.ReferenceModel;
+import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
+import org.apache.flex.compiler.problems.VariableHasNoTypeDeclarationProblem;
 
 import com.google.javascript.jscomp.AbstractCompiler;
 import com.google.javascript.jscomp.NodeTraversal;
 import com.google.javascript.rhino.JSDocInfo;
 import com.google.javascript.rhino.Node;
+import com.google.javascript.rhino.StaticSourceFile;
 
 public class NamespaceResolutionPass extends AbstractCompilerPass
 {
@@ -87,6 +90,18 @@ public class NamespaceResolutionPass extends AbstractCompilerPass
                     Node lastAssignChild = first.getLastChild();
                     if (lastAssignChild.isObjectLit())
                     {
+                        if (comment == null)
+                        {
+                        	StaticSourceFile ssf = first.getStaticSourceFile();
+                        	String source = getSourceCode(ssf, first.getLineno());
+                        	IdentifierNode node = new IdentifierNode(source);
+                        	String externName = getSourceFileName(ssf.getName(), model);
+                        	node.setSourcePath(externName);
+                        	node.setLine(first.getLineno());
+                        	VariableHasNoTypeDeclarationProblem problem = new VariableHasNoTypeDeclarationProblem(node,
source);
+                        	model.problems.add(problem);
+                        	return;
+                        }
                         if (comment.getType() != null)
                         {
                             //print("Class "

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2b6e4d69/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
index f59c8bc..f93eb55 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
@@ -28,7 +28,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.flex.compiler.clients.EXTERNC;
+import org.apache.flex.compiler.internal.codegen.externals.pass.AbstractCompilerPass;
 import org.apache.flex.compiler.internal.codegen.externals.utils.DebugLogUtils;
 import org.apache.flex.compiler.internal.codegen.externals.utils.JSTypeUtils;
 import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
@@ -537,10 +537,11 @@ public class ClassReference extends BaseReference
             else
             {
             	IdentifierNode node = new IdentifierNode(interfaceName);
-            	node.setSourcePath(this.getNode().getStaticSourceFile().toString());
+            	String externName = AbstractCompilerPass.getSourceFileName(this.getNode().getStaticSourceFile().getName(),
getModel());
+            	node.setSourcePath(externName);
             	node.setLine(this.getNode().getLineno());
             	UnresolvedClassReferenceProblem problem = new UnresolvedClassReferenceProblem(node,
interfaceName);
-            	EXTERNC.problems.add(problem);
+            	getModel().problems.add(problem);
             }
         }
         return result;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2b6e4d69/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
index c50806d..5049189 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/externals/reference/ReferenceModel.java
@@ -23,10 +23,12 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Set;
 
 import org.apache.flex.compiler.clients.ExternCConfiguration;
 import org.apache.flex.compiler.clients.ExternCConfiguration.ExcludedMember;
 import org.apache.flex.compiler.internal.codegen.externals.utils.DebugLogUtils;
+import org.apache.flex.compiler.problems.ICompilerProblem;
 
 import com.google.javascript.jscomp.Compiler;
 import com.google.javascript.jscomp.NodeUtil;
@@ -37,6 +39,7 @@ import com.google.javascript.rhino.jstype.JSType;
 
 public class ReferenceModel
 {
+    public Set<ICompilerProblem> problems;
     private ExternCConfiguration configuration;
     private Compiler jscompiler;
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2b6e4d69/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestBase.java
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestBase.java
index 078534b..eafd375 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestBase.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestBase.java
@@ -54,8 +54,8 @@ public abstract class ExternalsTestBase
         config = new ExternCConfiguration();
         configure(config);
         client = new EXTERNC(config);
-        EXTERNC.problems = new HashSet<ICompilerProblem>();
         model = client.getModel();
+        model.problems = new HashSet<ICompilerProblem>();
     }
 
     protected abstract void configure(ExternCConfiguration config) throws IOException;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/2b6e4d69/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternChrome.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternChrome.java
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternChrome.java
index bd3f39f..107c725 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternChrome.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternChrome.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 
-import org.apache.flex.compiler.clients.EXTERNC;
 import org.apache.flex.compiler.clients.ExternCConfiguration;
 import org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
 import org.apache.flex.compiler.problems.ICompilerProblem;
@@ -41,12 +40,12 @@ public class TestExternChrome extends ExternalsTestBase
         client.cleanOutput();
         Result result = compile();
         assertTrue(result.success);
-        if (EXTERNC.problems.size() > 0)
+        if (model.problems.size() > 0)
         {
-        	for (ICompilerProblem problem : EXTERNC.problems)
+        	for (ICompilerProblem problem : model.problems)
         		System.out.println(problem.toString() + " " + problem.getSourcePath() + " " + problem.getLine());
       	
         }
-        assertEquals(0, EXTERNC.problems.size());
+        assertEquals(0, model.problems.size());
 
         String[] classes = {
                 "chrome",
@@ -83,12 +82,12 @@ public class TestExternChrome extends ExternalsTestBase
         client.cleanOutput();
         Result result = compile();
         assertTrue(result.success);
-        if (EXTERNC.problems.size() > 0)
+        if (model.problems.size() > 0)
         {
-        	for (ICompilerProblem problem : EXTERNC.problems)
+        	for (ICompilerProblem problem : model.problems)
         		System.out.println(problem.toString() + " " + problem.getSourcePath() + " " + problem.getLine());
       	
         }
-        assertEquals(0, EXTERNC.problems.size());
+        assertEquals(0, model.problems.size());
 
         // Port
         ClassReference Port = model.getClassReference("Port");


Mime
View raw message