branch: externals/phpinspect
commit 31c6e069343eb63ed519b8de67089c841c86113a
Author: Hugo Thunnissen <de...@hugot.nl>
Commit: Hugo Thunnissen <de...@hugot.nl>

    Reparse buffer when fixing import (+ add comment explaining why)
---
 phpinspect-buffer.el  |  2 +-
 phpinspect-imports.el | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/phpinspect-buffer.el b/phpinspect-buffer.el
index bfd603c470..058d31cecb 100644
--- a/phpinspect-buffer.el
+++ b/phpinspect-buffer.el
@@ -518,7 +518,7 @@ use."
   (interactive)
   (when phpinspect-current-buffer
     (let ((buffer phpinspect-current-buffer))
-      (pop-to-buffer (generate-new-buffer "phpinspect-buffer-tree"))
+      (pop-to-buffer (generate-new-buffer "phpinspect-buffer-index"))
       (insert (pp-to-string (phpinspect--index-tokens (phpinspect-buffer-parse 
buffer 'no-interrupt))))
       (read-only-mode))))
 
diff --git a/phpinspect-imports.el b/phpinspect-imports.el
index f2329abd61..6a5f2516fd 100644
--- a/phpinspect-imports.el
+++ b/phpinspect-imports.el
@@ -185,7 +185,16 @@ that there are import (\"use\") statements for them."
   (interactive)
   (if phpinspect-current-buffer
       (let* ((buffer phpinspect-current-buffer)
-             (tree (phpinspect-buffer-parse buffer))
+             ;; use buffer-reparse to ensure fully structurally correct
+             ;; tree. (at the time of writing, incremental parsing has some
+             ;; limitations causing reused tokens to lose their special meaning
+             ;; when they are reused. For example the "class" keyword being
+             ;; reused as just a word instead of a special keyword marking the
+             ;; start of a class)
+             ;;
+             ;; FIXME: Change to buffer-parse when this particular problem in
+             ;; incremental parsing has been solved
+             (tree (phpinspect-buffer-reparse buffer))
              (index (phpinspect--index-tokens
                      tree nil (phpinspect-buffer-location-resolver buffer)))
              (classes (alist-get 'classes index))

Reply via email to