]> code.delx.au - gnu-emacs-elpa/commitdiff
Properly record function qnames in object literals
authorDmitry Gutov <dgutov@yandex.ru>
Wed, 4 May 2011 23:01:36 +0000 (03:01 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Wed, 4 May 2011 23:01:36 +0000 (03:01 +0400)
This fixes imenu index for quux and baz:

let foo = {
  bar: function() {
    function quux() {
      // ...
    }

    let oot = {
      baz: function() {},
    }
  }
}

js2-mode.el

index 70c38860b634b027165db79a281eb3e3b76cd6a8..06906476d7672785d0d5da1ff230fe74baea9b7f 100644 (file)
@@ -6846,7 +6846,7 @@ POS is the absolute position of the node.
 We do a depth-first traversal of NODE.  Any functions we find are prefixed
 with QNAME plus the property name of the function and appended to the
 variable `js2-imenu-recorder'."
-  (let (left right)
+  (let (left right prop-qname)
     (dolist (e (js2-object-node-elems node))  ; e is a `js2-object-prop-node'
       (let ((left (js2-infix-node-left e))
             ;; Element positions are relative to the parent position.
@@ -6858,9 +6858,9 @@ variable `js2-imenu-recorder'."
             ;; As a policy decision, we record the position of the property,
             ;; not the position of the `function' keyword, since the property
             ;; is effectively the name of the function.
-            (push (append qname (list left pos))
+            (push (setq prop-qname (append qname (list left pos)))
                   js2-imenu-recorder)
-            (js2-record-function-qname right qname)))
+            (js2-record-function-qname right prop-qname)))
          ;; foo: {object-literal} -- add foo to qname, offset position, and recurse
          ((js2-object-node-p right)
           (js2-record-object-literal right