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 20:29:27 UTC
git commit: [flex-falcon] [refs/heads/develop] - quick fix for simple
e4x filters
Repository: flex-falcon
Updated Branches:
refs/heads/develop 12b324767 -> a56951bbe
quick fix for simple e4x filters
Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/a56951bb
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/a56951bb
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/a56951bb
Branch: refs/heads/develop
Commit: a56951bbe452a761fe96391f121fe70d6aecf6c3
Parents: 12b3247
Author: Alex Harui <ah...@apache.org>
Authored: Tue Apr 12 11:29:30 2016 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Apr 12 11:29:30 2016 -0700
----------------------------------------------------------------------
.../codegen/js/flexjs/TestFlexJSGlobalClasses.java | 10 ++++++++++
.../internal/codegen/js/jx/IdentifierEmitter.java | 12 ++++++++++++
2 files changed, 22 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a56951bb/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 0edd621..295d636 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
@@ -515,6 +515,16 @@ public class TestFlexJSGlobalClasses extends TestGoogGlobalClasses
}
@Test
+ public void testXMLFilterForChild()
+ {
+ IVariableNode node = getVariable("var a:XML = new XML(\"<top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>\");var b:XMLList = a..grandchild.(year == '2016');");
+ IASNode parentNode = node.getParent();
+ node = (IVariableNode) parentNode.getChild(1);
+ asBlockWalker.visitVariable(node);
+ assertOut("var /** @type {XMLList} */ b = a.descendants('grandchild').filter(function(node){return (node.child('year') == '2016')})");
+ }
+
+ @Test
public void testXMLSetAttribute()
{
IBinaryOperatorNode node = getBinaryNode("var a:XML = new XML(\"<top attr1='cat'><child attr2='dog'><grandchild attr3='fish'>text</grandchild></child></top>\");a.@bar = 'foo'");
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/a56951bb/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java
index 0d91fcf..0e849ef 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java
@@ -36,6 +36,7 @@ import org.apache.flex.compiler.internal.definitions.TypeDefinitionBase;
import org.apache.flex.compiler.internal.tree.as.NonResolvingIdentifierNode;
import org.apache.flex.compiler.tree.ASTNodeID;
import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
import org.apache.flex.compiler.tree.as.IFunctionObjectNode;
import org.apache.flex.compiler.tree.as.IIdentifierNode;
import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
@@ -64,6 +65,8 @@ public class IdentifierEmitter extends JSSubEmitter implements
IASNode parentNode = node.getParent();
ASTNodeID parentNodeId = parentNode.getNodeID();
+ IASNode grandparentNode = parentNode.getParent();
+ ASTNodeID grandparentNodeId = (parentNode != null) ? grandparentNode.getNodeID() : null;
boolean identifierIsAccessorFunction = nodeDef instanceof AccessorDefinition;
boolean identifierIsPlainFunction = nodeDef instanceof FunctionDefinition
@@ -245,6 +248,15 @@ public class IdentifierEmitter extends JSSubEmitter implements
write(qname);
endMapping(node);
}
+ else if (grandparentNodeId == ASTNodeID.E4XFilterID &&
+ (!(parentNodeId == ASTNodeID.MemberAccessExpressionID || parentNodeId == ASTNodeID.Op_DescendantsID)))
+ {
+ startMapping(node);
+ write("child('");
+ write(node.getName());
+ write("')");
+ endMapping(node);
+ }
else
{
startMapping(node);