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/11 19:13:54 UTC

[royale-compiler] 02/02: ClosureUtils: refactor collectSymbolNamesToExport() to better match collectPropertyNamesToKeep()

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 9aeb984fb7f9c1afd73e21007ceaa16cb383b538
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon May 11 12:08:49 2020 -0700

    ClosureUtils: refactor collectSymbolNamesToExport() to better match collectPropertyNamesToKeep()
    
    Currently still limited to types and public static methods, though. Will slowly switch over more exports later.
---
 .../apache/royale/compiler/utils/ClosureUtils.java | 30 ++++++++++++++++------
 1 file changed, 22 insertions(+), 8 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 a1ae12f..78c2ea7 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
@@ -116,6 +116,8 @@ public class ClosureUtils
         {
             return;
         }
+        boolean exportPublic = project.config != null && project.config.getExportPublicSymbols();
+        boolean exportProtected = project.config != null && project.config.getExportProtectedSymbols();
         try
         {
             String parentQName = null;
@@ -161,17 +163,29 @@ public class ClosureUtils
                             continue;
                         }
 
-                        for(IDefinition childDef : typeDef.getContainedScope().getAllLocalDefinitions())
+                        for(IDefinition localDef : typeDef.getContainedScope().getAllLocalDefinitions())
                         {
-                            if(childDef instanceof IFunctionDefinition && !(childDef instanceof IVariableDefinition) && childDef.isStatic() && childDef.isPublic())
+                            if (localDef.isImplicit())
                             {
-                                if(isFilePrivate)
-                                {
-                                    filePrivateNames.add(qualifiedName + "." + childDef.getBaseName());
-                                }
-                                else
+                                continue;
+                            }
+                            INamespaceReference nsRef = localDef.getNamespaceReference();
+                            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 ((isPublic && exportPublic) || (isProtected && exportProtected))
                                 {
-                                    symbolsResult.add(qualifiedName + "." + childDef.getBaseName());
+                                    if (isFilePrivate)
+                                    {
+                                        filePrivateNames.add(qualifiedName + "." + localDef.getBaseName());
+                                    }
+                                    else
+                                    {
+                                        symbolsResult.add(qualifiedName + "." + localDef.getBaseName());
+                                    }
                                 }
                             }
                         }