[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 3207e5c 05/38: correctly handle arrow functions in js2-nod
From: |
Dmitry Gutov |
Subject: |
[elpa] master 3207e5c 05/38: correctly handle arrow functions in js2-node-parent-stmt |
Date: |
Wed, 28 Feb 2018 20:12:08 -0500 (EST) |
branch: master
commit 3207e5cb1da32300dacd0bcbe119629b9be0365f
Author: felipe <address@hidden>
Commit: felipe <address@hidden>
correctly handle arrow functions in js2-node-parent-stmt
Arrow functions are always expressions, so js2-node-parent-stmt should
continue recursing to their parent to find the first statement
---
js2-mode.el | 3 +--
tests/consume.el | 9 +++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 4a9a068..4ba99ec 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -5247,8 +5247,7 @@ appearing in a statement context will have a parent that
is a
(if (or (null parent)
(js2-stmt-node-p parent)
(and (js2-function-node-p parent)
- (not (eq (js2-function-node-form parent)
- 'FUNCTION_EXPRESSION))))
+ (eq (js2-function-node-form parent) 'FUNCTION_STATEMENT)))
parent
(js2-node-parent-stmt parent))))
diff --git a/tests/consume.el b/tests/consume.el
index c48f6a0..8e6ca17 100644
--- a/tests/consume.el
+++ b/tests/consume.el
@@ -20,6 +20,7 @@
;;; Code:
(require 'ert)
+(require 'ert-x)
(require 'js2-mode)
(defun js2-mode--and-parse ()
@@ -73,3 +74,11 @@
t))
(setq visit-log (nreverse visit-log))
(should (equal visit-log (list "defaultImport" "a" "b" "c"))))))
+
+(ert-deftest js2-node-parent-stmt/arrow-function ()
+ (ert-with-test-buffer (:name 'js2-node-parent-stmt/arrow-function)
+ (insert "expect(() => ")
+ (save-excursion (insert "func(undefined)).toThrow(/undefined/);"))
+ (js2-mode--and-parse)
+ (let ((parent-stmt (js2-node-parent-stmt (js2-node-at-point))))
+ (should (= (js2-node-abs-pos parent-stmt) 1)))))
- [elpa] master updated (94c7628 -> a6c39c2), Dmitry Gutov, 2018/02/28
- [elpa] master 4daab44 03/38: remove stray message call, Dmitry Gutov, 2018/02/28
- [elpa] master b0f8f03 02/38: make sure to visit import clause children in order, Dmitry Gutov, 2018/02/28
- [elpa] master 3207e5c 05/38: correctly handle arrow functions in js2-node-parent-stmt,
Dmitry Gutov <=
- [elpa] master 91c745a 04/38: Merge pull request #440 from felipeochoa/issue439, Dmitry Gutov, 2018/02/28
- [elpa] master daed014 10/38: add support for trailing comma in function arguments, Dmitry Gutov, 2018/02/28
- [elpa] master 048da26 06/38: Merge pull request #442 from felipeochoa/arrowStatements, Dmitry Gutov, 2018/02/28
- [elpa] master 6cf9ea4 07/38: Add jsdoc highlighting for yield and yields, Dmitry Gutov, 2018/02/28
- [elpa] master 43306d1 08/38: Merge pull request #444 from felipeochoa/jsdoc-yield, Dmitry Gutov, 2018/02/28
- [elpa] master dd295e8 13/38: Merge pull request #461 from Fuco1/feature/add-object-property-access-face, Dmitry Gutov, 2018/02/28
- [elpa] master ce540d2 19/38: Merge pull request #465 from felipeochoa/jsdoc-abstract, Dmitry Gutov, 2018/02/28
- [elpa] master ba14eb8 16/38: [feat] add jsdoc @abstract and @virtual empty tags, Dmitry Gutov, 2018/02/28
- [elpa] master 4062ae4 22/38: [bugfix] Mark @type jsdoc tag as a typed tag not an arg tag, Dmitry Gutov, 2018/02/28
- [elpa] master 47dc8f2 25/38: [feat] add @typedef jsdoc highlighting support, Dmitry Gutov, 2018/02/28