Repository: flex-falcon Updated Branches: refs/heads/develop 3971196a4 -> 11f5e2852
FLEX-34991 fix internal class output Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/11f5e285 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/11f5e285 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/11f5e285 Branch: refs/heads/develop Commit: 11f5e28523628569ef79117dd1e6fd94f0c7b4a2 Parents: 3971196 Author: Alex Harui <[email protected]> Authored: Tue Dec 22 23:30:31 2015 -0800 Committer: Alex Harui <[email protected]> Committed: Tue Dec 22 23:30:31 2015 -0800 ---------------------------------------------------------------------- .../codegen/js/flexjs/TestFlexJSPackage.java | 96 +++++++++++++++++++- .../internal/codegen/js/jx/ClassEmitter.java | 3 +- 2 files changed, 96 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/11f5e285/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java ---------------------------------------------------------------------- diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java index d2b5ba6..9473f19 100644 --- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java +++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSPackage.java @@ -180,8 +180,8 @@ public class TestFlexJSPackage extends TestGoogPackage " myString = internalClass.someMethod();\n" + "};\n" + "\n" + - "\n/" + - "**\n" + + "\n" + + "/**\n" + " * Metadata\n" + " *\n" + " * @type {Object.<string, Array.<Object>>}\n" + @@ -230,6 +230,98 @@ public class TestFlexJSPackage extends TestGoogPackage "foo.bar.baz.A.InternalClass.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'InternalClass', qName: 'foo.bar.baz.A.InternalClass'}] };\n"); } + @Test + public void testPackageQualified_ClassAndInternalGettersAndSetters() + { + IFileNode node = compileAS("package foo.bar.baz {\n" + + "public class A {\n" + + "public function A(){\n" + + "var internalClass:InternalClass = new InternalClass();\n" + + "myString = internalClass.someString;\n" + + "internalClass.someString = myString;\n" + + "}\n" + + "public function get myString():String {\n" + + " return null;\n" + + "}\n" + + "public function set myString(value:String):void {}\n" + + "}}\n" + + "class InternalClass {\n" + + "public function InternalClass(){\n" + + "}\n" + + "public function get someString():String {\n" + + " return null;\n" + + "}\n" + + "public function set someString(value:String):void {}\n" + + "}"); + asBlockWalker.visitFile(node); + assertOutWithMetadata("/**\n" + + " * foo.bar.baz.A\n" + + " *\n" + + " * @fileoverview\n" + + " *\n" + + " * @suppress {checkTypes|accessControls}\n" + + " */\n" + + "\n" + + "goog.provide('foo.bar.baz.A');\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " */\n" + + "foo.bar.baz.A = function() {\n" + + " var /** @type {foo.bar.baz.A.InternalClass} */ internalClass = new foo.bar.baz.A.InternalClass();\n" + + " this.myString = internalClass.someString;\n" + + " internalClass.someString = this.myString;\n" + + "};\n" + + "\n" + + "\n" + + "Object.defineProperties(foo.bar.baz.A.prototype, /** @lends {foo.bar.baz.A.prototype} */ {\n" + + "/** @export */\n" + + "myString: {\n" + + "get: /** @this {foo.bar.baz.A} */ function() {\n" + + " return null;\n" + + "},\n" + + "set: /** @this {foo.bar.baz.A} */ function(value) {\n" + + "}}}\n" + + ");\n" + + "\n" + + "\n" + + "/**\n" + + " * Metadata\n" + + " *\n" + + " * @type {Object.<string, Array.<Object>>}\n" + + " */\n" + + "foo.bar.baz.A.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'A', qName: 'foo.bar.baz.A'}] };\n" + + "\n" + + "\n" + + "\n" + + "/**\n" + + " * @constructor\n" + + " */\n" + + "foo.bar.baz.A.InternalClass = function() {\n" + + "};\n" + + "\n" + + "\n" + + "Object.defineProperties(foo.bar.baz.A.InternalClass.prototype, /** @lends {foo.bar.baz.A.InternalClass.prototype} */ {\n" + + "/** @export */\n" + + "someString: {\n" + + "get: /** @this {foo.bar.baz.A.InternalClass} */ function() {\n" + + " return null;\n" + + "},\n" + + "set: /** @this {foo.bar.baz.A.InternalClass} */ function(value) {\n" + + "}}}\n" + + ");\n" + + "\n" + + "\n" + + "/**\n" + + " * Metadata\n" + + " *\n" + + " * @type {Object.<string, Array.<Object>>}\n" + + " */\n" + + "foo.bar.baz.A.InternalClass.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'InternalClass', qName: 'foo.bar.baz.A.InternalClass'}] };\n"); + } + @Override protected IBackend createBackend() { http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/11f5e285/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java ---------------------------------------------------------------------- diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java index f96ceca..bd6289f 100644 --- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java +++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/ClassEmitter.java @@ -50,7 +50,7 @@ public class ClassEmitter extends JSSubEmitter implements @Override public void emit(IClassNode node) { - getModel().setCurrentClass(node.getDefinition()); + getModel().pushClass(node.getDefinition()); // TODO (mschmalle) will remove this cast as more things get abstracted JSFlexJSEmitter fjs = (JSFlexJSEmitter) getEmitter(); @@ -141,6 +141,7 @@ public class ClassEmitter extends JSSubEmitter implements fjs.getAccessorEmitter().emit(definition); fjs.getPackageFooterEmitter().emitClassInfo(node); + getModel().popClass(); } public void emitComplexInitializers(IClassNode node)
