Skip to content

Commit

Permalink
Make make-completion public and improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
xendk committed Apr 15, 2017
1 parent 71427ec commit abc64bc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ede-php-autoload/class-loader/classmap.el
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ prefix."
(when (string-prefix-p prefix class)
(add-to-list 'completions class)))
(oref this class-hash))
(cl-loop for name in completions collect (ede-php-autoload--make-completion name :file name))))
(cl-loop for name in completions collect (ede-php-autoload-make-completion name :file name))))

(ede-php-autoload-class-loader-define-factory :class-map (classes)
(let ((class-hash))
Expand Down
16 changes: 9 additions & 7 deletions ede-php-autoload/class-loader/core.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ FILE-NAME must be absolute or relative to the project root."
PREFIX is the beginning of a fully-qualified name.
The result is a list of completion suggestions for this
prefix. Completions are not guaranteed to give full class names,
this can only suggest the next namespace."
'())
The result is a list of completion suggestions for this prefix,
see `ede-php-autoload-make-completion' for the structure of each
completion." '())

;;; Utility functions for loaders

Expand All @@ -76,11 +75,14 @@ Example: (ede-php-autoload--get-path-relative-to-ns \"My\\Ns\\My\\Class\" \"My\\
"/")
(or extension ".php")))

(defun ede-php-autoload--make-completion (name type full-name)
(defun ede-php-autoload-make-completion (name type full-name)
"Create a completion item.
NAME is the name of the completion. TYPE is the type and
FULL-NAME is the fully qualified name."
NAME is the name of the completion. TYPE is one
of :namespace, :file or :directory and FULL-NAME is the fully
qualified name.
Returns an alist with corresponding keys."
`((name . ,name)
(type . ,type)
(full-name . ,full-name)))
Expand Down
4 changes: 2 additions & 2 deletions ede-php-autoload/class-loader/psr0.el
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ PREFIX is the beginning of the type to complete."
((string-prefix-p prefix namespace t)
;; If `prefix' is the beginning of `namespace', let's use
;; `namespace' as suggestion
(push (ede-php-autoload--make-completion namespace :namespace namespace) suggestions))
(push (ede-php-autoload-make-completion namespace :namespace namespace) suggestions))
((string-prefix-p namespace prefix)
;; If `prefix' starts with `namespace', let's use directory and
;; file structure to create suggestions
Expand All @@ -129,7 +129,7 @@ PREFIX is the beginning of the type to complete."
(let ((suggestion (ede-php-autoload--create-psr-0-suggestions
file-name
prefix)))
(ede-php-autoload--make-completion
(ede-php-autoload-make-completion
suggestion
;; A bit of a cop out, but right now it's the best option.
(if (string-match-p "\\.php$" file-name) :file :directory)
Expand Down
4 changes: 2 additions & 2 deletions ede-php-autoload/class-loader/psr4.el
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ PREFIX is the beginning of the type to complete."
((string-prefix-p prefix namespace t)
;; If `prefix' is the beginning of `namespace', let's use
;; `namespace' as suggestion
(push (ede-php-autoload--make-completion namespace :namespace namespace) suggestions))
(push (ede-php-autoload-make-completion namespace :namespace namespace) suggestions))
((string-prefix-p namespace prefix)
;; If `prefix' starts with `namespace', let's use directory and
;; file structure to create suggestions
Expand All @@ -150,7 +150,7 @@ PREFIX is the beginning of the type to complete."
(mapcar
#'(lambda (file-name)
(let ((suggestion (file-name-base file-name)))
(ede-php-autoload--make-completion
(ede-php-autoload-make-completion
suggestion
(if (equal suggestion file-name) :directory :file)
(mapconcat 'identity
Expand Down

0 comments on commit abc64bc

Please sign in to comment.