Compare commits

...

2 Commits

Author SHA1 Message Date
Hugo Thunnissen 4d9907fedc Strip partially typed attributes from resolvecontext when suggesting attributes
ci/woodpecker/push/woodpecker Pipeline failed Details
1 month ago
Hugo Thunnissen 797efe9530 Only attempt to return completion kind when it can be found
When completions aren't found this is probably the result of a bug, but errors
in corfu's hooks are a pain for users so it is better to handle them gracefully
1 month ago

@ -307,9 +307,13 @@ Returns list of `phpinspect--completion'."
(phpinspect--completion-target comp))))
(insert ")")))))
:company-kind (lambda (comp-name)
(phpinspect--completion-kind
(phpinspect--completion-list-get-metadata
phpinspect--last-completion-list
comp-name))))))))
(let ((comp
(phpinspect--completion-list-get-metadata
phpinspect--last-completion-list
comp-name)))
(if comp
(phpinspect--completion-kind comp)
(phpinspect--log "Unable to find matching completion for name %s" comp-name)
nil))))))))
(provide 'phpinspect-completion)

@ -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

Loading…
Cancel
Save