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/03/31 17:47:57 UTC

[royale-compiler] branch develop updated (f74841b -> 82e5c22)

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 f74841b  try using -1 as the zipentry time.  It shows as 1969 but maybe it will not be recomputed by the zip library
     new 21d8cae  Prevent renaming of public variables (static or non-static)
     new ac021e8  Merge branch 'develop' into rename-control
     new 51923a5  prevent-rename-public-symbols and prevent-rename-protected-symbols compiler options
     new fbe6f6d  prevent rename: nocollapse annotation is only included when renaming is prevented
     new 82e5c22  Merge branch 'rename-control' into develop

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:
 .../javascript/jscomp/RoyaleClosurePassConfig.java | 53 ++++++++++++-
 .../apache/royale/compiler/clients/MXMLJSC.java    | 10 ++-
 .../royale/compiler/clients/MXMLJSCNative.java     | 11 ++-
 .../royale/compiler/clients/MXMLJSCNode.java       | 10 ++-
 .../royale/compiler/clients/MXMLJSCRoyale.java     | 11 ++-
 .../compiler/clients/MXMLJSCRoyaleCordova.java     | 11 ++-
 .../{IJSGoogEmitter.java => IJSGoogPublisher.java} | 16 ++--
 .../codegen/js/royale/JSRoyaleDocEmitter.java      | 15 +++-
 .../codegen/mxml/royale/MXMLRoyalePublisher.java   | 12 ++-
 .../driver/js/goog/JSGoogCompcConfiguration.java   |  2 +-
 .../driver/js/goog/JSGoogConfiguration.java        | 39 +++++++++-
 .../apache/royale/compiler/utils/ClosureUtils.java | 86 ++++++++++++++++++++++
 .../compiler/utils/JSClosureCompilerWrapper.java   |  9 ++-
 .../codegen/js/royale/TestRoyaleClass.java         |  2 +-
 .../codegen/js/royale/TestRoyaleFieldMembers.java  | 14 ++--
 .../codegen/mxml/royale/TestRoyaleMXMLScript.java  |  4 -
 16 files changed, 259 insertions(+), 46 deletions(-)
 copy compiler-jx/src/main/java/org/apache/royale/compiler/codegen/js/goog/{IJSGoogEmitter.java => IJSGoogPublisher.java} (74%)
 create mode 100644 compiler-jx/src/main/java/org/apache/royale/compiler/utils/ClosureUtils.java


[royale-compiler] 05/05: Merge branch 'rename-control' into develop

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 82e5c2251b8f7765d34eafb03003272eb97fbae8
Merge: f74841b fbe6f6d
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue Mar 31 10:42:13 2020 -0700

    Merge branch 'rename-control' into develop

 .../javascript/jscomp/RoyaleClosurePassConfig.java | 53 ++++++++++++-
 .../apache/royale/compiler/clients/MXMLJSC.java    | 10 ++-
 .../royale/compiler/clients/MXMLJSCNative.java     | 11 ++-
 .../royale/compiler/clients/MXMLJSCNode.java       | 10 ++-
 .../royale/compiler/clients/MXMLJSCRoyale.java     | 11 ++-
 .../compiler/clients/MXMLJSCRoyaleCordova.java     | 11 ++-
 .../compiler/codegen/js/goog/IJSGoogPublisher.java | 33 +++++++++
 .../codegen/js/royale/JSRoyaleDocEmitter.java      | 15 +++-
 .../codegen/mxml/royale/MXMLRoyalePublisher.java   | 12 ++-
 .../driver/js/goog/JSGoogCompcConfiguration.java   |  2 +-
 .../driver/js/goog/JSGoogConfiguration.java        | 39 +++++++++-
 .../apache/royale/compiler/utils/ClosureUtils.java | 86 ++++++++++++++++++++++
 .../compiler/utils/JSClosureCompilerWrapper.java   |  9 ++-
 .../codegen/js/royale/TestRoyaleClass.java         |  2 +-
 .../codegen/js/royale/TestRoyaleFieldMembers.java  | 14 ++--
 .../codegen/mxml/royale/TestRoyaleMXMLScript.java  |  4 -
 16 files changed, 284 insertions(+), 38 deletions(-)


[royale-compiler] 04/05: prevent rename: nocollapse annotation is only included when renaming is prevented

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 fbe6f6de9a54f30a003dfe7ff3c583664041fcc2
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue Mar 31 10:40:14 2020 -0700

    prevent rename: nocollapse annotation is only included when renaming is prevented
---
 .../internal/codegen/js/royale/JSRoyaleDocEmitter.java     | 13 +++++++++++--
 .../internal/codegen/js/royale/TestRoyaleClass.java        |  2 +-
 .../internal/codegen/js/royale/TestRoyaleFieldMembers.java | 14 +++++++-------
 .../internal/codegen/mxml/royale/TestRoyaleMXMLScript.java |  4 ----
 4 files changed, 19 insertions(+), 14 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 62c8e04..e2f7805 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
