You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2016/11/17 07:30:54 UTC

git commit: [flex-falcon] [refs/heads/develop] - FLEX-35012 handle internal classes for non-classes like functions

Repository: flex-falcon
Updated Branches:
  refs/heads/develop 966cc7e03 -> 9c5dc8e21


FLEX-35012 handle internal classes for non-classes like functions


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

Branch: refs/heads/develop
Commit: 9c5dc8e217e4cea25f9e46c3bfdc799e531a9096
Parents: 966cc7e
Author: Alex Harui <ah...@apache.org>
Authored: Wed Nov 16 23:30:44 2016 -0800
Committer: Alex Harui <ah...@apache.org>
Committed: Wed Nov 16 23:30:44 2016 -0800

----------------------------------------------------------------------
 .../codegen/js/flexjs/JSFlexJSEmitter.java      | 16 +++++
 .../codegen/js/flexjs/TestFlexJSPackage.java    | 76 ++++++++++++++++++++
 2 files changed, 92 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9c5dc8e2/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
index 61b41e3..6d6cb8c 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSEmitter.java
@@ -590,6 +590,22 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
 	    	        	mainClassName = ((IClassNode)cnode).getQualifiedName();
 	    	        	break;
 	    	        }
+	    	        else if (j == 0)
+	    	        {
+	    	            if (cnode instanceof IFunctionNode)
+	    	            {
+	    	                mainClassName = ((IFunctionNode)cnode).getQualifiedName();
+	    	            }
+	    	            else if (cnode instanceof INamespaceNode)
+	    	            {
+	    	            	mainClassName = ((INamespaceNode)cnode).getQualifiedName();
+	    	            }
+	    	            else if (cnode instanceof IVariableNode)
+	    	            {
+	    	            	mainClassName = ((IVariableNode)cnode).getQualifiedName();
+	    	            }
+	    	        	
+	    	        }
 	            }
 	        }
 	        else if (pnode instanceof IClassNode)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/9c5dc8e2/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java
index 7230646..4a0bbeb 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java
@@ -1133,6 +1133,82 @@ public class TestFlexJSPackage extends TestGoogPackage
     }
 
 	@Test
+	public void testPackageQualified_ClassAndInternalStaticConst()
+	{
+		IFileNode node = compileAS("package foo.bar {\n" +
+				"public function A():Number {\n" +
+				"    return Internal.x;\n" +
+				"}}\n" +
+				"internal class Internal {" +
+				"public static const x:Number = 3;}");
+		
+		asBlockWalker.visitFile(node);
+		assertOutWithMetadata("/**\n" +
+				" * foo.bar.A\n" +
+				" *\n" +
+				" * @fileoverview\n" +
+				" *\n" +
+				" * @suppress {checkTypes|accessControls}\n" +
+				" */\n" +
+				"\n" +
+				"goog.provide('foo.bar.A');\n" +
+				"\n" +
+				"\n" +
+				"\n" +
+				"/**\n" +
+				" * @export\n" +
+				" * @return {number}\n" +
+				" */\n" +
+				"foo.bar.A = function() {\n" +
+				"  return foo.bar.A.Internal.x;\n" +
+				"}\n" +
+				"\n" +
+				"\n" +
+				"/**\n" +
+				" * @constructor\n" +
+				" */\n" +
+				"foo.bar.A.Internal = function() {\n" +
+				"};\n" +
+				"\n" +
+				"\n" +
+				"/**\n" +
+				" * @export\n" +
+				" * @const\n" +
+				" * @type {number}\n" +
+				" */\n" +
+				"foo.bar.A.Internal.x = 3;\n" +
+				"\n" +
+				"\n" +
+				"/**\n" +
+				" * Metadata\n" +
+				" *\n" +
+				" * @type {Object.<string, Array.<Object>>}\n" +
+				" */\n" +
+				"foo.bar.A.Internal.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'Internal', qName: 'foo.bar.A.Internal', kind: 'class' }] };\n" +
+        		"\n" +
+        		"\n" +
+        		"/**\n" +
+        		" * Prevent renaming of class. Needed for reflection.\n" +
+        		" */\n" +
+        		"goog.exportSymbol('foo.bar.A.Internal', foo.bar.A.Internal);\n" +
+          		"\n" +
+        		"\n" +
+        		"\n" +
+        		"/**\n" +
+        		" * Reflection\n" +
+        		" *\n" +
+        		" * @return {Object.<string, Function>}\n" +
+        		" */\n" +
+        		"foo.bar.A.Internal.prototype.FLEXJS_REFLECTION_INFO = function () {\n" +
+        		"  return {\n" +
+				"    variables: function () {return {};},\n" +
+				"    accessors: function () {return {};},\n" +
+				"    methods: function () {return {};}\n" +
+        		"  };\n" +
+        		"};\n");
+	}
+	
+	@Test
 	public void testPackageSimple_Function()
 	{
 		IFileNode node = compileAS("package {public function A(){}}");