incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gordonsm...@apache.org
Subject svn commit: r1407673 - in /incubator/flex/falcon/trunk: compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStringNodeTests.java compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLTreeBuilder.java
Date Fri, 09 Nov 2012 22:32:18 GMT
Author: gordonsmith
Date: Fri Nov  9 22:32:18 2012
New Revision: 1407673

URL: http://svn.apache.org/viewvc?rev=1407673&view=rev
Log:
Falcon: An empty attribute of type String, Object, or * now produces an empty-string value,
as in the old compiler. (FLEX-32240)

Modified:
    incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStringNodeTests.java
    incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLTreeBuilder.java

Modified: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStringNodeTests.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStringNodeTests.java?rev=1407673&r1=1407672&r2=1407673&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStringNodeTests.java
(original)
+++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLStringNodeTests.java
Fri Nov  9 22:32:18 2012
@@ -49,7 +49,7 @@ public class MXMLStringNodeTests extends
 	{
 		String code = "<fx:String/>";
 		IMXMLStringNode node = getMXMLStringNode(code);
-		assertThat("getValue", node.getValue(), is((String)null));
+		assertThat("getValue", node.getValue(), is((String)"")); // was null in old compiler, but
this is inconsistent with an empty String attribute
 		//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
 	}
 	
@@ -58,7 +58,7 @@ public class MXMLStringNodeTests extends
 	{
 		String code = "<fx:String></fx:String>";
 		IMXMLStringNode node = getMXMLStringNode(code);
-		assertThat("getValue", node.getValue(), is((String)null));
+		assertThat("getValue", node.getValue(), is((String)""));
 		//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
 	}
 
@@ -67,7 +67,7 @@ public class MXMLStringNodeTests extends
 	{
 		String code = "<fx:String> \t\r\n</fx:String>";
 		IMXMLStringNode node = getMXMLStringNode(code);
-		assertThat("getValue", node.getValue(), is((String)null));
+		assertThat("getValue", node.getValue(), is((String)""));
 		//assertThat("getExpressionNode", node.getExpressionNode(), is((IASNode)null));
 	}
 	

Modified: incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLTreeBuilder.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLTreeBuilder.java?rev=1407673&r1=1407672&r2=1407673&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLTreeBuilder.java
(original)
+++ incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLTreeBuilder.java
Fri Nov  9 22:32:18 2012
@@ -455,23 +455,25 @@ public class MXMLTreeBuilder
                                               EnumSet<TextParsingFlags> flags,
                                               Object defaultValue)
     {
-        MXMLLiteralNode literalNode = null;
-
         String text = SourceFragmentsReader.concatLogicalText(fragments);
 
         Object value = mxmlDialect.isWhitespace(text) ?
                        defaultValue :
                        parseValue(propertyNode, type, text, flags);
 
-        if (value != null ||
-            type.getQualifiedName().equals(IASLanguageConstants.String))
+        if (value == null)
         {
-            // Note: A null value for type String is allowed
-            // and creates an MXMLLiteralNode whose value is null.
-            literalNode = new MXMLLiteralNode(null, value);
-            literalNode.setSourceLocation(location);
+            String typeName = type.getQualifiedName();
+            if (typeName.equals(IASLanguageConstants.String) ||
+                typeName.equals(IASLanguageConstants.Object)||
+                typeName.equals(IASLanguageConstants.ANY_TYPE))
+            {
+                value = "";
+            }
         }
-
+        
+        MXMLLiteralNode literalNode = new MXMLLiteralNode(null, value);
+        literalNode.setSourceLocation(location);
         return literalNode;
     }
 



Mime
View raw message