]> code.delx.au - gnu-emacs-elpa/commitdiff
Make sure js2-mode-ast is available for callbacks
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 10 Feb 2013 05:03:53 +0000 (09:03 +0400)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 10 Feb 2013 05:06:41 +0000 (09:06 +0400)
js2-imenu-extras.el
js2-mode.el

index f9215a4785feffeb06ec79191818179eda66606a..30619051b3d0b4b46c2f27a210fb6291497b82e2 100644 (file)
@@ -104,8 +104,6 @@ prefix any functions defined inside the IIFE with the module name."
   (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
@@ -113,9 +111,7 @@ prefix any functions defined inside the IIFE with the module name."
                        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
@@ -163,7 +159,7 @@ prefix any functions defined inside the IIFE with the module name."
 \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
index 55027300e29ff78f68ca4d1c17006fe2aa85958d..2074173b3047f03e5fab27fa3e3ceda0a7584c62 100644 (file)
@@ -879,7 +879,7 @@ externs appropriate for the specific file, perhaps based on its path.
 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
@@ -7384,6 +7384,7 @@ Scanner should be initialized."
         (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)
@@ -10608,7 +10609,7 @@ buffer will only rebuild its `js2-mode-ast' if the buffer is dirty."
                     (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)