You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2021/09/30 04:12:56 UTC

[royale-compiler] branch develop updated: Added a new compiler option 'force-local-id', which is false by default. Setting this to true has the effect of treating all id="name" as localId="name" which avoids lots of small mxml file changes when localId behaviour is the preferred behavior for the entire compilation scope, which (in my experience) is for the majority of cases.

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

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


The following commit(s) were added to refs/heads/develop by this push:
     new 60ffbb2  Added a new compiler option 'force-local-id', which is false by default. Setting this to true has the effect of treating all id="name" as localId="name" which avoids lots of small mxml file changes when localId behaviour is the preferred behavior for the entire compilation scope, which (in my experience) is for the majority of cases.
60ffbb2 is described below

commit 60ffbb2e0ea6dafd7ada378e9c68559e81cb07d1
Author: greg-dove <gr...@gmail.com>
AuthorDate: Thu Sep 30 17:12:43 2021 +1300

    Added a new compiler option 'force-local-id', which is false by default.
    Setting this to true has the effect of treating all id="name" as localId="name" which avoids lots of small mxml file changes when localId behaviour is the preferred behavior for the entire compilation scope, which (in my experience) is for the majority of cases.
---
 RELEASE_NOTES.md                                   |  1 +
 .../royale/compiler/config/Configuration.java      | 24 ++++++++++++++++++++++
 .../compiler/internal/projects/RoyaleProject.java  | 19 +++++++++++++++++
 .../projects/RoyaleProjectConfigurator.java        |  2 ++
 .../internal/tree/mxml/MXMLInstanceNode.java       |  9 +++++---
 5 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 3fb23f1..93d15b5 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -5,6 +5,7 @@ Apache Royale Compiler 0.9.9
 =================
 
 - **asformat** is a new formatter for ActionScript code
+- Added a boolean new compiler option 'compiler.mxml.force-local-id' - (short commandline form 'force-local-id'). This is a quick way to avoid propagating id attributes to browser DOM in JSRoyale. 
 
 Apache Royale Compiler 0.9.8
 =================
diff --git a/compiler-common/src/main/java/org/apache/royale/compiler/config/Configuration.java b/compiler-common/src/main/java/org/apache/royale/compiler/config/Configuration.java
index d41198e..b9c81e6 100644
--- a/compiler-common/src/main/java/org/apache/royale/compiler/config/Configuration.java
+++ b/compiler-common/src/main/java/org/apache/royale/compiler/config/Configuration.java
@@ -2614,6 +2614,30 @@ public class Configuration
     }
 
     //
+    // 'compiler.mxml.force-local-id' option
+    //
+    private Boolean forceLocalId = false;
+
+    public Boolean getCompilerMxmlForceLocalId()
+    {
+        return forceLocalId;
+    }
+
+    /**
+     * Specifies whether localId behavior should be 'forced' for the current compilation target. This has the
+     * effect of treating all mxml id="name" specifications as localId="name" for the current compilation target.
+     * This is false by default and the results of usage will vary by compilation target depending on the effect of using
+     * localId vs. id (e.g. for swf target it has no effect, because they are effectively the same)
+     */
+    @Config
+    @Mapping({ "compiler", "mxml", "force-local-id" })
+    @RoyaleOnly
+    public void setCompilerMxmlMxmlForceLocalId(ConfigurationValue cv, Boolean asData) throws ConfigurationException
+    {
+        forceLocalId = asData;
+    }
+
+    //
     // 'compiler.info.flex' option
     // used to suppress some of info() fields
     //
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
index 0613ffe..a97354f 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProject.java
@@ -290,6 +290,15 @@ public class RoyaleProject extends ASProject implements IRoyaleProject, ICompile
      * Currently this is "mx.core.IMXMLObject".
      */
     private String mxmlObjectInterface;
+
+    /**
+     * Whether localId behavior should be 'forced'
+     * for the current compilation target. This has the
+     * effect of treating all mxml id="name" specifications
+     * as localId="name" for the current compilation target.
+     * This is false by default and is managed via Configuration
+     */
+    private Boolean mxmlForceLocalId;
     
     /**
      * The fully-qualified name of the runtime interface
@@ -765,6 +774,16 @@ public class RoyaleProject extends ASProject implements IRoyaleProject, ICompile
         this.mxmlObjectInterface = mxmlObjectInterface;
     }
 
+    public Boolean getMXMLForceLocalId()
+    {
+        return mxmlForceLocalId;
+    }
+
+    public void setMXMLForceLocalId(Boolean mxmlForceLocalId)
+    {
+        this.mxmlForceLocalId = mxmlForceLocalId;
+    }
+
     public String getProxyBaseClass()
     {
         return proxyBaseClass;
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProjectConfigurator.java b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProjectConfigurator.java
index 56d2265..e9dc454 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProjectConfigurator.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleProjectConfigurator.java
@@ -261,6 +261,8 @@ public class RoyaleProjectConfigurator extends Configurator
             configValue = configuration.getProxyBaseClass();
             project.setProxyBaseClass(configValue);
 
+            project.setMXMLForceLocalId(configuration.getCompilerMxmlForceLocalId());
+
             project.setStrictXML(configuration.isStrictXML());
             project.setAllowPrivateNameConflicts(configuration.getCompilerAllowPrivateNameConflicts());
 
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLInstanceNode.java b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLInstanceNode.java
index 3d6d469..c1f6fc2 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLInstanceNode.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLInstanceNode.java
@@ -214,9 +214,12 @@ public class MXMLInstanceNode extends MXMLClassReferenceNodeBase implements IMXM
                                                IMXMLTagAttributeData attribute,
                                                MXMLNodeInfo info)
     {
-        if (attribute.isSpecialAttribute(ATTRIBUTE_ID))
-            id = processIDAttribute(builder, attribute);
-
+        if (attribute.isSpecialAttribute(ATTRIBUTE_ID)) {
+            if (builder.getProject().getMXMLForceLocalId())
+                localId = processIDAttribute(builder, attribute);
+            else
+                id = processIDAttribute(builder, attribute);
+        }
         else if (attribute.isSpecialAttribute(ATTRIBUTE_LOCAL_ID))
             localId = processIDAttribute(builder, attribute);