@@ -546,6 +546,7 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
     {
         begin();
 
+        RoyaleJSProject fjp =  (RoyaleJSProject)project;
         String ns = node.getNamespace();
         if (ns == IASKeywordConstants.PRIVATE)
         {
@@ -554,10 +555,17 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
         else if (ns == IASKeywordConstants.PROTECTED)
         {
             emitProtected(node);
+            boolean preventRename = fjp.config != null && fjp.config.getPreventRenameProtectedSymbols();
+            if(preventRename && node.hasModifier(ASModifier.STATIC) && !(node instanceof IAccessorNode))
+            {
+                //dynamically getting/setting a protected static variable
+                //won't work properly if it is collapsed, even when it
+                //has been exported
+                emitJSDocLine(JSGoogDocEmitterTokens.NOCOLLAPSE);
+            }
         }
         else
         {
-        	RoyaleJSProject fjp =  (RoyaleJSProject)project;
             boolean warnPublicVars = fjp.config != null && fjp.config.getWarnPublicVars() && !fjp.config.getPreventRenamePublicSymbols();
             IMetaTagsNode meta = node.getMetaTags();
             boolean bindable = false;
@@ -598,7 +606,8 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
                 if (ns.equals(IASKeywordConstants.PUBLIC))
                 {
                     emitPublic(node);
-                    if(node.hasModifier(ASModifier.STATIC) && !(node instanceof IAccessorNode))
+                    boolean preventRename = fjp.config != null && fjp.config.getPreventRenamePublicSymbols();
+                    if(preventRename && node.hasModifier(ASModifier.STATIC) && !(node instanceof IAccessorNode))
                     {
                         //dynamically getting/setting a public static variable
                         //won't work properly if it is collapsed, even when it
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 0febdc1..7246eb8 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
@@ -653,7 +653,7 @@ public class TestRoyaleClass extends TestGoogClass
                 + "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 * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('org.apache.royale.A', org.apache.royale.A);\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 * @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;\ [...]
+        assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('org.apache.royale.A', org.apache.royale.A);\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.r [...]
     }
 
     @Override
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 9502c33..f92714a 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
@@ -175,7 +175,7 @@ public class TestRoyaleFieldMembers extends TestGoogFieldMembers
     {
         IVariableNode node = getField("public static var foo:int;");
         asBlockWalker.visitVariable(node);
-        assertOut("/**\n * @export\n * @nocollapse\n * @type {number}\n */\nRoyaleTest_A.foo = 0");
+        assertOut("/**\n * @export\n * @type {number}\n */\nRoyaleTest_A.foo = 0");
     }
 
     @Test
@@ -210,7 +210,7 @@ public class TestRoyaleFieldMembers extends TestGoogFieldMembers
     	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 * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('RoyaleTest_A', RoyaleTest_A);\n\n\n/**\n * @export\n * @nocollapse\n * @type {Object}\n */\nRoyaleTest_A.foo;\n\n\n/**\n * @export\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$ [...]
+        assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('RoyaleTest_A', RoyaleTest_A);\n\n\n/**\n * @export\n * @type {Object}\n */\nRoyaleTest_A.foo;\n\n\n/**\n * @export\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__initF [...]
     }
     
     @Test
@@ -219,7 +219,7 @@ public class TestRoyaleFieldMembers extends TestGoogFieldMembers
     	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 * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('RoyaleTest_A', RoyaleTest_A);\n\n\n/**\n * @export\n * @nocollapse\n * @type {Object}\n */\nRoyaleTest_A.foo = {'foo':'bar'};");
+        assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('RoyaleTest_A', RoyaleTest_A);\n\n\n/**\n * @export\n * @type {Object}\n */\nRoyaleTest_A.foo = {'foo':'bar'};");
     }
     
     @Test
@@ -259,7 +259,7 @@ public class TestRoyaleFieldMembers extends TestGoogFieldMembers
     {
         IVariableNode node = getField("public static const foo;");
         asBlockWalker.visitVariable(node);
-        assertOut("/**\n * @export\n * @nocollapse\n * @const\n * @type {*}\n */\nRoyaleTest_A.foo");
+        assertOut("/**\n * @export\n * @const\n * @type {*}\n */\nRoyaleTest_A.foo");
     }
 
     @Test
@@ -276,7 +276,7 @@ public class TestRoyaleFieldMembers extends TestGoogFieldMembers
     {
         IVariableNode node = getField("public static const foo:int;");
         asBlockWalker.visitVariable(node);
-        assertOut("/**\n * @export\n * @nocollapse\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = 0");
+        assertOut("/**\n * @export\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = 0");
     }
 
     @Test
@@ -293,7 +293,7 @@ public class TestRoyaleFieldMembers extends TestGoogFieldMembers
     {
         IVariableNode node = getField("public static const foo:int = 420;");
         asBlockWalker.visitVariable(node);
-        assertOut("/**\n * @export\n * @nocollapse\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = 420");
+        assertOut("/**\n * @export\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = 420");
     }
 
     @Test
@@ -301,7 +301,7 @@ public class TestRoyaleFieldMembers extends TestGoogFieldMembers
     {
         IVariableNode node = getField("public static const foo:Number = parseFloat('1E2');");
         asBlockWalker.visitVariable(node);
-        assertOut("/**\n * @export\n * @nocollapse\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = parseFloat('1E2')");
+        assertOut("/**\n * @export\n * @const\n * @type {number}\n */\nRoyaleTest_A.foo = parseFloat('1E2')");
     }
 
     @Test
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 d191566..eb5713b 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
@@ -402,7 +402,6 @@ public class TestRoyaleMXMLScript extends RoyaleTestBase
 				"Object.defineProperties(AppName, /** @lends {AppName} */ {\n" +
 				"/**\n" +
 				" * @export\n" +
-				" * @nocollapse\n" +
 				" * @type {string}\n" +
 				" */\n" +
 				"foo: {\n" +
@@ -505,7 +504,6 @@ public class TestRoyaleMXMLScript extends RoyaleTestBase
 				"\n" +
 				"/**\n" +
 				" * @export\n" +
-				" * @nocollapse\n" +
 				" * @type {string}\n" +
 				" */\n" +
 				"AppName.foo = 'foo';\n" +
@@ -605,7 +603,6 @@ public class TestRoyaleMXMLScript extends RoyaleTestBase
 				"\n" +
 				"/**\n" +
 				" * @export\n" +
-				" * @nocollapse\n" +
 				" * @type {Array}\n" +
 				" */\n" +
 				"AppName.foo = ['foo'];\n" +
@@ -713,7 +710,6 @@ public class TestRoyaleMXMLScript extends RoyaleTestBase
 				"Object.defineProperties(AppName, /** @lends {AppName} */ {\n" +
 				"/**\n" +
 				" * @export\n" +
-				" * @nocollapse\n" +
 				" * @const\n" +
 				" * @type {string}\n" +
 				" */\n" +


[royale-compiler] 01/05: Prevent renaming of public variables (static or non-static)

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 21d8cae1a1bf444390ab66435b46f0f9b4c6800c
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Mar 30 18:02:02 2020 -0700

    Prevent renaming of public variables (static or non-static)
---
 .../javascript/jscomp/RoyaleClosurePassConfig.java | 53 ++++++++++++-
 .../apache/royale/compiler/clients/MXMLJSC.java    | 10 ++-
 .../royale/compiler/clients/MXMLJSCNative.java     | 11 ++-
 .../royale/compiler/clients/MXMLJSCNode.java       | 10 ++-
 .../royale/compiler/clients/MXMLJSCRoyale.java     | 11 ++-
 .../compiler/clients/MXMLJSCRoyaleCordova.java     | 11 ++-
 .../compiler/codegen/js/goog/IJSGoogPublisher.java | 33 +++++++++
 .../codegen/mxml/royale/MXMLRoyalePublisher.java   | 12 ++-
 .../driver/js/goog/JSGoogCompcConfiguration.java   |  2 +-
 .../driver/js/goog/JSGoogConfiguration.java        |  2 +-
 .../apache/royale/compiler/utils/ClosureUtils.java | 86 ++++++++++++++++++++++
 .../compiler/utils/JSClosureCompilerWrapper.java   |  9 ++-
 12 files changed, 227 insertions(+), 23 deletions(-)

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 84fae02..449918c 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
@@ -61,7 +61,10 @@ import com.google.javascript.jscomp.lint.CheckUselessBlocks;
 import com.google.javascript.jscomp.parsing.ParserRunner;
 import com.google.javascript.jscomp.parsing.parser.FeatureSet;
 import com.google.javascript.rhino.IR;
+import com.google.javascript.rhino.JSDocInfo;
+import com.google.javascript.rhino.JSDocInfoBuilder;
 import com.google.javascript.rhino.Node;
+import com.google.javascript.rhino.Token;
 
 import java.io.File;
 import java.util.ArrayList;
@@ -130,8 +133,10 @@ public final class RoyaleClosurePassConfig extends PassConfig {
 
   /** file of already renamed vars */
   private File varRenameMapFile;
+
+  private Set<String> propertyNamesToKeep;
   
-  public RoyaleClosurePassConfig(CompilerOptions options, String sourceFileName, File varRenameMapFile) {
+  public RoyaleClosurePassConfig(CompilerOptions options, String sourceFileName, File varRenameMapFile, Set<String> propertyNamesToKeep) {
     super(options);
 
     // The current approach to protecting "hidden" side-effects is to
@@ -141,6 +146,7 @@ public final class RoyaleClosurePassConfig extends PassConfig {
     preprocessorSymbolTableFactory = new PreprocessorSymbolTable.CachedInstanceFactory();
     this.varRenameMapFile = varRenameMapFile;
     this.sourceFileName = sourceFileName;
+    this.propertyNamesToKeep = propertyNamesToKeep;
   }
 
   GlobalNamespace getGlobalNamespace() {
@@ -335,6 +341,10 @@ public final class RoyaleClosurePassConfig extends PassConfig {
       checks.add(angularPass);
     }
 
+    if (propertyNamesToKeep != null && propertyNamesToKeep.size() > 0) {
+      checks.add(keepPropertyNamesPass);
+    }
+
     if (!options.generateExportsAfterTypeChecking && options.generateExports) {
       checks.add(generateExports);
     }
@@ -1255,6 +1265,47 @@ public final class RoyaleClosurePassConfig extends PassConfig {
         }
       };
 
+    private final PassFactory keepPropertyNamesPass = 
+        new PassFactory("keep-property-names", true) {
+          @Override
+          protected CompilerPass create(final AbstractCompiler compiler) {
+            return new CompilerPass() {
+              @Override
+              public void process(Node externs, Node root) {
+
+                Node propsObj = new Node(Token.OBJECTLIT);
+                for(String nameToKeep : propertyNamesToKeep)
+                {
+                  Node nameStringKey = IR.stringKey(nameToKeep);
+                  JSDocInfoBuilder builder = new JSDocInfoBuilder(true);
+                  builder.recordExport();
+                  JSDocInfo jsDocInfo = builder.build();
+                  nameStringKey.setJSDocInfo(jsDocInfo);
+
+                  Node propertyDescriptor = new Node(Token.OBJECTLIT);
+                  propertyDescriptor.addChildToBack(IR.propdef(IR.stringKey("get"), NodeUtil.emptyFunction()));
+
+                  Node prop = IR.propdef(nameStringKey, propertyDescriptor);
+                  propsObj.addChildToBack(prop);
+                }
+
+                Node definePropertiesTarget = NodeUtil.newQName(compiler, "Object.defineProperties");
+                Node definePropertiesCall = IR.call(definePropertiesTarget, IR.objectlit(), propsObj);
+                Node expression = IR.exprResult(definePropertiesCall);
+                
+                Node scriptNode = compiler.getScriptNode(sourceFileName);
+                scriptNode.addChildToBack(expression);
+                compiler.reportChangeToEnclosingScope(expression);
+              }
+            };
+          }
+    
+          @Override
+          protected FeatureSet featureSet() {
+            return ES_NEXT;
+          }
+        };
+
   /** Raw exports processing pass. */
   private final PassFactory gatherRawExports =
       new PassFactory(PassNames.GATHER_RAW_EXPORTS, true) {
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSC.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSC.java
index 5bed5df..748c169 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSC.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSC.java
@@ -35,8 +35,8 @@ import org.apache.royale.compiler.clients.problems.ProblemPrinter;
 import org.apache.royale.compiler.clients.problems.ProblemQuery;
 import org.apache.royale.compiler.clients.problems.ProblemQueryProvider;
 import org.apache.royale.compiler.clients.problems.WorkspaceProblemFormatter;
-import org.apache.royale.compiler.codegen.js.IJSPublisher;
 import org.apache.royale.compiler.codegen.js.IJSWriter;
+import org.apache.royale.compiler.codegen.js.goog.IJSGoogPublisher;
 import org.apache.royale.compiler.common.VersionInfo;
 import org.apache.royale.compiler.config.CommandLineConfigurator;
 import org.apache.royale.compiler.config.CompilerDiagnosticsConstants;
@@ -75,6 +75,7 @@ import org.apache.royale.compiler.targets.ITarget;
 import org.apache.royale.compiler.targets.ITarget.TargetType;
 import org.apache.royale.compiler.targets.ITargetSettings;
 import org.apache.royale.compiler.units.ICompilationUnit;
+import org.apache.royale.compiler.utils.ClosureUtils;
 import org.apache.royale.swf.ISWF;
 import org.apache.royale.swf.SWF;
 import org.apache.royale.swf.types.RGB;
@@ -272,7 +273,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
     protected ITarget target;
     protected ITargetSettings targetSettings;
     protected IJSApplication jsTarget;
-    private IJSPublisher jsPublisher;
+    private IJSGoogPublisher jsPublisher;
     protected MXMLC mxmlc;
     protected JSCompilerEntryPoint lastCompiler;
     public boolean noLink;
@@ -532,7 +533,8 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
                         return false;
                 }
 
-                jsPublisher = (IJSPublisher) project.getBackend().createPublisher(
+                Set<String> closurePropNamesToKeep = new HashSet<String>();
+                jsPublisher = (IJSGoogPublisher) project.getBackend().createPublisher(
                         project, errors, config);
 
                 File outputFolder = jsPublisher.getOutputFolder();
@@ -617,11 +619,13 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
 	                    		outputClassFile.setLastModified(fileDate);
 	                    	}
 	                    }
+                        ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep);
 	                }
                 }
                 
                 if (jsPublisher != null)
                 {
+                    jsPublisher.setClosurePropertyNamesToKeep(closurePropNamesToKeep);
                     compilationSuccess = jsPublisher.publish(problems);
                 }
                 else
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNative.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNative.java
index 1c4474f..9b54b1e 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNative.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNative.java
@@ -27,6 +27,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
@@ -36,8 +37,8 @@ import org.apache.royale.compiler.clients.problems.ProblemPrinter;
 import org.apache.royale.compiler.clients.problems.ProblemQuery;
 import org.apache.royale.compiler.clients.problems.ProblemQueryProvider;
 import org.apache.royale.compiler.clients.problems.WorkspaceProblemFormatter;
-import org.apache.royale.compiler.codegen.js.IJSPublisher;
 import org.apache.royale.compiler.codegen.js.IJSWriter;
+import org.apache.royale.compiler.codegen.js.goog.IJSGoogPublisher;
 import org.apache.royale.compiler.config.Configuration;
 import org.apache.royale.compiler.config.ConfigurationBuffer;
 import org.apache.royale.compiler.config.Configurator;
@@ -72,6 +73,7 @@ import org.apache.royale.compiler.targets.ITarget.TargetType;
 import org.apache.royale.compiler.targets.ITargetSettings;
 import org.apache.royale.compiler.units.ICompilationUnit;
 import org.apache.royale.compiler.units.ICompilationUnit.UnitType;
+import org.apache.royale.compiler.utils.ClosureUtils;
 import org.apache.flex.tools.FlexTool;
 import org.apache.royale.utils.ArgumentUtil;
 import org.apache.royale.utils.FilenameNormalization;
@@ -169,7 +171,7 @@ public class MXMLJSCNative implements JSCompilerEntryPoint, ProblemQueryProvider
     protected ITarget target;
     protected ITargetSettings targetSettings;
     protected IJSApplication jsTarget;
-    private IJSPublisher jsPublisher;
+    private IJSGoogPublisher jsPublisher;
     
     public MXMLJSCNative()
     {
@@ -315,7 +317,8 @@ public class MXMLJSCNative implements JSCompilerEntryPoint, ProblemQueryProvider
                         return false;
                 }
 
-                jsPublisher = (IJSPublisher) project.getBackend().createPublisher(
+                Set<String> closurePropNamesToKeep = new HashSet<String>();
+                jsPublisher = (IJSGoogPublisher) project.getBackend().createPublisher(
                         project, errors, config);
 
                 File outputFolder = jsPublisher.getOutputFolder();
@@ -381,11 +384,13 @@ public class MXMLJSCNative implements JSCompilerEntryPoint, ProblemQueryProvider
                             }
 	                        writer.close();
 	                    }
+                        ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep);
 	                }
                 }
                 
                 if (jsPublisher != null)
                 {
+                    jsPublisher.setClosurePropertyNamesToKeep(closurePropNamesToKeep);
                     compilationSuccess = jsPublisher.publish(problems);
                 }
                 else
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNode.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNode.java
index bb83228..70c1c24 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNode.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCNode.java
@@ -27,6 +27,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
@@ -36,8 +37,8 @@ import org.apache.royale.compiler.clients.problems.ProblemPrinter;
 import org.apache.royale.compiler.clients.problems.ProblemQuery;
 import org.apache.royale.compiler.clients.problems.ProblemQueryProvider;
 import org.apache.royale.compiler.clients.problems.WorkspaceProblemFormatter;
