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 780afff2042e6f7d0fc549958b5f83554f00b039 Author: Josh Tynjala <[email protected]> AuthorDate: Thu Jul 23 12:40:40 2026 -0700 MXMLStateSplitter: allow dot (.) character in MXML namespace prefixes Examples: xmlns:com.exmaple="com.example.*" <com.example:MyClass/> The Flex compiler differentiated between . as a state override and . in an MXML namespace prefix. These locations for the . don't conflict at all, so it is safe to make the Royale behavior support this same syntax as Flex. --- RELEASE_NOTES.md | 1 + .../compiler/internal/mxml/MXMLStateSplitter.java | 43 ++++++++++++++++------ .../problems/MXMLStateSyntaxNotAllowedProblem.java | 40 ++++++++++++++++++++ 3 files changed, 72 insertions(+), 12 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 06e7da227..eb1d3927a 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -92,6 +92,7 @@ Apache Royale Compiler 1.0.0 - compiler: Fixed null exception when emitting embedded plain text to JS. - compiler: Fixed operand stack underflow error when using data binding in MXML to assign to `<fx:Object>` property. - compiler: Fixed race condition in populating metadata on definitions. +- compiler: Fixed dot character in MXML namespace prefixes not being recognized, like `xmlns:com.example="com.example.*"`. - debugger: Added missing isolate ID to SWF load and unload events. - debugger: Fixed debugger targeting the current JDK version instead of the intended minimum JDK version. - debugger: Fixed localized messages appearing as unprocessed tokens. diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLStateSplitter.java b/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLStateSplitter.java index cee707d16..b938fb40e 100644 --- a/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLStateSplitter.java +++ b/compiler/src/main/java/org/apache/royale/compiler/internal/mxml/MXMLStateSplitter.java @@ -22,10 +22,10 @@ package org.apache.royale.compiler.internal.mxml; import java.util.Collection; import org.apache.royale.compiler.filespecs.IFileSpecification; -import org.apache.royale.compiler.internal.parsing.mxml.MXMLToken; import org.apache.royale.compiler.parsing.IMXMLToken; +import org.apache.royale.compiler.parsing.MXMLTokenTypes; import org.apache.royale.compiler.problems.ICompilerProblem; -import org.apache.royale.compiler.problems.SyntaxProblem; +import org.apache.royale.compiler.problems.MXMLStateSyntaxNotAllowedProblem; /** * Simple utility for parsing attribute.state phrases. @@ -37,16 +37,35 @@ public class MXMLStateSplitter */ public MXMLStateSplitter(IMXMLToken nameToken, MXMLDialect mxmlDialect, Collection<ICompilerProblem> problems, IFileSpecification fileSpec) { - // Is there a dot in the name? String name = nameToken.getText(); - int i = name.indexOf('.'); - if (i >= 0) + + // Is there a dot in the name? + int dotIndex = name.lastIndexOf('.'); + boolean dotIsStateSyntax = false; + if (dotIndex != -1) + { + // a namespace prefix is allowed to include the "." character + switch (nameToken.getType()) + { + case MXMLTokenTypes.TOKEN_NAME: + dotIsStateSyntax = !name.startsWith("xmlns:"); + break; + case MXMLTokenTypes.TOKEN_OPEN_TAG_START: + case MXMLTokenTypes.TOKEN_CLOSE_TAG_START: + int nsIndex = name.indexOf(":"); + dotIsStateSyntax = nsIndex < dotIndex; + break; + default: + dotIsStateSyntax = true; + } + } + if (dotIsStateSyntax) { if (mxmlDialect != null && mxmlDialect.isEqualToOrAfter(MXMLDialect.MXML_2009)) { - baseName = name.substring(0, i); - stateName = name.substring(i + 1); - stateNameOffset = i + 1; + baseName = name.substring(0, dotIndex); + stateName = name.substring(dotIndex + 1); + stateNameOffset = dotIndex + 1; } else { @@ -54,15 +73,15 @@ public class MXMLStateSplitter baseName = name; stateName = null; - // TODO: I don't think is going to make the right kind of "problem" - // This is how the old code worked, but I think it will give a strange message if (problems != null && fileSpec != null) - problems.add(new SyntaxProblem((MXMLToken)nameToken, "Spark state overrides not supported by current language version")); + { + problems.add(new MXMLStateSyntaxNotAllowedProblem(nameToken, name)); + } } } else { - // no dot. + // no dot, or a dot that is allowed in the namespace prefix baseName = name; stateNameOffset = -1; stateName = null; diff --git a/compiler/src/main/java/org/apache/royale/compiler/problems/MXMLStateSyntaxNotAllowedProblem.java b/compiler/src/main/java/org/apache/royale/compiler/problems/MXMLStateSyntaxNotAllowedProblem.java new file mode 100644 index 000000000..9a0fec13d --- /dev/null +++ b/compiler/src/main/java/org/apache/royale/compiler/problems/MXMLStateSyntaxNotAllowedProblem.java @@ -0,0 +1,40 @@ +/* + * + * 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.problems; + +import org.apache.royale.compiler.parsing.IMXMLToken; + +/** + * Problem generated when state syntax is used with a language version before + * MXML 2009. + */ +public final class MXMLStateSyntaxNotAllowedProblem extends MXMLSyntaxProblem +{ + public static final String DESCRIPTION = + "State overrides for attribute '${attribute} not supported by current MXML language version."; + + public MXMLStateSyntaxNotAllowedProblem(IMXMLToken site, String attribute) + { + super(site); + this.attribute = attribute; + } + + public final String attribute; +}
