Reparse buffer when fixing import (+ add comment explaining why)

master
Hugo Thunnissen 1 month ago
parent d141f8a6db
commit 31c6e06934

@ -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))))

@ -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))

Loading…
Cancel
Save