-import org.apache.royale.compiler.codegen.js.IJSPublisher;
 import org.apache.royale.compiler.codegen.js.IJSWriter;
+import org.apache.royale.compiler.codegen.js.goog.IJSGoogPublisher;
 import org.apache.royale.compiler.config.Configuration;
 import org.apache.royale.compiler.config.ConfigurationBuffer;
 import org.apache.royale.compiler.config.Configurator;
@@ -72,6 +73,7 @@ import org.apache.royale.compiler.targets.ITarget.TargetType;
 import org.apache.royale.compiler.targets.ITargetSettings;
 import org.apache.royale.compiler.units.ICompilationUnit;
 import org.apache.royale.compiler.units.ICompilationUnit.UnitType;
+import org.apache.royale.compiler.utils.ClosureUtils;
 import org.apache.flex.tools.FlexTool;
 import org.apache.royale.utils.ArgumentUtil;
 import org.apache.royale.utils.FilenameNormalization;
@@ -168,7 +170,7 @@ public class MXMLJSCNode implements JSCompilerEntryPoint, ProblemQueryProvider,
     protected ITarget target;
     protected ITargetSettings targetSettings;
     protected IJSApplication jsTarget;
-    private IJSPublisher jsPublisher;
+    private IJSGoogPublisher jsPublisher;
 
     public MXMLJSCNode()
     {
@@ -317,7 +319,8 @@ public class MXMLJSCNode implements JSCompilerEntryPoint, ProblemQueryProvider,
                         return false;
                 }
 
