flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject [43/50] git commit: [flex-falcon] [refs/heads/master] - fix more complex dependency scenarios. Hope this doesn't slow down big project compiles too much.
Date Tue, 21 Mar 2017 23:11:20 GMT
fix more complex dependency scenarios.  Hope this doesn't slow down big project compiles too
much.


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

Branch: refs/heads/master
Commit: 200c568c9034045b5392d7049ad07a47bc094085
Parents: 0271ed0
Author: Alex Harui <aharui@apache.org>
Authored: Tue Mar 14 12:39:15 2017 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Mar 14 12:39:15 2017 -0700

----------------------------------------------------------------------
 .../compiler/internal/graph/GoogDepsWriter.java | 62 ++++++++++++++++++--
 1 file changed, 58 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/200c568c/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
index 9b843b3..5833696 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
@@ -130,6 +130,7 @@ public class GoogDepsWriter {
     public ArrayList<String> additionalHTML = new ArrayList<String>();
     
     private HashMap<String, GoogDep> visited = new HashMap<String, GoogDep>();
+    private HashMap<String, GoogDep> inArray = new HashMap<String, GoogDep>();
     
 	private ArrayList<GoogDep> sort(String rootClassName)
 	{
@@ -148,16 +149,46 @@ public class GoogDepsWriter {
 			removeCirculars(current);
         System.out.println("Dependencies calculated for '" + current.filePath + "'");
 
+		ArrayList<GoogDep> visitedButNotAdded = new ArrayList<GoogDep>();
 		ArrayList<String> deps = current.deps;
 		for (String className : deps)
 		{
-			if (!visited.containsKey(className) && !isGoogClass(className))
+			if (!isGoogClass(className))
 			{
-				GoogDep gd = depMap.get(className);
-				sortFunction(gd, arr);
+				if (!visited.containsKey(className))
+				{
+					GoogDep gd = depMap.get(className);
+					sortFunction(gd, arr);
+				}
+				else
+				{
+			        if (!inArray.containsKey(className))
+			        {
+			        	// if we get here, we haven't yet added the dependency to the
+			        	// array of GoogDeps because we are computing its dependencies.
+			        	// For example, class A extends B which references class C which
+			        	// extends B.  This isn't a circular reference.  But B needs to
+			        	// be in the array before C instead of just before A.
+			        	visitedButNotAdded.add(depMap.get(className));
+				        System.out.println("Visited but haven't added: '" + className + "'");
+			        }
+				}
 			}
 		}
-		arr.add(current);
+		for (GoogDep gdep : visitedButNotAdded)
+		{
+			if (!inArray.containsKey(gdep.className))
+			{
+				arr.add(gdep);
+				inArray.put(gdep.className, gdep);
+			}
+		}
+		if (!inArray.containsKey(current.className))
+		{
+			arr.add(current);
+			inArray.put(current.className, current);
+		}
+		
 	}
 	
 	private void addDeps(String className)
@@ -248,6 +279,13 @@ public class GoogDepsWriter {
 	                        	System.out.println(gd.filePath + " removing circular: " + s);
 	                        	continue;
 	                        }
+	                        else if (gd.deps.contains(s) && !isGoogClass(s) &&
onProtoChain(s, className))
+	                        {
+	                        	// if we are on the proto chain of s, then take away our require
of s
+	                        	suppressCount++;
+	                        	System.out.println(gd.filePath + " removing circular (proto): "
+ s);
+	                        	continue;
+	                        }
                         }
                     }
             	}
@@ -331,6 +369,22 @@ public class GoogDepsWriter {
         }		
 	}
 	
+	boolean onProtoChain(String name, String base)
+	{
+		GoogDep gd = depMap.get(name);
+		if (gd.fileInfo.impls != null)
+		{
+			if (gd.fileInfo.impls.contains(base))
+				return true;
+			for (String s : gd.fileInfo.impls)
+			{
+				if (!isGoogClass(s) && onProtoChain(s, base))
+					return true;
+			}
+		}
+		return false;
+	}
+	
 	FileInfo getFileInfo(List<String> lines, String className)
 	{
 		FileInfo fi = new FileInfo();


Mime
View raw message