You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2020/05/26 21:40:31 UTC

[royale-compiler] branch develop updated (2b6b669 -> 10f6ef0)

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git.


    from 2b6b669  Avoid outputting declarations if an MXMLDescriptorSpecifier doesn't actually have an id (explicit or 'effective'). This avoids declarations that would be made for 'null_' which serve no purpose in any case.
     new 7ee7f4e  PackageFooterEmitter: uses getModel().suppressExports instead of doc.getEmitExports() because doc.getEmitExports() may not always be accurate
     new de570f7  JSRoyaleDocEmitter: updates emitExports and exportProtected more accurately when config is missing and for fields
     new 1d597f2  ClosureUtils: some forward-looking tweaks to detecting symbols to export (but behavior currently remains the same)
     new 60fa42b  JSRoyaleDocEmitter: no export annotation for closure on package-level variables and functions
     new 10f6ef0  ClosureUtils: better rename prevention and export symbol calls for package-level variables

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../codegen/js/jx/PackageFooterEmitter.java        |  2 +-
 .../codegen/js/royale/JSRoyaleDocEmitter.java      | 26 +++++++++++++++++-
 .../apache/royale/compiler/utils/ClosureUtils.java | 31 +++++++++++++++++++---
 .../codegen/js/royale/TestRoyalePackage.java       |  9 +++----
 4 files changed, 57 insertions(+), 11 deletions(-)


[royale-compiler] 02/05: JSRoyaleDocEmitter: updates emitExports and exportProtected more accurately when config is missing and for fields

Posted by jo...@apache.org.
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

commit de570f74f36877c1fbdab10c582d62951c38beb6
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue May 26 12:42:57 2020 -0700

    JSRoyaleDocEmitter: updates emitExports and exportProtected more accurately when config is missing and for fields
---
 .../codegen/js/royale/JSRoyaleDocEmitter.java      | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

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 305a950..ad57c68 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
@@ -140,6 +140,11 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
         	emitExports = !suppressExports && fjp.config.getExportPublicSymbols();
         	exportProtected = !suppressExports && fjp.config.getExportProtectedSymbols();
         }
+        else
+        {
+            emitExports = !suppressExports;
+            exportProtected = false;
+        }
         
         coercionList = null;
         ignoreList = null;
@@ -544,9 +549,24 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
     @Override
     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();
+        }
+        else
+        {
+            emitExports = !suppressExports;
+            exportProtected = false;
+        }
+
         begin();
 
-        RoyaleJSProject fjp =  (RoyaleJSProject)project;
         String ns = node.getNamespace();
         if (ns == IASKeywordConstants.PRIVATE)
         {


[royale-compiler] 05/05: ClosureUtils: better rename prevention and export symbol calls for package-level variables

Posted by jo...@apache.org.
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

commit 10f6ef0d2ef8a73e4568146a8d20bd2e550bf84d
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue May 26 14:40:18 2020 -0700

    ClosureUtils: better rename prevention and export symbol calls for package-level variables
---
 .../apache/royale/compiler/utils/ClosureUtils.java    | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

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 819af3c..c1323d4 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
@@ -30,6 +30,7 @@ import org.apache.royale.compiler.definitions.INamespaceDefinition;
 import org.apache.royale.compiler.definitions.IPackageDefinition;
 import org.apache.royale.compiler.definitions.ITypeDefinition;
 import org.apache.royale.compiler.definitions.IVariableDefinition;
+import org.apache.royale.compiler.definitions.IVariableDefinition.VariableClassification;
 import org.apache.royale.compiler.definitions.references.INamespaceReference;
 import org.apache.royale.compiler.internal.codegen.js.utils.DocEmitterUtils;
 import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
@@ -68,6 +69,14 @@ public class ClosureUtils
                         //file-private symbols are emitted like static variables
                         result.add(def.getBaseName());
                     }