-                jsPublisher = (IJSPublisher) project.getBackend().createPublisher(
+                Set<String> closurePropNamesToKeep = new HashSet<String>();
+                jsPublisher = (IJSGoogPublisher) project.getBackend().createPublisher(
                         project, errors, config);
 
                 File outputFolder = jsPublisher.getOutputFolder();
@@ -383,6 +386,7 @@ public class MXMLJSCNode implements JSCompilerEntryPoint, ProblemQueryProvider,
                             }
 	                        writer.close();
 	                    }
+                        ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep);
 	                }
                 }
                 
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java
index 1236ef2..fe73f30 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyale.java
@@ -38,8 +38,8 @@ import org.apache.royale.compiler.clients.problems.ProblemPrinter;
 import org.apache.royale.compiler.clients.problems.ProblemQuery;
 import org.apache.royale.compiler.clients.problems.ProblemQueryProvider;
 import org.apache.royale.compiler.clients.problems.WorkspaceProblemFormatter;
-import org.apache.royale.compiler.codegen.js.IJSPublisher;
 import org.apache.royale.compiler.codegen.js.IJSWriter;
+import org.apache.royale.compiler.codegen.js.goog.IJSGoogPublisher;
 import org.apache.royale.compiler.config.Configuration;
 import org.apache.royale.compiler.config.ConfigurationBuffer;
 import org.apache.royale.compiler.config.Configurator;
