[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 2ed3cc0 17/22: Merge pull request #501 from thorrr/obj-lit
From: |
Dmitry Gutov |
Subject: |
[elpa] master 2ed3cc0 17/22: Merge pull request #501 from thorrr/obj-literal-fix |
Date: |
Tue, 19 Feb 2019 06:06:48 -0500 (EST) |
branch: master
commit 2ed3cc070c7819556c9c89826b0f5c4629b104ef
Merge: 3bea9ab 76b7f45
Author: Dmitry Gutov <address@hidden>
Commit: GitHub <address@hidden>
Merge pull request #501 from thorrr/obj-literal-fix
fix for nav into shorthand prop:value syntax
---
js2-mode.el | 6 ++++--
tests/navigation.el | 28 +++++++++++++++++++++++-----
2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/js2-mode.el b/js2-mode.el
index 5058020..6aca826 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -12746,8 +12746,10 @@ it marks the next defun after the ones already marked."
(error "Node is not a supported jump node"))
(push (or (and names (pop names))
(unless (and (js2-object-prop-node-p parent)
- (eq node (js2-object-prop-node-left parent)))
- node)) names)
+ (eq node (js2-object-prop-node-left parent))
+ (not (js2-node-get-prop parent 'SHORTHAND)))
+ node)
+ (error "Node is not a supported jump node")) names)
(setq node-init (js2-search-scope node names))
;; todo: display list of results in buffer
diff --git a/tests/navigation.el b/tests/navigation.el
index 73737ba..26431da 100644
--- a/tests/navigation.el
+++ b/tests/navigation.el
@@ -22,15 +22,20 @@
(require 'ert)
(require 'js2-mode)
-(cl-defun js2-navigation-helper (buffer-content &optional expected-point
(point-offset 1))
+(cl-defun js2-navigation-helper (buffer-content &optional expected-point
(point-offset 1) expected-error-msg)
(with-temp-buffer
(insert buffer-content)
- (let ((start-point (or (- (point) point-offset))))
+ (let ((start-point (or (- (point) point-offset)))
+ actual-error-msg)
(js2-mode)
(goto-char start-point)
- (ignore-errors (js2-jump-to-definition))
+ (if expected-error-msg
+ (setq actual-error-msg
+ (cadr (should-error (js2-jump-to-definition) :type 'error)))
+ (js2-jump-to-definition))
(print (format "%d %d" (point) start-point))
- (should (= (point) (or expected-point start-point))))))
+ (should (= (point) (or expected-point start-point)))
+ (should (string= actual-error-msg expected-error-msg)))))
(ert-deftest js2-jump-to-var ()
(js2-navigation-helper "var soup = 2; soup" 5))
@@ -45,7 +50,8 @@
(js2-navigation-helper "var aObject = {prop1: 3, prop2: \"hello\"};
aObject.prop1" 16))
(ert-deftest js2-no-jump-to-object-property ()
- (js2-navigation-helper "var aObject = {prop1: 3, prop2: \"hello\"};
anotherObject.prop1"))
+ (js2-navigation-helper "var aObject = {prop1: 3, prop2: \"hello\"};
anotherObject.prop1"
+ 61 1 "No jump location found"))
(ert-deftest js2-jump-to-nested-property ()
(js2-navigation-helper "var aObject = {prop1: {prop2: { prop3: 4}}};
aObject.prop1.prop2.prop3" 33))
@@ -59,6 +65,18 @@
(ert-deftest js2-jump-to-property-object-property ()
(js2-navigation-helper "aObject.value = {prop:1};aObject.value.prop" 18))
+(ert-deftest js2-jump-to-function-definition-inside-object-value ()
+ (js2-navigation-helper
+ "function aFunction(p1, p2) {return p1+p2}; module.exports =
{aFunction:aFunction};" 1 6))
+
+(ert-deftest js2-no-jump-to-function-definition-object-property ()
+ (js2-navigation-helper
+ "function aFunction(p1, p2) {return p1+p2}; module.exports =
{aFunction:aFunction};"
+ 67 16 "Node is not a supported jump node"))
+
+(ert-deftest js2-jump-to-function-inside-property-value-syntax ()
+ (js2-navigation-helper "function aFunction(p1, p2) {return p1+p2};
module.exports = {aFunction};" 1 6))
+
;; forward-sexp
- [elpa] master updated (ddd6b22 -> c5cc951), Dmitry Gutov, 2019/02/19
- [elpa] master 243ba59 02/22: Fix typo in test name, namepsace -> namespace, Dmitry Gutov, 2019/02/19
- [elpa] master 6d160d0 06/22: Use regular forward-sexp when inside strings, Dmitry Gutov, 2019/02/19
- [elpa] master 3bea9ab 14/22: Merge pull request #498 from wyuenho/fix-short-name-for-emacs26, Dmitry Gutov, 2019/02/19
- [elpa] master bf61e6f 10/22: Fix #495 Aggressively reparse during imenu-create-index when possible, Dmitry Gutov, 2019/02/19
- [elpa] master 47dee19 03/22: Properly classify imported symbols, Dmitry Gutov, 2019/02/19
- [elpa] master dee4c47 07/22: Merge pull request #491 from felipeochoa/forward-sexp-in-str, Dmitry Gutov, 2019/02/19
- [elpa] master 40a43b1 13/22: Fix broken js2-node-short-name for Emacs 26, Dmitry Gutov, 2019/02/19
- [elpa] master 8bb1907 01/22: Silence "variable ‘_’ not left unused", Dmitry Gutov, 2019/02/19
- [elpa] master 2ed3cc0 17/22: Merge pull request #501 from thorrr/obj-literal-fix,
Dmitry Gutov <=
- [elpa] master 58006df 20/22: Release new version, Dmitry Gutov, 2019/02/19
- [elpa] master 381545b 08/22: Make js2-additional-externs safe as a local variable, Dmitry Gutov, 2019/02/19
- [elpa] master ed955e7 21/22: Update NEWS, Dmitry Gutov, 2019/02/19
- [elpa] master 4125b49a 04/22: Merge pull request #487 from lelit/classify-imported, Dmitry Gutov, 2019/02/19
- [elpa] master 1b0e174 12/22: Don't record js2-xml-ref-node's in js2-recorder-identifiers, Dmitry Gutov, 2019/02/19
- [elpa] master 5165f4d 19/22: Merge pull request #507 from piotr-yuxuan/patch-1, Dmitry Gutov, 2019/02/19
- [elpa] master 4de0e2d 05/22: Don't warn about trailing commas by default, Dmitry Gutov, 2019/02/19
- [elpa] master f863e08 18/22: Update README.md, Dmitry Gutov, 2019/02/19
- [elpa] master d76b4df 09/22: Merge pull request #492 from felipeochoa/additional-externs-safe-local, Dmitry Gutov, 2019/02/19
- [elpa] master b92b3ae 15/22: allow testing for specific errors and add test for object property, Dmitry Gutov, 2019/02/19