+                    if (def instanceof IVariableDefinition
+                            && !(def instanceof IAccessorDefinition))
+                    {
+                        IVariableDefinition varDef = (IVariableDefinition) def;
+                        if (varDef.getVariableClassification().equals(VariableClassification.PACKAGE_MEMBER)) {
+                            result.add(def.getBaseName());
+                        }
+                    }
                     if (def instanceof ITypeDefinition)
                     {
                         if (def.isImplicit() || def.isNative())
@@ -148,6 +157,16 @@ public class ClosureUtils
                     }
                     else
                     {
+                        if (def instanceof IVariableDefinition
+                                && !(def instanceof IAccessorDefinition))
+                        {
+                            IVariableDefinition varDef = (IVariableDefinition) def;
+                            if (varDef.getVariableClassification().equals(VariableClassification.PACKAGE_MEMBER)
+                                    && varDef.getPackageName() != null
+                                    && varDef.getPackageName().length() > 0) {
+                                symbolsResult.add(def.getPackageName());
+                            }
+                        }
                         symbolsResult.add(qualifiedName);
                         if(parentQName == null)
                         {


[royale-compiler] 03/05: ClosureUtils: some forward-looking tweaks to detecting symbols to export (but behavior currently remains the same)

Posted by jo...@apache.org.
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

commit 1d597f2593fba7ddbf0b2bbacac419570133e656
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue May 26 12:46:57 2020 -0700

    ClosureUtils: some forward-looking tweaks to detecting symbols to export (but behavior currently remains the same)
---
 .../java/org/apache/royale/compiler/utils/ClosureUtils.java  | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

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 78c2ea7..819af3c 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
@@ -173,18 +173,22 @@ public class ClosureUtils
                             boolean isPublic = nsRef instanceof INamespaceDefinition.IPublicNamespaceDefinition;
                             boolean isProtected = nsRef instanceof INamespaceDefinition.IProtectedNamespaceDefinition
                                     || nsRef instanceof INamespaceDefinition.IStaticProtectedNamespaceDefinition;
-                            if (localDef instanceof IFunctionDefinition && !(localDef instanceof IVariableDefinition)
-                                    && localDef.isStatic() && isPublic)
+                            if (localDef instanceof IFunctionDefinition
+                                    && !(localDef instanceof IAccessorDefinition)
+                                    // the next two conditions are temporary
+                                    // and more symbols will be exported in the future
+                                    && localDef.isStatic()
+                                    && isPublic)
                             {
                                 if ((isPublic && exportPublic) || (isProtected && exportProtected))
                                 {
                                     if (isFilePrivate)
                                     {
-                                        filePrivateNames.add(qualifiedName + "." + localDef.getBaseName());
+                                        filePrivateNames.add(qualifiedName + (localDef.isStatic() ? "." : ".prototype.") + localDef.getBaseName());
                                     }
                                     else
                                     {
-                                        symbolsResult.add(qualifiedName + "." + localDef.getBaseName());
+                                        symbolsResult.add(qualifiedName + (localDef.isStatic() ? "." : ".prototype.") + localDef.getBaseName());
                                     }
                                 }
                             }


[royale-compiler] 04/05: JSRoyaleDocEmitter: no export annotation for closure on package-level variables and functions

Posted by jo...@apache.org.
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

commit 60fa42b95d0fc64a8911a69800f61b2631b3a78a
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue May 26 14:39:51 2020 -0700

    JSRoyaleDocEmitter: no export annotation for closure on package-level variables and functions
---
 .../compiler/internal/codegen/js/royale/JSRoyaleDocEmitter.java  | 4 ++++
 .../compiler/internal/codegen/js/royale/TestRoyalePackage.java   | 9 ++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

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 ad57c68..37d38f8 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
@@ -31,7 +31,9 @@ import org.apache.royale.compiler.constants.IASLanguageConstants;
 import org.apache.royale.compiler.definitions.IClassDefinition;
 import org.apache.royale.compiler.definitions.IDefinition;
 import org.apache.royale.compiler.definitions.IFunctionDefinition;
+import org.apache.royale.compiler.definitions.IFunctionDefinition.FunctionClassification;
 import org.apache.royale.compiler.definitions.ITypeDefinition;
+import org.apache.royale.compiler.definitions.IVariableDefinition.VariableClassification;
 import org.apache.royale.compiler.definitions.references.IReference;
 import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
 import org.apache.royale.compiler.internal.codegen.js.JSEmitterTokens;
@@ -145,6 +147,7 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
             emitExports = !suppressExports;
             exportProtected = false;
         }
+        emitExports = emitExports && !node.getFunctionClassification().equals(FunctionClassification.PACKAGE_MEMBER);
         
         coercionList = null;
         ignoreList = null;
@@ -564,6 +567,7 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
             emitExports = !suppressExports;
             exportProtected = false;
         }
+        emitExports = emitExports && !node.getVariableClassification().equals(VariableClassification.PACKAGE_MEMBER);
 
         begin();
 
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 08c748d..dfb6c30 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
@@ -1133,7 +1133,6 @@ public class TestRoyalePackage extends TestGoogPackage
 				"\n" +
 				"\n" +
 				"/**\n" +
-				" * @export\n" +
 				" * @return {number}\n" +
 				" */\n" +
 				"foo.bar.A = function() {\n" +
