Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F333E200B96 for ; Thu, 22 Sep 2016 00:22:39 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id F1C85160ADE; Wed, 21 Sep 2016 22:22:39 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C2865160ADB for ; Thu, 22 Sep 2016 00:22:38 +0200 (CEST) Received: (qmail 21648 invoked by uid 500); 21 Sep 2016 22:22:37 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 21639 invoked by uid 99); 21 Sep 2016 22:22:37 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Sep 2016 22:22:37 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B82A9E07FE; Wed, 21 Sep 2016 22:22:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aharui@apache.org To: commits@flex.apache.org Date: Wed, 21 Sep 2016 22:22:37 -0000 Message-Id: <1044e62115bc40238397836ab3afd1ad@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/5] git commit: [flex-falcon] [refs/heads/develop] - custom namespaces output quoted qname.tostring() archived-at: Wed, 21 Sep 2016 22:22:40 -0000 Repository: flex-falcon Updated Branches: refs/heads/develop a069c04ac -> b7e9b15f0 custom namespaces output quoted qname.tostring() Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/15aef85b Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/15aef85b Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/15aef85b Branch: refs/heads/develop Commit: 15aef85b2ef51443319ee3eb3d75b73330997a7a Parents: a7fac3f Author: Alex Harui Authored: Mon Sep 19 15:29:55 2016 -0700 Committer: Alex Harui Committed: Wed Sep 21 15:22:29 2016 -0700 ---------------------------------------------------------------------- .../codegen/js/flexjs/JSFlexJSDocEmitter.java | 2 +- .../codegen/js/flexjs/JSFlexJSEmitter.java | 34 ++++++++++++++++++++ .../internal/codegen/js/jx/AccessorEmitter.java | 14 +++++++- .../internal/codegen/js/jx/MethodEmitter.java | 5 +-- .../codegen/js/flexjs/TestFlexJSClass.java | 33 ++++++++++++++----- .../js/flexjs/TestFlexJSMethodMembers.java | 4 +-- 6 files changed, 78 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15aef85b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java index ef06e5a..01b7122 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSDocEmitter.java @@ -386,7 +386,7 @@ public class JSFlexJSDocEmitter extends JSGoogDocEmitter { emitProtected(node); } - else if (ns == IASKeywordConstants.PUBLIC) + else if (ns != null && ns != IASKeywordConstants.INTERNAL) { emitPublic(node); } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15aef85b/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 e17e681..827d2c0 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 @@ -26,9 +26,11 @@ import java.util.List; import org.apache.flex.compiler.codegen.IASGlobalFunctionConstants; import org.apache.flex.compiler.codegen.js.flexjs.IJSFlexJSEmitter; import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter; +import org.apache.flex.compiler.constants.IASKeywordConstants; import org.apache.flex.compiler.constants.IASLanguageConstants; import org.apache.flex.compiler.definitions.IClassDefinition; import org.apache.flex.compiler.definitions.IDefinition; +import org.apache.flex.compiler.definitions.INamespaceDefinition; import org.apache.flex.compiler.definitions.IPackageDefinition; import org.apache.flex.compiler.definitions.ITypeDefinition; import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens; @@ -65,6 +67,7 @@ import org.apache.flex.compiler.internal.tree.as.BinaryOperatorAsNode; import org.apache.flex.compiler.internal.tree.as.BlockNode; import org.apache.flex.compiler.internal.tree.as.DynamicAccessNode; import org.apache.flex.compiler.internal.tree.as.FunctionCallNode; +import org.apache.flex.compiler.internal.tree.as.FunctionNode; import org.apache.flex.compiler.internal.tree.as.IdentifierNode; import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode; import org.apache.flex.compiler.internal.tree.as.MemberAccessExpressionNode; @@ -88,6 +91,7 @@ import org.apache.flex.compiler.tree.as.IIdentifierNode; import org.apache.flex.compiler.tree.as.IInterfaceNode; import org.apache.flex.compiler.tree.as.ILiteralNode; import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode; +import org.apache.flex.compiler.tree.as.INamespaceDecorationNode; import org.apache.flex.compiler.tree.as.INamespaceNode; import org.apache.flex.compiler.tree.as.IPackageNode; import org.apache.flex.compiler.tree.as.IScopedNode; @@ -414,9 +418,39 @@ public class JSFlexJSEmitter extends JSGoogEmitter implements IJSFlexJSEmitter write(ASEmitterTokens.SEMICOLON); } + public boolean isCustomNamespace(FunctionNode node) + { + INamespaceDecorationNode ns = ((FunctionNode)node).getActualNamespaceNode(); + if (ns != null) + { + String nsName = node.getNamespace(); + if (!(nsName == IASKeywordConstants.PRIVATE || + nsName == IASKeywordConstants.PROTECTED || + nsName == IASKeywordConstants.INTERNAL || + nsName == IASKeywordConstants.PUBLIC)) + { + return true; + } + } + return false; + } + @Override public void emitMemberName(IDefinitionNode node) { + if (node.getNodeID() == ASTNodeID.FunctionID) + { + FunctionNode fn = (FunctionNode)node; + if (isCustomNamespace(fn)) + { + INamespaceDecorationNode ns = ((FunctionNode)node).getActualNamespaceNode(); + ICompilerProject project = getWalker().getProject(); + INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); + String s = nsDef.getURI(); + write("[\"" + s + "::" + node.getName() + "\"]"); + return; + } + } write(node.getName()); } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15aef85b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/AccessorEmitter.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/AccessorEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/AccessorEmitter.java index 5e7aa50..3f4090b 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/AccessorEmitter.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/AccessorEmitter.java @@ -30,6 +30,7 @@ import org.apache.flex.compiler.common.ModifiersSet; import org.apache.flex.compiler.definitions.IAccessorDefinition; import org.apache.flex.compiler.definitions.IClassDefinition; import org.apache.flex.compiler.definitions.IFunctionDefinition; +import org.apache.flex.compiler.definitions.INamespaceDefinition; import org.apache.flex.compiler.definitions.ITypeDefinition; import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens; import org.apache.flex.compiler.internal.codegen.js.JSDocEmitterTokens; @@ -48,6 +49,7 @@ import org.apache.flex.compiler.projects.ICompilerProject; import org.apache.flex.compiler.tree.ASTNodeID; import org.apache.flex.compiler.tree.as.IAccessorNode; import org.apache.flex.compiler.tree.as.IGetterNode; +import org.apache.flex.compiler.tree.as.INamespaceDecorationNode; import org.apache.flex.compiler.tree.as.ISetterNode; public class AccessorEmitter extends JSSubEmitter implements @@ -118,7 +120,17 @@ public class AccessorEmitter extends JSSubEmitter implements { startMapping(setterNode); } - write(propName); + FunctionNode fnNode = getterNode != null ? (FunctionNode) getterNode : (FunctionNode) setterNode; + if (fjs.isCustomNamespace(fnNode)) + { + INamespaceDecorationNode ns = fnNode.getActualNamespaceNode(); + ICompilerProject project = getWalker().getProject(); + INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); + String s = nsDef.getURI(); + write("\"" + s + "::" + propName + "\""); + } + else + write(propName); write(ASEmitterTokens.COLON); write(ASEmitterTokens.SPACE); write(ASEmitterTokens.BLOCK_OPEN); http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15aef85b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/MethodEmitter.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/MethodEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/MethodEmitter.java index 00c8b16..d26f9f5 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/MethodEmitter.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/MethodEmitter.java @@ -93,12 +93,13 @@ public class MethodEmitter extends JSSubEmitter implements write(fjs.formatQualifiedName(qname)); if (!isConstructor) { - write(ASEmitterTokens.MEMBER_ACCESS); if (!fn.hasModifier(ASModifier.STATIC)) { - write(JSEmitterTokens.PROTOTYPE); write(ASEmitterTokens.MEMBER_ACCESS); + write(JSEmitterTokens.PROTOTYPE); } + if (!fjs.isCustomNamespace(fn)) + write(ASEmitterTokens.MEMBER_ACCESS); } } if (!isConstructor) http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15aef85b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java index 18dad33..f4ba174 100644 --- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java +++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSClass.java @@ -22,6 +22,7 @@ package org.apache.flex.compiler.internal.codegen.js.flexjs; import org.apache.flex.compiler.driver.IBackend; import org.apache.flex.compiler.internal.codegen.js.goog.TestGoogClass; import org.apache.flex.compiler.internal.driver.js.flexjs.FlexJSBackend; +import org.apache.flex.compiler.internal.projects.FlexJSProject; import org.apache.flex.compiler.tree.as.IClassNode; import org.junit.Test; @@ -38,6 +39,13 @@ public class TestFlexJSClass extends TestGoogClass // import somePackage.someClass; someClass; @Override + public void setUp() + { + project = new FlexJSProject(workspace); + super.setUp(); + } + + @Override @Test public void testConstructor_super() { @@ -188,6 +196,15 @@ public class TestFlexJSClass extends TestGoogClass assertOut(expected); } + @Test + public void testMethod_customNamespace() + { + IClassNode node = getClassNode("import flash.utils.flash_proxy; use namespace flash_proxy; public class B {public function B() {}; flash_proxy function foo():void {};}"); + asBlockWalker.visitClass(node); + String expected = "/**\n * @constructor\n */\norg.apache.flex.B = function() {\n};\n\n\n/**\n * @export\n */\norg.apache.flex.B.prototype[\"http://www.adobe.com/2006/actionscript/flash/proxy::foo\"] = function() {\n};"; + assertOut(expected); + } + @Override @Test public void testExtendsConstructor_withArguments() @@ -224,7 +241,7 @@ public class TestFlexJSClass extends TestGoogClass @Test public void testAccessors() { - IClassNode node = getClassNode("public class A {" + IClassNode node = getClassNode("import flash.utils.flash_proxy;public class A {" + "public function get foo1():Object{return null;}" + "public function set foo1(value:Object):void{}" + "protected function get foo2():Object{return null;}" @@ -233,28 +250,28 @@ public class TestFlexJSClass extends TestGoogClass + "private function set foo3(value:Object):void{}" + "internal function get foo5():Object{return null;}" + "internal function set foo5(value:Object):void{}" - + "foo_bar function get foo6():Object{return null;}" - + "foo_bar function set foo6(value:Object):void{}" + "}"); + + "flash_proxy function get foo6():Object{return null;}" + + "flash_proxy function set foo6(value:Object):void{}" + "}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\nObject.defineProperties(org.apache.flex.A.prototype, /** @lends {org.apache.flex.A.prototype} */ {\n/** @export */\nfoo1: {\nget: /** @this {org.apache.flex.A} */ function() {\n return null;\n},\nset: /** @this {org.apache.flex.A} */ function(value) {\n}},\n/** @export */\nfoo2: {\nget: /** @this {org.apache.flex.A} */ function() {\n return null;\n},\nset: /** @this {org.apache.flex.A} */ function(value) {\n}},\n/** @export */\nfoo3: {\nget: /** @this {org.apache.flex.A} */ function() {\n return null;\n},\nset: /** @this {org.apache.flex.A} */ function(value) {\n}},\n/** @export */\nfoo5: {\nget: /** @this {org.apache.flex.A} */ function() {\n return null;\n},\nset: /** @this {org.apache.flex.A} */ function(value) {\n}},\n/** @export */\nfoo6: {\nget: /** @this {org.apache.flex.A} */ function() {\n return null;\n},\nset: /** @this {org.apache.flex.A} */ function(value) {\n}}}\n);"); + assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\nObject.defineProperties(org.apache.flex.A.prototype, /** @lends {org.apache.flex.A.prototype} */ {\n/** @export */\nfoo1: {\nget: /** @this {org.apache.flex.A} */ function() {\n return null;\n},\nset: /** @this {org.apache.flex.A} */ function(value) {\n}},\n/** @export */\nfoo2: {\nget: /** @this {org.apache.flex.A} */ function() {\n return null;\n},\nset: /** @this {org.apache.flex.A} */ function(value) {\n}},\n/** @export */\nfoo3: {\nget: /** @this {org.apache.flex.A} */ function() {\n return null;\n},\nset: /** @this {org.apache.flex.A} */ function(value) {\n}},\n/** @export */\nfoo5: {\nget: /** @this {org.apache.flex.A} */ function() {\n return null;\n},\nset: /** @this {org.apache.flex.A} */ function(value) {\n}},\n/** @export */\n\"http://www.adobe.com/2006/actionscript/flash/proxy::foo6\": {\nget: /** @this {org.apache.flex.A} */ function() {\n return null;\n},\nset: /** @this {org. apache.flex.A} */ function(value) {\n}}}\n);"); } @Override @Test public void testMethods() { - IClassNode node = getClassNode("public class A {" + IClassNode node = getClassNode("import flash.utils.flash_proxy;public class A {" + "public function foo1():Object{return null;}" + "public final function foo1a():Object{return null;}" + "override public function foo1b():Object{return super.foo1b();}" + "protected function foo2(value:Object):void{}" + "private function foo3(value:Object):void{}" + "internal function foo5(value:Object):void{}" - + "foo_bar function foo6(value:Object):void{}" + + "flash_proxy function foo6(value:Object):void{}" + "public static function foo7(value:Object):void{}" - + "foo_bar static function foo7(value:Object):void{}" + "}"); + + "flash_proxy static function foo7(value:Object):void{}" + "}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1 = function() {\n return null;\n};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1a = function() {\n return null;\n};\n\n\n/**\n * @export\n * @override\n */\norg.apache.flex.A.prototype.foo1b = function() {\n return org.apache.flex.A.base(this, 'foo1b');\n};\n\n\n/**\n * @protected\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo2 = function(value) {\n};\n\n\n/**\n * @private\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo3 = function(value) {\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo5 = function(value) {\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo6 = function(value) {\n};\n\n\n/**\n * @export\n * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};\n\n\n/**\n * @para m {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};"); + assertOut("/**\n * @constructor\n */\norg.apache.flex.A = function() {\n};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1 = function() {\n return null;\n};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.flex.A.prototype.foo1a = function() {\n return null;\n};\n\n\n/**\n * @export\n * @override\n */\norg.apache.flex.A.prototype.foo1b = function() {\n return org.apache.flex.A.base(this, 'foo1b');\n};\n\n\n/**\n * @protected\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo2 = function(value) {\n};\n\n\n/**\n * @private\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo3 = function(value) {\n};\n\n\n/**\n * @param {Object} value\n */\norg.apache.flex.A.prototype.foo5 = function(value) {\n};\n\n\n/**\n * @export\n * @param {Object} value\n */\norg.apache.flex.A.prototype[\"http://www.adobe.com/2006/actionscript/flash/proxy::foo6\"] = function(value) {\n};\n\n\n/**\n * @export\n * @param {Object} value\n */\norg.apache.flex.A.foo7 = function(value) {\n};\n\n\n/**\n * @export\n * @param {Object} value\n */\norg.apache.flex.A[\"http://www.adobe.com/2006/actionscript/flash/proxy::foo7\"] = function(value) {\n};"); } @Test http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/15aef85b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSMethodMembers.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSMethodMembers.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSMethodMembers.java index 5f6256d..56dcd46 100644 --- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSMethodMembers.java +++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSMethodMembers.java @@ -90,9 +90,9 @@ public class TestFlexJSMethodMembers extends TestGoogMethodMembers @Test public void testMethod_withNamespaceCustom() { - IFunctionNode node = getMethod("mx_internal function foo(bar:String, baz:int = null):int{ return -1;}"); + IFunctionNode node = getMethod("import flash.utils.flash_proxy;flash_proxy function foo(bar:String, baz:int = null):int{ return -1;}"); asBlockWalker.visitFunction(node); - assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nFalconTest_A.prototype.foo = function(bar, baz) {\n baz = typeof baz !== 'undefined' ? baz : null;\n return -1;\n}"); + assertOut("/**\n * @export\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nFalconTest_A.prototype[\"http://www.adobe.com/2006/actionscript/flash/proxy::foo\"] = function(bar, baz) {\n baz = typeof baz !== 'undefined' ? baz : null;\n return -1;\n}"); } //--------------------------------------------------------------------------