Refactor phpinspect--project to phpinspect-project
ci/woodpecker/push/woodpecker Pipeline was successful Details

WIP-incremental-parsing
Hugo Thunnissen 11 months ago
parent c2b06fe265
commit 47335f3450

@ -57,7 +57,7 @@
(cl-defstruct (phpinspect-autoloader (cl-defstruct (phpinspect-autoloader
(:constructor phpinspect-make-autoloader)) (:constructor phpinspect-make-autoloader))
(project nil (project nil
:type phpinspect--project :type phpinspect-project
:documentation "The project that this autoloader can find files for") :documentation "The project that this autoloader can find files for")
(own-types (make-hash-table :test 'eq :size 10000 :rehash-size 10000) (own-types (make-hash-table :test 'eq :size 10000 :rehash-size 10000)
:type hash-table :type hash-table
@ -111,8 +111,8 @@ bareword typenames."))
(cl-defmethod phpinspect-autoloader-refresh ((autoloader phpinspect-autoloader)) (cl-defmethod phpinspect-autoloader-refresh ((autoloader phpinspect-autoloader))
"Refresh autoload definitions by reading composer.json files "Refresh autoload definitions by reading composer.json files
from the project and vendor folders." from the project and vendor folders."
(let* ((project-root (phpinspect--project-root (phpinspect-autoloader-project autoloader))) (let* ((project-root (phpinspect-project-root (phpinspect-autoloader-project autoloader)))
(fs (phpinspect--project-fs (phpinspect-autoloader-project autoloader))) (fs (phpinspect-project-fs (phpinspect-autoloader-project autoloader)))
(vendor-dir (concat project-root "/vendor")) (vendor-dir (concat project-root "/vendor"))
(composer-json-path (concat project-root "/composer.json")) (composer-json-path (concat project-root "/composer.json"))
(composer-json) (composer-json)

@ -55,7 +55,7 @@ then returned."
:worker (phpinspect-make-dynamic-worker)) :worker (phpinspect-make-dynamic-worker))
(phpinspect--cache-projects cache))) (phpinspect--cache-projects cache)))
(let ((autoload (phpinspect-make-autoloader :project project))) (let ((autoload (phpinspect-make-autoloader :project project)))
(setf (phpinspect--project-autoload project) autoload) (setf (phpinspect-project-autoload project) autoload)
(phpinspect-autoloader-refresh autoload))) (phpinspect-autoloader-refresh autoload)))
project)) project))

