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 2024/05/28 21:38:49 UTC
(royale-compiler) 02/05: compiler: fix parsing of source, destination, and twoWay values in MXMLBindingNode
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 04b917f41dc97a50d25d00a0749921419cf4b33c
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue May 28 13:39:05 2024 -0700
compiler: fix parsing of source, destination, and twoWay values in MXMLBindingNode
Had a null exception of attribute existed without value, and twoWay didn't report an error for value that wasn't true or false
---
RELEASE_NOTES.md | 2 ++
.../internal/tree/mxml/MXMLBindingNode.java | 33 ++++++++++++++++++----
2 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index c775e8638..a0245d597 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -35,6 +35,8 @@ Apache Royale Compiler 0.9.11
- compiler: Add CSS support for declaring custom properties (CSS variables) and using `var` function in JS.
- compiler: Fix crash when `[Style]` is of type `Object` and value is passed in MXML.
- compiler: Fix null pointer exception when omitting quoted `<fx:Style>` value for `source` attribute.
+- compiler: Fix null pointer exception when omitting quoted `<fx:Binding>` value for `source`, `destination`, and `twoWay` attributes.
+- compiler: Fix missing problem for invalid `twoWay` value for `<fx:Binding>` tag.
- debugger: Fix exception when evaluating certain expressions at run-time.
- formatter: Added `insert-new-line-else` configuration option.
- formatter: Filtered out unnecessary compiler warnings.
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLBindingNode.java b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLBindingNode.java
index 5ed122b3f..193422ab1 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLBindingNode.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLBindingNode.java
@@ -27,6 +27,7 @@ import org.apache.royale.compiler.mxml.IMXMLTagAttributeData;
import org.apache.royale.compiler.mxml.IMXMLTagData;
import org.apache.royale.compiler.problems.ICompilerProblem;
import org.apache.royale.compiler.problems.MXMLEmptyAttributeProblem;
+import org.apache.royale.compiler.problems.MXMLInvalidTextForTypeProblem;
import org.apache.royale.compiler.problems.MXMLRequiredAttributeProblem;
import org.apache.royale.compiler.problems.MXMLSameBindingSourceAndDestinationProblem;
import org.apache.royale.compiler.tree.ASTNodeID;
@@ -109,14 +110,24 @@ public class MXMLBindingNode extends MXMLNodeBase implements IMXMLBindingNode
}
else if (attribute.isSpecialAttribute(ATTRIBUTE_TWO_WAY))
{
- String value = attribute.getMXMLDialect().trim(attribute.getRawValue());
- if (value.equals(IASLanguageConstants.TRUE))
+ String twoWayValue = "";
+ String rawTwoWayValue = attribute.getRawValue();
+ if (rawTwoWayValue != null)
+ {
+ twoWayValue = attribute.getMXMLDialect().trim(rawTwoWayValue);
+ }
+ if (twoWayValue.equals(IASLanguageConstants.TRUE))
+ {
twoWay = true;
- else if (value.equals(IASLanguageConstants.FALSE))
+ }
+ else if (twoWayValue.equals(IASLanguageConstants.FALSE))
+ {
twoWay = false;
+ }
else
{
- // TODO Report a problem;
+ MXMLInvalidTextForTypeProblem problem = new MXMLInvalidTextForTypeProblem(attribute, twoWayValue, "Boolean");
+ builder.addProblem(problem);
}
}
else
@@ -154,7 +165,12 @@ public class MXMLBindingNode extends MXMLNodeBase implements IMXMLBindingNode
}
else
{
- trimmedSourceValue = builder.getMXMLDialect().trim(sourceAttribute.getRawValue());
+ trimmedSourceValue = "";
+ String rawSourceValue = sourceAttribute.getRawValue();
+ if (rawSourceValue != null)
+ {
+ trimmedSourceValue = builder.getMXMLDialect().trim(rawSourceValue);
+ }
if (trimmedSourceValue.isEmpty())
{
// 'source' attribute value cannot be empty
@@ -173,7 +189,12 @@ public class MXMLBindingNode extends MXMLNodeBase implements IMXMLBindingNode
}
else
{
- trimmedDestinationValue = builder.getMXMLDialect().trim(destinationAttribute.getRawValue());
+ trimmedDestinationValue = "";
+ String rawDestValue = destinationAttribute.getRawValue();
+ if (rawDestValue != null)
+ {
+ trimmedDestinationValue = builder.getMXMLDialect().trim(rawDestValue);
+ }
if (trimmedDestinationValue.isEmpty())
{
// 'destination' attribute value cannot be empty