This is an automated email from the ASF dual-hosted git repository.
joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
The following commit(s) were added to refs/heads/develop by this push:
new 23e64f0 AccessorEmitter: similar to static accessors, instance
accessors are written as a variable first
23e64f0 is described below
commit 23e64f0e7297d9267cbd9b2d4d37fb60c6582552
Author: Josh Tynjala <[email protected]>
AuthorDate: Tue Jan 5 10:50:56 2021 -0800
AccessorEmitter: similar to static accessors, instance accessors are
written as a variable first
As with statics, this is because Closure compiler doesn't know how to
properly analyze defineProperties() calls and assumes that getters/setters have
no side effects. Declaring them as a variable first ensures that Closure
understands that changes are possible.
This will eventually allow accessors to be safely renamed with advanced
optimizations enabled.
---
.../internal/codegen/js/jx/AccessorEmitter.java | 39 +++++++++++++++++++++-
.../js/royale/TestRoyaleAccessorMembers.java | 10 ++++++
.../codegen/js/royale/TestRoyaleAccessors.java | 8 +++++
.../codegen/js/royale/TestRoyaleClass.java | 29 +++++++++++++---
.../codegen/js/royale/TestRoyaleExpressions.java | 3 +-
.../codegen/js/royale/TestRoyalePackage.java | 16 +++++++++
.../resources/royale/files/MyInitialView_result.js | 32 ++++++++++++++++++
.../royale/files/models/MyModel_result.js | 24 +++++++++++++
.../resources/royale/projects/super/Base_result.js | 8 +++++
.../royale/projects/super/Super_result.js | 8 +++++
10 files changed, 171 insertions(+), 6 deletions(-)
diff --git
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
index 9ec37a7..771a56c 100644
---
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
+++
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
@@ -128,7 +128,44 @@ public class AccessorEmitter extends JSSubEmitter
implements
}
else
{
- if (getterNode != null)
+ // start by writing out the instance accessors as regular
variables
+ // because Closure Compiler doesn't properly analyze calls
to
+ // defineProperties() alone.
+ // since there's no analysis, Closure assumes that
getters/setters
+ // have no side effects, which results in important
get/set calls
+ // being removed as dead code.
+ // defining the accessors as variables first convinces
Closure to
+ // handle them more intelligently while not preventing
them from
+ // being real accessors.
+ // Source:
https://developers.google.com/closure/compiler/docs/limitations
+ writeNewline();
+ writeNewline();
+ writeNewline();
+ writeNewline("/**");
+ if (p.preventRename)
+ writeNewline(" * @nocollapse");
+ if (p.resolvedExport && !p.suppressExport)
+ writeNewline(" * @export");
+ if (p.type != null)
+ writeNewline(" * @type {" +
JSGoogDocEmitter.convertASTypeToJSType(p.type.getBaseName(),
p.type.getPackageName()) + "}");
+ writeNewline(" */");
+ write(getEmitter().formatQualifiedName(qname));
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ write(JSEmitterTokens.PROTOTYPE);
+ write(ASEmitterTokens.MEMBER_ACCESS);
+ if (p.uri != null)
+ {
+ IAccessorNode node = (getterNode != null) ? getterNode
: setterNode;
+ INamespaceDecorationNode ns =
((FunctionNode)node).getActualNamespaceNode();
+ INamespaceDefinition nsDef =
(INamespaceDefinition)ns.resolve(project);
+ fjs.formatQualifiedName(nsDef.getQualifiedName()); //
register with used names
+ write(JSRoyaleEmitter.formatNamespacedProperty(p.uri,
baseName, false));
+ }
+ else
+ write(baseName);
+ write(ASEmitterTokens.SEMICOLON);
+
+ if (getterNode != null)
{
writeNewline();
writeNewline();
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessorMembers.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessorMembers.java
index 574c406..c8d4c3a 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessorMembers.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessorMembers.java
@@ -38,6 +38,7 @@ public class TestRoyaleAccessorMembers extends
TestGoogAccessorMembers
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function()
{\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @type {number}\n
*/\nRoyaleTest_A.prototype.foo;\n\n\n" +
"RoyaleTest_A.prototype.get__foo = function()
{\n};\n\n\n" +
"Object.defineProperties(RoyaleTest_A.prototype, /**
@lends {RoyaleTest_A.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nget:
RoyaleTest_A.prototype.get__foo}}\n);");
}
@@ -50,6 +51,7 @@ public class TestRoyaleAccessorMembers extends
TestGoogAccessorMembers
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function()
{\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @type {number}\n
*/\nRoyaleTest_A.prototype.foo;\n\n\n" +
"RoyaleTest_A.prototype.get__foo = function()
{\n return -1;\n};\n\n\n" +
"Object.defineProperties(RoyaleTest_A.prototype, /**
@lends {RoyaleTest_A.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nget:
RoyaleTest_A.prototype.get__foo}}\n);");
}
@@ -62,6 +64,7 @@ public class TestRoyaleAccessorMembers extends
TestGoogAccessorMembers
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function()
{\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {number}\n
*/\nRoyaleTest_A.prototype.foo;\n\n\n" +
"RoyaleTest_A.prototype.get__foo = function()
{\n return -1;\n};\n\n\n" +
"Object.defineProperties(RoyaleTest_A.prototype, /**
@lends {RoyaleTest_A.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nget:
RoyaleTest_A.prototype.get__foo}}\n);");
}
@@ -74,6 +77,7 @@ public class TestRoyaleAccessorMembers extends
TestGoogAccessorMembers
IClassNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n * @extends {A}\n */\nB = function()
{\n B.base(this, 'constructor');\n};\ngoog.inherits(B, A);\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {number}\n
*/\nB.prototype.foo;\n\n\n" +
"B.prototype.get__foo = function() {\n return
B.superClass_.get__foo.apply(this);\n};\n\n\n" +
"Object.defineProperties(B.prototype, /** @lends
{B.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nget:
B.prototype.get__foo}}\n);");
}
@@ -85,6 +89,7 @@ public class TestRoyaleAccessorMembers extends
TestGoogAccessorMembers
IClassNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n * @extends {A}\n */\nB = function()
{\n B.base(this, 'constructor');\n};\ngoog.inherits(B, A);\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {number}\n
*/\nB.prototype.foo;\n\n\n" +
"B.prototype.get__foo = function() {\n return
B.superClass_.get__foo.apply(this);\n};\n\n\n" +
"Object.defineProperties(B.prototype, /** @lends
{B.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nget:
B.prototype.get__foo,\nset: A.prototype.set__foo}}\n);");
}
@@ -110,6 +115,7 @@ public class TestRoyaleAccessorMembers extends
TestGoogAccessorMembers
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function()
{\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @type {number}\n
*/\nRoyaleTest_A.prototype.foo;\n\n\n" +
"RoyaleTest_A.prototype.set__foo =
function(value) {\n};\n\n\n" +
"Object.defineProperties(RoyaleTest_A.prototype, /**
@lends {RoyaleTest_A.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nset:
RoyaleTest_A.prototype.set__foo}}\n);");
}
@@ -122,6 +128,7 @@ public class TestRoyaleAccessorMembers extends
TestGoogAccessorMembers
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function()
{\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @type {number}\n
*/\nRoyaleTest_A.prototype.foo;\n\n\n" +
"RoyaleTest_A.prototype.set__foo =
function(value) {\n fetch('haai');\n};\n\n\n" +
"Object.defineProperties(RoyaleTest_A.prototype, /**
@lends {RoyaleTest_A.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nset:
RoyaleTest_A.prototype.set__foo}}\n);");
}
@@ -134,6 +141,7 @@ public class TestRoyaleAccessorMembers extends
TestGoogAccessorMembers
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function()
{\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {number}\n
*/\nRoyaleTest_A.prototype.foo;\n\n\n" +
"RoyaleTest_A.prototype.set__foo =
function(value) {\n};\n\n\n" +
"Object.defineProperties(RoyaleTest_A.prototype, /**
@lends {RoyaleTest_A.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nset:
RoyaleTest_A.prototype.set__foo}}\n);");
}
@@ -146,6 +154,7 @@ public class TestRoyaleAccessorMembers extends
TestGoogAccessorMembers
IClassNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n * @extends {A}\n */\nB = function()
{\n B.base(this, 'constructor');\n};\ngoog.inherits(B, A);\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {number}\n
*/\nB.prototype.foo;\n\n\n" +
"B.prototype.set__foo = function(value) {\n
B.superClass_.set__foo.apply(this, [ value] );\n};\n\n\n" +
"Object.defineProperties(B.prototype, /** @lends
{B.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nset:
B.prototype.set__foo}}\n);");
}
@@ -170,6 +179,7 @@ public class TestRoyaleAccessorMembers extends
TestGoogAccessorMembers
IClassNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n * @extends {A}\n */\nB = function()
{\n B.base(this, 'constructor');\n};\ngoog.inherits(B, A);\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {number}\n
*/\nB.prototype.foo;\n\n\n" +
"B.prototype.set__foo = function(value) {\n
B.superClass_.set__foo.apply(this, [ value] );\n};\n\n\n" +
"Object.defineProperties(B.prototype, /** @lends
{B.prototype} */ {\n/**\n * @type {number}\n */\nfoo: {\nget:
A.prototype.get__foo,\nset: B.prototype.set__foo}}\n);");
}
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java
index 8cd7047..dd74e14 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java
@@ -47,6 +47,7 @@ public class TestRoyaleAccessors extends ASTestBase
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
String expected = "/**\n * @constructor\n */\nRoyaleTest_A =
function() {\n};\n\n\n/**\n */\nRoyaleTest_A.prototype.doStuff = function() {\n
this.label = 'hello, bye';\n var /** @type {string} */ theLabel =
this.label;\n};\n\n\n/**\n * @private\n * @type {string}\n
*/\nRoyaleTest_A.prototype._label = null;\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {string}\n
*/\nRoyaleTest_A.prototype.label;\n\n\n" +
"RoyaleTest_A.prototype.get__label = function() {\n
return this._label;\n};\n\n\n" +
"RoyaleTest_A.prototype.set__label = function(value)
{\n this._label = value;\n};\n\n\n" +
"Object.defineProperties(RoyaleTest_A.prototype, /**
@lends {RoyaleTest_A.prototype} */ {\n/**\n * @type {string}\n */\n" +
@@ -62,6 +63,7 @@ public class TestRoyaleAccessors extends ASTestBase
IClassNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitClass(node);
String expected = "/**\n * @constructor\n */\nB = function()
{\n};\n\n\n/**\n */\nB.prototype.doStuff = function() {\n this.label =
this.label + 'bye';\n var /** @type {string} */ theLabel =
this.label;\n};\n\n\n/**\n * @private\n * @type {string}\n
*/\nB.prototype._label = null;\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {string}\n
*/\nB.prototype.label;\n\n\n" +
"B.prototype.get__label = function() {\n
return this._label;\n};\n\n\n" +
"B.prototype.set__label = function(value) {\n
this._label = value;\n};\n\n\n" +
"Object.defineProperties(B.prototype, /** @lends
{B.prototype} */ {\n/**\n * @type {string}\n */\nlabel: {\n" +
@@ -77,6 +79,7 @@ public class TestRoyaleAccessors extends ASTestBase
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
String expected = "/**\n * @constructor\n */\nRoyaleTest_A =
function() {\n};\n\n\n/**\n */\nRoyaleTest_A.prototype.doStuff = function() {\n
this.label = this.label + 'bye';\n var /** @type {string} */ theLabel =
this.label;\n};\n\n\n/**\n * @private\n * @type {string}\n
*/\nRoyaleTest_A.prototype._label = null;\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {string}\n
*/\nRoyaleTest_A.prototype.label;\n\n\n" +
"RoyaleTest_A.prototype.get__label = function()
{\n return this._label;\n};\n\n\n" +
"RoyaleTest_A.prototype.set__label =
function(value) {\n this._label = value;\n};\n\n\n" +
"Object.defineProperties(RoyaleTest_A.prototype, /** @lends
{RoyaleTest_A.prototype} */ {\n/**\n * @type {string}\n */\nlabel: {\n" +
@@ -92,6 +95,7 @@ public class TestRoyaleAccessors extends ASTestBase
IClassNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitClass(node);
String expected = "/**\n * @constructor\n */\nB = function()
{\n};\n\n\n/**\n */\nB.prototype.doStuff = function() {\n this.label =
this.label;\n var /** @type {string} */ theLabel = this.label;\n};\n\n\n/**\n
* @private\n * @type {string}\n */\nB.prototype._label = null;\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {string}\n
*/\nB.prototype.label;\n\n\n" +
"B.prototype.get__label = function() {\n
return this._label;\n};\n\n\n" +
"B.prototype.set__label = function(value) {\n
this._label = value;\n};\n\n\n" +
"Object.defineProperties(B.prototype, /**
@lends {B.prototype} */ {\n/**\n * @type {string}\n */\nlabel: {\n" +
@@ -107,6 +111,7 @@ public class TestRoyaleAccessors extends ASTestBase
IClassNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitClass(node);
String expected = "/**\n * @constructor\n */\nB = function()
{\n};\n\n\n/**\n */\nB.prototype.doStuff = function() {\n var /** @type
{string} */ theLabel =
this.http_$$ns_apache_org$2017$custom$namespace__label;\n
this.http_$$ns_apache_org$2017$custom$namespace__label =
theLabel;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB.prototype._label
= null;\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {string}\n
*/\nB.prototype.http_$$ns_apache_org$2017$custom$namespace__label;\n\n\n" +
"B.prototype.http_$$ns_apache_org$2017$custom$namespace__get__label =
function() {\n return this._label;\n};\n\n\n" +
"B.prototype.http_$$ns_apache_org$2017$custom$namespace__set__label =
function(value) {\n this._label = value;\n};\n\n\n" +
"Object.defineProperties(B.prototype, /** @lends
{B.prototype} */ {\n/**\n * @type {string}\n
*/\nhttp_$$ns_apache_org$2017$custom$namespace__label: {\nget:
B.prototype.http_$$ns_apache_org$2017$custom$namespace__get__label,\nset:
B.prototype.http_$$ns_apache_org$2017$custom$namespace__set__label}}\n);";
@@ -121,6 +126,7 @@ public class TestRoyaleAccessors extends ASTestBase
IClassNode.class, WRAP_LEVEL_PACKAGE);
asBlockWalker.visitClass(node);
String expected = "/**\n * @constructor\n */\nB = function()
{\n};\n\n\n/**\n */\nB.prototype.doStuff = function() {\n var /** @type
{string} */ theLabel =
this.http_$$ns_apache_org$2017$custom$namespace__label;\n
this.http_$$ns_apache_org$2017$custom$namespace__label =
theLabel;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB.prototype._label
= null;\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {string}\n
*/\nB.prototype.http_$$ns_apache_org$2017$custom$namespace__label;\n\n\n" +
"B.prototype.http_$$ns_apache_org$2017$custom$namespace__get__label =
function() {\n return this._label;\n};\n\n\n" +
"B.prototype.http_$$ns_apache_org$2017$custom$namespace__set__label =
function(value) {\n this._label = value;\n};\n\n\n" +
"Object.defineProperties(B.prototype, /** @lends
{B.prototype} */ {\n/**\n * @type {string}\n
*/\nhttp_$$ns_apache_org$2017$custom$namespace__label: {\nget:
B.prototype.http_$$ns_apache_org$2017$custom$namespace__get__label,\nset:
B.prototype.http_$$ns_apache_org$2017$custom$namespace__set__label}}\n);";
@@ -165,6 +171,7 @@ public class TestRoyaleAccessors extends ASTestBase
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
String expected ="/**\n * @constructor\n */\nRoyaleTest_A = function()
{\n};\n\n\n/**\n */\nRoyaleTest_A.prototype.doStuff = function() {\n
this.label = 'hello, bye';\n var /** @type {string} */ theLabel =
this.label;\n};\n\n\n/**\n * @private\n * @type {string}\n
*/\nRoyaleTest_A.prototype._label = null;\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {string}\n
*/\nRoyaleTest_A.prototype.label;\n\n\n" +
"RoyaleTest_A.prototype.get__label = function() {\n return
this._label;\n};\n\n\n" +
"RoyaleTest_A.prototype.bindable__set__label_RoyaleTest_A =
function(value) {\n" +
" this._label = value;" +
@@ -195,6 +202,7 @@ public class TestRoyaleAccessors extends ASTestBase
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
String expected = "/**\n * @constructor\n */\nRoyaleTest_A =
function() {\n};\n\n\n/**\n */\nRoyaleTest_A.prototype.doStuff = function() {\n
this.label = 'hello, bye';\n var /** @type {string} */ theLabel =
this.label;\n};\n\n\n/**\n * @private\n * @type {string}\n
*/\nRoyaleTest_A.prototype._label = null;\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {string}\n
*/\nRoyaleTest_A.prototype.label;\n\n\n" +
"RoyaleTest_A.prototype.get__label = function()
{\n return this._label;\n};\n\n\n" +
"RoyaleTest_A.prototype.set__label =
function(value) {\n this._label = value;\n};\n\n\n" +
"Object.defineProperties(RoyaleTest_A.prototype, /**
@lends {RoyaleTest_A.prototype} */ {\n/**\n * @type {string}\n */\n" +
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
index b8f50e1..a30202b 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java
@@ -261,7 +261,12 @@ public class TestRoyaleClass extends TestGoogClass
{
IClassNode node = getClassNode("public class B {public function B()
{}; public function set baz(value:Object):void {}; public function set
foo(value:Object):void {baz = value;};}");
asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n */\norg.apache.royale.B =
function() {\n};\n\n\norg.apache.royale.B.prototype.set__baz = function(value)
{\n};\n\n\norg.apache.royale.B.prototype.set__foo = function(value) {\n
this.baz =
value;\n};\n\n\nObject.defineProperties(org.apache.royale.B.prototype, /**
@lends {org.apache.royale.B.prototype} */ {\n/**\n * @type {Object}\n */\nbaz:
{\nset: org.apache.royale.B.prototype.set__baz},\n/**\n * @type {Object}\n
*/\nfoo: {\nset: org.apa [...]
+ String expected = "/**\n * @constructor\n */\norg.apache.royale.B =
function() {\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {Object}\n
*/\norg.apache.royale.B.prototype.baz;\n\n\n" +
+ "org.apache.royale.B.prototype.set__baz = function(value)
{\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {Object}\n
*/\norg.apache.royale.B.prototype.foo;\n\n\n" +
+ "org.apache.royale.B.prototype.set__foo = function(value) {\n
this.baz = value;\n};\n\n\n" +
+ "Object.defineProperties(org.apache.royale.B.prototype, /**
@lends {org.apache.royale.B.prototype} */ {\n/**\n * @type {Object}\n */\nbaz:
{\nset: org.apache.royale.B.prototype.set__baz},\n/**\n * @type {Object}\n
*/\nfoo: {\nset: org.apache.royale.B.prototype.set__foo}}\n);";
assertOut(expected);
}
@@ -270,7 +275,10 @@ public class TestRoyaleClass extends TestGoogClass
{
IClassNode node = getClassNode("public class B extends A {public
function B() {}; override public function set foo(value:Object):void {super.foo
= value;};} class A {public function set foo(value:Object):void {}}");
asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n * @extends
{org.apache.royale.A}\n */\norg.apache.royale.B = function() {\n
org.apache.royale.B.base(this,
'constructor');\n};\ngoog.inherits(org.apache.royale.B,
org.apache.royale.A);\n\n\norg.apache.royale.B.prototype.set__foo =
function(value) {\n org.apache.royale.B.superClass_.set__foo.apply(this, [
value] );\n};\n\n\nObject.defineProperties(org.apache.royale.B.prototype, /**
@lends {org.apache.royale.B.prototype} */ {\n/**\n * @ty [...]
+ String expected = "/**\n * @constructor\n * @extends
{org.apache.royale.A}\n */\norg.apache.royale.B = function() {\n
org.apache.royale.B.base(this,
'constructor');\n};\ngoog.inherits(org.apache.royale.B,
org.apache.royale.A);\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {Object}\n
*/\norg.apache.royale.B.prototype.foo;\n\n\n" +
+ "org.apache.royale.B.prototype.set__foo = function(value) {\n
org.apache.royale.B.superClass_.set__foo.apply(this, [ value] );\n};\n\n\n" +
+ "Object.defineProperties(org.apache.royale.B.prototype, /**
@lends {org.apache.royale.B.prototype} */ {\n/**\n * @type {Object}\n */\nfoo:
{\nset: org.apache.royale.B.prototype.set__foo}}\n);";
assertOut(expected);
}
@@ -328,6 +336,14 @@ public class TestRoyaleClass extends TestGoogClass
"};\n" +
"\n" +
"\n" +
+ "/**\n" +
+ " * @nocollapse\n" +
+ " * @export\n" +
+ " * @type {A}\n" +
+ " */\n" +
+ "org.apache.royale.B.A.prototype.a;\n" +
+ "\n" +
+ "\n" +
"org.apache.royale.B.A.prototype.get__a = function()
{\n" +
" return null;\n" +
"};\n" +
@@ -676,14 +692,19 @@ public class TestRoyaleClass extends TestGoogClass
+ "custom_namespace function set foo6(value:Object):void{}" +
"}");
asBlockWalker.visitClass(node);
assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function()
{\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {Object}\n
*/\norg.apache.royale.A.prototype.foo1;\n\n\n" +
"org.apache.royale.A.prototype.get__foo1 = function()
{\n return null;\n};\n\n\n" +
- "org.apache.royale.A.prototype.set__foo1 =
function(value) {\n};\n\n\n" +
+ "org.apache.royale.A.prototype.set__foo1 = function(value)
{\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @type {Object}\n
*/\norg.apache.royale.A.prototype.foo2;\n\n\n" +
"org.apache.royale.A.prototype.get__foo2 = function()
{\n return null;\n};\n\n\n" +
"org.apache.royale.A.prototype.set__foo2 =
function(value) {\n};\n\n\n" +
+ "/**\n * @type {Object}\n
*/\norg.apache.royale.A.prototype.foo3;\n\n\n" +
"org.apache.royale.A.prototype.get__foo3 = function()
{\n return null;\n};\n\n\n" +
"org.apache.royale.A.prototype.set__foo3 =
function(value) {\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @type {Object}\n
*/\norg.apache.royale.A.prototype.foo5;\n\n\n" +
"org.apache.royale.A.prototype.get__foo5 = function()
{\n return null;\n};\n\n\n" +
- "org.apache.royale.A.prototype.set__foo5 =
function(value) {\n};\n\n\n" +
+ "org.apache.royale.A.prototype.set__foo5 = function(value)
{\n};\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {Object}\n
*/\norg.apache.royale.A.prototype.http_$$ns_apache_org$2017$custom$namespace__foo6;\n\n\n"
+
"org.apache.royale.A.prototype.http_$$ns_apache_org$2017$custom$namespace__get__foo6
= function() {\n return null;\n};\n\n\n" +
"org.apache.royale.A.prototype.http_$$ns_apache_org$2017$custom$namespace__set__foo6
= function(value) {\n};\n\n\n" +
"Object.defineProperties(org.apache.royale.A.prototype,
/** @lends {org.apache.royale.A.prototype} */ {\n/**\n * @type {Object}\n */\n"
+
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
index 6540ece..300db31 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
@@ -120,7 +120,8 @@ public class TestRoyaleExpressions extends
TestGoogExpressions
" */\n" +
"RoyaleTest_A.prototype.isDefaultPrevented =
function() {\n" +
" return this.defaultPrevented;\n" +
- "};\n\n\n" +
+ "};\n\n\n" +
+ "/**\n * @nocollapse\n * @export\n * @type {Object}\n
*/\nRoyaleTest_A.prototype.defaultPrevented;\n\n\n" +
"RoyaleTest_A.prototype.get__defaultPrevented =
function() {\n" +
" return
RoyaleTest_A.superClass_.isDefaultPrevented.apply(this);\n" +
"};\n\n\n" +
diff --git
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyalePackage.java
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyalePackage.java
index a24a6b0..8b9af2f 100644
---
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyalePackage.java
+++
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyalePackage.java
@@ -827,6 +827,14 @@ public class TestRoyalePackage extends TestGoogPackage
"};\n" +
"\n" +
"\n" +
+ "/**\n" +
+ " * @nocollapse\n" +
+ " * @export\n" +
+ " * @type {string}\n" +
+ " */\n" +
+ "foo.bar.baz.A.prototype.myString;\n" +
+ "\n" +
+ "\n" +
"foo.bar.baz.A.prototype.get__myString =
function() {\n" +
" return null;\n" +
"};\n" +
@@ -889,6 +897,14 @@ public class TestRoyalePackage extends TestGoogPackage
"};\n" +
"\n" +
"\n" +
+ "/**\n" +
+ " * @nocollapse\n" +
+ " * @export\n" +
+ " * @type {string}\n" +
+ " */\n" +
+
"foo.bar.baz.A.InternalClass.prototype.someString;\n" +
+ "\n" +
+ "\n" +
"foo.bar.baz.A.InternalClass.prototype.get__someString = function() {\n" +
" return null;\n" +
"};\n" +
diff --git
a/compiler-jx/src/test/resources/royale/files/MyInitialView_result.js
b/compiler-jx/src/test/resources/royale/files/MyInitialView_result.js
index 624e2d9..8efd46d 100644
--- a/compiler-jx/src/test/resources/royale/files/MyInitialView_result.js
+++ b/compiler-jx/src/test/resources/royale/files/MyInitialView_result.js
@@ -241,21 +241,53 @@ MyInitialView.prototype.timerHandler = function(event) {
+/**
+ * @nocollapse
+ * @export
+ * @type {string}
+ */
+MyInitialView.prototype.symbol;
+
+
MyInitialView.prototype.get__symbol = function() {
return org.apache.royale.utils.Language.as(this.list.selectedItem, String);
};
+/**
+ * @nocollapse
+ * @export
+ * @type {string}
+ */
+MyInitialView.prototype.city;
+
+
MyInitialView.prototype.get__city = function() {
return org.apache.royale.utils.Language.as(this.cityList.selectedItem,
String);
};
+/**
+ * @nocollapse
+ * @export
+ * @type {string}
+ */
+MyInitialView.prototype.inputText;
+
+
MyInitialView.prototype.get__inputText = function() {
return this.input.text;
};
+/**
+ * @nocollapse
+ * @export
+ * @type {string}
+ */
+MyInitialView.prototype.comboBoxValue;
+
+
MyInitialView.prototype.get__comboBoxValue = function() {
return String(this.comboBox.selectedItem);
};
diff --git
a/compiler-jx/src/test/resources/royale/files/models/MyModel_result.js
b/compiler-jx/src/test/resources/royale/files/models/MyModel_result.js
index 5be3502..98a73a9 100644
--- a/compiler-jx/src/test/resources/royale/files/models/MyModel_result.js
+++ b/compiler-jx/src/test/resources/royale/files/models/MyModel_result.js
@@ -60,6 +60,14 @@ models.MyModel.prototype._strings = null;
models.MyModel.prototype._cities = null;
+/**
+ * @nocollapse
+ * @export
+ * @type {string}
+ */
+models.MyModel.prototype.labelText;
+
+
models.MyModel.prototype.get__labelText = function() {
return this._labelText;
};
@@ -73,11 +81,27 @@ models.MyModel.prototype.set__labelText = function(value) {
};
+/**
+ * @nocollapse
+ * @export
+ * @type {Array}
+ */
+models.MyModel.prototype.strings;
+
+
models.MyModel.prototype.get__strings = function() {
return this._strings;
};
+/**
+ * @nocollapse
+ * @export
+ * @type {Array}
+ */
+models.MyModel.prototype.cities;
+
+
models.MyModel.prototype.get__cities = function() {
return this._cities;
};
diff --git
a/compiler-jx/src/test/resources/royale/projects/super/Base_result.js
b/compiler-jx/src/test/resources/royale/projects/super/Base_result.js
index fcaa48c..169067a 100644
--- a/compiler-jx/src/test/resources/royale/projects/super/Base_result.js
+++ b/compiler-jx/src/test/resources/royale/projects/super/Base_result.js
@@ -35,6 +35,14 @@ Base = function() {
goog.inherits(Base, Super);
+/**
+ * @nocollapse
+ * @export
+ * @type {string}
+ */
+Base.prototype.text;
+
+
Base.prototype.get__text = function() {
return "A" + Base.superClass_.get__text.apply(this);
};
diff --git
a/compiler-jx/src/test/resources/royale/projects/super/Super_result.js
b/compiler-jx/src/test/resources/royale/projects/super/Super_result.js
index 6991be4..3f2b7c1 100644
--- a/compiler-jx/src/test/resources/royale/projects/super/Super_result.js
+++ b/compiler-jx/src/test/resources/royale/projects/super/Super_result.js
@@ -37,6 +37,14 @@ Super = function() {
Super.prototype._text = '';
+/**
+ * @nocollapse
+ * @export
+ * @type {string}
+ */
+Super.prototype.text;
+
+
Super.prototype.get__text = function() {
return this._text;
};