You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jo...@apache.org on 2016/04/21 22:35:26 UTC

[1/5] git commit: [flex-falcon] [refs/heads/develop] - look for RequireExtern metadata on external classes to see if require() is needed for an external class (such as in Node.js). in the future, if different module output types are allowed, the emitter

Repository: flex-falcon
Updated Branches:
  refs/heads/develop ce38e3e39 -> b4e4fadb7


look for RequireExtern metadata on external classes to see if require() is needed for an external class (such as in Node.js). in the future, if different module output types are allowed, the emitter may decide to output it differently than in the current CommonJS format


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

Branch: refs/heads/develop
Commit: 53e6204e466a76f458cc52ee35693eb44502da6a
Parents: fb2dc7a
Author: Josh Tynjala <jo...@apache.org>
Authored: Thu Apr 21 11:05:59 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Thu Apr 21 11:05:59 2016 -0700

----------------------------------------------------------------------
 .../codegen/js/jx/PackageHeaderEmitter.java     | 119 +++++++++++++------
 .../codegen/js/node/NodeEmitterTokens.java      |  21 ++++
 .../internal/projects/FlexJSProject.java        |  50 ++++++++
 3 files changed, 155 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/53e6204e/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
index d47c6dc..6ce6328 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
@@ -38,6 +38,7 @@ import org.apache.flex.compiler.internal.codegen.js.JSSubEmitter;
 import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
 import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.node.NodeEmitterTokens;
 import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
 import org.apache.flex.compiler.internal.projects.FlexJSProject;
 import org.apache.flex.compiler.internal.scopes.ASProjectScope;
@@ -187,10 +188,53 @@ public class PackageHeaderEmitter extends JSSubEmitter implements
                 .getCompilationUnitForDefinition(type != null ? type : otherMainDefinition);
         ArrayList<String> requiresList = flexProject.getRequires(cu);
         ArrayList<String> interfacesList = flexProject.getInterfaces(cu);
+        ArrayList<String> externalRequiresList = flexProject.getExternalRequires(cu);
         
         String cname = (type != null) ? type.getQualifiedName() : otherMainDefinition.getQualifiedName();
         writtenRequires.add(cname); // make sure we don't add ourselves
 
+        boolean emitsRequires = emitRequires(requiresList, writtenRequires, cname);
+        boolean emitsInterfaces = emitInterfaces(interfacesList, writtenRequires);
+
+        // erikdebruin: Add missing language feature support, with e.g. 'is' and 
+        //              'as' operators. We don't need to worry about requiring
+        //              this in every project: ADVANCED_OPTIMISATIONS will NOT
+        //              include any of the code if it is not used in the project.
+        boolean makingSWC = flexProject.getSWFTarget() != null && 
+        					flexProject.getSWFTarget().getTargetType() == TargetType.SWC;
+        boolean isMainCU = flexProject.mainCU != null
+                && cu.getName().equals(flexProject.mainCU.getName());
+        if (isMainCU || makingSWC)
+        {
+            ICompilerProject project = this.getProject();
+            if (project instanceof FlexJSProject)
+            {
+            	if (((FlexJSProject)project).needLanguage)
+            	{
+		            write(JSGoogEmitterTokens.GOOG_REQUIRE);
+		            write(ASEmitterTokens.PAREN_OPEN);
+		            write(ASEmitterTokens.SINGLE_QUOTE);
+		            write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
+		            write(ASEmitterTokens.SINGLE_QUOTE);
+		            write(ASEmitterTokens.PAREN_CLOSE);
+		            writeNewline(ASEmitterTokens.SEMICOLON);
+            	}
+            }
+        }
+
+        boolean emitsExternalRequires = emitExternalRequires(externalRequiresList, writtenRequires);
+
+        if (emitsRequires || emitsInterfaces || emitsExternalRequires || isMainCU)
+        {
+            writeNewline();
+        }
+
+        writeNewline();
+        writeNewline();
+    }
+    
+    private boolean emitRequires(List<String> requiresList, List<String> writtenRequires, String cname)
+    {
         boolean emitsRequires = false;
         if (requiresList != null)
         {
@@ -208,8 +252,8 @@ public class PackageHeaderEmitter extends JSSubEmitter implements
 
                 if (NativeUtils.isNative(imp))
                 {
-                	if (!(imp.equals("QName") || imp.equals("Namespace") || imp.equals("XML") || imp.equals("XMLList")))
-                		continue;                	
+                    if (!(imp.equals("QName") || imp.equals("Namespace") || imp.equals("XML") || imp.equals("XMLList")))
+                        continue;
                 }
 
                 if (writtenRequires.indexOf(imp) == -1)
@@ -219,7 +263,7 @@ public class PackageHeaderEmitter extends JSSubEmitter implements
                     write(JSGoogEmitterTokens.GOOG_REQUIRE);
                     write(ASEmitterTokens.PAREN_OPEN);
                     write(ASEmitterTokens.SINGLE_QUOTE);
-                    write(fjs.formatQualifiedName(imp));
+                    write(getEmitter().formatQualifiedName(imp));
                     write(ASEmitterTokens.SINGLE_QUOTE);
                     write(ASEmitterTokens.PAREN_CLOSE);
                     writeNewline(ASEmitterTokens.SEMICOLON);
@@ -230,7 +274,11 @@ public class PackageHeaderEmitter extends JSSubEmitter implements
                 }
             }
         }