@@ -86,6 +86,7 @@ import org.apache.royale.compiler.targets.ITarget.TargetType;
 import org.apache.royale.compiler.targets.ITargetSettings;
 import org.apache.royale.compiler.units.ICompilationUnit;
 import org.apache.royale.compiler.units.ICompilationUnit.UnitType;
+import org.apache.royale.compiler.utils.ClosureUtils;
 import org.apache.flex.tools.FlexTool;
 import org.apache.royale.swc.ISWC;
 import org.apache.royale.swc.ISWCFileEntry;
@@ -188,7 +189,7 @@ public class MXMLJSCRoyale implements JSCompilerEntryPoint, ProblemQueryProvider
     protected ITarget target;
     protected ITargetSettings targetSettings;
     protected IJSApplication jsTarget;
-    private IJSPublisher jsPublisher;
+    private IJSGoogPublisher jsPublisher;
     
     public MXMLJSCRoyale()
     {
@@ -337,7 +338,8 @@ public class MXMLJSCRoyale implements JSCompilerEntryPoint, ProblemQueryProvider
                         return false;
                 }
 
-                jsPublisher = (IJSPublisher) project.getBackend().createPublisher(
+                Set<String> closurePropNamesToKeep = new HashSet<String>();
+                jsPublisher = (IJSGoogPublisher) project.getBackend().createPublisher(
                         project, errors, config);
 
                 File outputFolder = jsPublisher.getOutputFolder();
@@ -414,6 +416,7 @@ public class MXMLJSCRoyale implements JSCompilerEntryPoint, ProblemQueryProvider
                             }
 	                        writer.close();
 	                    }
