branch: externals/javaimp
commit 378c8fe5c3fabe7c9060c8a998ba82c4d890c4c5
Author: Filipp Gunbin <[email protected]>
Commit: Filipp Gunbin <[email protected]>

    Support displaying all scopes in javaimp-show-scopes
---
 javaimp-parse.el |  6 +++---
 javaimp.el       | 38 ++++++++++++++++++++++----------------
 2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/javaimp-parse.el b/javaimp-parse.el
index 18e7eaf7b4..17c3bbdec4 100644
--- a/javaimp-parse.el
+++ b/javaimp-parse.el
@@ -763,7 +763,7 @@ either of symbols `normal' or `static'."
     (cons (and start-pos end-pos (cons start-pos end-pos))
           class-alist)))
 
-(defun javaimp-parse-get-all-scopes (&optional beg end pred no-filter)
+(defun javaimp-parse-get-all-scopes (&optional beg end pred no-filter-parents)
   "Return copies of all scopes in the current buffer between
 positions BEG and END, both exclusive, optionally filtering them
 with PRED.  PRED should not move point.  Note that parents may be
@@ -772,7 +772,7 @@ argument to `previous-single-property-change', and so may 
be nil.
 END defaults to end of accessible portion of the buffer.
 
 Scope parents are filtered according to
-`javaimp-parse--scope-type-defun-p', but if NO-FILTER is non-nil
+`javaimp-parse--scope-type-defun-p', but if NO-FILTER-PARENTS is non-nil
 then no filtering is done."
   (javaimp-parse--all-scopes)
   (let ((pos (or end (point-max)))
@@ -788,7 +788,7 @@ then no filtering is done."
                      (funcall pred scope)))
         (setq scope
               (javaimp-scope-copy
-               scope (unless no-filter #'javaimp-parse--scope-type-defun-p)
+               scope (unless no-filter-parents 
#'javaimp-parse--scope-type-defun-p)
                scope-alist))
         (push scope res)
         ;; Fill alist going up.  Stop at the first already existing
diff --git a/javaimp.el b/javaimp.el
index 67d48c7300..c64d4275e0 100644
--- a/javaimp.el
+++ b/javaimp.el
@@ -926,10 +926,10 @@ children."
 
 (defun javaimp-show-scopes-goto-scope (event &optional to-start)
   "Go to the opening brace (`javaimp-scope-open-brace') of the scope.
-Target scope is determined by location of mouse EVENT, if it's
-non-nil.  Else, take the scope at current line.  When TO-START is
-non-nil, go to scope start (`javaimp-scope-start') instead of the
-opening brace."
+Target scope is determined by location of mouse EVENT, if it's non-nil.
+Else, take the scope at current line.  When TO-START is
+non-nil (interactively, a prefix arg), go to scope
+start (`javaimp-scope-start') instead of the opening brace."
   (interactive (list last-nonmenu-event current-prefix-arg))
   (let* ((buf (current-buffer))
          (scopes-buf (if event
@@ -955,33 +955,38 @@ opening brace."
   (setq-local revert-buffer-function #'javaimp-show-scopes-revert)
   (setq next-error-function #'javaimp-show-scopes-next-error))
 
-(defun javaimp-show-scopes ()
-  "Show scopes in *javaimp-scopes* buffer."
-  (interactive)
+(defun javaimp-show-scopes (&optional all)
+  "Show scopes in *javaimp-scopes* buffer.
+By default, only type & method scopes are displayed, but if ALL is
+non-nil (interactively, a prefix arg) then no filtering is done.  This
+is useful mainly for debugging."
+  (interactive (list current-prefix-arg))
   (display-buffer
-   (javaimp-show-scopes-1 (current-buffer))))
+   (javaimp-show-scopes-1 (current-buffer) all)))
 
 (defun javaimp-show-scopes-revert (_ignore1 _ignore2)
   "Function to be used as `revert-buffer-function' in
 `javaimp-show-scopes-mode' buffers."
   (let ((source-buf
          (get-file-buffer
-          (get-text-property (point-min) 'javaimp-show-scopes-file))))
+          (get-text-property (point-min) 'javaimp-show-scopes-file)))
+        (all (get-text-property (point-min) 'javaimp-show-scopes-all)))
     (if source-buf
-        (javaimp-show-scopes-1 source-buf)
+        (javaimp-show-scopes-1 source-buf all)
       (user-error "Source buffer has been killed"))))
 
-(defun javaimp-show-scopes-1 (source-buf)
-  "Subroutine of `javaimp-show-scopes', outputs scopes from
-SOURCE-BUF in *javaimp-scopes* buffer.  Returns resulting
-buffer."
+(defun javaimp-show-scopes-1 (source-buf all)
+  "Subroutine of `javaimp-show-scopes', displays scopes from
+SOURCE-BUF in *javaimp-scopes* buffer.  Returns resulting buffer.  By
+default, only type & method scopes are displayed, but if ALL is non-nil
+then no filtering is done."
   (let ((scopes
          (with-current-buffer source-buf
            (save-excursion
              (save-restriction
                (widen)
                (javaimp-parse-get-all-scopes
-                nil nil (javaimp-scope-defun-p t))))))
+                nil nil (unless all (javaimp-scope-defun-p t)))))))
         (default-dir
          (with-current-buffer source-buf
            default-directory))
@@ -993,7 +998,8 @@ buffer."
             (buffer-undo-list t))
         (erase-buffer)
         (insert (propertize (format "%s" (buffer-file-name source-buf))
-                            'javaimp-show-scopes-file (buffer-file-name 
source-buf))
+                            'javaimp-show-scopes-file (buffer-file-name 
source-buf)
+                            'javaimp-show-scopes-all all)
                 "\n\n")
         (dolist (scope scopes)
           (let ((depth 0)

Reply via email to