@@ -1193,7 +1192,7 @@ public class TestRoyalePackage extends TestGoogPackage
 	{
 		IFileNode node = compileAS("package {public function A(){}}");
 		asBlockWalker.visitFile(node);
-		assertOutWithMetadata("/**\n * A\n *\n * @fileoverview\n *\n * @suppress {checkTypes|accessControls}\n */\n\ngoog.provide('A');\n\n\n\n/**\n * @export\n */\nA = function() {\n}");
+		assertOutWithMetadata("/**\n * A\n *\n * @fileoverview\n *\n * @suppress {checkTypes|accessControls}\n */\n\ngoog.provide('A');\n\n\n\n/**\n */\nA = function() {\n}");
 	}
 
 	@Test
@@ -1201,7 +1200,7 @@ public class TestRoyalePackage extends TestGoogPackage
 	{
 		IFileNode node = compileAS("package foo.bar.baz {public function A(){}}");
 		asBlockWalker.visitFile(node);
-		assertOutWithMetadata("/**\n * foo.bar.baz.A\n *\n * @fileoverview\n *\n * @suppress {checkTypes|accessControls}\n */\n\ngoog.provide('foo.bar.baz.A');\n\n\n\n/**\n * @export\n */\nfoo.bar.baz.A = function() {\n}");
+		assertOutWithMetadata("/**\n * foo.bar.baz.A\n *\n * @fileoverview\n *\n * @suppress {checkTypes|accessControls}\n */\n\ngoog.provide('foo.bar.baz.A');\n\n\n\n/**\n */\nfoo.bar.baz.A = function() {\n}");
 	}
 
 	@Test
@@ -1209,7 +1208,7 @@ public class TestRoyalePackage extends TestGoogPackage
 	{
 		IFileNode node = compileAS("package {public var A:String = \"Hello\";}");
 		asBlockWalker.visitFile(node);
-		assertOutWithMetadata("/**\n * A\n *\n * @fileoverview\n *\n * @suppress {checkTypes|accessControls}\n */\n\ngoog.provide('A');\n\n\n\n/**\n * @export\n * @type {string}\n */\nA = \"Hello\"");
+		assertOutWithMetadata("/**\n * A\n *\n * @fileoverview\n *\n * @suppress {checkTypes|accessControls}\n */\n\ngoog.provide('A');\n\n\n\n/**\n * @type {string}\n */\nA = \"Hello\"");
 	}
 
 	@Test
@@ -1217,7 +1216,7 @@ public class TestRoyalePackage extends TestGoogPackage
 	{
 		IFileNode node = compileAS("package foo.bar.baz {public var A:String = \"Hello\";}");
 		asBlockWalker.visitFile(node);
-		assertOutWithMetadata("/**\n * foo.bar.baz.A\n *\n * @fileoverview\n *\n * @suppress {checkTypes|accessControls}\n */\n\ngoog.provide('foo.bar.baz.A');\n\n\n\n/**\n * @export\n * @type {string}\n */\nfoo.bar.baz.A = \"Hello\"");
+		assertOutWithMetadata("/**\n * foo.bar.baz.A\n *\n * @fileoverview\n *\n * @suppress {checkTypes|accessControls}\n */\n\ngoog.provide('foo.bar.baz.A');\n\n\n\n/**\n * @type {string}\n */\nfoo.bar.baz.A = \"Hello\"");
 	}
     
     @Override


[royale-compiler] 01/05: PackageFooterEmitter: uses getModel().suppressExports instead of doc.getEmitExports() because doc.getEmitExports() may not always be accurate

Posted by jo...@apache.org.
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

commit 7ee7f4e4b988b02fc274a7ac3086e63f64db4a3b
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue May 26 12:42:01 2020 -0700

    PackageFooterEmitter: uses getModel().suppressExports instead of doc.getEmitExports() because doc.getEmitExports() may not always be accurate
---
 .../royale/compiler/internal/codegen/js/jx/PackageFooterEmitter.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/PackageFooterEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/PackageFooterEmitter.java
index 1e54271..64edb13 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/PackageFooterEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/PackageFooterEmitter.java
@@ -79,7 +79,7 @@ public class PackageFooterEmitter extends JSSubEmitter implements
         JSRoyaleDocEmitter doc = (JSRoyaleDocEmitter) getEmitter()
         .getDocEmitter();
 
-	    if (!getEmitter().getModel().isExterns && doc.getEmitExports())
+	    if (!getEmitter().getModel().isExterns && !getEmitter().getModel().suppressExports)
 	    {
 			boolean isInterface = tnode instanceof IInterfaceNode;
 			boolean isDynamic = tnode instanceof IClassNode && tnode.hasModifier(ASModifier.DYNAMIC);