You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jo...@apache.org on 2016/04/06 01:56:29 UTC

[11/33] git commit: [flex-falcon] [refs/heads/develop] - source maps can be specified at a specific line and column (instead of the line and column where the node starts), and updated how literal containers map their commas

source maps can be specified at a specific line and column (instead of the line and column where the node starts), and updated how literal containers map their commas


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

Branch: refs/heads/develop
Commit: 715c92fc44f9128adb35a4c60f986b46bc7d988d
Parents: 74cb443
Author: Josh Tynjala <jo...@apache.org>
Authored: Tue Mar 29 16:53:28 2016 -0700
Committer: Josh Tynjala <jo...@apache.org>
Committed: Tue Mar 29 16:53:28 2016 -0700

----------------------------------------------------------------------
 .../flex/compiler/codegen/js/IJSEmitter.java      |  2 ++
 .../compiler/internal/codegen/js/JSEmitter.java   | 18 ++++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/715c92fc/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
index 6aa7f61..6dcea99 100644
--- a/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/codegen/js/IJSEmitter.java
@@ -46,6 +46,8 @@ public interface IJSEmitter extends IASEmitter
     
     void startMapping(ISourceLocation node);
     void startMapping(ISourceLocation node, int startOffset);
+    void startMapping(ISourceLocation node, int line, int column);
+    
     void endMapping(ISourceLocation node);
     void pushSourceMapName(ISourceLocation node);
     void popSourceMapName();

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/715c92fc/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
index cec48b9..08fc599 100644
--- a/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
+++ b/compiler.jx/src/org/apache/flex/compiler/internal/codegen/js/JSEmitter.java
@@ -228,7 +228,10 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
             getWalker().walk(child);
             if (i < len - 1)
             {
-                startMapping(node, child.getAbsoluteEnd() - node.getAbsoluteStart() + 1);
+                //we're mapping the comma to the literal container, but we use
+                //the child line/column in case the comma is not on the same
+                //line as the opening { or [
+                startMapping(node, child.getLine(), child.getColumn() + child.getEnd() - child.getStart());
                 writeToken(ASEmitterTokens.COMMA);
                 endMapping(node);
             }
@@ -516,11 +519,16 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
 
     public void startMapping(ISourceLocation node)
     {
-        startMapping(node, 0);
+        startMapping(node, node.getLine(), node.getColumn());
     }
-    
+
     public void startMapping(ISourceLocation node, int startOffset)
     {
+        startMapping(node, node.getLine(), node.getColumn() + startOffset);
+    }
+    
+    public void startMapping(ISourceLocation node, int line, int column)
+    {
         if (lastMapping != null)
         {
             FilePosition sourceStartPosition = lastMapping.sourceStartPosition;
@@ -547,8 +555,6 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
             }
             return;
         }
-        int sourceLine = node.getLine();
-        int sourceColumn = node.getColumn() + startOffset;
         
         String nodeName = null;
         if (nameStack.size() > 0)
@@ -558,7 +564,7 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
         SourceMapMapping mapping = new SourceMapMapping();
         mapping.sourcePath = sourcePath;
         mapping.name = nodeName;
-        mapping.sourceStartPosition = new FilePosition(sourceLine, sourceColumn);
+        mapping.sourceStartPosition = new FilePosition(line, column);
         mapping.destStartPosition = new FilePosition(getCurrentLine(), getCurrentColumn());
         lastMapping = mapping;
     }