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

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

[elpa] externals/phpinspect 4d9907fedc 2/2: Strip partially typed attrib


From: ELPA Syncer
Subject: [elpa] externals/phpinspect 4d9907fedc 2/2: Strip partially typed attributes from resolvecontext when suggesting attributes
Date: Fri, 22 Mar 2024 12:58:58 -0400 (EDT)

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

    Strip partially typed attributes from resolvecontext when suggesting 
attributes
---
 phpinspect-suggest.el | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/phpinspect-suggest.el b/phpinspect-suggest.el
index 30c83c87e3..e6e87dff24 100644
--- a/phpinspect-suggest.el
+++ b/phpinspect-suggest.el
@@ -113,6 +113,19 @@ resolved to provide completion candidates.
 
 If STATIC is non-nil, candidates are provided for constants,
 static variables and static methods."
+  ;; Strip away the existing (incomplete) attribute token. Otherwise, resolving
+  ;; a type from this context while the user has already typed part of an
+  ;; attribute name could return the type of an existing attribute that matches
+  ;; the incomplete name. (this could for example result in methods of the type
+  ;; of $this->entity to be suggested when we really want more suggestions for
+  ;; attributes of the type $this like $this->entityRepository). Essentially, 
we
+  ;; convert the subject $this->entity into $this so that only the type of 
$this
+  ;; (or whatever comes before the attribute accessor token (-> or ::)) is
+  ;; actually resolved.
+  (when (phpinspect-attrib-p (car (last (phpinspect--resolvecontext-subject 
resolvecontext))))
+    (setf (phpinspect--resolvecontext-subject resolvecontext)
+          (butlast (phpinspect--resolvecontext-subject resolvecontext))))
+
   (let* ((type-resolver (phpinspect--make-type-resolver-for-resolvecontext
                          resolvecontext))
          (method-lister (phpinspect--make-method-lister



reply via email to

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