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

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

[elpa] externals/phpinspect b6978105e5 25/30: Fix: Don't discard first c


From: ELPA Syncer
Subject: [elpa] externals/phpinspect b6978105e5 25/30: Fix: Don't discard first char after opening brace of class block
Date: Sat, 31 Aug 2024 09:58:54 -0400 (EDT)

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

    Fix: Don't discard first char after opening brace of class block
---
 phpinspect-parser.el |  1 -
 test/test-buffer.el  | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/phpinspect-parser.el b/phpinspect-parser.el
index 728e546c2f..9e818e120a 100644
--- a/phpinspect-parser.el
+++ b/phpinspect-parser.el
@@ -716,7 +716,6 @@ static keywords with the same meaning as in a class block."
 (phpinspect-defhandler class-block (start-token max-point)
   "Handler for code blocks that cannot contain classes"
   ((regexp . "{"))
-  (forward-char (length start-token))
   (let* ((complete-block nil)
          (continue-condition (lambda ()
                                (not (and (char-equal (char-after) ?})
diff --git a/test/test-buffer.el b/test/test-buffer.el
index e5bfa16c10..eb2474c6e5 100644
--- a/test/test-buffer.el
+++ b/test/test-buffer.el
@@ -738,3 +738,47 @@ class Bar {
         (phpinspect-buffer-update-project-index buffer)
 
         (should (= 1 (length (phpi-typedef-get-methods class))))))))
+
+
+(ert-deftest phpinspect-buffer-parse-incrementally-class-block-scope ()
+  (with-temp-buffer
+    (let* ((project (phpinspect--make-dummy-composer-project-with-code))
+           (buffer (phpinspect-make-buffer :-project project :buffer 
(current-buffer))))
+
+      (insert "<?php class A { public function A() {} }")
+
+      (setq-local phpinspect-current-buffer buffer)
+      (add-hook 'after-change-functions #'phpinspect-after-change-function)
+      (let ((expected `(:root
+                       (:class
+                        (:declaration
+                         (:word "class")
+                         (:word "A"))
+                        (:block
+                         (:public
+                          (:function
+                           (:declaration
+                            (:word "function")
+                            (:word "A")
+                            (:list))
+                           (:block)))))))
+           (result (phpinspect-buffer-parse buffer 'no-interrupt)))
+
+       (should result)
+       (pp result)
+       (should (equal expected result))
+
+       (goto-char 17)
+       (delete-backward-char 1)
+       (message (buffer-string))
+       (setq result (phpinspect-buffer-parse buffer 'no-interrupt))
+       (pp result)
+       (should result)
+       (should (equal expected result))
+
+       (backward-char)
+       (insert " ")
+       (message (buffer-string))
+       (setq result (phpinspect-buffer-parse buffer 'no-interrupt))
+       (should result)
+       (should (equal expected result))))))



reply via email to

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