You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2016/04/12 18:51:14 UTC

[1/2] git commit: [flex-falcon] [refs/heads/develop] - handle multiline XML literals

Repository: flex-falcon
Updated Branches:
  refs/heads/develop b0cd32c79 -> 33821939f


handle multiline XML literals


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/11e53909
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/11e53909
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/11e53909

Branch: refs/heads/develop
Commit: 11e53909863d82632c362d67aa37aab3d6631623
Parents: b0cd32c
Author: Alex Harui <ah...@apache.org>
Authored: Tue Apr 12 09:36:25 2016 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Apr 12 09:36:35 2016 -0700

----------------------------------------------------------------------
 .../js/flexjs/TestFlexJSGlobalClasses.java      | 16 +++++++++---
 .../internal/codegen/js/jx/LiteralEmitter.java  | 26 +++++++++++---------
 2 files changed, 26 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/11e53909/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
index 638f71b..d219506 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSGlobalClasses.java
@@ -321,7 +321,15 @@ public class TestFlexJSGlobalClasses extends TestGoogGlobalClasses
     {
         IVariableNode node = getVariable("var a:XML = <top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>");
         asBlockWalker.visitVariable(node);
-        assertOut("var /** @type {XML} */ a = new XML( \"<top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>\") ");
+        assertOut("var /** @type {XML} */ a = new XML( \"<top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>\")");
+    }
+    
+    @Test
+    public void testXMLLiteralMultiline()
+    {
+        IVariableNode node = getVariable("var a:XML = <top attr1='cat'>\n<child attr2='dog'>\n<grandchild attr3='fish'>text</grandchild>\n</child>\n</top>");
+        asBlockWalker.visitVariable(node);
+        assertOut("var /** @type {XML} */ a = new XML( \"<top attr1='cat'>\\\n<child attr2='dog'>\\\n<grandchild attr3='fish'>text</grandchild>\\\n</child>\\\n</top>\")");
     }
     
     @Test
@@ -334,7 +342,7 @@ public class TestFlexJSGlobalClasses extends TestGoogGlobalClasses
         							 "private function test() { var a:XML = <{tagname} {attributename}={attributevalue}>{content}</{tagname}>;}",
         							 VariableNode.class, WRAP_LEVEL_CLASS);
         asBlockWalker.visitVariable(node);
-        assertOut("var /** @type {XML} */ a = new XML( '<' + this.tagname + ' ' + this.attributename + '=' + this.attributevalue + '>' + this.content + '</' + this.tagname + '>') ");
+        assertOut("var /** @type {XML} */ a = new XML( '<' + this.tagname + ' ' + this.attributename + '=' + this.attributevalue + '>' + this.content + '</' + this.tagname + '>')");
     }
     
     @Test
@@ -343,7 +351,7 @@ public class TestFlexJSGlobalClasses extends TestGoogGlobalClasses
         IFunctionCallNode node = (IFunctionCallNode)getNode("var a:XML; a.appendChild(<top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>)",
         		IFunctionCallNode.class);
         asBlockWalker.visitFunctionCall(node);
-        assertOut("a.appendChild(new XML( \"<top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>\") )");
+        assertOut("a.appendChild(new XML( \"<top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>\"))");
     }
     
     @Test