-
+        return emitsRequires;
+    }
+    
+    private boolean emitInterfaces(List<String> interfacesList, List<String> writtenRequires)
+    {
         boolean emitsInterfaces = false;
         if (interfacesList != null)
         {
@@ -242,7 +290,7 @@ public class PackageHeaderEmitter extends JSSubEmitter implements
                     write(JSGoogEmitterTokens.GOOG_REQUIRE);
                     write(ASEmitterTokens.PAREN_OPEN);
                     write(ASEmitterTokens.SINGLE_QUOTE);
-                    write(fjs.formatQualifiedName(imp));
+                    write(getEmitter().formatQualifiedName(imp));
                     write(ASEmitterTokens.SINGLE_QUOTE);
                     write(ASEmitterTokens.PAREN_CLOSE);
                     writeNewline(ASEmitterTokens.SEMICOLON);
@@ -251,40 +299,41 @@ public class PackageHeaderEmitter extends JSSubEmitter implements
                 }
             }
         }
-
-        // erikdebruin: Add missing language feature support, with e.g. 'is' and 
-        //              'as' operators. We don't need to worry about requiring
-        //              this in every project: ADVANCED_OPTIMISATIONS will NOT
-        //              include any of the code if it is not used in the project.
-        boolean makingSWC = flexProject.getSWFTarget() != null && 
-        					flexProject.getSWFTarget().getTargetType() == TargetType.SWC;
-        boolean isMainCU = flexProject.mainCU != null
-                && cu.getName().equals(flexProject.mainCU.getName());
-        if (isMainCU || makingSWC)
+        return emitsInterfaces;
+    }
+    
+    private boolean emitExternalRequires(List<String> externalRequiresList, List<String> writtenRequires)
+    {
+        boolean emitsExternalRequires = false;
+        if (externalRequiresList != null)
         {
-            ICompilerProject project = this.getProject();
-            if (project instanceof FlexJSProject)
+            Collections.sort(externalRequiresList);
+            for (String imp : externalRequiresList)
             {
-            	if (((FlexJSProject)project).needLanguage)
-            	{
-		            write(JSGoogEmitterTokens.GOOG_REQUIRE);
-		            write(ASEmitterTokens.PAREN_OPEN);
-		            write(ASEmitterTokens.SINGLE_QUOTE);
-		            write(JSFlexJSEmitterTokens.LANGUAGE_QNAME);
-		            write(ASEmitterTokens.SINGLE_QUOTE);
-		            write(ASEmitterTokens.PAREN_CLOSE);
-		            writeNewline(ASEmitterTokens.SEMICOLON);
-            	}
-            }
-        }
+                if (writtenRequires.indexOf(imp) == -1)
+                {
+                    /* var x = require('x');\n */
+                    write(ASEmitterTokens.VAR);
+                    write(ASEmitterTokens.SPACE);
+                    write(imp);
+                    write(ASEmitterTokens.SPACE);
+                    write(ASEmitterTokens.EQUAL);
+                    write(ASEmitterTokens.SPACE);
+                    write(NodeEmitterTokens.REQUIRE);
+                    write(ASEmitterTokens.PAREN_OPEN);
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(imp);
+                    write(ASEmitterTokens.SINGLE_QUOTE);
+                    write(ASEmitterTokens.PAREN_CLOSE);
+                    writeNewline(ASEmitterTokens.SEMICOLON);
 
-        if (emitsRequires || emitsInterfaces || isMainCU)
-        {
-            writeNewline();
-        }
+                    writtenRequires.add(imp);
 
-        writeNewline();
-        writeNewline();
+                    emitsExternalRequires = true;
+                }
+            }
+        }
+        return emitsExternalRequires;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/53e6204e/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/node/NodeEmitterTokens.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/node/NodeEmitterTokens.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/node/NodeEmitterTokens.java
new file mode 100644
index 0000000..dddcf90
--- /dev/null
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/node/NodeEmitterTokens.java
@@ -0,0 +1,21 @@
+package org.apache.flex.compiler.internal.codegen.js.node;
+
+import org.apache.flex.compiler.codegen.IEmitterTokens;
+
+public enum NodeEmitterTokens implements IEmitterTokens
+{
+    REQUIRE("require"),
+    EXPORTS("exports");
+
+    private String token;
+
+    private NodeEmitterTokens(String value)
+    {
+        token = value;
+    }
+
+    public String getToken()
+    {
+        return token;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/53e6204e/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 67869ab..5796c91 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
@@ -21,6 +21,7 @@ package org.apache.flex.compiler.internal.projects;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -60,6 +61,7 @@ public class FlexJSProject extends FlexProject
 
     private HashMap<ICompilationUnit, HashMap<String, String>> interfaces = new HashMap<ICompilationUnit, HashMap<String, String>>();
     private HashMap<ICompilationUnit, HashMap<String, DependencyType>> requires = new HashMap<ICompilationUnit, HashMap<String, DependencyType>>();
+    private HashMap<ICompilationUnit, HashMap<String, DependencyType>> externalRequires = new HashMap<ICompilationUnit, HashMap<String, DependencyType>>();
 
     public JSGoogConfiguration config;
     
@@ -106,6 +108,19 @@ public class FlexJSProject extends FlexProject
                 		needXML = true;
                     reqs.put(qname, dt);
                 }
+                if (externalRequires.containsKey(from))
+                {
+                    reqs = externalRequires.get(from);
+                }
+                else
+                {
+                    reqs = new HashMap<String, DependencyType>();
+                    externalRequires.put(from, reqs);
+                }
+                if (hasRequireExternMetadata(to))
+                {
+                    reqs.put(qname, dt);
+                }
             }
         }
         else
