emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phpinspect 2e6b0e9d2f 15/30: Make handling of corrupt i


From: ELPA Syncer
Subject: [elpa] externals/phpinspect 2e6b0e9d2f 15/30: Make handling of corrupt index more robust + convert regexp to constant
Date: Sat, 31 Aug 2024 09:58:53 -0400 (EDT)

branch: externals/phpinspect
commit 2e6b0e9d2f53247c38318cc178de08b387b95834
Author: Hugo Thunnissen <devel@hugot.nl>
Commit: Hugo Thunnissen <devel@hugot.nl>

    Make handling of corrupt index more robust + convert regexp to constant
---
 phpinspect-buffer.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/phpinspect-buffer.el b/phpinspect-buffer.el
index e7bb71091d..115cf687a7 100644
--- a/phpinspect-buffer.el
+++ b/phpinspect-buffer.el
@@ -178,7 +178,9 @@ linked with."
                                      (phpinspect-buffer-project buffer)
                                      (car func))))
                     (phpi-typedef-delete-method class (cdr func))))
-                 (t (error "Invalid index location")))))
+                 (t (phpinspect-message "Invalid index location, reindexing 
buffer")
+                    (phpinspect-buffer-reindex buffer)
+                    (error "invalid index location")))))
         (t (error "Cannot delete index for token %s" token))))
 
 (cl-defmethod phpinspect-buffer-namespace-at-point ((buffer phpinspect-buffer) 
(point integer))
@@ -582,6 +584,10 @@ continuing execution."
   (phpinspect-buffer-parse buffer)
   (phpinspect-buffer-map buffer))
 
+(define-inline phpinspect--atom-regexp ()
+  "A regular expression that matches (sequences of) atomic tokens."
+  (inline-quote "\\(\\$\\|->\\|::\\)?[^][)(}{[:blank:]\n;'\"]+"))
+
 (cl-defmethod phpinspect-buffer-register-edit
   ((buffer phpinspect-buffer) (start integer) (end integer) (pre-change-length 
integer))
   "Mark a region of the buffer as edited."
@@ -591,7 +597,7 @@ continuing execution."
   ;; they grow or shrink, so their full regions need to be marked for a 
reparse).
   (save-excursion
     (goto-char start)
-    (when (looking-back "\\(\\$\\|->\\|::\\)?[^][)(}{[:blank:]\n;'\"]+" nil t)
+    (when (looking-back (phpinspect--atom-regexp) nil t)
       (setq start (- start (length (match-string 0))))
       (setq pre-change-length (+ pre-change-length (length (match-string 
0))))))
 
@@ -639,4 +645,12 @@ use."
   (when phpinspect-current-buffer
     (phpinspect-buffer-register-edit phpinspect-current-buffer start end 
pre-change-length)))
 
+(define-inline phpinspect-with-current-buffer (buffer &rest body)
+  (declare (indent 1))
+  (inline-letevals (buffer)
+    (push 'progn body)
+    (inline-quote
+     (with-current-buffer (phpinspect-buffer-buffer ,buffer)
+       ,body))))
+
 (provide 'phpinspect-buffer)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]