[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 41/46: js2-imenu-record-module-pattern: Support `js2-var-init-nod
From: |
Dmitry Gutov |
Subject: |
[elpa] 41/46: js2-imenu-record-module-pattern: Support `js2-var-init-node' |
Date: |
Sat, 15 Nov 2014 20:58:12 +0000 |
dgutov pushed a commit to branch master
in repository elpa.
commit c333ec95d2e7ac86b00072260a0ca0362886bc96
Author: Dmitry Gutov <address@hidden>
Date: Thu Nov 13 09:16:47 2014 +0200
js2-imenu-record-module-pattern: Support `js2-var-init-node'
* Update `js2-imenu-walk-ast' accordingly.
---
js2-imenu-extras.el | 55 ++++++++++++++++++++++++++++----------------------
1 files changed, 31 insertions(+), 24 deletions(-)
diff --git a/js2-imenu-extras.el b/js2-imenu-extras.el
index 77e247c..d32b912 100644
--- a/js2-imenu-extras.el
+++ b/js2-imenu-extras.el
@@ -238,8 +238,18 @@ Currently used for jQuery widgets, Dojo and Enyo
declarations."
(js2-function-node-p
(js2-assign-node-right node)))
(js2-imenu-record-orphan-assign-node-function node))
- (js2-imenu-show-module-pattern
- (js2-imenu-record-module-pattern node)))))
+ ((and js2-imenu-show-module-pattern
+ (js2-call-node-p
+ (js2-assign-node-right node)))
+ (js2-imenu-record-module-pattern
+ (js2-assign-node-left node)
+ (js2-assign-node-right node)))))
+ ((and (js2-var-init-node-p node)
+ (js2-call-node-p
+ (js2-var-init-node-initializer node)))
+ (js2-imenu-record-module-pattern
+ (js2-var-init-node-target node)
+ (js2-var-init-node-initializer node))))
t))))
(defun js2-imenu-parent-key-names (node)
@@ -300,29 +310,26 @@ NODE must be `js2-assign-node'."
(push js2-imenu-other-functions-ns chain)
(js2-record-imenu-entry fn-node chain (js2-node-abs-pos
fn-node)))))))
-(defun js2-imenu-record-module-pattern (node)
+(defun js2-imenu-record-module-pattern (target init)
"Recognize and record module pattern use instance.
-NODE must be `js2-assign-node'."
- (let ((init (js2-assign-node-right node)))
- (when (js2-call-node-p init)
- (let ((target (js2-assign-node-left node))
- (callt (js2-call-node-target init)))
- ;; Just basic call form: (function() {...})();
- ;; TODO: Handle variations without duplicating
`js2-wrapper-function-p'?
- (when (and (js2-paren-node-p callt)
- (js2-function-node-p (js2-paren-node-expr callt)))
- (let* ((fn (js2-paren-node-expr callt))
- (blk (js2-function-node-body fn))
- (ret (car (last (js2-block-node-kids blk)))))
- (when (and (js2-return-node-p ret)
- (js2-object-node-p (js2-return-node-retval ret)))
- ;; TODO: Map function names when revealing module pattern is
used.
- (let ((retval (js2-return-node-retval ret))
- (target-qname (js2-compute-nested-prop-get target)))
- (js2-record-object-literal retval target-qname
- (js2-node-abs-pos retval))
- (js2-record-imenu-entry fn target-qname
- (js2-node-abs-pos target))))))))))
+INIT must be `js2-call-node'."
+ (let ((callt (js2-call-node-target init)))
+ ;; Just basic call form: (function() {...})();
+ ;; TODO: Handle variations without duplicating `js2-wrapper-function-p'?
+ (when (and (js2-paren-node-p callt)
+ (js2-function-node-p (js2-paren-node-expr callt)))
+ (let* ((fn (js2-paren-node-expr callt))
+ (blk (js2-function-node-body fn))
+ (ret (car (last (js2-block-node-kids blk)))))
+ (when (and (js2-return-node-p ret)
+ (js2-object-node-p (js2-return-node-retval ret)))
+ ;; TODO: Map function names when revealing module pattern is used.
+ (let ((retval (js2-return-node-retval ret))
+ (target-qname (js2-compute-nested-prop-get target)))
+ (js2-record-object-literal retval target-qname
+ (js2-node-abs-pos retval))
+ (js2-record-imenu-entry fn target-qname
+ (js2-node-abs-pos target))))))))
;;;###autoload
(define-minor-mode js2-imenu-extras-mode
- [elpa] 33/46: js2-parse-primary-expr: Make some vars "more" local, (continued)
- [elpa] 33/46: js2-parse-primary-expr: Make some vars "more" local, Dmitry Gutov, 2014/11/15
- [elpa] 34/46: Add imenu support for the Sencha framework, Dmitry Gutov, 2014/11/15
- [elpa] 36/46: Indent before inequality operator at bol, Dmitry Gutov, 2014/11/15
- [elpa] 38/46: Indent after `+=', Dmitry Gutov, 2014/11/15
- [elpa] 37/46: Support object destructuring inside arrow function args, Dmitry Gutov, 2014/11/15
- [elpa] 30/46: js2-imenu-extras.el: Use Unix-style EOL, Dmitry Gutov, 2014/11/15
- [elpa] 42/46: js2-imenu-walk-ast: Look up js2-imenu-show-module-pattern in v-i-n case, too, Dmitry Gutov, 2014/11/15
- [elpa] 40/46: Support orphan functions on the right side of assignments, Dmitry Gutov, 2014/11/15
- [elpa] 35/46: Merge pull request #173 from lelit/master, Dmitry Gutov, 2014/11/15
- [elpa] 43/46: Fix toggling single-line comments, Dmitry Gutov, 2014/11/15
- [elpa] 41/46: js2-imenu-record-module-pattern: Support `js2-var-init-node',
Dmitry Gutov <=
- [elpa] 46/46: Merge commit '2c744815cf9e4653625dd25f2e7f8b59c152782d' from js2-mode, Dmitry Gutov, 2014/11/15
- [elpa] 45/46: Bump the version, Dmitry Gutov, 2014/11/15
- [elpa] 44/46: Merge pull request #180 from simenheg/master, Dmitry Gutov, 2014/11/15
- [elpa] 39/46: Check in LICENSE, Dmitry Gutov, 2014/11/15