@@ -146,6 +161,27 @@ public class FlexJSProject extends FlexProject
     // definitions that should be considered external linkage
     public Collection<String> unitTestExterns;
 
+    private boolean hasRequireExternMetadata(ICompilationUnit cu)
+    {
+        try
+        {
+            Iterator<IDefinition> iterator = cu.getFileScopeRequest().get().getExternallyVisibleDefinitions().iterator();
+            while(iterator.hasNext())
+            {
+                IDefinition def = iterator.next();
+                if (def.hasMetaTagByName("RequireExtern"))
+                {
+                    return true;
+                }
+            }
+        }
+        catch (Exception ex)
+        {
+            //it's safe to ignore an exception here
+        }
+        return false;
+    }
+
     private boolean isExternalLinkage(ICompilationUnit cu)
     {
         if (linkageChecker == null)
@@ -220,6 +256,20 @@ public class FlexJSProject extends FlexProject
         return null;
     }
 
+    public ArrayList<String> getExternalRequires(ICompilationUnit from)
+    {
+        if (externalRequires.containsKey(from))
+        {
+            HashMap<String, DependencyType> map = externalRequires.get(from);
+            ArrayList<String> arr = new ArrayList<String>();
+            Set<String> cus = map.keySet();
+            for (String s : cus)
+                arr.add(s);
+            return arr;
+        }
+        return null;
+    }
+
     JSCSSCompilationSession cssSession = new JSCSSCompilationSession();
 
     @Override


