[Pkg-javascript-commits] [node-acorn-jsx] 372/484: Make onToken only fire for actual final tokens

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:58 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 e271168cf604611a176f2c9452dcabde4bceab36
Author: Marijn Haverbeke <marijnh at gmail.com>
Date:   Sun Jan 4 22:13:18 2015 +0100

    Make onToken only fire for actual final tokens
    
    Issue #189
---
 acorn.js      | 11 ++++-------
 test/tests.js |  1 +
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/acorn.js b/acorn.js
index aa9b606..1fec391 100644
--- a/acorn.js
+++ b/acorn.js
@@ -634,9 +634,6 @@
     if (shouldSkipSpace !== false) skipSpace();
     tokVal = val;
     tokRegexpAllowed = type.beforeExpr;
-    if (options.onToken) {
-      options.onToken(new Token());
-    }
   }
 
   function skipBlockComment() {
@@ -1232,6 +1229,9 @@
   // Continue to the next token.
 
   function next() {
+    if (options.onToken)
+      options.onToken(new Token());
+
     lastStart = tokStart;
     lastEnd = tokEnd;
     lastEndLoc = tokEndLoc;
@@ -1542,9 +1542,7 @@
       first = false;
     }
 
-    lastStart = tokStart;
-    lastEnd = tokEnd;
-    lastEndLoc = tokEndLoc;
+    next();
     return finishNode(node, "Program");
   }
 
@@ -2664,5 +2662,4 @@
     node.generator = isGenerator;
     return finishNode(node, "ComprehensionExpression");
   }
-
 });
diff --git a/test/tests.js b/test/tests.js
index f6df2ed..f1d7ce3 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -28757,6 +28757,7 @@ var tokTypes = acorn.tokTypes;
 
 test('var x = (1 + 2)', {}, {
   locations: true,
+  loose: false,
   onToken: [
     {
       type: tokTypes._var,

-- 
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