emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/js2-mode 39a3f50 1/2: js2-jump-to-definition: Stop erro


From: ELPA Syncer
Subject: [elpa] externals/js2-mode 39a3f50 1/2: js2-jump-to-definition: Stop erroring when encounter 'this'
Date: Sun, 11 Jul 2021 22:57:12 -0400 (EDT)

branch: externals/js2-mode
commit 39a3f50af6b5126f717a4d1649124418771308ba
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    js2-jump-to-definition: Stop erroring when encounter 'this'
    
    #423
---
 js2-mode.el         | 21 +++++++++++++++------
 tests/navigation.el |  2 +-
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index d72f4ec..f86f578 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -12978,7 +12978,10 @@ i.e. (\\='name\\=' \\='value\\=') = {name : { value: 
3}}"
 NAMES is a list of property values to search for. For functions
 and variables NAMES will contain one element."
   (let (node-init
-        (val (js2-name-node-name (car names))))
+        (val (and
+              ;; TODO: Consider 'this' specially, to limit search scope.
+              (js2-name-node-p (car names))
+              (js2-name-node-name (car names)))))
     (setq node-init (js2-get-symbol-declaration node val))
 
     (when (> (length names) 1)
@@ -13004,11 +13007,17 @@ and variables NAMES will contain one element."
                      (temp-names names))
                  (when (js2-prop-get-node-p left)
                    (let* ((prop-list (js2-compute-nested-prop-get left))
-                          (found (cl-loop for prop in prop-list
-                                          until (not (string= 
(js2-name-node-name
-                                                               (pop 
temp-names))
-                                                              
(js2-name-node-name prop)))
-                                          if (not temp-names) return prop))
+                          ;; 'this' or 'super'
+                          (target-is-keyword (js2-keyword-node-p (car 
temp-names)))
+                          (_ (when target-is-keyword
+                               (pop temp-names)))
+                          (found (unless target-is-keyword
+                                   (cl-loop for prop in prop-list
+                                            until (not (string= 
(js2-name-node-name
+                                                                 (pop 
temp-names))
+                                                                (and 
(js2-name-node-p prop)
+                                                                     
(js2-name-node-name prop))))
+                                            if (not temp-names) return prop)))
                           (found-node (or found
                                           (when (js2-object-node-p right)
                                             (js2-search-object-for-prop right
diff --git a/tests/navigation.el b/tests/navigation.el
index c71afae..b56089f 100644
--- a/tests/navigation.el
+++ b/tests/navigation.el
@@ -47,7 +47,7 @@
   (js2-navigation-helper "var p1 = 4; function aFunction(p1, p2) {p1};" 32 4))
 
 (ert-deftest js2-jump-to-object-property ()
-  (js2-navigation-helper "var aObject = {prop1: 3, prop2: \"hello\"}; 
aObject.prop1" 16))
+  (js2-navigation-helper "var aObject = {prop1: 3, prop2: \"hello\"}; 
this.prop1 = 4; aObject.prop1" 16))
 
 (ert-deftest js2-no-jump-to-object-property ()
   (js2-navigation-helper "var aObject = {prop1: 3, prop2: \"hello\"}; 
anotherObject.prop1"



reply via email to

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