flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject [1/9] git commit: [flex-falcon] [refs/heads/develop] - VarDeclarationEmitter: fixed sourcemap for assignment when type is omitted
Date Mon, 18 Apr 2016 06:27:26 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop bc19c66a4 -> e9fd628e5


VarDeclarationEmitter: fixed sourcemap for assignment when type is omitted


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

Branch: refs/heads/develop
Commit: e36c544cf9ebe6900dfb84ddffd2bdc9bd94733c
Parents: bc19c66
Author: Josh Tynjala <joshtynjala@apache.org>
Authored: Sun Apr 17 14:03:18 2016 -0700
Committer: Josh Tynjala <joshtynjala@apache.org>
Committed: Sun Apr 17 14:03:18 2016 -0700

----------------------------------------------------------------------
 .../js/sourcemaps/TestSourceMapStatements.java        | 14 ++++++++++++++
 .../internal/codegen/js/jx/VarDeclarationEmitter.java | 12 ++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e36c544c/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
----------------------------------------------------------------------
diff --git a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
index 3c25d07..8f4cf77 100644
--- a/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
+++ b/compiler.jx.tests/src/org/apache/flex/compiler/internal/codegen/js/sourcemaps/TestSourceMapStatements.java
@@ -27,6 +27,20 @@ public class TestSourceMapStatements extends SourceMapTestBase
     }
 
     @Test
+    public void testVarDeclaration_withAssignedValue()
+    {
+        IVariableNode node = (IVariableNode) getNode("var a = 42;",
+                IVariableNode.class);
+        asBlockWalker.visitVariable(node);
+        //var /** @type {*} */ a = 42
+        assertMapping(node, 0, 0, 0, 0, 0, 4);   // var
+        assertMapping(node, 0, 4, 0, 21, 0, 22); // a
+        assertMapping(node, 0, 5, 0, 4, 0, 21);  // (type)
+        assertMapping(node, 0, 5, 0, 22, 0, 25); // =
+        assertMapping(node, 0, 8, 0, 25, 0, 27); // 42
+    }
+
+    @Test
     public void testVarDeclaration_withType()
     {
         IVariableNode node = (IVariableNode) getNode("var a:int;",

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/e36c544c/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
index f43b288..911a280 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/jx/VarDeclarationEmitter.java
@@ -54,7 +54,8 @@ public class VarDeclarationEmitter extends JSSubEmitter implements
         }
 
         IExpressionNode variableTypeNode = node.getVariableTypeNode();
-        if(variableTypeNode.getLine() >= 0)
+        boolean hasVariableType = variableTypeNode.getLine() >= 0;
+        if(hasVariableType)
         {
             startMapping(variableTypeNode,
                     variableTypeNode.getLine(),
@@ -95,7 +96,14 @@ public class VarDeclarationEmitter extends JSSubEmitter implements
         fjs.emitDeclarationName(node);
         if (avnode != null && !(avnode instanceof IEmbedNode))
         {
-            startMapping(node, node.getVariableTypeNode());
+            if (hasVariableType)
+            {
+                startMapping(node, node.getVariableTypeNode());
+            }
+            else
+            {
+                startMapping(node, node.getNameExpressionNode());
+            }
             write(ASEmitterTokens.SPACE);
             writeToken(ASEmitterTokens.EQUAL);
             endMapping(node);


Mime
View raw message