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

    Convert names to alist for use as completing-read collection
    
    Fixes bug in `phpinspect-fix-imports'
---
 phpinspect-imports.el |  2 +-
 phpinspect-util.el    | 13 ++++++++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/phpinspect-imports.el b/phpinspect-imports.el
index 03c23fe532..31efa763f2 100644
--- a/phpinspect-imports.el
+++ b/phpinspect-imports.el
@@ -100,7 +100,7 @@ buffer position to insert the use statement at."
     (cond ((= 1 (length fqns))
            (phpinspect-add-use (phpinspect-name-string (car fqns)) buffer 
namespace-token))
           ((> (length fqns) 1)
-           (phpinspect-add-use (completing-read "Class: " fqns)
+           (phpinspect-add-use (completing-read "Class: " 
(phpinspect-names-to-alist fqns))
                                buffer namespace-token))
           (t (phpinspect-message "No import found for type %s" typename)))))
 
diff --git a/phpinspect-util.el b/phpinspect-util.el
index 4f4e3517e3..bd722871f2 100644
--- a/phpinspect-util.el
+++ b/phpinspect-util.el
@@ -25,7 +25,7 @@
 
 (defvar phpinspect-names (make-hash-table :test #'equal :size 5000 
:rehash-size 1.2)
   "An hash-table containing cons cells representing encountered names in
-PHP code. Used to optimize string comparison. See also 
`phpinspect-indern-name'")
+PHP code. Used to optimize string comparison. See also 
`phpinspect-intern-name'")
 
 (defun phpinspect-make-name-hash ()
   (make-hash-table :test #'equal :size 5000 :rehash-size 1.2))
@@ -70,8 +70,6 @@ PHP code. Used to optimize string comparison. See also 
`phpinspect-indern-name'"
               (eq group (cdr cons)))
             phpinspect-enabled-log-groups))
 
-(phpinspect--declare-log-group 'bam)
-
 (defmacro phpinspect--log (&rest args)
   (let ((log-group (alist-get (macroexp-file-name)
                               phpinspect-log-groups nil nil #'string=)))
@@ -124,9 +122,14 @@ level of START-FILE in stead of `default-directory`."
               (phpinspect--find-project-root parent-without-vendor))))))))
 
 (defun phpinspect-intern-name (name)
-  (setq name (cons 'phpinspect-name name))
   (or (gethash name phpinspect-names)
-      (puthash name name phpinspect-names)))
+      (puthash name (cons 'phpinspect-name name) phpinspect-names)))
+
+(defun phpinspect-names-to-alist (names)
+  (let ((alist))
+    (dolist (name names)
+      (push (cons (phpinspect-name-string name) name) alist))
+    alist))
 
 (defsubst phpinspect--wrap-plist-name-in-symbol (property-list)
   (let ((new-plist)

Reply via email to