+                        ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep);
 	                }
 	                File externsReportFile = googConfiguration.getExternsReport();
 	                if (externsReportFile != null)
@@ -431,6 +434,7 @@ public class MXMLJSCRoyale implements JSCompilerEntryPoint, ProblemQueryProvider
                 
                 if (jsPublisher != null)
                 {
+                    jsPublisher.setClosurePropertyNamesToKeep(closurePropNamesToKeep);
                     compilationSuccess = jsPublisher.publish(problems);
                 }
                 else
@@ -817,7 +821,6 @@ public class MXMLJSCRoyale implements JSCompilerEntryPoint, ProblemQueryProvider
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
-
 	}
 	
 	/**
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyaleCordova.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyaleCordova.java
index 378339c..80bca1a 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyaleCordova.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/MXMLJSCRoyaleCordova.java
@@ -27,6 +27,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
@@ -36,8 +37,8 @@ import org.apache.royale.compiler.clients.problems.ProblemPrinter;
 import org.apache.royale.compiler.clients.problems.ProblemQuery;
 import org.apache.royale.compiler.clients.problems.ProblemQueryProvider;
 import org.apache.royale.compiler.clients.problems.WorkspaceProblemFormatter;
-import org.apache.royale.compiler.codegen.js.IJSPublisher;
 import org.apache.royale.compiler.codegen.js.IJSWriter;
+import org.apache.royale.compiler.codegen.js.goog.IJSGoogPublisher;
 import org.apache.royale.compiler.config.Configuration;
 import org.apache.royale.compiler.config.ConfigurationBuffer;
 import org.apache.royale.compiler.config.Configurator;
@@ -72,6 +73,7 @@ import org.apache.royale.compiler.targets.ITarget.TargetType;
 import org.apache.royale.compiler.targets.ITargetSettings;
 import org.apache.royale.compiler.units.ICompilationUnit;
 import org.apache.royale.compiler.units.ICompilationUnit.UnitType;
+import org.apache.royale.compiler.utils.ClosureUtils;
 import org.apache.flex.tools.FlexTool;
 import org.apache.royale.utils.ArgumentUtil;
 import org.apache.royale.utils.FilenameNormalization;
@@ -171,7 +173,7 @@ public class MXMLJSCRoyaleCordova implements JSCompilerEntryPoint, ProblemQueryP
     protected ITarget target;
     protected ITargetSettings targetSettings;
     protected IJSApplication jsTarget;
-    private IJSPublisher jsPublisher;
+    private IJSGoogPublisher jsPublisher;
     
     public MXMLJSCRoyaleCordova()
     {
@@ -320,7 +322,8 @@ public class MXMLJSCRoyaleCordova implements JSCompilerEntryPoint, ProblemQueryP
                         return false;
                 }
 
-                jsPublisher = (IJSPublisher) project.getBackend().createPublisher(
+                Set<String> closurePropNamesToKeep = new HashSet<String>();
+                jsPublisher = (IJSGoogPublisher) project.getBackend().createPublisher(
                         project, errors, config);
 
                 File outputFolder = jsPublisher.getOutputFolder();
@@ -386,11 +389,13 @@ public class MXMLJSCRoyaleCordova implements JSCompilerEntryPoint, ProblemQueryP
                             }
 	                        writer.close();
 	                    }
+                        ClosureUtils.collectPropertyNamesToKeep(cu, project, closurePropNamesToKeep);
 	                }
                 }
                 
                 if (jsPublisher != null)
                 {
+                    jsPublisher.setClosurePropertyNamesToKeep(closurePropNamesToKeep);
                     compilationSuccess = jsPublisher.publish(problems);
                 }
                 else
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/codegen/js/goog/IJSGoogPublisher.java b/compiler-jx/src/main/java/org/apache/royale/compiler/codegen/js/goog/IJSGoogPublisher.java
new file mode 100644
index 0000000..eaa3bad
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/codegen/js/goog/IJSGoogPublisher.java
@@ -0,0 +1,33 @@
+/*
+ *
+ *  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 org.apache.royale.compiler.codegen.js.goog;
+
+import java.util.Set;
+
+import org.apache.royale.compiler.codegen.js.IJSPublisher;
+
+/**
+ * The {@link IJSGoogPublisher} interface allows the abstraction of project output
+ * generation.
+ */
+public interface IJSGoogPublisher extends IJSPublisher
+{
+	void setClosurePropertyNamesToKeep(Set<String> propertyNames);
+}
\ No newline at end of file
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
index 77abfad..d823a33 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
@@ -28,7 +28,7 @@ import org.apache.commons.io.filefilter.FileFileFilter;
 import org.apache.commons.io.filefilter.FileFilterUtils;
 import org.apache.commons.io.filefilter.IOFileFilter;
 import org.apache.royale.compiler.clients.problems.ProblemQuery;
-import org.apache.royale.compiler.codegen.js.IJSPublisher;
+import org.apache.royale.compiler.codegen.js.goog.IJSGoogPublisher;
 import org.apache.royale.compiler.config.Configuration;
 import org.apache.royale.compiler.css.ICSSPropertyValue;
 import org.apache.royale.compiler.definitions.IClassDefinition;
