flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject [7/8] git commit: [flex-falcon] [refs/heads/feature/amf] - add class aliases to JS info structure
Date Wed, 06 Sep 2017 22:17:20 GMT
add class aliases to JS info structure


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

Branch: refs/heads/feature/amf
Commit: a9e09f4bc3aae17a6df461fa6bb1e8dc88570e32
Parents: 135b749
Author: Alex Harui <aharui@apache.org>
Authored: Thu Aug 31 21:09:26 2017 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Aug 31 21:09:26 2017 -0700

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/MXMLJSC.java   |  3 +++
 .../flex/compiler/clients/MXMLJSCFlex.java      |  3 +++
 .../codegen/mxml/flexjs/MXMLFlexJSEmitter.java  | 20 ++++++++++++++++++++
 .../internal/projects/FlexJSProject.java        |  2 +-
 .../compiler/internal/targets/FlexJSTarget.java | 14 ++++++++++++++
 .../targets/FlexApplicationFrame1Info.java      | 20 ++++++++++++++++++++
 6 files changed, 61 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a9e09f4b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
index cd67a51..3c97c78 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -28,6 +28,7 @@ import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
@@ -519,8 +520,10 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
 	                Set<ICompilationUnit> incs = target.getIncludesCompilationUnits();
 	                roots.addAll(incs);
 	                project.mixinClassNames = new TreeSet<String>();
+	                project.remoteClassAliasMap = new HashMap<String, String>();
 	                List<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(roots);
 	                ((FlexJSTarget)target).collectMixinMetaData(project.mixinClassNames, reachableCompilationUnits);
+	                ((FlexJSTarget)target).collectRemoteClassMetaData(project.remoteClassAliasMap,
reachableCompilationUnits);
 	                for (final ICompilationUnit cu : reachableCompilationUnits)
 	                {
 	                    ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a9e09f4b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSCFlex.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSCFlex.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSCFlex.java
index 49de954..659e83d 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSCFlex.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSCFlex.java
@@ -27,6 +27,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
@@ -330,8 +331,10 @@ public class MXMLJSCFlex implements JSCompilerEntryPoint, ProblemQueryProvider,
 	                Set<ICompilationUnit> incs = target.getIncludesCompilationUnits();
 	                roots.addAll(incs);
 	                project.mixinClassNames = new TreeSet<String>();
+	                project.remoteClassAliasMap = new HashMap<String, String>();
 	                List<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(roots);
 	                ((FlexJSTarget)target).collectMixinMetaData(project.mixinClassNames, reachableCompilationUnits);
+	                ((FlexJSTarget)target).collectRemoteClassMetaData(project.remoteClassAliasMap,
reachableCompilationUnits);
 	                for (final ICompilationUnit cu : reachableCompilationUnits)
 	                {
 	                    ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a9e09f4b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
index 77bbf52..549d40e 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/mxml/flexjs/MXMLFlexJSEmitter.java
@@ -301,6 +301,26 @@ public class MXMLFlexJSEmitter extends MXMLEmitter implements
 		            	infoInject += mixinInject;
 		            	sep = ",\n";
 	            	}
+	            	Map<String, String> aliases = flexJSProject.remoteClassAliasMap;
+	            	if (aliases != null && aliases.size() > 0)
+	            	{
+		            	String aliasInject = "remoteClassAliases: {";
+		            	boolean firstOne = true;
+		            	for (String className : aliases.keySet())
+		            	{
+		            		if (isExternal(className))
+		            			continue;
+		            		if (!firstOne)
+		            			aliasInject += ", "; 
+		            		aliasInject += "\"" + className + "\": ";
+		            		String alias = aliases.get(className);
+		            		aliasInject += "\"" + alias + "\"";
+		            		firstOne = false;
+		            	}
+		            	aliasInject += "}";
+		            	infoInject += aliasInject;
+		            	sep = ",\n";
+	            	}
 	            	boolean isMX = false;
 	            	List<ISWC> swcs = flexJSProject.getLibraries();
 	            	for (ISWC swc : swcs)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a9e09f4b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/projects/FlexJSProject.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/projects/FlexJSProject.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/projects/FlexJSProject.java
index 4d905bf..6714d44 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/projects/FlexJSProject.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/projects/FlexJSProject.java
@@ -84,7 +84,7 @@ public class FlexJSProject extends FlexProject
     private HashMap<ICompilationUnit, HashMap<String, DependencyType>> requires
= new HashMap<ICompilationUnit, HashMap<String, DependencyType>>();
     private HashMap<ICompilationUnit, HashMap<String, DependencyType>> jsModules
= new HashMap<ICompilationUnit, HashMap<String, DependencyType>>();
     public TreeSet<String> mixinClassNames;
-
+    public HashMap<String, String> remoteClassAliasMap;
     public JSGoogConfiguration config;
     public Configurator configurator;
 

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a9e09f4b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
index b3c5bd2..560deb1 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/targets/FlexJSTarget.java
@@ -306,4 +306,18 @@ public class FlexJSTarget extends JSTarget implements IJSTarget
 			}
     	}
     }
+    
+    public void collectRemoteClassMetaData(Map<String, String> remoteClassAliasMap,
List<ICompilationUnit> units)
+    {
+    	for (ICompilationUnit unit : units)
+    	{
+        	try {
+				FlexApplicationFrame1Info.collectRemoteClassMetaData(remoteClassAliasMap, unit);
+			} catch (InterruptedException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+    	}
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a9e09f4b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexApplicationFrame1Info.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexApplicationFrame1Info.java
b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexApplicationFrame1Info.java
index 08c1f79..9392cc6 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexApplicationFrame1Info.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/targets/FlexApplicationFrame1Info.java
@@ -21,6 +21,7 @@ package org.apache.flex.compiler.internal.targets;
 
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -135,6 +136,25 @@ final class FlexApplicationFrame1Info extends FlexFrame1Info
     }
     
     /**
+     * Collects names of classes that are mix-ins.
+     * 
+     * @param compilationUnit
+     * @throws InterruptedException
+     */
+    public static void collectRemoteClassMetaData(Map<String, String> remoteClassNames,
ICompilationUnit compilationUnit) throws InterruptedException
+    {
+        IFileScopeRequestResult result = compilationUnit.getFileScopeRequest().get();
+
+        for(IDefinition def : result.getExternallyVisibleDefinitions()) 
+        {
+            IMetaTag md = def.getMetaTagByName(IMetaAttributeConstants.ATTRIBUTE_REMOTECLASS);
+            if (md != null)
+                remoteClassNames.put(def.getQualifiedName(), md.getAttributeValue("alias"));
+        }
+    }
+    
+
+    /**
      * Collect the swcs that are contributing compilation units to this swf.
      * 
      * @param cu


Mime
View raw message