[4/5] git commit: [flex-falcon] [refs/heads/develop] - externs/node: uses named-module argument for externc to name the node modules

Posted by jo...@apache.org.
externs/node: uses named-module argument for externc to name the node modules


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

Branch: refs/heads/develop
Commit: e15fcf0104fec24d8148894a5f78017e1acd9a3e
Parents: bfb462c
Author: Josh Tynjala <jo...@apache.org>
Authored: Thu Apr 21 13:13:12 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Thu Apr 21 13:13:12 2016 -0700

----------------------------------------------------------------------
 externs/node/node-compile-config.xml | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e15fcf01/externs/node/node-compile-config.xml
----------------------------------------------------------------------
diff --git a/externs/node/node-compile-config.xml b/externs/node/node-compile-config.xml
index d836f6d..d262740 100644
--- a/externs/node/node-compile-config.xml
+++ b/externs/node/node-compile-config.xml
@@ -61,6 +61,36 @@
         <path-element>externs/vm.js</path-element>
         <path-element>externs/zlib.js</path-element>
     </external>
+    <named-module>
+        <module>assert</module>
+        <module>buffer</module>
+        <module>child_process</module>
+        <module>cluster</module>
+        <module>crypto</module>
+        <module>dgram</module>
+        <module>dns</module>
+        <module>domain</module>
+        <module>events</module>
+        <module>fs</module>
+        <module>globals</module>
+        <module>http</module>
+        <module>https</module>
+        <module>net</module>
+        <module>os</module>
+        <module>path</module>
+        <module>punycode</module>
+        <module>querystring</module>
+        <module>readline</module>
+        <module>repl</module>
+        <module>stream</module>
+        <module>string_decoder</module>
+        <module>tls</module>
+        <module>tty</module>
+        <module>url</module>
+        <module>util</module>
+        <module>vm</module>
+        <module>zlib</module>
+    </named-module>
     <exclude>
         <class>Buffer</class>
         <name>toJSON</name>


[5/5] git commit: [flex-falcon] [refs/heads/develop] - Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/flex-falcon into develop

Posted by jo...@apache.org.
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/flex-falcon into develop


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

Branch: refs/heads/develop
Commit: b4e4fadb7062a6f7a180fce4536de54590bf9aff
Parents: e15fcf0 ce38e3e
Author: Josh Tynjala <jo...@apache.org>
Authored: Thu Apr 21 13:35:14 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Thu Apr 21 13:35:14 2016 -0700

----------------------------------------------------------------------
 build.xml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------



[3/5] git commit: [flex-falcon] [refs/heads/develop] - compiler.jx: externc now supports a -named-module argument that will output JSModule metadata for classes in the same base package as the module name

Posted by jo...@apache.org.
compiler.jx: externc now supports a -named-module argument that will output JSModule metadata for classes in the same base package as the module name


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

Branch: refs/heads/develop
Commit: bfb462c6d6460d2bbace8032ba5e66867636030b
Parents: 021fa66
Author: Josh Tynjala <jo...@apache.org>
Authored: Thu Apr 21 13:12:39 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Thu Apr 21 13:12:39 2016 -0700

----------------------------------------------------------------------
 .../compiler/clients/ExternCConfiguration.java  | 54 ++++++++++++++++++++
 .../externals/reference/ClassReference.java     | 30 ++++++++++-
 2 files changed, 83 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/bfb462c6/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
index c15786a..c6e7212 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/ExternCConfiguration.java
@@ -56,6 +56,8 @@ public class ExternCConfiguration extends Configuration
     private List<ExternalFile> externals = new ArrayList<ExternalFile>();
     private List<ExternalFile> externalExterns = new ArrayList<ExternalFile>();
 
+    private List<String> namedModules = new ArrayList<String>();
+
     private List<String> classToFunctions = new ArrayList<String>();
     private List<ExcludedMember> excludesClass = new ArrayList<ExcludedMember>();
     private List<ExcludedMember> excludesField = new ArrayList<ExcludedMember>();
