[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phpinspect b6eadfb799 12/18: Make autoload indexation m
From: |
ELPA Syncer |
Subject: |
[elpa] externals/phpinspect b6eadfb799 12/18: Make autoload indexation more robust and prevent double indexation |
Date: |
Fri, 16 Aug 2024 06:58:57 -0400 (EDT) |
branch: externals/phpinspect
commit b6eadfb79970350b5ebc5441207931ad2247539a
Author: Hugo Thunnissen <devel@hugot.nl>
Commit: Hugo Thunnissen <devel@hugot.nl>
Make autoload indexation more robust and prevent double indexation
Prevent the project directory from being indexed multiple times (because of
directory-files-recursively also returning "." and "..".
---
phpinspect-autoload.el | 112 ++++++++++++++++++++++++++-----------------------
phpinspect-pipeline.el | 2 +-
2 files changed, 60 insertions(+), 54 deletions(-)
diff --git a/phpinspect-autoload.el b/phpinspect-autoload.el
index d556c9c395..1481c8705c 100644
--- a/phpinspect-autoload.el
+++ b/phpinspect-autoload.el
@@ -127,7 +127,9 @@ the vendor directory."
(when (phpinspect-fs-file-directory-p fs vendor-dir)
(dolist (author-dir (phpinspect-fs-directory-files fs vendor-dir))
- (when (phpinspect-fs-file-directory-p fs author-dir)
+ (when (and (phpinspect-fs-file-directory-p fs author-dir)
+ ;; Exclude current/parent directory
+ (not (member (file-name-base author-dir) (list ".." "."))))
(dolist (dependency-dir (phpinspect-fs-directory-files fs
author-dir))
(setq cj-path (concat dependency-dir "/composer.json"))
(when (and (phpinspect-fs-file-directory-p fs dependency-dir)
@@ -169,9 +171,13 @@ the vendor directory."
(cl-defmethod phpinspect-al-strategy-execute ((strat phpinspect-files))
(phpinspect--log "indexing files list: %s" (phpinspect-files-list strat))
- (let* ((indexer (phpinspect-autoloader-file-indexer
(phpinspect-files-autoloader strat))))
+ (let* ((indexer (phpinspect-autoloader-file-indexer
(phpinspect-files-autoloader strat)))
+ (wrapped-indexer (lambda (file)
+ (condition-case-unless-debug err
+ (funcall indexer file)
+ (t (phpinspect--log "Error indexing file %s: %s"
file err))))))
(phpinspect-pipeline (phpinspect-files-list strat)
- :into (funcall :with-context indexer))))
+ :into (funcall :with-context wrapped-indexer))))
(cl-defmethod phpinspect-autoloader-put-type-bag ((al phpinspect-autoloader)
(type-fqn (head phpinspect-name)))
(let* ((type-name (phpinspect-intern-name
@@ -189,62 +195,62 @@ the vendor directory."
((al phpinspect-autoloader) file)
(let* ((fs (phpinspect-autoloader-fs al))
(project-root (file-name-directory (cdr file)))
- json autoload batch)
-
+ json batch)
(condition-case err
(setq json (phpinspect--read-json-file fs (cdr file)))
(t (phpinspect-message "Error parsing composer json at %s : %s " (cdr
file) err)))
(when json
- (setq autoload (gethash "autoload" json))
-
- (when (hash-table-p autoload)
- (maphash
- (lambda (type prefixes)
- (let ((strategy))
- (pcase type
- ("psr-0"
- (maphash
- (lambda (prefix directory-paths)
- (when (stringp directory-paths)
- (setq directory-paths (list directory-paths)))
- (setq strategy (phpinspect-make-psr0-generated
- :autoloader al
- :fs fs
- :prefix prefix
- :own (eq 'local (car file))))
- (dolist (path directory-paths)
- (push (file-name-concat project-root path)
- (phpinspect-psr0-directories strategy)))
- (push strategy batch))
- prefixes))
- ("psr-4"
- (maphash
- (lambda (prefix directory-paths)
- (when (stringp directory-paths)
- (setq directory-paths (list directory-paths)))
- (setq strategy (phpinspect-make-psr4-generated
- :fs fs
- :autoloader al
- :prefix prefix
- :own (eq 'local (car file))))
- (dolist (path directory-paths)
- (push (file-name-concat project-root path)
- (phpinspect-psr4-directories strategy)))
- (push strategy batch))
- prefixes))
- ("files"
- (setq strategy
- (phpinspect-make-files
- :list (mapcar
- (lambda (file) (file-name-concat project-root
file))
- prefixes)
- :autoloader al))
- (push strategy batch))
- (_ (phpinspect--log "Unsupported autoload strategy \"%s\"
encountered" type)))))
- autoload)
- (phpinspect-pipeline-emit-all batch)))))
+ (dolist (autoload (list (gethash "autoload" json)
+ (when (eq 'local (car file)) (gethash
"autoload-dev" json))))
+ (when (hash-table-p autoload)
+ (maphash
+ (lambda (type prefixes)
+ (let ((strategy))
+ (pcase type
+ ("psr-0"
+ (maphash
+ (lambda (prefix directory-paths)
+ (when (stringp directory-paths)
+ (setq directory-paths (list directory-paths)))
+ (setq strategy (phpinspect-make-psr0-generated
+ :autoloader al
+ :fs fs
+ :prefix prefix
+ :own (eq 'local (car file))))
+ (dolist (path directory-paths)
+ (push (file-name-concat project-root path)
+ (phpinspect-psr0-directories strategy)))
+ (push strategy batch))
+ prefixes))
+ ("psr-4"
+ (maphash
+ (lambda (prefix directory-paths)
+ (when (stringp directory-paths)
+ (setq directory-paths (list directory-paths)))
+ (setq strategy (phpinspect-make-psr4-generated
+ :fs fs
+ :autoloader al
+ :prefix prefix
+ :own (eq 'local (car file))))
+ (dolist (path directory-paths)
+ (push (file-name-concat project-root path)
+ (phpinspect-psr4-directories strategy)))
+ (push strategy batch))
+ prefixes))
+ ("files"
+ (setq strategy
+ (phpinspect-make-files
+ :list (mapcar
+ (lambda (file) (file-name-concat project-root
file))
+ prefixes)
+ :autoloader al))
+ (push strategy batch))
+ (_ (phpinspect--log "Unsupported autoload strategy \"%s\"
encountered" type)))))
+ autoload)))
+ (phpinspect--log "Batch: %s" (length batch))
+ (phpinspect-pipeline-emit-all batch))))
(cl-defmethod phpinspect-autoloader-resolve ((autoloader phpinspect-autoloader)
diff --git a/phpinspect-pipeline.el b/phpinspect-pipeline.el
index 8e5fecbb27..a79636347c 100644
--- a/phpinspect-pipeline.el
+++ b/phpinspect-pipeline.el
@@ -319,7 +319,7 @@ directories."
(when ,seed-sym
(phpinspect-pipeline--enqueue
,queue-sym
- (phpinspect-make-pipeline-emission :collection ,seed-form)
'no-notify))
+ (phpinspect-make-pipeline-emission :collection ,seed-sym)
'no-notify))
(phpinspect-pipeline--enqueue
,queue-sym (phpinspect-make-pipeline-end :thread (current-thread)))
- [elpa] externals/phpinspect 93b815d71a 14/18: Index used traits (juste use of type, no actual functionality outside of that), (continued)
- [elpa] externals/phpinspect 93b815d71a 14/18: Index used traits (juste use of type, no actual functionality outside of that), ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect 6a175c9e44 06/18: Update a few doc strings in phpinspect-index.el, ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect 31c6e06934 09/18: Reparse buffer when fixing import (+ add comment explaining why), ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect 2e064d52e1 17/18: Implement containing type inference for collection-like class properties, ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect 5528aff2a2 01/18: Handle cases where the filepath of a type cannot be determined, ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect 2520c89680 02/18: Account for tokens after @method annotation when indexing, ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect f2f1ac9b84 05/18: Add property types and anonymous function argument types to used-types index, ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect 130e2c06c5 13/18: Index types used in arrays, ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect f1dc699560 11/18: Detect types used with "instanceoff", ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect 3a0ce3ac2d 16/18: Fix another infinite recursion bug, ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect b6eadfb799 12/18: Make autoload indexation more robust and prevent double indexation,
ELPA Syncer <=
- [elpa] externals/phpinspect c20f010ee4 10/18: Introduce `phpinspect-buffer-fresh-p' and `phpinspect-buffer-reparse-if-not-fresh', ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect 2d93ec7f79 15/18: Fix infinite recursion bug in `phpinspect--get-pattern-type-in-block', ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect 4ec4c40c9d 18/18: Add eldoc for sigil variables and allow display of multiple eldoc results, ELPA Syncer, 2024/08/16