branch: master commit 92a8857c7b99c6469434c2c4ae0f0f8fe29e2a47 Author: Dmitry Gutov <dgu...@yandex.ru> Commit: Dmitry Gutov <dgu...@yandex.ru>
Support async arrow function without parentheses Fixes #433. --- NEWS.md | 1 + js2-mode.el | 7 +++++-- tests/parser.el | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 587fe0d..bdf52ae 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ ## Next +* Support async arrow function without parentheses. * Support for trailing commas in function parameter lists. ## 2017-01-16 diff --git a/js2-mode.el b/js2-mode.el index d7977e5..9b7f7fd 100644 --- a/js2-mode.el +++ b/js2-mode.el @@ -9890,8 +9890,11 @@ If NODE is non-nil, it is the AST node associated with the symbol." (js2-record-imenu-functions right left)) ;; do this last so ide checks above can use absolute positions (js2-node-add-children pn left right)) - ((and (= tt js2-ARROW) - (>= js2-language-version 200)) + ((and (>= js2-language-version 200) + (or + (= tt js2-ARROW) + (and async-p + (= (js2-peek-token) js2-ARROW)))) (js2-ts-seek ts-state) (when async-p (js2-record-face 'font-lock-keyword-face) diff --git a/tests/parser.el b/tests/parser.el index 65cb209..181e741 100644 --- a/tests/parser.el +++ b/tests/parser.el @@ -501,6 +501,9 @@ the test." (js2-deftest-parse async-arrow-function-expression "a = async (b) => { b;\n};") +(js2-deftest-parse async-arrow-function-without-parens + "a = async b => 3;" :reference "a = async (b) => {3};") + (js2-deftest-parse async-method-in-object-literal "({async f() {}});")