@@ -295,6 +297,58 @@ public class ExternCConfiguration extends Configuration
         excludesClass.add(new ExcludedMember(className, null, ""));
     }
 
+    @Config(allowMultiple = true)
+    @Mapping("named-module")
+    @Arguments("module")
+    @InfiniteArguments
+    public void setNamedModules(ConfigurationValue cfgval, List<String> values)
+    {
+        for (String moduleName : values)
+        {
+            addNamedModule(moduleName);
+        }
+    }
+    public void addNamedModule(String moduleName)
+    {
+        namedModules.add(moduleName);
+    }
+
+    public String isNamedModule(ClassReference classReference)
+    {
+        String basePackageName = classReference.getPackageName();
+        int packageIndex = basePackageName.indexOf(".");
+        if (packageIndex != -1)
+        {
+            basePackageName = basePackageName.substring(0, packageIndex);
+        }
+        for (String module : namedModules)
+        {
+            //convert to camel case
+            String camelCaseModule = module;
+            int moduleIndex = camelCaseModule.indexOf("-");
+            while (moduleIndex != -1 && moduleIndex < camelCaseModule.length() - 1)
+            {
+                camelCaseModule = camelCaseModule.substring(0, moduleIndex)
+                        + camelCaseModule.substring(moduleIndex + 1, moduleIndex + 2).toUpperCase()
+                        + camelCaseModule.substring(moduleIndex + 2);
+                moduleIndex = camelCaseModule.indexOf("-");
+            }
+            if(basePackageName.length() == 0)
+            {
+                if (classReference.getBaseName().equals(camelCaseModule))
+                {
+                    return module;
+                }
+                continue;
+            }
+            if(basePackageName.equals(camelCaseModule))
+            {
+                return module;
+            }
+        }
+        return null;
+    }
+
     public File getJsRoot()
     {
         return jsRoot;

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/bfb462c6/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
index b04fb0e..fc1df39 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/externals/reference/ClassReference.java
@@ -41,6 +41,7 @@ public class ClassReference extends BaseReference
 {
     private boolean isFinal;
     private boolean isDynamic;
+    private String moduleName;
     private int enumConstantCounter = 0;
 
     private Set<String> imports = new HashSet<String>();
@@ -142,6 +143,16 @@ public class ClassReference extends BaseReference
         this.isFinal = isFinal;
     }
 
+    public String getModuleName()
+    {
+        return moduleName;
+    }
+
+    public void setModuleName(String moduleName)
+    {
+        this.moduleName = moduleName;
+    }
+
     public final boolean isInterface()
     {
         return getComment().isInterface();
@@ -294,6 +305,8 @@ public class ClassReference extends BaseReference
             constructor = new MethodReference(model, this, functionNode, getBaseName(), comment, false);
         }
 
+        moduleName = model.getConfiguration().isNamedModule(this);
+
     }
 
     private static List<String> definedPackages = new ArrayList<String>();
@@ -341,6 +354,21 @@ public class ClassReference extends BaseReference
 	
 	        emitImports(sb);
         }
+
+        if (moduleName != null)
+        {
+            sb.append("[JSModule");
+            if (packageName.length() > 0 || !getBaseName().equals(moduleName))
+            {
+                sb.append("(");
+                sb.append("name=\"");
+                sb.append(moduleName);
+                sb.append("\"");
+                sb.append(")");
+            }
+            sb.append("]");
+            sb.append("\n");
+        }
         
         emitComment(sb);
 
