[Pkg-javascript-commits] [node-acorn-jsx] 112/484: [loose parser] More fixes to locations

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:12 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-acorn-jsx.

commit a6b3034e71e93bd37632deb83271559aec63d91a
Author: Paul Harper <benekastah at gmail.com>
Date:   Sun Mar 17 15:35:48 2013 -0600

    [loose parser] More fixes to locations
---
 acorn_loose.js | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/acorn_loose.js b/acorn_loose.js
index 87802f3..114e0c9 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -110,7 +110,7 @@
           throw e;
         }
         resetTo(pos);
-        if (replace === true) replace = {start: pos, end: pos, type: tt.name, value: "✖"};
+        if (replace === true) replace = {start: pos, end: pos, type: tt.name, value: "✖", loc: getDummyLoc()};
         if (replace) return replace;
       }
     }
@@ -202,9 +202,16 @@
       node.loc = new node_loc_t();
     return node
   }
+
   function startNodeFrom(other) {
-    return new node_t(other.start);
+    var node = new node_t(other.start);
+    if (options.locations) {
+      node.loc = new node_loc_t();
+      node.loc.start = other.loc.start;
+    }
+    return node;
   }
+
   function finishNode(node, type) {
     node.type = type;
     node.end = lastEnd;
@@ -213,11 +220,23 @@
     return node;
   }
 
+  function getDummyLoc(dummy) {
+    if (options.locations) {
+      var loc = new node_loc_t();
+      loc.end = {
+        line: loc.start.line,
+        column: loc.start.column + 1
+      };
+      return loc;
+    }
+  };
+
   function dummyIdent() {
     var dummy = new node_t(0);
     dummy.type = "Identifier";
     dummy.end = 0;
     dummy.name = "✖";
+    dummy.loc = getDummyLoc();
     return dummy;
   }
   function isDummy(node) { return node.name == "✖"; }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-acorn-jsx.git



More information about the Pkg-javascript-commits mailing list