@ -27,7 +27,7 @@
(cl-defstruct (phpinspect--class (:constructor phpinspect--make-class-generated)) (cl-defstruct (phpinspect--class (:constructor phpinspect--make-class-generated))
(project nil (project nil
:type phpinspect--project :type phpinspect-project
:documentaton :documentaton
"The project that this class belongs to") "The project that this class belongs to")
(index nil (index nil
@ -85,7 +85,7 @@
#'phpinspect--class-p #'phpinspect--class-p
(mapcar (mapcar
(lambda (class-name) (lambda (class-name)
(phpinspect--project-get-class-create (phpinspect--class-project class) (phpinspect-project-get-class-create (phpinspect--class-project class)
class-name)) class-name))
`(,@(alist-get 'implements index) ,@(alist-get 'extends index))))) `(,@(alist-get 'implements index) ,@(alist-get 'extends index)))))

@ -87,7 +87,7 @@ buffer position to insert the use statement at."
(format "%c%cuse %s;%c%c" ?\n ?\n fqn ?\n ?\n)))))))) (format "%c%cuse %s;%c%c" ?\n ?\n fqn ?\n ?\n))))))))
(defun phpinspect-add-use-interactive (typename buffer project &optional namespace-token) (defun phpinspect-add-use-interactive (typename buffer project &optional namespace-token)
(let* ((autoloader (phpinspect--project-autoload project)) (let* ((autoloader (phpinspect-project-autoload project))
(fqn-bags (phpinspect-autoloader-type-name-fqn-bags autoloader))) (fqn-bags (phpinspect-autoloader-type-name-fqn-bags autoloader)))
(let ((fqns (gethash typename fqn-bags))) (let ((fqns (gethash typename fqn-bags)))
@ -117,7 +117,7 @@ that there are import (\"use\") statements for them."
(imports (alist-get 'imports index)) (imports (alist-get 'imports index))
(project (phpinspect--cache-get-project-create (project (phpinspect--cache-get-project-create
(phpinspect--get-or-create-global-cache) (phpinspect--get-or-create-global-cache)
(phpinspect-project-root)))) (phpinspect-current-project-root))))
(dolist (class classes) (dolist (class classes)
(let* ((class-imports (alist-get 'imports class)) (let* ((class-imports (alist-get 'imports class))
(used-types (alist-get 'used-types class)) (used-types (alist-get 'used-types class))
@ -137,7 +137,7 @@ that there are import (\"use\") statements for them."
"\\" "\\"
(symbol-name type))) (symbol-name type)))
(phpinspect-autoloader-types (phpinspect-autoloader-types
(phpinspect--project-autoload project)))) (phpinspect-project-autoload project))))
(phpinspect-add-use-interactive (phpinspect-add-use-interactive
type phpinspect-current-buffer project namespace) type phpinspect-current-buffer project namespace)
;; Buffer has been modified by adding type, update tree + ;; Buffer has been modified by adding type, update tree +

@ -462,7 +462,7 @@ Return value is a list of the types that are \"newed\"."
(let ((project (phpinspect--cache-get-project-create (let ((project (phpinspect--cache-get-project-create
(phpinspect--get-or-create-global-cache) (phpinspect--get-or-create-global-cache)
project-root))) project-root)))
(phpinspect--project-get-class-create project class-fqn)))) (phpinspect-project-get-class-create project class-fqn))))
(defun phpinspect--index-current-buffer () (defun phpinspect--index-current-buffer ()
(phpinspect--index-tokens (phpinspect-parse-current-buffer))) (phpinspect--index-tokens (phpinspect-parse-current-buffer)))
@ -471,11 +471,11 @@ Return value is a list of the types that are \"newed\"."
"Index a PHP file for classes and the methods they have" "Index a PHP file for classes and the methods they have"
(phpinspect--index-tokens (phpinspect-parse-current-buffer))) (phpinspect--index-tokens (phpinspect-parse-current-buffer)))
(cl-defmethod phpinspect--index-type-file ((project phpinspect--project) (cl-defmethod phpinspect--index-type-file ((project phpinspect-project)
(type phpinspect--type)) (type phpinspect--type))
(condition-case error (condition-case error
(let* ((class-file (with-temp-buffer (let* ((class-file (with-temp-buffer
(cd (phpinspect--project-root project)) (cd (phpinspect-project-root project))
(phpinspect-type-filepath type))) (phpinspect-type-filepath type)))
(visited-buffer (when class-file (find-buffer-visiting class-file))) (visited-buffer (when class-file (find-buffer-visiting class-file)))
(new-index) (new-index)

@ -28,7 +28,7 @@
(require 'phpinspect-fs) (require 'phpinspect-fs)
(require 'filenotify) (require 'filenotify)
(cl-defstruct (phpinspect--project (:constructor phpinspect--make-project)) (cl-defstruct (phpinspect-project (:constructor phpinspect--make-project))
(class-index (make-hash-table :test 'eq :size 100 :rehash-size 40) (class-index (make-hash-table :test 'eq :size 100 :rehash-size 40)
:type hash-table :type hash-table
:documentation :documentation
@ -61,115 +61,115 @@ Projects get purged when they are removed from the global cache.")
:documentation "All active file watchers in this project, :documentation "All active file watchers in this project,
indexed by the absolute paths of the files they're watching.")) indexed by the absolute paths of the files they're watching."))
(cl-defgeneric phpinspect--project-add-class (cl-defgeneric phpinspect-project-add-class
((project phpinspect--project) (class (head phpinspect--indexed-class))) ((project phpinspect-project) (class (head phpinspect--indexed-class)))
"Add an indexed CLASS to PROJECT.") "Add an indexed CLASS to PROJECT.")
(cl-defmethod phpinspect--project-purge ((project phpinspect--project)) (cl-defmethod phpinspect-project-purge ((project phpinspect-project))
"Disable all background processes for project and put it in a `purged` state." "Disable all background processes for project and put it in a `purged` state."
(maphash (lambda (_ watcher) (file-notify-rm-watch watcher)) (maphash (lambda (_ watcher) (file-notify-rm-watch watcher))
(phpinspect--project-file-watchers project)) (phpinspect-project-file-watchers project))
(setf (phpinspect--project-file-watchers project) (setf (phpinspect-project-file-watchers project)
(make-hash-table :test #'equal :size 10000 :rehash-size 10000)) (make-hash-table :test #'equal :size 10000 :rehash-size 10000))
(setf (phpinspect--project-purged project) t)) (setf (phpinspect-project-purged project) t))
(cl-defmethod phpinspect--project-watch-file ((project phpinspect--project) (cl-defmethod phpinspect-project-watch-file ((project phpinspect-project)
filepath filepath
callback) callback)
(let ((watcher (file-notify-add-watch filepath '(change) callback))) (let ((watcher (file-notify-add-watch filepath '(change) callback)))
(puthash filepath watcher (phpinspect--project-file-watchers project)))) (puthash filepath watcher (phpinspect-project-file-watchers project))))
(cl-defmethod phpinspect--project-add-return-types-to-index-queueue (cl-defmethod phpinspect-project-add-return-types-to-index-queueue
((project phpinspect--project) methods) ((project phpinspect-project) methods)
(dolist (method methods) (dolist (method methods)
(when (phpinspect--function-return-type method) (when (phpinspect--function-return-type method)
(phpinspect--project-enqueue-if-not-present (phpinspect-project-enqueue-if-not-present
project project
(phpinspect--function-return-type method))))) (phpinspect--function-return-type method)))))
(cl-defmethod phpinspect--project-add-variable-types-to-index-queue (cl-defmethod phpinspect-project-add-variable-types-to-index-queue
((project phpinspect--project) variables) ((project phpinspect-project) variables)
(dolist (var variables) (dolist (var variables)
(when (phpinspect--variable-type var) (when (phpinspect--variable-type var)
(phpinspect--project-enqueue-if-not-present project (phpinspect--variable-type var))))) (phpinspect-project-enqueue-if-not-present project (phpinspect--variable-type var)))))
(cl-defmethod phpinspect--project-enqueue-if-not-present (cl-defmethod phpinspect-project-enqueue-if-not-present
((project phpinspect--project) (type phpinspect--type)) ((project phpinspect-project) (type phpinspect--type))
(unless (phpinspect--type-is-native type) (unless (phpinspect--type-is-native type)
(let ((class (phpinspect--project-get-class project type))) (let ((class (phpinspect-project-get-class project type)))
(when (or (not class) (when (or (not class)
(not (or (phpinspect--class-initial-index class)))) (not (or (phpinspect--class-initial-index class))))
(when (not class) (when (not class)
(setq class (phpinspect--project-create-class project type))) (setq class (phpinspect-project-create-class project type)))
(phpinspect--log "Adding unpresent class %s to index queue" type) (phpinspect--log "Adding unpresent class %s to index queue" type)
(phpinspect-worker-enqueue (phpinspect--project-worker project) (phpinspect-worker-enqueue (phpinspect-project-worker project)
(phpinspect-make-index-task project type)))))) (phpinspect-make-index-task project type))))))
(cl-defmethod phpinspect--project-add-class-attribute-types-to-index-queue (cl-defmethod phpinspect-project-add-class-attribute-types-to-index-queue
((project phpinspect--project) (class phpinspect--class)) ((project phpinspect-project) (class phpinspect--class))
(phpinspect--project-add-return-types-to-index-queueue (phpinspect-project-add-return-types-to-index-queueue
project project
(phpinspect--class-get-method-list class)) (phpinspect--class-get-method-list class))
(phpinspect--project-add-return-types-to-index-queueue (phpinspect-project-add-return-types-to-index-queueue
project project
(phpinspect--class-get-static-method-list class)) (phpinspect--class-get-static-method-list class))
(phpinspect--project-add-variable-types-to-index-queue (phpinspect-project-add-variable-types-to-index-queue
project project
(phpinspect--class-variables class))) (phpinspect--class-variables class)))
(cl-defmethod phpinspect--project-add-index (cl-defmethod phpinspect-project-add-index
((project phpinspect--project) (index (head phpinspect--root-index))) ((project phpinspect-project) (index (head phpinspect--root-index)))
(dolist (indexed-class (alist-get 'classes (cdr index))) (dolist (indexed-class (alist-get 'classes (cdr index)))
(phpinspect--project-add-class project (cdr indexed-class)))) (phpinspect-project-add-class project (cdr indexed-class))))
(cl-defmethod phpinspect--project-enqueue-imports (cl-defmethod phpinspect-project-enqueue-imports
((project phpinspect--project) imports) ((project phpinspect-project) imports)
(dolist (import imports) (dolist (import imports)
(when import (when import
(phpinspect--log "Adding import to index queue: %s" import) (phpinspect--log "Adding import to index queue: %s" import)
(phpinspect--project-enqueue-if-not-present project (cdr import))))) (phpinspect-project-enqueue-if-not-present project (cdr import)))))
(cl-defmethod phpinspect--project-add-class (cl-defmethod phpinspect-project-add-class
((project phpinspect--project) (indexed-class (head phpinspect--indexed-class))) ((project phpinspect-project) (indexed-class (head phpinspect--indexed-class)))
(let* ((class-name (phpinspect--type-name-symbol (let* ((class-name (phpinspect--type-name-symbol
(alist-get 'class-name (cdr indexed-class)))) (alist-get 'class-name (cdr indexed-class))))
(class (gethash class-name (class (gethash class-name
(phpinspect--project-class-index project)))) (phpinspect-project-class-index project))))
(unless class (unless class
(setq class (phpinspect--make-class-generated :project project))) (setq class (phpinspect--make-class-generated :project project)))
(phpinspect--class-set-index class indexed-class) (phpinspect--class-set-index class indexed-class)
(puthash class-name class (phpinspect--project-class-index project)) (puthash class-name class (phpinspect-project-class-index project))
(phpinspect--project-add-class-attribute-types-to-index-queue project class))) (phpinspect-project-add-class-attribute-types-to-index-queue project class)))
(cl-defmethod phpinspect--project-set-class (cl-defmethod phpinspect-project-set-class
((project phpinspect--project) (class-fqn phpinspect--type) (class phpinspect--class)) ((project phpinspect-project) (class-fqn phpinspect--type) (class phpinspect--class))
(puthash (phpinspect--type-name-symbol class-fqn) (puthash (phpinspect--type-name-symbol class-fqn)
class class
(phpinspect--project-class-index project))) (phpinspect-project-class-index project)))
(cl-defmethod phpinspect--project-create-class (cl-defmethod phpinspect-project-create-class
((project phpinspect--project) (class-fqn phpinspect--type)) ((project phpinspect-project) (class-fqn phpinspect--type))
(let ((class (phpinspect--make-class-generated :project project))) (let ((class (phpinspect--make-class-generated :project project)))
(phpinspect--project-set-class project class-fqn class) (phpinspect-project-set-class project class-fqn class)
class)) class))
(cl-defmethod phpinspect--project-get-class-create (cl-defmethod phpinspect-project-get-class-create
((project phpinspect--project) (class-fqn phpinspect--type)) ((project phpinspect-project) (class-fqn phpinspect--type))
(let ((class (phpinspect--project-get-class project class-fqn))) (let ((class (phpinspect-project-get-class project class-fqn)))
(unless class (unless class
(setq class (phpinspect--project-create-class project class-fqn)) (setq class (phpinspect-project-create-class project class-fqn))
(phpinspect--project-enqueue-if-not-present project class-fqn)) (phpinspect-project-enqueue-if-not-present project class-fqn))
class)) class))
(defalias 'phpinspect--project-add-class-if-missing #'phpinspect--project-get-class-create) (defalias 'phpinspect-project-add-class-if-missing #'phpinspect-project-get-class-create)
(cl-defmethod phpinspect--project-get-class (cl-defmethod phpinspect-project-get-class
((project phpinspect--project) (class-fqn phpinspect--type)) ((project phpinspect-project) (class-fqn phpinspect--type))
"Get indexed class by name of CLASS-FQN stored in PROJECT." "Get indexed class by name of CLASS-FQN stored in PROJECT."
(gethash (phpinspect--type-name-symbol class-fqn) (gethash (phpinspect--type-name-symbol class-fqn)
(phpinspect--project-class-index project))) (phpinspect-project-class-index project)))
(provide 'phpinspect-project) (provide 'phpinspect-project)
;;; phpinspect-project.el ends here ;;; phpinspect-project.el ends here

@ -35,7 +35,7 @@
(:constructor phpinspect-make-index-task-generated)) (:constructor phpinspect-make-index-task-generated))
"Represents an index task that can be executed by a `phpinspect-worker`." "Represents an index task that can be executed by a `phpinspect-worker`."
(project nil (project nil
:type phpinspect--project :type phpinspect-project
:documentation :documentation
"The project that the task should be executed for.") "The project that the task should be executed for.")
(type nil (type nil
@ -267,7 +267,7 @@ CONTINUE must be a condition-variable"
(if task (if task
;; Execute task if it belongs to a project that has not been ;; Execute task if it belongs to a project that has not been
;; purged (meaning that it is still actively used). ;; purged (meaning that it is still actively used).
(unless (phpinspect--project-purged (phpinspect-task-project task)) (unless (phpinspect-project-purged (phpinspect-task-project task))
(phpinspect-task-execute task worker)) (phpinspect-task-execute task worker))
;; else: join with the main thread until wakeup is signaled ;; else: join with the main thread until wakeup is signaled
(thread-join main-thread)) (thread-join main-thread))
@ -319,7 +319,7 @@ CONTINUE must be a condition-variable"
(interactive) (interactive)
(phpinspect-worker-stop phpinspect-worker)) (phpinspect-worker-stop phpinspect-worker))
(cl-defgeneric phpinspect-make-index-task ((project phpinspect--project) (cl-defgeneric phpinspect-make-index-task ((project phpinspect-project)
(type phpinspect--type)) (type phpinspect--type))
(phpinspect-make-index-task-generated (phpinspect-make-index-task-generated
:project project :project project
@ -342,7 +342,7 @@ CONTINUE must be a condition-variable"
(phpinspect-index-task-type task)))) (phpinspect-index-task-type task))))
(phpinspect--log "Indexing class %s for project in %s from index thread" (phpinspect--log "Indexing class %s for project in %s from index thread"
(phpinspect-index-task-type task) (phpinspect-index-task-type task)
(phpinspect--project-root project)) (phpinspect-project-root project))
(cond (is-native-type (cond (is-native-type
(phpinspect--log "Skipping indexation of native type %s" (phpinspect--log "Skipping indexation of native type %s"
@ -356,7 +356,7 @@ CONTINUE must be a condition-variable"
(let* ((type (phpinspect-index-task-type task)) (let* ((type (phpinspect-index-task-type task))
(root-index (phpinspect--index-type-file project type))) (root-index (phpinspect--index-type-file project type)))
(when root-index (when root-index
(phpinspect--project-add-index project root-index))))))) (phpinspect-project-add-index project root-index)))))))
(provide 'phpinspect-worker) (provide 'phpinspect-worker)

@ -136,7 +136,7 @@ statement of the innermost incomplete token as subject
accompanied by all of its enclosing tokens." accompanied by all of its enclosing tokens."
(unless resolvecontext (unless resolvecontext
(setq resolvecontext (phpinspect--make-resolvecontext (setq resolvecontext (phpinspect--make-resolvecontext
:project-root (phpinspect-project-root)))) :project-root (phpinspect-current-project-root))))
(let ((last-token (car (last token))) (let ((last-token (car (last token)))
(last-encountered-token (car (last-encountered-token (car
@ -160,14 +160,14 @@ accompanied by all of its enclosing tokens."
(defsubst phpinspect-cache-project-class (project-root indexed-class) (defsubst phpinspect-cache-project-class (project-root indexed-class)
(when project-root (when project-root
(phpinspect--project-add-class (phpinspect-project-add-class
(phpinspect--cache-get-project-create (phpinspect--get-or-create-global-cache) (phpinspect--cache-get-project-create (phpinspect--get-or-create-global-cache)
project-root) project-root)
indexed-class))) indexed-class)))
(defsubst phpinspect-get-cached-project-class (project-root class-fqn) (defsubst phpinspect-get-cached-project-class (project-root class-fqn)
(when project-root (when project-root
(phpinspect--project-get-class (phpinspect-project-get-class
(phpinspect--cache-get-project-create (phpinspect--get-or-create-global-cache) (phpinspect--cache-get-project-create (phpinspect--get-or-create-global-cache)
project-root) project-root)
class-fqn))) class-fqn)))
@ -354,7 +354,7 @@ TODO:
(let* ((type-of-previous-statement (let* ((type-of-previous-statement
(phpinspect-resolve-type-from-context resolvecontext type-resolver)) (phpinspect-resolve-type-from-context resolvecontext type-resolver))
(method-name-sym (phpinspect-intern-name (cadr (cadar (last statement 2))))) (method-name-sym (phpinspect-intern-name (cadr (cadar (last statement 2)))))
(class (phpinspect--project-get-class-create (class (phpinspect-project-get-class-create
(phpinspect--cache-get-project-create (phpinspect--cache-get-project-create
(phpinspect--get-or-create-global-cache) (phpinspect--get-or-create-global-cache)
(phpinspect--resolvecontext-project-root resolvecontext)) (phpinspect--resolvecontext-project-root resolvecontext))
@ -768,7 +768,7 @@ EXPRESSION."
(defun phpinspect--get-variables-for-class (buffer-classes class-name &optional static) (defun phpinspect--get-variables-for-class (buffer-classes class-name &optional static)
(let ((class (phpinspect-get-or-create-cached-project-class (let ((class (phpinspect-get-or-create-cached-project-class
(phpinspect-project-root) (phpinspect-current-project-root)
class-name))) class-name)))
;; TODO return static variables/constants when static is set ;; TODO return static variables/constants when static is set
(when class (when class
@ -828,18 +828,18 @@ users will have to use \\[phpinspect-purge-cache]."
(let ((imports (alist-get 'imports phpinspect--buffer-index)) (let ((imports (alist-get 'imports phpinspect--buffer-index))
(project (phpinspect--cache-get-project-create (project (phpinspect--cache-get-project-create
(phpinspect--get-or-create-global-cache) (phpinspect--get-or-create-global-cache)
(phpinspect-project-root)))) (phpinspect-current-project-root))))
(dolist (class (alist-get 'classes phpinspect--buffer-index)) (dolist (class (alist-get 'classes phpinspect--buffer-index))
(when class (when class
(phpinspect--project-add-class project (cdr class)) (phpinspect-project-add-class project (cdr class))
(let ((imports (alist-get 'imports (cdr class)))) (let ((imports (alist-get 'imports (cdr class))))
(when imports (when imports
(phpinspect--project-enqueue-imports project imports))))) (phpinspect-project-enqueue-imports project imports)))))
(when imports (phpinspect--project-enqueue-imports project imports))))) (when imports (phpinspect-project-enqueue-imports project imports)))))
(defun phpinspect--disable-mode () (defun phpinspect--disable-mode ()
@ -1187,7 +1187,7 @@ currently opened projects."
(when phpinspect-cache (when phpinspect-cache
;; Allow currently known cached projects to cleanup after themselves ;; Allow currently known cached projects to cleanup after themselves
(maphash (lambda (_ project) (maphash (lambda (_ project)
(phpinspect--project-purge project)) (phpinspect-project-purge project))
(phpinspect--cache-projects phpinspect-cache))) (phpinspect--cache-projects phpinspect-cache)))
;; Assign a fresh cache object ;; Assign a fresh cache object
@ -1229,7 +1229,7 @@ level of START-FILE in stead of `default-directory`."
(string= parent-without-vendor ""))) (string= parent-without-vendor "")))
(phpinspect--find-project-root parent-without-vendor)))))))) (phpinspect--find-project-root parent-without-vendor))))))))
(defsubst phpinspect-project-root () (defsubst phpinspect-current-project-root ()
"Call `phpinspect-project-root-function' with ARGS as arguments." "Call `phpinspect-project-root-function' with ARGS as arguments."
(unless (and (boundp 'phpinspect--buffer-project) phpinspect--buffer-project) (unless (and (boundp 'phpinspect--buffer-project) phpinspect--buffer-project)
(set (make-local-variable 'phpinspect--buffer-project) (funcall phpinspect-project-root-function))) (set (make-local-variable 'phpinspect--buffer-project) (funcall phpinspect-project-root-function)))
@ -1255,8 +1255,8 @@ fully qualified names from the project's source, and not its
dependencies, are returned." dependencies, are returned."
(let* ((project (phpinspect--cache-get-project-create (let* ((project (phpinspect--cache-get-project-create
(phpinspect--get-or-create-global-cache) (phpinspect--get-or-create-global-cache)
(phpinspect-project-root))) (phpinspect-current-project-root)))
(autoloader (phpinspect--project-autoload project))) (autoloader (phpinspect-project-autoload project)))
(let ((fqns)) (let ((fqns))
(maphash (lambda (type _) (push (symbol-name type) fqns)) (maphash (lambda (type _) (push (symbol-name type) fqns))
(if (eq 'own filter) (if (eq 'own filter)
@ -1298,8 +1298,8 @@ when INDEX-NEW is non-nil, new files are added to the index
before the search is executed." before the search is executed."
(let* ((project (phpinspect--cache-get-project-create (let* ((project (phpinspect--cache-get-project-create
(phpinspect--get-or-create-global-cache) (phpinspect--get-or-create-global-cache)
(phpinspect-project-root))) (phpinspect-current-project-root)))
(autoloader (phpinspect--project-autoload project))) (autoloader (phpinspect-project-autoload project)))
(when (eq index-new 'index-new) (when (eq index-new 'index-new)
(phpinspect-autoloader-refresh autoloader)) (phpinspect-autoloader-refresh autoloader))
(let* ((result (phpinspect-autoloader-resolve (let* ((result (phpinspect-autoloader-resolve
@ -1329,8 +1329,8 @@ before the search is executed."
(interactive) (interactive)
(let* ((project (phpinspect--cache-get-project-create (let* ((project (phpinspect--cache-get-project-create
(phpinspect--get-or-create-global-cache) (phpinspect--get-or-create-global-cache)
(phpinspect-project-root))) (phpinspect-current-project-root)))
(autoloader (phpinspect--project-autoload project))) (autoloader (phpinspect-project-autoload project)))
(phpinspect-autoloader-refresh autoloader) (phpinspect-autoloader-refresh autoloader)
(message (concat "Refreshed project autoloader. Found %d types within project," (message (concat "Refreshed project autoloader. Found %d types within project,"
" %d types total.") " %d types total.")

@ -484,7 +484,7 @@ class Thing
(phpinspect-eldoc-word-width 100)) (phpinspect-eldoc-word-width 100))
(phpinspect-purge-cache) (phpinspect-purge-cache)
(phpinspect-cache-project-class (phpinspect-cache-project-class
(phpinspect-project-root) (phpinspect-current-project-root)
(cdar (alist-get 'classes (cdr index)))) (cdar (alist-get 'classes (cdr index))))
(should (string= "getThis: ($moment DateTime, $thing Thing, $other): Thing" (should (string= "getThis: ($moment DateTime, $thing Thing, $other): Thing"
@ -510,7 +510,7 @@ class Thing
(phpinspect-eldoc-word-width 100)) (phpinspect-eldoc-word-width 100))
(phpinspect-purge-cache) (phpinspect-purge-cache)
(phpinspect-cache-project-class (phpinspect-cache-project-class
(phpinspect-project-root) (phpinspect-current-project-root)
(cdar (alist-get 'classes (cdr index)))) (cdar (alist-get 'classes (cdr index))))
(should (string= "doThing: ($moment DateTime, $thing Thing, $other): Thing" (should (string= "doThing: ($moment DateTime, $thing Thing, $other): Thing"
@ -538,7 +538,7 @@ class Thing
(context (phpinspect--get-resolvecontext tokens))) (context (phpinspect--get-resolvecontext tokens)))
(phpinspect-purge-cache) (phpinspect-purge-cache)
(phpinspect-cache-project-class (phpinspect-cache-project-class
(phpinspect-project-root) (phpinspect-current-project-root)
(cdar (alist-get 'classes (cdr index)))) (cdar (alist-get 'classes (cdr index))))
(should (phpinspect--type= (phpinspect--make-type :name "\\Thing") (should (phpinspect--type= (phpinspect--make-type :name "\\Thing")
@ -567,7 +567,7 @@ class Thing
(context (phpinspect--get-resolvecontext tokens))) (context (phpinspect--get-resolvecontext tokens)))
(phpinspect-purge-cache) (phpinspect-purge-cache)
(phpinspect-cache-project-class (phpinspect-cache-project-class
(phpinspect-project-root) (phpinspect-current-project-root)
(cdar (alist-get 'classes (cdr index)))) (cdar (alist-get 'classes (cdr index))))
(should (phpinspect--type= (phpinspect--make-type :name "\\Thing") (should (phpinspect--type= (phpinspect--make-type :name "\\Thing")

@ -28,9 +28,9 @@
(ert-deftest phpinspect-project-purge () (ert-deftest phpinspect-project-purge ()
(let ((project (phpinspect--make-project))) (let ((project (phpinspect--make-project)))
(phpinspect--project-purge project) (phpinspect-project-purge project)
(should (eq t (phpinspect--project-purged project))))) (should (eq t (phpinspect-project-purged project)))))
(ert-deftest phpinspect-project-watch-file-and-purge () (ert-deftest phpinspect-project-watch-file-and-purge ()
(let* ((root (make-temp-file "phpinspect-test" 'dir)) (let* ((root (make-temp-file "phpinspect-test" 'dir))
@ -38,9 +38,9 @@
(worker (phpinspect-make-worker)) (worker (phpinspect-make-worker))
(watch-file (concat root "/watch1")) (watch-file (concat root "/watch1"))
(project (phpinspect--make-project :fs fs :root root))) (project (phpinspect--make-project :fs fs :root root)))
(phpinspect--project-watch-file project watch-file (phpinspect-project-watch-file project watch-file
(lambda (&rest ignored))) (lambda (&rest ignored)))
(phpinspect--project-purge project) (phpinspect-project-purge project)
(should (= 0 (length (hash-table-values (phpinspect--project-file-watchers project))))))) (should (= 0 (length (hash-table-values (phpinspect-project-file-watchers project)))))))

Loading…
Cancel
Save