@@ -351,7 +359,7 @@ public class TestFlexJSGlobalClasses extends TestGoogGlobalClasses
     {
     	IBinaryOperatorNode node = getBinaryNode("var a:XML = <foo />; a = <top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>)");
         asBlockWalker.visitBinaryOperator(node);
-        assertOut("a = new XML( \"<top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>\") ");
+        assertOut("a = new XML( \"<top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>\")");
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/11e53909/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
index 70d2c48..068d870 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/LiteralEmitter.java
@@ -45,48 +45,50 @@ public class LiteralEmitter extends JSSubEmitter implements
     {
         boolean isWritten = false;
 
+        String newlineReplacement = "\\\\n";
         String s = node.getValue(true);
         if (!(node instanceof RegExpLiteralNode))
         {
             if (node.getLiteralType() == LiteralType.XML)
             {
-                write("new XML");
-                writeToken(ASEmitterTokens.PAREN_OPEN);
+            	newlineReplacement = "\\\\\n";
             	XMLLiteralNode xmlNode = (XMLLiteralNode)node;
             	if (xmlNode.getContentsNode().getChildCount() == 1)
             	{
 	            	if (s.contains("'"))
-	            		write("\"" + s + "\"");
+	            		s = "\"" + s + "\"";
 	            	else
-	            		write("'" + s + "'");
-	                isWritten = true;
+	            		s = "'" + s + "'";
+	            	s = "new XML( " + s + ")";
             	}
             	else
             	{
+        			StringBuilder sb = new StringBuilder();
+        			sb.append("new XML( ");
             		// probably contains {initializers}
             		int n = xmlNode.getContentsNode().getChildCount();
             		for (int i = 0; i < n; i++)
             		{
             			if (i > 0)
-            				write(" + ");
+            				sb.append(" + ");
             			IASNode child = xmlNode.getContentsNode().getChild(i);
             			if (child instanceof LiteralNode)
             			{
             				s = ((LiteralNode)child).getValue(true);
         	            	if (s.contains("'"))
-        	            		write("\"" + s + "\"");
+        	            		sb.append("\"" + s + "\"");
         	            	else
-        	            		write("'" + s + "'");
-        	                isWritten = true;
+        	            		sb.append("'" + s + "'");
             			}
             			else if (child instanceof IdentifierNode)
             			{
             				s = getEmitter().stringifyNode(child);
-            				write(s);
+            				sb.append(s);
             			}
             		}
+            		sb.append(")");
+            		s = sb.toString();
             	}
-                writeToken(ASEmitterTokens.PAREN_CLOSE);
             }
             s = s.replaceAll("\n", "__NEWLINE_PLACEHOLDER__");
             s = s.replaceAll("\r", "__CR_PLACEHOLDER__");
@@ -102,7 +104,7 @@ public class LiteralEmitter extends JSSubEmitter implements
             s = s.replaceAll("__FORMFEED_PLACEHOLDER__", "\\\\f");
             s = s.replaceAll("__TAB_PLACEHOLDER__", "\\\\t");
             s = s.replaceAll("__CR_PLACEHOLDER__", "\\\\r");
-            s = s.replaceAll("__NEWLINE_PLACEHOLDER__", "\\\\n");
+            s = s.replaceAll("__NEWLINE_PLACEHOLDER__", newlineReplacement);
             if (node.getLiteralType() == LiteralType.STRING)
             {
             	char c = s.charAt(0);


[2/2] git commit: [flex-falcon] [refs/heads/develop] - fix one more test

Posted by ah...@apache.org.
fix one more test


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/33821939
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/33821939
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/33821939

Branch: refs/heads/develop
Commit: 33821939f86c74e15f591badeb8eb76bf4a9df0c
Parents: 11e5390
Author: Alex Harui <ah...@apache.org>
Authored: Tue Apr 12 09:51:11 2016 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Apr 12 09:51:11 2016 -0700

----------------------------------------------------------------------
 .../test-files/flexjs/projects/xml_requires/XMLRequire_result.js   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/33821939/compiler.jx.tests/test-files/flexjs/projects/xml_requires/XMLRequire_result.js
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/test-files/flexjs/projects/xml_requires/XMLRequire_result.js b/compiler.jx.tests/test-files/flexjs/projects/xml_requires/XMLRequire_result.js
index d6affbe..3f8722a 100644
--- a/compiler.jx.tests/test-files/flexjs/projects/xml_requires/XMLRequire_result.js
+++ b/compiler.jx.tests/test-files/flexjs/projects/xml_requires/XMLRequire_result.js
@@ -31,7 +31,7 @@ goog.require('XML');
  * @constructor
  */
 XMLRequire = function() {
-  var /** @type {XML} */ myXML = new XML( '<node />') ;
+  var /** @type {XML} */ myXML = new XML( '<node />');
 };