Use `phpinspect--display-format-type-name' as standardized propertized string

- Move `propertize' calls into `phpinspect--display-format-type-name'
- Use for completion as well as eldoc hints
master
Hugo Thunnissen 1 month ago
parent 4ec4c40c9d
commit 2052c289e1

@ -255,7 +255,7 @@ Returns list of `phpinspect--completion'."
(phpinspect--function-arguments completion-candidate) (phpinspect--function-arguments completion-candidate)
", ") ", ")
") " ") "
(phpinspect--format-type-name (phpinspect--function-return-type completion-candidate))) (phpinspect--display-format-type-name (phpinspect--function-return-type completion-candidate)))
:annotation (concat " " :annotation (concat " "
(phpinspect--type-bare-name (phpinspect--type-bare-name
(phpinspect--function-return-type completion-candidate))) (phpinspect--function-return-type completion-candidate)))
@ -266,7 +266,7 @@ Returns list of `phpinspect--completion'."
((completion-candidate phpinspect--variable)) ((completion-candidate phpinspect--variable))
(phpinspect--construct-completion (phpinspect--construct-completion
:value (phpinspect--variable-name completion-candidate) :value (phpinspect--variable-name completion-candidate)
:meta (phpinspect--format-type-name :meta (phpinspect--display-format-type-name
(or (phpinspect--variable-type completion-candidate) (or (phpinspect--variable-type completion-candidate)
phpinspect--null-type)) phpinspect--null-type))
:target completion-candidate :target completion-candidate
@ -300,7 +300,7 @@ Returns list of `phpinspect--completion'."
(dolist (comp completions) (dolist (comp completions)
(setq completion (phpinspect--completion-list-get-metadata comp-list comp)) (setq completion (phpinspect--completion-list-get-metadata comp-list comp))
(push (list comp (phpinspect--prefix-for-completion completion) (push (list comp (phpinspect--prefix-for-completion completion)
(phpinspect--completion-meta completion)) (concat " " (phpinspect--completion-meta completion)))
affixated)) affixated))
(nreverse affixated))) (nreverse affixated)))
:exit-function :exit-function

@ -226,8 +226,7 @@ be implemented for return values of `phpinspect-eld-strategy-execute'")
'face 'font-lock-variable-name-face) 'face 'font-lock-variable-name-face)
phpinspect-eldoc-word-width) phpinspect-eldoc-word-width)
": " ": "
(propertize (phpinspect--display-format-type-name (phpinspect--variable-type var)) (phpinspect--display-format-type-name (phpinspect--variable-type var))))
'face 'font-lock-type-face)))
(cl-defstruct (phpinspect-function-doc (:constructor phpinspect-make-function-doc)) (cl-defstruct (phpinspect-function-doc (:constructor phpinspect-make-function-doc))
(fn nil (fn nil
@ -256,9 +255,7 @@ be implemented for return values of `phpinspect-eld-strategy-execute'")
(phpinspect--function-arguments fn) (phpinspect--function-arguments fn)
", ") ", ")
"): " "): "
(propertize (phpinspect--display-format-type-name (phpinspect--function-return-type fn)))))
(phpinspect--display-format-type-name (phpinspect--function-return-type fn))
'face 'font-lock-type-face))))
(defvar phpinspect-eldoc-strategies (list (phpinspect-make-eld-attribute) (defvar phpinspect-eldoc-strategies (list (phpinspect-make-eld-attribute)
(phpinspect-make-eld-function-args) (phpinspect-make-eld-function-args)

@ -216,13 +216,15 @@ NAMESPACE may be nil, or a string with a namespace FQN."
(phpinspect--format-type-name (phpinspect--type-name type))) (phpinspect--format-type-name (phpinspect--type-name type)))
(cl-defmethod phpinspect--display-format-type-name ((name string)) (cl-defmethod phpinspect--display-format-type-name ((name string))
(phpinspect--format-type-name name)) (propertize (phpinspect--format-type-name name) 'face 'font-lock-type-face))
(cl-defmethod phpinspect--display-format-type-name ((type phpinspect--type)) (cl-defmethod phpinspect--display-format-type-name ((type phpinspect--type))
(let ((self (phpinspect--format-type-name type))) (let ((self (phpinspect--format-type-name type)))
(if (phpinspect--type-contains type) (propertize
(if (phpinspect--type-contains type)
(concat self "<" (phpinspect--format-type-name (phpinspect--type-contains type)) ">") (concat self "<" (phpinspect--format-type-name (phpinspect--type-contains type)) ">")
self))) self)
'face 'font-lock-type-face)))
(cl-defstruct (phpinspect--function (:constructor phpinspect--make-function-generated) (cl-defstruct (phpinspect--function (:constructor phpinspect--make-function-generated)
(:copier phpinspect--copy-function)) (:copier phpinspect--copy-function))

Loading…
Cancel
Save