@@ -730,7 +758,7 @@ public class ClassReference extends BaseReference
     {
     	if (outputJS)
     		return;
-    	
+
         sb.append("public ");
         if (isDynamic)
         {


[2/5] git commit: [flex-falcon] [refs/heads/develop] - compiler.jx renamed RequireExtern metadata to JSModule

Posted by jo...@apache.org.
compiler.jx renamed RequireExtern metadata to JSModule


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

Branch: refs/heads/develop
Commit: 021fa664680a320c387a10926a2119e8e7a06f33
Parents: 53e6204
Author: Josh Tynjala <jo...@apache.org>
Authored: Thu Apr 21 13:11:14 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Thu Apr 21 13:11:14 2016 -0700

----------------------------------------------------------------------
 .../internal/projects/FlexJSProject.java        | 35 +++++++++++++-------
 1 file changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/021fa664/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 5796c91..dab4843 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
@@ -27,6 +27,8 @@ import java.util.Set;
 
 import org.apache.flex.compiler.common.DependencyType;
 import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.definitions.metadata.IMetaTag;
+import org.apache.flex.compiler.definitions.metadata.IMetaTagAttribute;
 import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSEmitterTokens;
 import org.apache.flex.compiler.internal.css.codegen.CSSCompilationSession;
 import org.apache.flex.compiler.internal.definitions.InterfaceDefinition;
@@ -61,7 +63,7 @@ public class FlexJSProject extends FlexProject
 
     private HashMap<ICompilationUnit, HashMap<String, String>> interfaces = new HashMap<ICompilationUnit, HashMap<String, String>>();
     private HashMap<ICompilationUnit, HashMap<String, DependencyType>> requires = new HashMap<ICompilationUnit, HashMap<String, DependencyType>>();
-    private HashMap<ICompilationUnit, HashMap<String, DependencyType>> externalRequires = new HashMap<ICompilationUnit, HashMap<String, DependencyType>>();
+    private HashMap<ICompilationUnit, HashMap<String, DependencyType>> jsModules = new HashMap<ICompilationUnit, HashMap<String, DependencyType>>();
 
     public JSGoogConfiguration config;
     
@@ -108,18 +110,27 @@ public class FlexJSProject extends FlexProject
                 		needXML = true;
                     reqs.put(qname, dt);
                 }
-                if (externalRequires.containsKey(from))
+                if (jsModules.containsKey(from))
                 {
-                    reqs = externalRequires.get(from);
+                    reqs = jsModules.get(from);
                 }
                 else
                 {
                     reqs = new HashMap<String, DependencyType>();
-                    externalRequires.put(from, reqs);
+                    jsModules.put(from, reqs);
                 }
-                if (hasRequireExternMetadata(to))
+                IMetaTag tag = getJSModuleMetadata(to);
+                if (tag != null)
                 {
-                    reqs.put(qname, dt);
+                    IMetaTagAttribute nameAttribute = tag.getAttribute("name");
+                    if (nameAttribute != null)
+                    {
+                        reqs.put(nameAttribute.getValue(), dt);
+                    }
+                    else
+                    {
+                        reqs.put(qname, dt);
+                    }
                 }
             }
         }
@@ -161,7 +172,7 @@ public class FlexJSProject extends FlexProject
     // definitions that should be considered external linkage
     public Collection<String> unitTestExterns;
 
-    private boolean hasRequireExternMetadata(ICompilationUnit cu)
+    private IMetaTag getJSModuleMetadata(ICompilationUnit cu)
     {
         try
         {
@@ -169,9 +180,9 @@ public class FlexJSProject extends FlexProject
             while(iterator.hasNext())
             {
                 IDefinition def = iterator.next();
-                if (def.hasMetaTagByName("RequireExtern"))
+                if (def.hasMetaTagByName("JSModule"))
                 {
-                    return true;
+                    return def.getMetaTagByName("JSModule");
                 }
             }
         }
@@ -179,7 +190,7 @@ public class FlexJSProject extends FlexProject
         {
             //it's safe to ignore an exception here
         }
-        return false;
+        return null;
     }
 
     private boolean isExternalLinkage(ICompilationUnit cu)
@@ -258,9 +269,9 @@ public class FlexJSProject extends FlexProject
 
     public ArrayList<String> getExternalRequires(ICompilationUnit from)
     {
-        if (externalRequires.containsKey(from))
+        if (jsModules.containsKey(from))
         {
-            HashMap<String, DependencyType> map = externalRequires.get(from);
+            HashMap<String, DependencyType> map = jsModules.get(from);
             ArrayList<String> arr = new ArrayList<String>();
             Set<String> cus = map.keySet();
             for (String s : cus)