Fix bugs in phpinspect-fix-imports
continuous-integration/drone/push Build is passing Details

WIP-incremental-parsing
Hugo Thunnissen 1 year ago
parent 1b1cf45638
commit 97377c2922

@ -94,7 +94,7 @@ buffer position to insert the use statement at."
(cond ((= 1 (length fqns)) (cond ((= 1 (length fqns))
(phpinspect-add-use (symbol-name (car fqns)) buffer namespace-token)) (phpinspect-add-use (symbol-name (car fqns)) buffer namespace-token))
((> (length fqns) 1) ((> (length fqns) 1)
(phpinspect-add-use (symbol-name (completing-read "Class: " fqns)) (phpinspect-add-use (completing-read "Class: " fqns)
buffer namespace-token)) buffer namespace-token))
(t (message "No import found for type %s" typename)))))) (t (message "No import found for type %s" typename))))))

@ -217,11 +217,13 @@ function (think \"new\" statements, return types etc.)."
(cond (enc-extends (cond (enc-extends
(push (funcall type-resolver (phpinspect--make-type (push (funcall type-resolver (phpinspect--make-type
:name (cadr word))) :name (cadr word)))
extends)) extends)
(push (cadr word) used-types))
(enc-implements (enc-implements
(push (funcall type-resolver (phpinspect--make-type (push (funcall type-resolver (phpinspect--make-type
:name (cadr word))) :name (cadr word)))
implements)))))))) implements)
(push (cadr word) used-types))))))))
(dolist (token (caddr class)) (dolist (token (caddr class))
(cond ((phpinspect-scope-p token) (cond ((phpinspect-scope-p token)
@ -319,7 +321,6 @@ function (think \"new\" statements, return types etc.)."
(setq methods (setq methods
(nconc methods (phpinspect--index-method-annotations type-resolver doc-block)))) (nconc methods (phpinspect--index-method-annotations type-resolver doc-block))))
(let ((class-name (funcall type-resolver (phpinspect--make-type :name class-name)))) (let ((class-name (funcall type-resolver (phpinspect--make-type :name class-name))))
`(,class-name . `(,class-name .
(phpinspect--indexed-class (phpinspect--indexed-class

@ -70,7 +70,7 @@
(ert-deftest phpinspect-index-used-types-in-class () (ert-deftest phpinspect-index-used-types-in-class ()
(let* ((result (phpinspect--index-tokens (let* ((result (phpinspect--index-tokens
(phpinspect-parse-string (phpinspect-parse-string
"<?php namespace Field; class Potato { "<?php namespace Field; class Potato extends Cheese, Bacon implements Ham, Bagel {
public function makeThing(): Thing public function makeThing(): Thing
{ {
if ((new Monkey())->tree() === true) { if ((new Monkey())->tree() === true) {
@ -82,7 +82,8 @@ return StaticThing::create(new ThingFactory())->makeThing((((new Potato())->anti
(should (equal (should (equal
(mapcar #'phpinspect-intern-name (mapcar #'phpinspect-intern-name
(sort (sort
'("Monkey" "ExtendedThing" "StaticThing" "Thing" "ThingFactory" "Potato" "OtherThing") '("Cheese" "Bacon" "Ham" "Bagel" "Monkey" "ExtendedThing"
"StaticThing" "Thing" "ThingFactory" "Potato" "OtherThing")
#'string<)) #'string<))
(sort used-types (lambda (s1 s2) (string< (symbol-name s1) (symbol-name s2)))))))) (sort used-types (lambda (s1 s2) (string< (symbol-name s1) (symbol-name s2))))))))

Loading…
Cancel
Save