[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 9b63a13 16/49: Special methods should allow keywords as na

From: Dmitry Gutov
Subject: [elpa] master 9b63a13 16/49: Special methods should allow keywords as names
Date: Mon, 16 Jan 2017 15:35:47 +0000 (UTC)

branch: master
commit 9b63a130d968daf0ca5459bf947acaaf3c80342f
Author: Lei Siao <address@hidden>
Commit: Lei Siao <address@hidden>

    Special methods should allow keywords as names
 js2-mode.el     |    6 +++---
 tests/parser.el |    3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index fb3482c..3f18bc1 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -7734,14 +7734,14 @@ is only true until the node is added to its parent; 
i.e., while parsing."
         ;; Tell cc-engine the bounds of the comment.
         (js2-record-text-property beg (1- end) 'c-in-sws t)))))
-(defun js2-peek-token ()
+(defun js2-peek-token (&optional modifier)
   "Return the next token type without consuming it.
 If `js2-ti-lookahead' is positive, return the type of next token
 from `js2-ti-tokens'.  Otherwise, call `js2-get-token'."
   (if (not (zerop js2-ti-lookahead))
        (aref js2-ti-tokens (mod (1+ js2-ti-tokens-cursor) js2-ti-ntokens)))
-    (let ((tt (js2-get-token-internal nil)))
+    (let ((tt (js2-get-token-internal modifier)))
@@ -10805,7 +10805,7 @@ expression)."
         (when (and (>= js2-language-version 200)
                    (= js2-NAME tt)
                    (member prop '("get" "set" "async"))
-                   (member (js2-peek-token)
+                   (member (js2-peek-token 'KEYWORD_IS_NAME)
                            (list js2-NAME js2-STRING js2-NUMBER js2-LB)))
           (setq previous-token (js2-current-token)
                 tt (js2-get-prop-name-token))))
diff --git a/tests/parser.el b/tests/parser.el
index a0e2c5a..f6345e1 100644
--- a/tests/parser.el
+++ b/tests/parser.el
@@ -497,6 +497,9 @@ the test."
 (js2-deftest-parse async-method-in-object-literal
   "({async f() {}});")
+(js2-deftest-parse async-method-kwname-in-object-literal
+  "({async delete() {}});")
 (js2-deftest-parse async-method-in-class-body
   "class C {\n  async foo() {}\n}")

reply via email to

[Prev in Thread] Current Thread [Next in Thread]