@@ -40,7 +40,6 @@ import org.apache.royale.compiler.internal.codegen.js.goog.JarSourceFile;
 import org.apache.royale.compiler.internal.css.CSSArrayPropertyValue;
 import org.apache.royale.compiler.internal.css.CSSFontFace;
 import org.apache.royale.compiler.internal.css.CSSFunctionCallPropertyValue;
-import org.apache.royale.compiler.internal.definitions.ClassDefinition;
 import org.apache.royale.compiler.internal.driver.js.royale.JSCSSCompilationSession;
 import org.apache.royale.compiler.internal.driver.js.goog.JSGoogConfiguration;
 import org.apache.royale.compiler.internal.graph.GoogDepsWriter;
@@ -58,7 +57,7 @@ import java.net.URLDecoder;
 import java.nio.charset.Charset;
 import java.util.*;
 
-public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSPublisher
+public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSGoogPublisher
 {
 
     public static final String ROYALE_OUTPUT_DIR_NAME = "bin";
@@ -103,6 +102,7 @@ public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSPublisher
     private String moduleOutput;
     private boolean useStrictPublishing;
     private List<String> additionalHTML = new ArrayList<String>();
+    private Set<String> closurePropertyNamesToKeep;
 
     private GoogDepsWriter getGoogDepsWriter(File intermediateDir, 
     										String mainClassQName, 
@@ -183,6 +183,11 @@ public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSPublisher
         return outputFolder;
     }
 
+    public void setClosurePropertyNamesToKeep(Set<String> propertyNames)
+    {
+        closurePropertyNamesToKeep = propertyNames;
+    }
+
     @Override
     public boolean publish(ProblemQuery problems) throws IOException
     {
@@ -381,6 +386,7 @@ public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSPublisher
         if (configuration.release())
         {
             compilerWrapper = new JSClosureCompilerWrapper(googConfiguration.getJSCompilerOptions());
+            compilerWrapper.setPropertyNamesToKeep(closurePropertyNamesToKeep);
         }
 
         if (compilerWrapper != null)
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java
index 2fa9464..a63a741 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogCompcConfiguration.java
@@ -446,7 +446,7 @@ public class JSGoogCompcConfiguration extends JSConfiguration
     // 'warn-public-vars'
     //
 
-    private boolean warnPublicVars = true;
+    private boolean warnPublicVars = false;
 
     public boolean getWarnPublicVars()
     {
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java
index d4e5328..9942bd0 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java
@@ -451,7 +451,7 @@ public class JSGoogConfiguration extends JSConfiguration
     // 'warn-public-vars'
     //
 
-    private boolean warnPublicVars = true;
+    private boolean warnPublicVars = false;
 
     public boolean getWarnPublicVars()
     {
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
new file mode 100644
index 0000000..785385e
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/utils/ClosureUtils.java
@@ -0,0 +1,86 @@
+/*
+ *
+ *  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 org.apache.royale.compiler.utils;
+
+import java.util.Set;
+
+import org.apache.royale.compiler.definitions.IDefinition;
+import org.apache.royale.compiler.definitions.IFunctionDefinition;
+import org.apache.royale.compiler.definitions.ITypeDefinition;
+import org.apache.royale.compiler.definitions.IVariableDefinition;
+import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
+import org.apache.royale.compiler.internal.scopes.ASProjectScope.DefinitionPromise;
+import org.apache.royale.compiler.units.ICompilationUnit;
+
+public class ClosureUtils
+{
+	public static void collectPropertyNamesToKeep(ICompilationUnit cu, RoyaleJSProject project, Set<String> result)
+    {
+        if (project.isExternalLinkage(cu))
+        {
+            return;
+        }
+		boolean renamePublic = false;
+		boolean renameProtected = true;
+        for (IDefinition def : cu.getDefinitionPromises())
+        {
+            if(def instanceof DefinitionPromise)
+            {
+                def = ((DefinitionPromise) def).getActualDefinition();
+            }
+            if (def instanceof ITypeDefinition)
+            {
+                if (def.isImplicit() || def.isNative())
+                {
+                    continue;
+                }
+                ITypeDefinition typeDef = (ITypeDefinition) def;
+                for (IDefinition localDef : typeDef.getContainedScope().getAllLocalDefinitions())
+                {
+                    if (localDef.isImplicit())
+                    {
+                        continue;
+                    }
+                    if (!localDef.isPublic() && !localDef.isProtected())
+                    {
+                        continue;
+                    }
+                    if (localDef.isProtected() && renameProtected)
+                    {
+                        continue;
+                    }
+                    if (localDef.isPublic() && renamePublic)
+                    {
+                        continue;
+                    }
+                    if (!(localDef instanceof IVariableDefinition))
+                    {
+                        continue;
+                    }
+                    if (localDef instanceof IFunctionDefinition)
+                    {
+                        continue;
+                    }
+                    result.add(localDef.getBaseName());
+                }
+            }
+        }
+    } 
+}
\ No newline at end of file
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/utils/JSClosureCompilerWrapper.java b/compiler-jx/src/main/java/org/apache/royale/compiler/utils/JSClosureCompilerWrapper.java
index ae3d614..0364d35 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/utils/JSClosureCompilerWrapper.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/utils/JSClosureCompilerWrapper.java
@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Set;
 import java.util.logging.Level;
 
 import com.google.javascript.jscomp.CheckLevel;
@@ -91,6 +92,7 @@ public class JSClosureCompilerWrapper
     private boolean skipTypeInference;
     private boolean sourceMap = false;
     private boolean verbose = false;
+    private Set<String> propertyNamesToKeep;
     
     public String targetFilePath;
     
@@ -123,6 +125,11 @@ public class JSClosureCompilerWrapper
     {
         verbose = enabled;
     }
+
+    public void setPropertyNamesToKeep(Set<String> propertyNames)
+    {
+        propertyNamesToKeep = propertyNames;
+    }
     
     public boolean compile()
     {
@@ -160,7 +167,7 @@ public class JSClosureCompilerWrapper
 
         compiler_.setPassConfig(new RoyaleClosurePassConfig(options_, 
         		jsSourceFiles_.get(jsSourceFiles_.size() - 1).getName(), 
-        		variableMapInputPath == null ? null : new File(outputFolder, variableMapInputPath)));
+        		variableMapInputPath == null ? null : new File(outputFolder, variableMapInputPath), propertyNamesToKeep));
         Result result = compiler_.compile(jsExternsFiles_, jsSourceFiles_, options_);
         
         try


[royale-compiler] 03/05: prevent-rename-public-symbols and prevent-rename-protected-symbols compiler options

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 51923a52ada24d8e7a8e7c77bcf71f01126092bb
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue Mar 31 10:03:39 2020 -0700

    prevent-rename-public-symbols and prevent-rename-protected-symbols compiler options
---
 .../codegen/js/royale/JSRoyaleDocEmitter.java      |  2 +-
 .../driver/js/goog/JSGoogConfiguration.java        | 41 ++++++++++++++++++++--
 .../apache/royale/compiler/utils/ClosureUtils.java |  8 ++---
 3 files changed, 44 insertions(+), 7 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 d3d9442..62c8e04 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
@@ -558,7 +558,7 @@ public class JSRoyaleDocEmitter extends JSGoogDocEmitter
         else
         {
         	RoyaleJSProject fjp =  (RoyaleJSProject)project;
-            boolean warnPublicVars = fjp.config != null && fjp.config.getWarnPublicVars();
+            boolean warnPublicVars = fjp.config != null && fjp.config.getWarnPublicVars() && !fjp.config.getPreventRenamePublicSymbols();
             IMetaTagsNode meta = node.getMetaTags();
             boolean bindable = false;
             if (meta != null)
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java
index 9942bd0..1d813e4 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java
@@ -425,7 +425,6 @@ public class JSGoogConfiguration extends JSConfiguration
     {
     	exportPublicSymbols = value;
     }
-
     
     //
     // 'export-protected-symbols'
@@ -446,12 +445,50 @@ public class JSGoogConfiguration extends JSConfiguration
     	exportProtectedSymbols = value;
     }
 
+    //
+    // 'prevent-rename-public-symbols'
+    //
+
+    private boolean preventRenamePublicSymbols = true;
+
+    public boolean getPreventRenamePublicSymbols()
+    {
+        return preventRenamePublicSymbols;
+    }
+
+    @Config
+    @Mapping("prevent-rename-public-symbols")
+    public void setPreventRenamePublicSymbols(ConfigurationValue cv, boolean value)
+            throws ConfigurationException
+    {
+    	preventRenamePublicSymbols = value;
+    }
+
+    //
+    // 'prevent-rename-protected-symbols'
+    //
+
+    private boolean preventRenameProtectedSymbols = true;
+
+    public boolean getPreventRenameProtectedSymbols()
+    {
+        return preventRenameProtectedSymbols;
+    }
+
+    @Config
+    @Mapping("prevent-rename-protected-symbols")
+    public void setPreventRenameProtectedSymbols(ConfigurationValue cv, boolean value)
+            throws ConfigurationException
+    {
+    	preventRenameProtectedSymbols = value;
+    }
+
     
     //
     // 'warn-public-vars'
     //
 
-    private boolean warnPublicVars = false;
+    private boolean warnPublicVars = true;
 
     public boolean getWarnPublicVars()
     {
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 785385e..b94fdf2 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
@@ -37,8 +37,8 @@ public class ClosureUtils
         {
             return;
         }
-		boolean renamePublic = false;
-		boolean renameProtected = true;
+		boolean preventRenamePublic = project.config.getPreventRenamePublicSymbols();
+		boolean preventRenameProtected = project.config.getPreventRenameProtectedSymbols();
         for (IDefinition def : cu.getDefinitionPromises())
         {
             if(def instanceof DefinitionPromise)
@@ -62,11 +62,11 @@ public class ClosureUtils
                     {
                         continue;
                     }
-                    if (localDef.isProtected() && renameProtected)
+                    if (localDef.isProtected() && !preventRenameProtected)
                     {
                         continue;
                     }
-                    if (localDef.isPublic() && renamePublic)
+                    if (localDef.isPublic() && !preventRenamePublic)
                     {
                         continue;
                     }


[royale-compiler] 02/05: Merge branch 'develop' into rename-control

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 ac021e8342a03082fcb388e0960046abe6ac48a3
Merge: 21d8cae 940801b
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Mar 30 18:31:26 2020 -0700

    Merge branch 'develop' into rename-control

 .../compiler/internal/codegen/js/royale/TestRoyaleClass.java      | 4 ++--
 .../internal/codegen/js/royale/TestRoyaleFieldMembers.java        | 8 ++++----
 .../compiler/internal/codegen/js/royale/TestRoyalePackage.java    | 1 +
 .../internal/codegen/mxml/royale/TestRoyaleMXMLScript.java        | 1 +
 4 files changed, 8 insertions(+), 6 deletions(-)