[Pkg-javascript-commits] [node-acorn-jsx] 363/484: [loose parser] Make unclosed objects / lists span to the start of the next node

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:56 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 97f4e9a0268ca1bc5c4a1a18618878fd0dc668ef
Author: Marijn Haverbeke <marijnh at gmail.com>
Date:   Wed Dec 17 11:53:20 2014 +0100

    [loose parser] Make unclosed objects / lists span to the start of the next node
    
    That way, whitespace at their end is considered part of them,
    and Tern can recognize when the cursor is inside of them.
---
 acorn_loose.js | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/acorn_loose.js b/acorn_loose.js
index 39157f3..97a3df6 100644
--- a/acorn_loose.js
+++ b/acorn_loose.js
@@ -905,7 +905,12 @@
       }
     }
     popCx();
-    eat(tt.braceR);
+    if (!eat(tt.braceR)) {
+      // If there is no closing brace, make the node span to the start
+      // of the next token (this is useful for Tern)
+      lastEnd = token.start;
+      if (options.locations) lastEndLoc = token.startLoc;
+    }
     if (isClass) {
       semicolon();
       finishNode(node.body, "ClassBody");
@@ -1152,7 +1157,12 @@
       eat(tt.comma);
     }
     popCx();
-    eat(close);
+    if (!eat(close)) {
+      // If there is no closing brace, make the node span to the start
+      // of the next token (this is useful for Tern)
+      lastEnd = token.start;
+      if (options.locations) lastEndLoc = token.startLoc;
+    }
     return elts;
   }
 });

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