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 2026/05/19 16:35:36 UTC
(royale-compiler) 02/03: IJSMetaAttributeConstants: move from some magic strings to constants for existing JS metadata
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 b1370d2e1ce5e0f2a397bace45adc1fca0444205
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue May 19 09:30:15 2026 -0700
IJSMetaAttributeConstants: move from some magic strings to constants for existing JS metadata
---
.../apache/royale/compiler/clients/COMPJSCNative.java | 13 +++++++------
.../apache/royale/compiler/clients/COMPJSCRoyale.java | 13 +++++++------
.../compiler/constants/IJSMetaAttributeConstants.java | 18 ++++++++++++++++++
.../codegen/mxml/royale/MXMLRoyalePublisher.java | 13 +++++++------
.../internal/parsing/as/RoyaleASDocDelegate.java | 5 +++--
.../compiler/internal/projects/RoyaleJSProject.java | 5 +++--
.../apache/royale/compiler/utils/DefinitionUtils.java | 6 ++----
7 files changed, 47 insertions(+), 26 deletions(-)
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
index b8998ca3f..8f4e65196 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCNative.java
@@ -57,6 +57,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.royale.compiler.clients.MXMLJSC.JSTargetType;
import org.apache.royale.compiler.clients.problems.ProblemQuery;
import org.apache.royale.compiler.codegen.js.IJSWriter;
+import org.apache.royale.compiler.constants.IJSMetaAttributeConstants;
import org.apache.royale.compiler.definitions.IDefinition;
import org.apache.royale.compiler.definitions.metadata.IMetaTag;
import org.apache.royale.compiler.definitions.metadata.IMetaTagAttribute;
@@ -519,12 +520,12 @@ public class COMPJSCNative extends MXMLJSCNative
{
def = ((DefinitionPromise) def).getActualDefinition();
}
- for (IMetaTag metaTag : def.getMetaTagsByName("JSIncludeScript"))
+ for (IMetaTag metaTag : def.getMetaTagsByName(IJSMetaAttributeConstants.ATTRIBUTE_INCLUDE_SCRIPT))
{
for (IMetaTagAttribute metaAttr : metaTag.getAllAttributes())
{
String key = metaAttr.getKey();
- if ("source".equals(key) || key == null)
+ if (IJSMetaAttributeConstants.NAME_INCLUDE_SCRIPT_SOURCE.equals(key) || key == null)
{
String includePath = metaAttr.getValue();
@@ -555,12 +556,12 @@ public class COMPJSCNative extends MXMLJSCNative
}
}
}
- for (IMetaTag metaTag : def.getMetaTagsByName("JSIncludeCSS"))
+ for (IMetaTag metaTag : def.getMetaTagsByName(IJSMetaAttributeConstants.ATTRIBUTE_INCLUDE_CSS))
{
for (IMetaTagAttribute metaAttr : metaTag.getAllAttributes())
{
String key = metaAttr.getKey();
- if ("source".equals(key) || key == null)
+ if (IJSMetaAttributeConstants.NAME_INCLUDE_CSS_SOURCE.equals(key) || key == null)
{
String includePath = metaAttr.getValue();
@@ -591,12 +592,12 @@ public class COMPJSCNative extends MXMLJSCNative
}
}
}
- for (IMetaTag metaTag : def.getMetaTagsByName("JSIncludeAsset"))
+ for (IMetaTag metaTag : def.getMetaTagsByName(IJSMetaAttributeConstants.ATTRIBUTE_INCLUDE_ASSET))
{
for (IMetaTagAttribute metaAttr : metaTag.getAllAttributes())
{
String key = metaAttr.getKey();
- if ("source".equals(key) || key == null)
+ if (IJSMetaAttributeConstants.NAME_INCLUDE_ASSET_SOURCE.equals(key) || key == null)
{
String includePath = metaAttr.getValue();
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
index 989aa8c93..b3e7ab73a 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/COMPJSCRoyale.java
@@ -49,6 +49,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.royale.compiler.clients.MXMLJSC.JSTargetType;
import org.apache.royale.compiler.clients.problems.ProblemQuery;
import org.apache.royale.compiler.codegen.js.IJSWriter;
+import org.apache.royale.compiler.constants.IJSMetaAttributeConstants;
import org.apache.royale.compiler.definitions.IDefinition;
import org.apache.royale.compiler.definitions.metadata.IMetaTag;
import org.apache.royale.compiler.definitions.metadata.IMetaTagAttribute;
@@ -586,12 +587,12 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
{
def = ((DefinitionPromise) def).getActualDefinition();
}
- for (IMetaTag metaTag : def.getMetaTagsByName("JSIncludeScript"))
+ for (IMetaTag metaTag : def.getMetaTagsByName(IJSMetaAttributeConstants.ATTRIBUTE_INCLUDE_SCRIPT))
{
for (IMetaTagAttribute metaAttr : metaTag.getAllAttributes())
{
String key = metaAttr.getKey();
- if ("source".equals(key) || key == null)
+ if (IJSMetaAttributeConstants.NAME_INCLUDE_SCRIPT_SOURCE.equals(key) || key == null)
{
String includePath = metaAttr.getValue();
@@ -622,12 +623,12 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
}
}
}
- for (IMetaTag metaTag : def.getMetaTagsByName("JSIncludeCSS"))
+ for (IMetaTag metaTag : def.getMetaTagsByName(IJSMetaAttributeConstants.ATTRIBUTE_INCLUDE_CSS))
{
for (IMetaTagAttribute metaAttr : metaTag.getAllAttributes())
{
String key = metaAttr.getKey();
- if ("source".equals(key) || key == null)
+ if (IJSMetaAttributeConstants.NAME_INCLUDE_CSS_SOURCE.equals(key) || key == null)
{
String includePath = metaAttr.getValue();
@@ -658,12 +659,12 @@ public class COMPJSCRoyale extends MXMLJSCRoyale
}
}
}
- for (IMetaTag metaTag : def.getMetaTagsByName("JSIncludeAsset"))
+ for (IMetaTag metaTag : def.getMetaTagsByName(IJSMetaAttributeConstants.ATTRIBUTE_INCLUDE_ASSET))
{
for (IMetaTagAttribute metaAttr : metaTag.getAllAttributes())
{
String key = metaAttr.getKey();
- if ("source".equals(key) || key == null)
+ if (IJSMetaAttributeConstants.NAME_INCLUDE_ASSET_SOURCE.equals(key) || key == null)
{
String includePath = metaAttr.getValue();
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/constants/IJSMetaAttributeConstants.java b/compiler-jx/src/main/java/org/apache/royale/compiler/constants/IJSMetaAttributeConstants.java
index 0b11f585c..cd9bd1a6c 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/constants/IJSMetaAttributeConstants.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/constants/IJSMetaAttributeConstants.java
@@ -40,4 +40,22 @@ public interface IJSMetaAttributeConstants
static final String NAME_FOR_EACH_OVERRIDE_ITERATOR_METHOD = "iteratorMethod";
static final String NAME_FOR_EACH_OVERRIDE_ITERATOR_NEXT_METHOD = "iteratorNextMethod";
static final String NAME_FOR_EACH_OVERRIDE_ITERATOR_HAS_NEXT_METHOD = "iteratorHasNextMethod";
+
+ // [JSIncludeScript]
+ static final String ATTRIBUTE_INCLUDE_SCRIPT = "JSIncludeScript";
+ static final String NAME_INCLUDE_SCRIPT_SOURCE = "source";
+
+ // [JSIncludeCSS]
+ static final String ATTRIBUTE_INCLUDE_CSS = "JSIncludeCSS";
+ static final String NAME_INCLUDE_CSS_SOURCE = "source";
+
+ // [JSIncludeAsset]
+ static final String ATTRIBUTE_INCLUDE_ASSET = "JSIncludeAsset";
+ static final String NAME_INCLUDE_ASSET_SOURCE = "source";
+
+ // [JSModule]
+ static final String ATTRIBUTE_MODULE = "JSModule";
+
+ // [JSRoyaleSuppressExport]
+ static final String ATTRIBUTE_SUPPRESS_EXPORT = "JSRoyaleSuppressExport";
}
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 627a7a11d..b11561d6f 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
@@ -32,6 +32,7 @@ import org.apache.royale.compiler.clients.problems.ProblemQuery;
import org.apache.royale.compiler.codegen.js.royale.IJSRoyalePublisher;
import org.apache.royale.compiler.common.ISourceLocation;
import org.apache.royale.compiler.config.Configuration;
+import org.apache.royale.compiler.constants.IJSMetaAttributeConstants;
import org.apache.royale.compiler.css.ICSSPropertyValue;
import org.apache.royale.compiler.definitions.IClassDefinition;
import org.apache.royale.compiler.definitions.IDefinition;
@@ -1122,13 +1123,13 @@ public class MXMLRoyalePublisher extends JSPublisher implements IJSRoyalePublish
if (def instanceof DefinitionPromise)
{
def = ((DefinitionPromise) def).getActualDefinition();
- for (IMetaTag metaTag : def.getMetaTagsByName("JSIncludeScript"))
+ for (IMetaTag metaTag : def.getMetaTagsByName(IJSMetaAttributeConstants.ATTRIBUTE_INCLUDE_SCRIPT))
{
boolean foundSource = false;
for (IMetaTagAttribute metaAttr : metaTag.getAllAttributes())
{
String key = metaAttr.getKey();
- if ("source".equals(key) || key == null)
+ if (IJSMetaAttributeConstants.NAME_INCLUDE_SCRIPT_SOURCE.equals(key) || key == null)
{
foundSource = true;
@@ -1170,13 +1171,13 @@ public class MXMLRoyalePublisher extends JSPublisher implements IJSRoyalePublish
problems.add(new JSIncludeMetaTagNoSourceAttributeProblem(metaTag));
}
}
- for (IMetaTag metaTag : def.getMetaTagsByName("JSIncludeCSS"))
+ for (IMetaTag metaTag : def.getMetaTagsByName(IJSMetaAttributeConstants.ATTRIBUTE_INCLUDE_CSS))
{
boolean foundSource = false;
for (IMetaTagAttribute metaAttr : metaTag.getAllAttributes())
{
String key = metaAttr.getKey();
- if ("source".equals(key) || key == null)
+ if (IJSMetaAttributeConstants.NAME_INCLUDE_CSS_SOURCE.equals(key) || key == null)
{
foundSource = true;
@@ -1218,13 +1219,13 @@ public class MXMLRoyalePublisher extends JSPublisher implements IJSRoyalePublish
problems.add(new JSIncludeMetaTagNoSourceAttributeProblem(metaTag));
}
}
- for (IMetaTag metaTag : def.getMetaTagsByName("JSIncludeAsset"))
+ for (IMetaTag metaTag : def.getMetaTagsByName(IJSMetaAttributeConstants.ATTRIBUTE_INCLUDE_ASSET))
{
boolean foundSource = false;
for (IMetaTagAttribute metaAttr : metaTag.getAllAttributes())
{
String key = metaAttr.getKey();
- if ("source".equals(key) || key == null)
+ if (IJSMetaAttributeConstants.NAME_INCLUDE_ASSET_SOURCE.equals(key) || key == null)
{
foundSource = true;
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/parsing/as/RoyaleASDocDelegate.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/parsing/as/RoyaleASDocDelegate.java
index 1e1be6e22..10d8c6502 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/parsing/as/RoyaleASDocDelegate.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/parsing/as/RoyaleASDocDelegate.java
@@ -30,6 +30,7 @@ import org.apache.royale.compiler.asdoc.IMetadataParserASDocDelegate;
import org.apache.royale.compiler.asdoc.IPackageDITAParser;
import org.apache.royale.compiler.asdoc.royale.ASDocComment;
import org.apache.royale.compiler.common.ISourceLocation;
+import org.apache.royale.compiler.constants.IJSMetaAttributeConstants;
import org.apache.royale.compiler.definitions.IDocumentableDefinition;
import org.apache.royale.compiler.internal.codegen.js.utils.DocEmitterUtils;
import org.apache.royale.compiler.internal.tree.as.BaseDefinitionNode;
@@ -137,8 +138,8 @@ public final class RoyaleASDocDelegate implements IASDocDelegate
tags = new MetaTagsNode();
((BaseDefinitionNode) definitionNode).setMetaTags(tags);
}
- if (!tags.hasTagByName(DefinitionUtils.JSROYALE_SUPPRESS_EXPORT)) {
- tags.addTag(new BasicMetaTagNode(DefinitionUtils.JSROYALE_SUPPRESS_EXPORT));
+ if (!tags.hasTagByName(IJSMetaAttributeConstants.ATTRIBUTE_SUPPRESS_EXPORT)) {
+ tags.addTag(new BasicMetaTagNode(IJSMetaAttributeConstants.ATTRIBUTE_SUPPRESS_EXPORT));
}
}
currentToken = null;
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleJSProject.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleJSProject.java
index 8bd86591a..5413d09c5 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleJSProject.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/projects/RoyaleJSProject.java
@@ -37,6 +37,7 @@ import org.apache.royale.compiler.common.DependencyTypeSet;
import org.apache.royale.compiler.config.CompilerDiagnosticsConstants;
import org.apache.royale.compiler.config.Configuration;
import org.apache.royale.compiler.config.Configurator;
+import org.apache.royale.compiler.constants.IJSMetaAttributeConstants;
import org.apache.royale.compiler.css.ICSSMediaQueryCondition;
import org.apache.royale.compiler.css.ICSSRule;
import org.apache.royale.compiler.definitions.IClassDefinition;
@@ -330,9 +331,9 @@ public class RoyaleJSProject extends RoyaleProject implements IRoyaleJSProject
while(iterator.hasNext())
{
IDefinition def = iterator.next();
- if (def.getQualifiedName().equals(qname) && def.hasMetaTagByName("JSModule"))
+ if (def.getQualifiedName().equals(qname) && def.hasMetaTagByName(IJSMetaAttributeConstants.ATTRIBUTE_MODULE))
{
- return def.getMetaTagByName("JSModule");
+ return def.getMetaTagByName(IJSMetaAttributeConstants.ATTRIBUTE_MODULE);
}
}
}
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/utils/DefinitionUtils.java b/compiler-jx/src/main/java/org/apache/royale/compiler/utils/DefinitionUtils.java
index dfb52bdd1..9afb59faf 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/utils/DefinitionUtils.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/utils/DefinitionUtils.java
@@ -19,6 +19,7 @@
package org.apache.royale.compiler.utils;
+import org.apache.royale.compiler.constants.IJSMetaAttributeConstants;
import org.apache.royale.compiler.definitions.IClassDefinition;
import org.apache.royale.compiler.definitions.IDefinition;
import org.apache.royale.compiler.definitions.IInterfaceDefinition;
@@ -33,9 +34,6 @@ import org.apache.royale.compiler.tree.as.IDocumentableDefinitionNode;
*/
public class DefinitionUtils
{
-
- public static final String JSROYALE_SUPPRESS_EXPORT = "JSRoyaleSuppressExport";
-
/**
* Utility method for checking if a definition has been marked to be suppressed for export by Closure.
* The implementation is to check for [JSRoyaleSuppressExport] Metadata.
@@ -44,7 +42,7 @@ public class DefinitionUtils
* @param def the definition to inspect as suppressed for export
*/
public static boolean hasExportSuppressed(IDefinition def) {
- return def.hasMetaTagByName(JSROYALE_SUPPRESS_EXPORT);
+ return def.hasMetaTagByName(IJSMetaAttributeConstants.ATTRIBUTE_SUPPRESS_EXPORT);
}