[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phpinspect 37fbfa4114 1/3: Add test for incremental par
From: |
ELPA Syncer |
Subject: |
[elpa] externals/phpinspect 37fbfa4114 1/3: Add test for incremental parsing of comments + fix bug in parser |
Date: |
Mon, 2 Sep 2024 18:58:33 -0400 (EDT) |
branch: externals/phpinspect
commit 37fbfa41148e5754cfb141f556b7f50fab10a7dd
Author: Hugo Thunnissen <devel@hugot.nl>
Commit: Hugo Thunnissen <devel@hugot.nl>
Add test for incremental parsing of comments + fix bug in parser
---
phpinspect-parser.el | 10 +++++++---
test/test-buffer.el | 16 ++++++++++++++++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/phpinspect-parser.el b/phpinspect-parser.el
index 67a3fe172f..f34262f4df 100644
--- a/phpinspect-parser.el
+++ b/phpinspect-parser.el
@@ -559,9 +559,13 @@ nature like argument lists"
(forward-char 2)
doc-block))
(t
- (let ((end-position (line-end-position)))
- (phpinspect--parse-comment (current-buffer) end-position)))))
-
+ (let* ((end-position (line-end-position))
+ (token
+ (phpinspect--parse-comment (current-buffer) end-position 1)))
+ ;; Move to start of next line (absorb end of line)
+ (while (not (bolp))
+ (forward-char))
+ token))))
(phpinspect-defhandler class-variable (start-token &rest _ignored)
"Handler for tokens indicating reference to a variable"
diff --git a/test/test-buffer.el b/test/test-buffer.el
index 2c35464362..7ba157f030 100644
--- a/test/test-buffer.el
+++ b/test/test-buffer.el
@@ -810,3 +810,19 @@ class TestClass
(let ((method (phpi-typedef-get-method typedef "testMethod")))
(should method))))))
+
+(ert-deftest phpinspect-buffer-parse-incrementally-comment ()
+ (with-temp-buffer
+ (let* ((project (phpinspect--make-project :autoload
(phpinspect-make-autoloader)))
+ (buffer (phpinspect-make-buffer :buffer (current-buffer) :-project
project)))
+ (insert "<?php\n\n// \n")
+ (setq-local phpinspect-current-buffer buffer)
+ (add-hook 'after-change-functions #'phpinspect-after-change-function)
+
+ (should (equal '(:root (:comment))
+ (phpinspect-buffer-parse buffer)))
+
+ (goto-char 11)
+ (insert "word")
+ (should (equal '(:root (:comment))
+ (phpinspect-buffer-parse buffer))))))