flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [1/3] git commit: [flex-falcon] - Enhance FlexJS publisher to handle 'libraries' (other folders of JS files). Now -sdk-js-lib option can be used multiple times to point to other folders of JS files that back AS files in a SWC. Because of the Closure Co
Date Mon, 29 Apr 2013 06:46:04 GMT
Updated Branches:
  refs/heads/develop d6fcec464 -> c4babfdcb


Enhance FlexJS publisher to handle 'libraries' (other folders of JS files).  Now -sdk-js-lib
option can be used multiple times to point to other folders of JS files that back AS files
in a SWC.  Because of the Closure Compiler's strict rules on circularities, we now have to
re-compute the goog.requires in the JS files as we copy them to the destination folder in
order to remove circularities based on the main class's dependencies.  So now, only the files
referenced get copied to the js-debug folder (which greatly sped up compile on my machine
because the 33MB copy of third_party no longer happens) and the JS files might get modified
after copy to remove goog.requires that appear circular so they will not always match the
source version.


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

Branch: refs/heads/develop
Commit: 54413efd8b270d5115416d6e6c38cc5fd80175b7
Parents: da59041
Author: Alex Harui <aharui@apache.org>
Authored: Fri Apr 26 15:52:08 2013 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Sun Apr 28 23:45:39 2013 -0700

----------------------------------------------------------------------
 .../internal/codegen/js/goog/JSGoogPublisher.java  |    4 +-
 .../codegen/mxml/flexjs/MXMLFlexJSPublisher.java   |   51 ++-
 .../driver/js/goog/JSGoogConfiguration.java        |   15 +-
 .../compiler/internal/graph/GoogDepsWriter.java    |  337 +++++++++++++++
 .../compiler/internal/projects/FlexJSProject.java  |   67 +---
 5 files changed, 392 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/54413efd/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
index ba022e6..c44c8bb 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/goog/JSGoogPublisher.java
@@ -75,7 +75,7 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
                 + "/third_party/closure/goog/";
         final String closureTPTgtLibDirPath = intermediateDirPath
                 + "/library/third_party/closure/goog";
-        final String vanillaSDKSrcLibDirPath = ((JSGoogConfiguration) configuration)
+        final List<String> vanillaSDKSrcLibDirPath = ((JSGoogConfiguration) configuration)
                 .getSDKJSLib();
         final String vanillaSDKTgtLibDirPath = intermediateDirPath
                 + "/VanillaSDK";
@@ -90,7 +90,7 @@ public class JSGoogPublisher extends JSPublisher implements IJSPublisher
 
         appendExportSymbol(projectIntermediateJSFilePath, projectName);
 
