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

    Add test for update of method names in buffers + fix bug in completion
---
 phpinspect-completion.el |  3 +++
 test/test-buffer.el      | 37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/phpinspect-completion.el b/phpinspect-completion.el
index 2b63db9ef4..cd7ba0b4dc 100644
--- a/phpinspect-completion.el
+++ b/phpinspect-completion.el
@@ -378,6 +378,9 @@ Returns list of `phpinspect--completion'."
   "Create a `phpinspect--completion` for COMPLETION-CANDIDATE."
   (phpinspect-make-fn-completion completion-candidate))
 
+(cl-defmethod phpinspect--make-completion ((completion-candidate 
phpinspect-property))
+  (phpinspect--make-completion (phpi-prop-definition completion-candidate)))
+
 (cl-defmethod phpinspect--make-completion
   ((completion-candidate phpinspect--variable))
   (phpinspect--construct-completion
diff --git a/test/test-buffer.el b/test/test-buffer.el
index 33229e71d8..89d44950b9 100644
--- a/test/test-buffer.el
+++ b/test/test-buffer.el
@@ -755,7 +755,9 @@ class Bar {
                          (:word "class")
                          (:word "A"))
                         (:block
-                         (:public
+                         (:public ;; This test explicitly tests that the
+                                  ;; "public" word doesn't lose its first
+                                  ;; character after edits.
                           (:function
                            (:declaration
                             (:word "function")
@@ -778,3 +780,36 @@ class Bar {
        (setq result (phpinspect-buffer-parse buffer 'no-interrupt))
        (should result)
        (should (equal expected result))))))
+
+(ert-deftest phpinspect-buffer-index-update-method-name ()
+    (with-temp-buffer
+      (let* ((project (phpinspect--make-project :autoload 
(phpinspect-make-autoloader)))
+            (buffer (phpinspect-make-buffer :buffer (current-buffer) :-project 
project))
+            (class-type (phpinspect--make-type :name "\\NS\\TestClass" 
:fully-qualified t)))
+      (insert "<?php
+namespace NS;
+
+class TestClass
+{
+    function testMe(): RelativeType {}
+}")
+      (setq-local phpinspect-current-buffer buffer)
+      (add-hook 'after-change-functions #'phpinspect-after-change-function)
+      (phpinspect-buffer-update-project-index buffer)
+
+      (goto-char 59)
+      (insert "thod")
+
+      (phpinspect-buffer-parse buffer 'no-interrupt)
+      (phpinspect-buffer-update-project-index buffer)
+      (pp (phpinspect-buffer-tree buffer))
+
+      (let ((typedef (phpinspect-project-get-typedef project class-type)))
+       (should typedef)
+
+       (should (length= (phpi-typedef-get-methods typedef) 1 ))
+
+       (pp (phpi-typedef-get-methods typedef))
+
+       (let ((method (phpi-typedef-get-method typedef "testMethod")))
+         (should method))))))

Reply via email to