(when (or js2-imenu-show-other-functions js2-imenu-show-module-pattern)\r
(add-to-list 'js2-post-parse-callbacks 'js2-imenu-walk-ast t)))\r
\r
-(declare (special root))\r
-\r
(defun js2-imenu-record-declarations ()\r
(let* ((styles (loop for style in js2-imenu-extension-styles\r
when (memq (plist-get style :framework)\r
collect style))\r
(re (mapconcat (lambda (style)\r
(concat "\\(" (plist-get style :call-re) "\\)"))\r
- styles "\\|"))\r
- ;; Dynamic scoping. Ew.\r
- (js2-mode-ast root))\r
+ styles "\\|")))\r
(goto-char (point-min))\r
(while (js2-re-search-forward re nil t)\r
(loop for i from 0 to (1- (length styles))\r
\r
(defun js2-imenu-walk-ast ()\r
(js2-visit-ast\r
- root\r
+ js2-mode-ast\r
(lambda (node end-p)\r
(unless end-p\r
(cond\r
These should go in `js2-additional-externs', which is buffer-local.
Finally, you can add a function to `js2-post-parse-callbacks',
-which is called after parsing completes, and `root' is bound to
+which is called after parsing completes, and `js2-mode-ast' is bound to
the root of the parse tree. At this stage you can set up an AST
node visitor using `js2-visit-ast' and examine the parse tree
for specific import patterns that may imply the existence of
(push comment (js2-ast-root-comments root))
(js2-node-add-children root comment)))
(setf (js2-node-len root) (- end pos))
+ (setq js2-mode-ast root) ; Make sure this is available for callbacks.
;; Give extensions a chance to muck with things before highlighting starts.
(let ((js2-additional-externs js2-additional-externs))
(dolist (callback js2-post-parse-callbacks)
(js2-time
(setq interrupted-p
(catch 'interrupted
- (setq js2-mode-ast (js2-parse))
+ (js2-parse)
;; if parsing is interrupted, comments and regex
;; literals stay ignored by `parse-partial-sexp'
(remove-text-properties (point-min) (point-max)