-        copyFile(vanillaSDKSrcLibDirPath, vanillaSDKTgtLibDirPath);
+        copyFile(vanillaSDKSrcLibDirPath.get(0), vanillaSDKTgtLibDirPath);
 
         List<SourceFile> inputs = new ArrayList<SourceFile>();
         Collection<File> files = org.apache.commons.io.FileUtils.listFiles(

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/54413efd/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
index 7636d9f..296c2f9 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSPublisher.java
@@ -21,14 +21,15 @@ import org.apache.flex.compiler.config.Configuration;
 import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
 import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogPublisher;
 import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+import org.apache.flex.compiler.internal.graph.GoogDepsWriter;
 import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.utils.JSClosureCompilerUtil;
 
-import com.google.javascript.jscomp.ErrorManager;
+//import com.google.javascript.jscomp.ErrorManager;
 import com.google.javascript.jscomp.SourceFile;
 import com.google.javascript.jscomp.SourceMap;
-import com.google.javascript.jscomp.deps.DepsGenerator;
-import com.google.javascript.jscomp.deps.DepsGenerator.InclusionStrategy;
+//import com.google.javascript.jscomp.deps.DepsGenerator;
+//import com.google.javascript.jscomp.deps.DepsGenerator.InclusionStrategy;
 
 public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         IJSPublisher
@@ -111,15 +112,16 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
                 + "/closure/goog/";
         final String closureGoogTgtLibDirPath = intermediateDirPath
                 + "/library/closure/goog";
+        /* AJH not needed by GoogDepsWriter
         final String closureGoogTgtLibDirRelPath = "./library/closure/goog";
         final String closureTPSrcLibDirPath = closureLibDirPath
                 + "/third_party/closure/goog/";
         final String closureTPTgtLibDirPath = intermediateDirPath
                 + "/library/third_party/closure/goog";
-        final String sdkJSLibSrcDirPath = ((JSGoogConfiguration) configuration)
+        final List<String> sdkJSLibSrcDirPaths = ((JSGoogConfiguration) configuration)
                 .getSDKJSLib();
         final String sdkJSLibTgtDirPath = intermediateDirPath;
-
+        */
         final String depsSrcFilePath = intermediateDirPath
                 + "/library/closure/goog/deps.js";
         final String depsTgtFilePath = intermediateDirPath + "/deps.js";
@@ -128,11 +130,28 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         final String projectReleaseJSFilePath = releaseDirPath
                 + File.separator + outputFileName;
 
+        // just copy base.js. All other goog files should get copied as the DepsWriter chases
down goog.requires
+        FileUtils.copyFile(new File(closureGoogSrcLibDirPath + File.separator + "base.js"),

+                new File(closureGoogTgtLibDirPath + File.separator + "base.js"));
+        GoogDepsWriter gdw = new GoogDepsWriter(intermediateDir, projectName, (JSGoogConfiguration)
configuration);
+        try
+        {
+            String depsFileData = gdw.generateDeps();
+            writeFile(depsTgtFilePath, depsFileData, false);        
+        }
+        catch (InterruptedException e)
+        {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        
         appendExportSymbol(projectIntermediateJSFilePath, projectName);
 
         if (!isMarmotinniRun)
-            copyFile(sdkJSLibSrcDirPath, sdkJSLibTgtDirPath);
-
+        {
+            //for (String sdkJSLibSrcDirPath : sdkJSLibSrcDirPaths)
+            //    copyFile(sdkJSLibSrcDirPath, sdkJSLibTgtDirPath);
+        }
         boolean isWindows = System.getProperty("os.name").indexOf("Mac") == -1;
 
         List<SourceFile> inputs = new ArrayList<SourceFile>();
@@ -160,8 +179,8 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
 
         if (!isMarmotinniRun)
         {
-            copyFile(closureGoogSrcLibDirPath, closureGoogTgtLibDirPath);
-            copyFile(closureTPSrcLibDirPath, closureTPTgtLibDirPath);
+            //copyFile(closureGoogSrcLibDirPath, closureGoogTgtLibDirPath);
+            //copyFile(closureTPSrcLibDirPath, closureTPTgtLibDirPath);
         }
 
         IOFileFilter pngSuffixFilter = FileFilterUtils.and(FileFileFilter.FILE,
@@ -181,13 +200,13 @@ public class MXMLFlexJSPublisher extends JSGoogPublisher implements
         final List<SourceFile> deps = new ArrayList<SourceFile>();
         deps.add(SourceFile.fromFile(srcDeps));
 
-        ErrorManager errorManager = new JSGoogErrorManager();
-        DepsGenerator depsGenerator = new DepsGenerator(deps, inputs,
-                InclusionStrategy.ALWAYS,
-                (isWindows) ? closureGoogTgtLibDirRelPath
-                        : closureGoogTgtLibDirPath, errorManager);
-        writeFile(depsTgtFilePath, depsGenerator.computeDependencyCalls(),
-                false);
+//        ErrorManager errorManager = new JSGoogErrorManager();
+//        DepsGenerator depsGenerator = new DepsGenerator(deps, inputs,
+//                InclusionStrategy.ALWAYS,
+//                (isWindows) ? closureGoogTgtLibDirRelPath
+//                        : closureGoogTgtLibDirPath, errorManager);
+//        writeFile(depsTgtFilePath, depsGenerator.computeDependencyCalls(),
+//                false);
 
         writeHTML("intermediate", projectName, intermediateDirPath);
         writeHTML("release", projectName, releaseDirPath);

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/54413efd/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
index 4426af6..30ccd5b 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
@@ -19,11 +19,15 @@
 
 package org.apache.flex.compiler.internal.driver.js.goog;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.flex.compiler.clients.JSConfiguration;
 import org.apache.flex.compiler.clients.MXMLJSC;
 import org.apache.flex.compiler.config.ConfigurationValue;
 import org.apache.flex.compiler.exceptions.ConfigurationException;
 import org.apache.flex.compiler.internal.config.annotations.Config;
+import org.apache.flex.compiler.internal.config.annotations.InfiniteArguments;
 import org.apache.flex.compiler.internal.config.annotations.Mapping;
 
 /**
@@ -85,19 +89,20 @@ public class JSGoogConfiguration extends JSConfiguration
     // 'sdk-js-lib'
     //
 
-    private String sdkJSLib;
+    private List<String> sdkJSLib = new ArrayList<String>();
 
-    public String getSDKJSLib()
+    public List<String> getSDKJSLib()
     {
         return sdkJSLib;
     }
 
-    @Config
+    @Config(allowMultiple = true)
     @Mapping("sdk-js-lib")
-    public void setSDKJSLib(ConfigurationValue cv, String value)
+    @InfiniteArguments
+    public void setSDKJSLib(ConfigurationValue cv, List<String> value)
             throws ConfigurationException
     {
-        sdkJSLib = value;
+        sdkJSLib.addAll(value);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/54413efd/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java b/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
new file mode 100644
index 0000000..e64da37
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
@@ -0,0 +1,337 @@
+package org.apache.flex.compiler.internal.graph;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Scanner;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+
+import com.google.common.io.Files;
+
+public class GoogDepsWriter {
+
+	public GoogDepsWriter(File outputFolder, String mainClassName, JSGoogConfiguration config)
+	{
+		this.outputFolderPath = outputFolder.getAbsolutePath();
+		this.mainName = mainClassName;
+		googPath = config.getClosureLib();
+		otherPaths = config.getSDKJSLib();
+	}
+	
+	private String outputFolderPath;
+	private String mainName;
+	private String googPath;
+	private List<String> otherPaths;
+	
+	private HashMap<String,GoogDep> depMap = new HashMap<String,GoogDep>();
+	
+	public ArrayList<String> getListOfFiles() throws InterruptedException
+	{
+		buildDB();
+		ArrayList<GoogDep> dps = sort(mainName);
+		ArrayList<String> files = new ArrayList<String>();
+		for (GoogDep gd : dps)
+		{
+			files.add(gd.filePath);
+		}
+		return files;
+	}
+	
+	public String generateDeps() throws InterruptedException, FileNotFoundException
+	{
+		buildDB();
+		ArrayList<GoogDep> dps = sort(mainName);
+		String outString = "// generated by FalconJS" + "\n";
+		int n = dps.size();
+		for (int i = n - 1; i >= 0; i--)
+		{
+			GoogDep gd = dps.get(i);
+			String s = "goog.addDependency('";
+			s += relativePath(gd.filePath);
+			s += "', ['";
+			s += gd.className;
+			s += "'], [";
+			s += getDependencies(gd.deps);
+			s += "]);\n";
+			outString += s;
+		}
+		return outString;
+	}
+	
+	private void buildDB()
+	{
+		addDeps(mainName);
+	}
+	
+	private HashMap<String, GoogDep> visited = new HashMap<String, GoogDep>();
+	
+	private ArrayList<GoogDep> sort(String rootClassName)
+	{
+		ArrayList<GoogDep> arr = new ArrayList<GoogDep>();
+		GoogDep current = depMap.get(rootClassName);
+		sortFunction(current, arr);
+		return arr;
+	}
+	
+	private void sortFunction(GoogDep current, ArrayList<GoogDep> arr)
+	{
+		visited.put(current.className, current);
+
+		ArrayList<String> deps = current.deps;
+		for (String className : deps)
+		{
+			if (!visited.containsKey(className))
+			{
+				GoogDep gd = depMap.get(className);
+				sortFunction(gd, arr);
+			}
+		}
+		arr.add(current);
+	}
+	
+	private void addDeps(String className)
+	{
+		if (depMap.containsKey(className))
+			return;
+		
+		// build goog dependency list
+		GoogDep gd = new GoogDep();
+		gd.className = className;
+		gd.filePath = getFilePath(className);
+		depMap.put(gd.className, gd);
+		ArrayList<String> deps = getDirectDependencies(gd.filePath);
+		gd.deps = new ArrayList<String>();
+		ArrayList<String> circulars = new ArrayList<String>();
+		for (String dep : deps)
+		{
+		    if (depMap.containsKey(dep))
+		    {
+		        circulars.add(dep);
+		        continue;
+		    }
+			gd.deps.add(dep);
+			addDeps(dep);
+		}
+		if (circulars.size() > 0)
+		{
+		    // remove requires that would cause circularity
+		    try
+            {
+                List<String> fileLines = Files.readLines(new File(gd.filePath), Charset.defaultCharset());
+                ArrayList<String> finalLines = new ArrayList<String>();
+                
+                String inherits = getBaseClass(fileLines, className);
+                
+                for (String line : fileLines)
+                {
+                    int c = line.indexOf("goog.require");
+                    if (c > -1)
+                    {
+                        int c2 = line.indexOf(")");
+                        String s = line.substring(c + 14, c2 - 1);
+                        if (circulars.contains(s) && !s.equals(inherits))
+                            continue;
+                    }
+                    finalLines.add(line);
+                }
+                File file = new File(gd.filePath);  
+                PrintWriter out = new PrintWriter(new FileWriter(file));  
+                for (String s : finalLines)
+                {
+                    out.println(s);
+                }
+                out.close();
+                    
+            }
+            catch (IOException e)
+            {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+		    
+		}
+	}
+	
+	String getBaseClass(List<String> lines, String className)
+	{
+	    int n = lines.size();
+	    for (int i = 0; i < n; i++)
+	    {
+	        String line = lines.get(i);
+	        int c2;
+	        int c = line.indexOf("goog.inherits");
+	        if (c > -1)
+	        {
+	            String inheritLine = ""; 
+                while (true)
+                {
+                    inheritLine += line;
+                    c2 = line.indexOf(")");
+                    if (c2 > -1)
+                        break;
+                    else
+                    {
+                        i++;
+                        line = lines.get(i);
+                    }
+                }
+	            c = inheritLine.indexOf(",");
+                c2 = inheritLine.indexOf(")");
+                return inheritLine.substring(c + 1, c2).trim();            
+	        }
+	    }
+	    System.out.println("couldn't find base class for " + className);
+	    return null;
+	}
+	
+	String getFilePath(String className)
+	{
+		System.out.println("Finding file for class: " + className);
+		String classPath = className.replace(".", File.separator);
+		String fn = googPath + File.separator + "closure" + File.separator + "goog" + File.separator
+ classPath + ".js";
+        File destFile;
+		File f = new File(fn);
+		if (f.exists())
+		{
+		    fn = outputFolderPath + File.separator + "library" +
+		        File.separator + "closure" + File.separator + "goog" + 
+		        File.separator + classPath + ".js";
+		    destFile = new File(fn);
+            // copy source to output
+            try {
+                FileUtils.copyFile(f, destFile);
+                System.out.println("Copying file for class: " + className);
+            } catch (IOException e) {
+                System.out.println("Error copying file for class: " + className);
+            }
+			return fn;
+		}
+		
+        fn = googPath + File.separator + "closure" + File.separator + "third_party" +  File.separator
+ classPath + ".js";
+        f = new File(fn);
+        if (f.exists())
+        {
+            fn = outputFolderPath + File.separator + "library" +
+                File.separator + "closure" + File.separator + "third_party" + 
+                File.separator + classPath + ".js";
+            destFile = new File(fn);
+            // copy source to output
+            try {
+                FileUtils.copyFile(f, destFile);
+                System.out.println("Copying file for class: " + className);
+            } catch (IOException e) {
+                System.out.println("Error copying file for class: " + className);
+            }
+            return fn;
+        }
+        
+        fn = outputFolderPath + File.separator + classPath + ".js";
+        f = new File(fn);
+        if (f.exists())
+        {
+            return fn;
+        }
+        
+        for (String otherPath : otherPaths)
+        {
+    		fn = otherPath + File.separator + classPath + ".js";
+    		f = new File(fn);
+    		if (f.exists())
+    		{
+    			fn = outputFolderPath + File.separator + classPath + ".js";
+    			destFile = new File(fn);
+    			// copy source to output
+    			try {
+    				FileUtils.copyFile(f, destFile);
+    				System.out.println("Copying file for class: " + className);
+    			} catch (IOException e) {
+    				// TODO Auto-generated catch block
+    				System.out.println("Error copying file for class: " + className);
+    			}
+    			return fn;
+    		}
+        }
+		System.out.println("Could not find file for class: " + className);
+		return "";
+	}
+	
+	private ArrayList<String> getDirectDependencies(String fn)
+	{
+		ArrayList<String> deps = new ArrayList<String>();
+		
+		FileInputStream fis;
+		try {
+			fis = new FileInputStream(fn);
+			Scanner scanner = new Scanner(fis, "UTF-8");
+			while (scanner.hasNextLine())
+			{
+				String s = scanner.nextLine();
+				if (s.indexOf("goog.inherits") > -1)
+					break;
+				int c = s.indexOf("goog.require");
+				if (c > -1)
+				{
+					int c2 = s.indexOf(")");
+					s = s.substring(c + 14, c2 - 1);
+					deps.add(s);
+				}
+			}
+		} catch (FileNotFoundException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return deps;
+	}
+	
+	private String getDependencies(ArrayList<String> deps)
+	{
+		String s = "";
+		for (String dep : deps)
+		{
+			if (s.length() > 0)
+			{
+				s += ", ";
+			}
+			s += "'" + dep + "'";			
+		}
+		return s;
+	}
+
+	String relativePath(String path)
+	{
+        if (path.indexOf(outputFolderPath) == 0)
+        {
+            path = path.replace(outputFolderPath, "../../..");
+        }
+        else
+        {
+    	    for (String otherPath : otherPaths)
+    	    {
+        		if (path.indexOf(otherPath) == 0)
+        		{
+        			path = path.replace(otherPath, "../../..");
+        			
+        		}
+    	    }
+        }
+		// paths are actually URIs and always have forward slashes
+		path = path.replace('\\', '/');
+		return path;
+	}
+	private class GoogDep
+	{
+		public String filePath;
+		public String className;
+		public ArrayList<String> deps;
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/54413efd/compiler.jx/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java
b/compiler.jx/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java
index 146da37..47014e6 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/projects/FlexJSProject.java
@@ -20,7 +20,6 @@ package org.apache.flex.compiler.internal.projects;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Set;
 
 import org.apache.flex.compiler.common.DependencyType;
@@ -30,8 +29,6 @@ import org.apache.flex.compiler.internal.scopes.ASProjectScope.DefinitionPromise
 import org.apache.flex.compiler.internal.workspaces.Workspace;
 import org.apache.flex.compiler.units.ICompilationUnit;
 
-import com.google.common.collect.ImmutableSet;
-
 /**
  * @author aharui
  * 
@@ -88,65 +85,17 @@ public class FlexJSProject extends FlexProject
         super.addDependency(from, to, dt, qname);
     }
 
-    private boolean needToDetermineRequires = true;
-
-    // this set is computed from the requires list .  we have to strip out any circularities
starting from the mainCU
-    private HashMap<ICompilationUnit, ArrayList<String>> googrequires = new HashMap<ICompilationUnit,
ArrayList<String>>();
-
-    private void determineRequires() throws InterruptedException
+    public ArrayList<String> getRequires(ICompilationUnit from)
     {
-        if (mainCU == null)
-            return;
-
-        needToDetermineRequires = false;
-        List<ICompilationUnit> reachableCompilationUnits = getReachableCompilationUnitsInSWFOrder(ImmutableSet
-                .of(mainCU));
-
-        HashMap<String, String> already = new HashMap<String, String>();
-
-        for (ICompilationUnit cu : reachableCompilationUnits)
+        if (requires.containsKey(from))
         {
-            if (requires.containsKey(cu))
-            {
-                String qname = cu.getQualifiedNames().get(0);
-                already.put(qname, qname);
-                HashMap<String, DependencyType> reqs = requires.get(cu);
-                Set<String> it = reqs.keySet();
-                ArrayList<String> newreqs = new ArrayList<String>();
-                for (String req : it)
-                {
-                    DependencyType dt = reqs.get(req);
-                    if (dt == DependencyType.INHERITANCE)
-                        newreqs.add(req);
-                    else
-                    {
-                        if (!already.containsKey(req))
-                        {
-                            newreqs.add(req);
-                            already.put(req, req);
-                        }
-                    }
-                }
-                googrequires.put(cu, newreqs);
-            }
+            HashMap<String, DependencyType> map = requires.get(from);
+            ArrayList<String> arr = new ArrayList<String>();
+            Set<String> cus = map.keySet();
+            for (String s : cus)
+                arr.add(s);
+            return arr;
         }
-    }
-
-    public ArrayList<String> getRequires(ICompilationUnit from)
-    {
-        if (needToDetermineRequires)
-            try
-            {
-                determineRequires();
-            }
-            catch (InterruptedException e)
-            {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-            }
-
-        if (googrequires.containsKey(from))
-            return googrequires.get(from);
         return null;
     }
 


Mime
View raw message