compiler-jx: dynamically export variables in release builds instead of using export annotations
This is a continuation of previous work that dynamically exported types and methods. Still need to do getters/setters.
diff --git a/compiler-jx/src/main/java/com/google/javascript/jscomp/GenerateRoyaleExports.java b/compiler-jx/src/main/java/com/google/javascript/jscomp/GenerateRoyaleExports.java
new file mode 100644
index 0000000..16997ac
--- /dev/null
+++ b/compiler-jx/src/main/java/com/google/javascript/jscomp/GenerateRoyaleExports.java
@@ -0,0 +1,126 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package com.google.javascript.jscomp;
+
+import java.util.Set;
+
+import com.google.javascript.jscomp.NodeTraversal.AbstractPostOrderCallback;
+import com.google.javascript.rhino.IR;
+import com.google.javascript.rhino.JSDocInfo;
+import com.google.javascript.rhino.Node;
+import com.google.javascript.rhino.Token;
+
+public class GenerateRoyaleExports extends AbstractPostOrderCallback {
+
+ private final AbstractCompiler compiler;
+ private Set<String> extraSymbolNamesToExport;
+
+ public GenerateRoyaleExports(AbstractCompiler compiler) {
+ this.compiler = compiler;
+ }
+
+ public void process(Node externs, Node root, Set<String> extraSymbolNamesToExport) {
+ this.extraSymbolNamesToExport = extraSymbolNamesToExport;
+ NodeTraversal.traverse(compiler, root, this);
+ }
+
+ @Override
+ public void visit(NodeTraversal t, Node n, Node parent) {
+ if(n.getToken() != Token.ASSIGN) {
+ return;
+ }
+ JSDocInfo docInfo = n.getJSDocInfo();
+ if(docInfo == null) {
+ return;
+ }
+ Node firstChild = n.getFirstChild();
+ if (!firstChild.isQualifiedName()) {
+ return;
+ }
+ String qualifiedName = firstChild.getQualifiedName();
+ if(!extraSymbolNamesToExport.contains(qualifiedName)) {
+ //System.err.println("~~~ NO MATCH! " + qualifiedName);
+ return;
+ }
+
+ Node parentNode = n.getParent();
+
+ if(parentNode == null) {
+ return;
+ }
+
+ Node gpNode = parentNode.getParent();
+
+ if(gpNode == null || !gpNode.isScript()) {
+ return;
+ }
+ //System.err.println("*** MATCH! " + qualifiedName);
+
+ addExportSymbolCall(qualifiedName, n);
+ }
+
+ private void addExportSymbolCall(String export, Node context) {
+ Node call =
+ IR.call(
+ NodeUtil.newQName(
+ compiler, compiler.getCodingConvention().getExportSymbolFunction(),
+ context, export),
+ IR.string(export),
+ NodeUtil.newQName(
+ compiler, export,
+ context, export));
+
+ Node expression = IR.exprResult(call).useSourceInfoIfMissingFromForTree(context);
+ annotate(expression);
+
+ addStatement(context, expression);
+ }
+
+ private void addStatement(Node context, Node stmt) {
+ CodingConvention convention = compiler.getCodingConvention();
+
+ Node n = context;
+ Node exprRoot = n;
+ while (!NodeUtil.isStatementBlock(exprRoot.getParent())) {
+ exprRoot = exprRoot.getParent();
+ }
+
+ // It's important that any class-building calls (goog.inherits)
+ // come right after the class definition, so move the export after that.
+ while (true) {
+ Node next = exprRoot.getNext();
+ if (next != null
+ && NodeUtil.isExprCall(next)
+ && convention.getClassesDefinedByCall(next.getFirstChild()) != null) {
+ exprRoot = next;
+ } else {
+ break;
+ }
+ }
+
+ Node block = exprRoot.getParent();
+ block.addChildAfter(stmt, exprRoot);
+ compiler.reportChangeToEnclosingScope(stmt);
+ }
+
+ private void annotate(Node node) {
+ NodeTraversal.traverse(
+ compiler, node, new PrepareAst.PrepareAnnotations());
+ }
+}
\ No newline at end of file
diff --git a/compiler-jx/src/main/java/com/google/javascript/jscomp/RoyaleClosurePassConfig.java b/compiler-jx/src/main/java/com/google/javascript/jscomp/RoyaleClosurePassConfig.java
index 92f3cc8..c332a81 100644
--- a/compiler-jx/src/main/java/com/google/javascript/jscomp/RoyaleClosurePassConfig.java
+++ b/compiler-jx/src/main/java/com/google/javascript/jscomp/RoyaleClosurePassConfig.java
@@ -344,6 +344,10 @@
checks.add(angularPass);
}
+ if (extraSymbolNamesToExport != null) {
+ checks.add(generateRoyaleExports);
+ }
+
if (!options.generateExportsAfterTypeChecking && options.generateExports) {
checks.add(generateExports);
}
@@ -362,10 +366,6 @@
checks.add(polymerPass);
}
- if (extraSymbolNamesToExport != null) {
- checks.add(extraSymbolsPass);
- }
-
if (options.checkSuspiciousCode
|| options.enables(DiagnosticGroups.GLOBAL_THIS)
|| options.enables(DiagnosticGroups.DEBUGGER_STATEMENT_PRESENT)) {
@@ -1268,31 +1268,15 @@
}
};
- private final PassFactory extraSymbolsPass =
- new PassFactory("extra-symbols-to-export", true) {
+ private final PassFactory generateRoyaleExports =
+ new PassFactory("generate-royale-exports", true) {
@Override
protected CompilerPass create(final AbstractCompiler compiler) {
+ final GenerateRoyaleExports pass = new GenerateRoyaleExports(compiler);
return new CompilerPass() {
@Override
public void process(Node externs, Node root) {
- Node scriptNode = compiler.getScriptNode(sourceFileName);
- for(String nameToExport : extraSymbolNamesToExport)
- {
- Node exportCallTarget = NodeUtil.newQName(compiler,
- compiler.getCodingConvention().getExportSymbolFunction(), scriptNode, nameToExport);
- Node call = IR.call(exportCallTarget);
- if (exportCallTarget.isName()) {
- call.putBooleanProp(Node.FREE_CALL, true);
- }
- call.addChildToBack(IR.string(nameToExport));
- call.addChildToBack(NodeUtil.newQName(compiler,
- nameToExport, scriptNode, nameToExport));
-
- Node expression = IR.exprResult(call);
-
- scriptNode.addChildToBack(expression);
- compiler.reportChangeToEnclosingScope(expression);
- }
+ pass.process(externs, root, extraSymbolNamesToExport);
}
};
}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java
index 6e403d3..05d27c2 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java
@@ -594,23 +594,11 @@
public void emitFieldDoc(IVariableNode node, IDefinition def, ICompilerProject project)
{
RoyaleJSProject fjp = (RoyaleJSProject)project;
- boolean suppressExports = false;
- if (emitter instanceof JSRoyaleEmitter) {
- suppressExports = ((JSRoyaleEmitter) emitter).getModel().suppressExports;
- }
- if (fjp.config != null)
- {
- emitExports = !suppressExports && fjp.config.getExportPublicSymbols();
- exportProtected = !suppressExports && fjp.config.getExportProtectedSymbols();
- exportInternal = !suppressExports && fjp.config.getExportInternalSymbols();
- }
- else
- {
- emitExports = !suppressExports;
- exportProtected = false;
- exportInternal = false;
- }
- emitExports = emitExports && !node.getVariableClassification().equals(VariableClassification.PACKAGE_MEMBER);
+
+ //exporting fields is handled dynamically in ClosureUtils
+ emitExports = false;
+ exportProtected = false;
+ exportInternal = false;
begin();
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/utils/ClosureUtils.java b/compiler-jx/src/main/java/org/apache/royale/compiler/utils/ClosureUtils.java
index 17676c7..a7ccbd8 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/utils/ClosureUtils.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/utils/ClosureUtils.java
@@ -195,8 +195,11 @@
{
continue;
}
- if (localDef instanceof IFunctionDefinition
- && !(localDef instanceof IAccessorDefinition))
+ boolean isMethod = localDef instanceof IFunctionDefinition
+ && !(localDef instanceof IAccessorDefinition);
+ boolean isVar = localDef instanceof IVariableDefinition
+ && !(localDef instanceof IAccessorDefinition);
+ if (isMethod || isVar)
{
INamespaceReference nsRef = localDef.getNamespaceReference();
boolean isCustomNS = !nsRef.isLanguageNamespace();
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 88f7032..e3a6d4e 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
@@ -126,7 +126,7 @@
{
IClassNode node = getClassNode("public class B {public function B(arg1:String) {this.arg1 = arg1}; public var arg1:String;}");
asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n * @param {string} arg1\n */\norg.apache.royale.B = function(arg1) {\n this.arg1 = arg1;\n};\n\n\n/**\n * @export\n * @type {string}\n */\norg.apache.royale.B.prototype.arg1 = null;";
+ String expected = "/**\n * @constructor\n * @param {string} arg1\n */\norg.apache.royale.B = function(arg1) {\n this.arg1 = arg1;\n};\n\n\n/**\n * @type {string}\n */\norg.apache.royale.B.prototype.arg1 = null;";
assertOut(expected);
}
@@ -135,7 +135,7 @@
{
IClassNode node = getClassNode("public class B {public function B() {}; public var event:Event = new Event(); public function foo():String {return event.type;};}");
asBlockWalker.visitClass(node);
- String expected = "/**\n * @constructor\n */\norg.apache.royale.B = function() {\n\nthis.event = new Event();\n};\n\n\n/**\n * @export\n * @type {Event}\n */\norg.apache.royale.B.prototype.event = null;\n\n\n/**\n * @return {string}\n */\norg.apache.royale.B.prototype.foo = function() {\n return this.event.type;\n};";
+ String expected = "/**\n * @constructor\n */\norg.apache.royale.B = function() {\n\nthis.event = new Event();\n};\n\n\n/**\n * @type {Event}\n */\norg.apache.royale.B.prototype.event = null;\n\n\n/**\n * @return {string}\n */\norg.apache.royale.B.prototype.foo = function() {\n return this.event.type;\n};";
assertOut(expected);
}
@@ -390,7 +390,7 @@
IClassNode node = getClassNode("public class A {public var a:Object;protected var b:String; "
+ "private var c:int; internal var d:uint; var e:Number}");
asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n\n/**\n * @export\n * @type {Object}\n */\norg.apache.royale.A.prototype.a = null;\n\n\n/**\n * @protected\n * @type {string}\n */\norg.apache.royale.A.prototype.b = null;\n\n\n/**\n * @private\n * @type {number}\n */\norg.apache.royale.A.prototype.c = 0;\n\n\n/**\n * @package\n * @type {number}\n */\norg.apache.royale.A.prototype.d = 0;\n\n\n/**\n * @package\n * @type {number}\n */\norg.apache.royale.A.prototype.e = NaN;");
+ assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n\n/**\n * @type {Object}\n */\norg.apache.royale.A.prototype.a = null;\n\n\n/**\n * @protected\n * @type {string}\n */\norg.apache.royale.A.prototype.b = null;\n\n\n/**\n * @private\n * @type {number}\n */\norg.apache.royale.A.prototype.c = 0;\n\n\n/**\n * @package\n * @type {number}\n */\norg.apache.royale.A.prototype.d = 0;\n\n\n/**\n * @package\n * @type {number}\n */\norg.apache.royale.A.prototype.e = NaN;");
}
@Test
@@ -403,7 +403,6 @@
" */\norg.apache.royale.A = function() {\n" +
"};\n\n\n" +
"/**\n" +
- " * @export\n" +
" * @type {Object}\n" +
" */\n" +
"org.apache.royale.A.prototype.a_ = null;\n\n\n" +
@@ -493,7 +492,6 @@
"this.a_ = {foo:1};\n" +
"};\n\n\n" +
"/**\n" +
- " * @export\n" +
" * @type {Object}\n" +
" */\n" +
"org.apache.royale.A.prototype.a_ = null;\n\n\n" +
@@ -582,7 +580,6 @@
" */\norg.apache.royale.A = function() {\n" +
"};\n\n\n" +
"/**\n" +
- " * @export\n" +
" * @type {Object}\n" +
" */\n" +
"org.apache.royale.A.prototype.a_ = null;\n\n\n" +
@@ -632,7 +629,7 @@
IClassNode node = getClassNode("public class A {public static var a:int = 10;public static var b:String = initStatic(); "
+ "private static function initStatic():String { return \"foo\"; }}");
asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n\n/**\n * @export\n * @nocollapse\n * @type {number}\n */\norg.apache.royale.A.a = 10;\n\n\n/**\n * @export\n * @nocollapse\n * @type {string}\n */\norg.apache.royale.A.b;\n\n\n/**\n * @private\n * @return {string}\n */\norg.apache.royale.A.initStatic = function() {\n return \"foo\";\n};\n\norg.apache.royale.A.b = org.apache.royale.A.initStatic();\n\n");
+ assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n\n/**\n * @nocollapse\n * @type {number}\n */\norg.apache.royale.A.a = 10;\n\n\n/**\n * @nocollapse\n * @type {string}\n */\norg.apache.royale.A.b;\n\n\n/**\n * @private\n * @return {string}\n */\norg.apache.royale.A.initStatic = function() {\n return \"foo\";\n};\n\norg.apache.royale.A.b = org.apache.royale.A.initStatic();\n\n");
}
@Test
@@ -653,7 +650,7 @@
+ "private static const C:Number = 42;"
+ "custom_namespace static const C:String = 'me' + 'you';}");
asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n\n/**\n * @export\n * @nocollapse\n * @const\n * @type {number}\n */\norg.apache.royale.A.A = 42;\n\n\n/**\n * @protected\n * @nocollapse\n * @const\n * @type {number}\n */\norg.apache.royale.A.B = 42;\n\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.royale.A.C = 42;\n\n\n/**\n * @const\n * @type {string}\n */\norg.apache.royale.A.http_$$ns_apache_org$2017$custom$namespace__C = 'me' + 'you';");
+ assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n\n/**\n * @nocollapse\n * @const\n * @type {number}\n */\norg.apache.royale.A.A = 42;\n\n\n/**\n * @protected\n * @nocollapse\n * @const\n * @type {number}\n */\norg.apache.royale.A.B = 42;\n\n\n/**\n * @private\n * @const\n * @type {number}\n */\norg.apache.royale.A.C = 42;\n\n\n/**\n * @const\n * @type {string}\n */\norg.apache.royale.A.http_$$ns_apache_org$2017$custom$namespace__C = 'me' + 'you';");
}
@Override
@@ -730,7 +727,7 @@
+ "public function foo2():String{function bar2(param1:String):String {return param1 + baz1;}; return bar2('foo');}"
+ "}");
asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\norg.apache.royale.B = function() {\n};\n\n\n/**\n * @export\n * @type {string}\n */\norg.apache.royale.B.prototype.baz1 = null;\n\n\n/**\n * @return {string}\n */\norg.apache.royale.B.prototype.foo1 = function() {\n var self = this;\n function bar1() {\n return self.baz1;\n };\n return bar1();\n};\n\n\n/**\n * @return {string}\n */\norg.apache.royale.B.prototype.foo2 = function() {\n var self = this;\n function bar2(param1) {\n return param1 + self.baz1;\n };\n return bar2('foo');\n};");
+ assertOut("/**\n * @constructor\n */\norg.apache.royale.B = function() {\n};\n\n\n/**\n * @type {string}\n */\norg.apache.royale.B.prototype.baz1 = null;\n\n\n/**\n * @return {string}\n */\norg.apache.royale.B.prototype.foo1 = function() {\n var self = this;\n function bar1() {\n return self.baz1;\n };\n return bar1();\n};\n\n\n/**\n * @return {string}\n */\norg.apache.royale.B.prototype.foo2 = function() {\n var self = this;\n function bar2(param1) {\n return param1 + self.baz1;\n };\n return bar2('foo');\n};");
}
@Test
@@ -837,7 +834,7 @@
{
IClassNode node = getClassNode("public class A {public function A(arg1:String, arg2:int) {arg2 = arg2 + 2;} public var foo:Array = [];}");
asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.royale.A = function(arg1, arg2) {\n \n this.foo = [];\n arg2 = (arg2 + 2) >> 0;\n};\n\n\n/**\n * @export\n * @type {Array}\n */\norg.apache.royale.A.prototype.foo = null;");
+ assertOut("/**\n * @constructor\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.royale.A = function(arg1, arg2) {\n \n this.foo = [];\n arg2 = (arg2 + 2) >> 0;\n};\n\n\n/**\n * @type {Array}\n */\norg.apache.royale.A.prototype.foo = null;");
}
@Test
@@ -853,7 +850,7 @@
{
IClassNode node = getClassNode("public class A extends TestImplementation {public function A(arg1:String, arg2:int) {arg2 = arg2 + 2;} public var foo:Array = [];}");
asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @extends {custom.TestImplementation}\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.royale.A = function(arg1, arg2) {\n org.apache.royale.A.base(this, 'constructor');\n \n this.foo = [];\n arg2 = (arg2 + 2) >> 0;\n};\ngoog.inherits(org.apache.royale.A, custom.TestImplementation);\n\n\n/**\n * @export\n * @type {Array}\n */\norg.apache.royale.A.prototype.foo = null;");
+ assertOut("/**\n * @constructor\n * @extends {custom.TestImplementation}\n * @param {string} arg1\n * @param {number} arg2\n */\norg.apache.royale.A = function(arg1, arg2) {\n org.apache.royale.A.base(this, 'constructor');\n \n this.foo = [];\n arg2 = (arg2 + 2) >> 0;\n};\ngoog.inherits(org.apache.royale.A, custom.TestImplementation);\n\n\n/**\n * @type {Array}\n */\norg.apache.royale.A.prototype.foo = null;");
}
@Test
@@ -861,7 +858,7 @@
{
IClassNode node = getClassNode("public class A {public static const NAME:String = 'Dummy'; public function A(arg1:String = NAME) {_name = arg1;} private var _name:String;}");
asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n * @param {string=} arg1\n */\norg.apache.royale.A = function(arg1) {\n arg1 = typeof arg1 !== 'undefined' ? arg1 : org.apache.royale.A.NAME;\n this._name = arg1;\n};\n\n\n/**\n * @export\n * @nocollapse\n * @const\n * @type {string}\n */\norg.apache.royale.A.NAME = 'Dummy';\n\n\n/**\n * @private\n * @type {string}\n */\norg.apache.royale.A.prototype._name = null;");
+ assertOut("/**\n * @constructor\n * @param {string=} arg1\n */\norg.apache.royale.A = function(arg1) {\n arg1 = typeof arg1 !== 'undefined' ? arg1 : org.apache.royale.A.NAME;\n this._name = arg1;\n};\n\n\n/**\n * @nocollapse\n * @const\n * @type {string}\n */\norg.apache.royale.A.NAME = 'Dummy';\n\n\n/**\n * @private\n * @type {string}\n */\norg.apache.royale.A.prototype._name = null;");
}
protected IBackend createBackend()
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java
index 67dc6e1..a45f7d0 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleEmitter.java
@@ -59,53 +59,52 @@
IFileNode node = compileAS(code);
asBlockWalker.visitFile(node);
assertOutWithMetadata("/**\n" +
- " * com.example.components.MyEventTarget\n" +
- " *\n" +
- " * @fileoverview\n" +
- " *\n" +
- " * @suppress {checkTypes|accessControls}\n" +
- " */\n" +
- "\n" +
- "goog.provide('com.example.components.MyEventTarget');\n" +
- "\n" +
- "goog.require('custom.TestImplementation');\n" +
- "\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * @constructor\n" +
- " * @extends {custom.TestImplementation}\n" +
- " */\n" +
- "com.example.components.MyEventTarget = function() {\n" +
- " com.example.components.MyEventTarget.base(this, 'constructor');\n" +
- " if (foo() != 42) {\n" +
- " bar();\n" +
- " }\n" +
- "};\n" +
- "goog.inherits(com.example.components.MyEventTarget, custom.TestImplementation);\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * @private\n" +
- " * @type {string}\n" +
- " */\n" +
- "com.example.components.MyEventTarget.prototype._privateVar = \"do \";\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * @export\n" +
- " * @type {number}\n" +
- " */\n" +
- "com.example.components.MyEventTarget.prototype.publicProperty = 100;\n" +
- "\n" +
- "\n" +
- "/**\n" +
- " * @param {string} value\n" +
- " * @return {string}\n" +
- " */\n" +
- "com.example.components.MyEventTarget.prototype.myFunction = function(value) {\n" +
- " return \"Don't \" + this._privateVar + value;\n" +
- "};\n" +
+ " * com.example.components.MyEventTarget\n" +
+ " *\n" +
+ " * @fileoverview\n" +
+ " *\n" +
+ " * @suppress {checkTypes|accessControls}\n" +
+ " */\n" +
+ "\n" +
+ "goog.provide('com.example.components.MyEventTarget');\n" +
+ "\n" +
+ "goog.require('custom.TestImplementation');\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * @constructor\n" +
+ " * @extends {custom.TestImplementation}\n" +
+ " */\n" +
+ "com.example.components.MyEventTarget = function() {\n" +
+ " com.example.components.MyEventTarget.base(this, 'constructor');\n" +
+ " if (foo() != 42) {\n" +
+ " bar();\n" +
+ " }\n" +
+ "};\n" +
+ "goog.inherits(com.example.components.MyEventTarget, custom.TestImplementation);\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * @private\n" +
+ " * @type {string}\n" +
+ " */\n" +
+ "com.example.components.MyEventTarget.prototype._privateVar = \"do \";\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * @type {number}\n" +
+ " */\n" +
+ "com.example.components.MyEventTarget.prototype.publicProperty = 100;\n" +
+ "\n" +
+ "\n" +
+ "/**\n" +
+ " * @param {string} value\n" +
+ " * @return {string}\n" +
+ " */\n" +
+ "com.example.components.MyEventTarget.prototype.myFunction = function(value) {\n" +
+ " return \"Don't \" + this._privateVar + value;\n" +
+ "};\n" +
"\n" +
"\n" +
"/**\n" +
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java
index c715e9d..fb4b64d 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java
@@ -52,7 +52,7 @@
{
IVariableNode node = getField("public var foo:String = null;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @type {string}\n */\nRoyaleTest_A.prototype.foo = null");
+ assertOut("/**\n * @type {string}\n */\nRoyaleTest_A.prototype.foo = null");
}
@Override
@@ -61,7 +61,7 @@
{
IVariableNode node = getField("public var foo:int;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 0");
+ assertOut("/**\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 0");
}
@Override
@@ -70,7 +70,7 @@
{
IVariableNode node = getField("public var foo:int = 420;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 420");
+ assertOut("/**\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 420");
}
@Test
@@ -78,7 +78,7 @@
{
IVariableNode node = getField("public var foo:int = -420;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = -420");
+ assertOut("/**\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = -420");
}
@Test
@@ -86,7 +86,7 @@
{
IVariableNode node = getField("public var foo:int = -123.4;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = -123");
+ assertOut("/**\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = -123");
}
@Test
@@ -94,7 +94,7 @@
{
IVariableNode node = getField("public var foo:uint = 123.4;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 123");
+ assertOut("/**\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 123");
}
@Test
@@ -102,7 +102,7 @@
{
IVariableNode node = getField("public var foo:uint = -123;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 4294967173");
+ assertOut("/**\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 4294967173");
}
@Test
@@ -175,7 +175,7 @@
{
IVariableNode node = getField("public static var foo:int;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @type {number}\n */\nRoyaleTest_A.foo = 0");
+ assertOut("/**\n * @type {number}\n */\nRoyaleTest_A.foo = 0");
}
@Test
@@ -210,7 +210,7 @@
IClassNode node = (IClassNode) getNode("import custom.custom_namespace;use namespace custom_namespace;public static var foo:Object = initFoo(); custom_namespace static function initFoo():Object { return null; }",
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\n\n/**\n * @export\n * @type {Object}\n */\nRoyaleTest_A.foo;\n\n\n/**\n * @return {Object}\n */\nRoyaleTest_A.http_$$ns_apache_org$2017$custom$namespace__initFoo = function() {\n return null;\n};\n\nRoyaleTest_A.foo = RoyaleTest_A.http_$$ns_apache_org$2017$custom$namespace__initFoo();\n\n");
+ assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\n\n/**\n * @type {Object}\n */\nRoyaleTest_A.foo;\n\n\n/**\n * @return {Object}\n */\nRoyaleTest_A.http_$$ns_apache_org$2017$custom$namespace__initFoo = function() {\n return null;\n};\n\nRoyaleTest_A.foo = RoyaleTest_A.http_$$ns_apache_org$2017$custom$namespace__initFoo();\n\n");
}
@Test
@@ -219,7 +219,7 @@
IClassNode node = (IClassNode) getNode("static public var foo:Object = { 'foo': 'bar' }",
IClassNode.class, WRAP_LEVEL_CLASS);
asBlockWalker.visitClass(node);
- assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\n\n/**\n * @export\n * @type {Object}\n */\nRoyaleTest_A.foo = {'foo':'bar'};");
+ assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\n\n/**\n * @type {Object}\n */\nRoyaleTest_A.foo = {'foo':'bar'};");
}
@Test
@@ -259,7 +259,7 @@
{
IVariableNode node = getField("public static const foo;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @const\n * @type {*}\n */\nRoyaleTest_A.foo");
+ assertOut("/**\n * @const\n * @type {*}\n */\nRoyaleTest_A.foo");
}
@Test
@@ -267,7 +267,7 @@
{
IVariableNode node = getField("public const foo;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @const\n * @type {*}\n */\nRoyaleTest_A.prototype.foo");
+ assertOut("/**\n * @const\n * @type {*}\n */\nRoyaleTest_A.prototype.foo");
}
@Override
@@ -276,7 +276,7 @@
{
IVariableNode node = getField("public static const foo:int;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = 0");
+ assertOut("/**\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = 0");
}
@Test
@@ -284,7 +284,7 @@
{
IVariableNode node = getField("public const foo:int;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @const\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 0");
+ assertOut("/**\n * @const\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 0");
}
@Override
@@ -293,7 +293,7 @@
{
IVariableNode node = getField("public static const foo:int = 420;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = 420");
+ assertOut("/**\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = 420");
}
@Test
@@ -301,7 +301,7 @@
{
IVariableNode node = getField("public static const foo:Number = parseFloat('1E2');");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = parseFloat('1E2')");
+ assertOut("/**\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = parseFloat('1E2')");
}
@Test
@@ -309,7 +309,7 @@
{
IVariableNode node = getField("public const foo:int = 420;");
asBlockWalker.visitVariable(node);
- assertOut("/**\n * @export\n * @const\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 420");
+ assertOut("/**\n * @const\n * @type {number}\n */\nRoyaleTest_A.prototype.foo = 420");
}
@Test
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 7d61fc4..cbced0a 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
@@ -713,7 +713,6 @@
"\n" +
"\n" +
"/**\n" +
- " * @export\n" +
" * @nocollapse\n" +
" * @type {string}\n" +
" */\n" +
@@ -1146,7 +1145,6 @@
"\n" +
"\n" +
"/**\n" +
- " * @export\n" +
" * @nocollapse\n" +
" * @const\n" +
" * @type {number}\n" +
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
index e435712..b5511f3 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
@@ -900,7 +900,6 @@
"\n" +
"\n" +
"/**\n" +
- " * @export\n" +
" * @type {binding.ComplexValueObject}\n" +
" */\n" +
"AppName.prototype.firstOne = null;\n" +
@@ -1077,7 +1076,6 @@
"\n" +
"\n" +
"/**\n" +
- " * @export\n" +
" * @type {XML}\n" +
" */\n" +
"AppName.prototype.xml = null;\n" +
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLScript.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLScript.java
index e42f4a1..cfd5acf 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLScript.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLScript.java
@@ -274,7 +274,6 @@
"\n" +
"\n" +
"/**\n" +
- " * @export\n" +
" * @type {Array}\n" +
" */\n" +
"AppName.prototype.foo;\n" +
@@ -378,14 +377,12 @@
" Object.defineProperty(AppName, 'foo', { value: value, writable: true });\n" +
"};\n" +
"/**\n" +
- " * @export\n" +
" * @type {string}\n" +
" */\n" +
"AppName.foo;\n" +
"\n" +
"Object.defineProperties(AppName, /** @lends {AppName} */ {\n" +
"/**\n" +
- " * @export\n" +
" * @type {string}\n" +
" */\n" +
"foo: {\n" +
@@ -482,7 +479,6 @@
"\n" +
"\n" +
"/**\n" +
- " * @export\n" +
" * @type {string}\n" +
" */\n" +
"AppName.foo = 'foo';\n" +
@@ -576,7 +572,6 @@
"\n" +
"\n" +
"/**\n" +
- " * @export\n" +
" * @type {Array}\n" +
" */\n" +
"AppName.foo = ['foo'];\n" +
@@ -677,7 +672,6 @@
" return value;\n" +
"};\n" +
"/**\n" +
- " * @export\n" +
" * @const\n" +
" * @type {string}\n" +
" */\n" +
@@ -685,7 +679,6 @@
"\n" +
"Object.defineProperties(AppName, /** @lends {AppName} */ {\n" +
"/**\n" +
- " * @export\n" +
" * @const\n" +
" * @type {string}\n" +
" */\n" +
diff --git a/compiler-jx/src/test/resources/royale/projects/internal/MainClass_result.js b/compiler-jx/src/test/resources/royale/projects/internal/MainClass_result.js
index 266e02b..52e26f7 100644
--- a/compiler-jx/src/test/resources/royale/projects/internal/MainClass_result.js
+++ b/compiler-jx/src/test/resources/royale/projects/internal/MainClass_result.js
@@ -73,7 +73,6 @@
/**
- * @export
* @type {OtherClass}
*/
MainClass.InternalClass.prototype.foo = null;