[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phpinspect d141f8a6db 08/18: Infer namespace token with
From: |
ELPA Syncer |
Subject: |
[elpa] externals/phpinspect d141f8a6db 08/18: Infer namespace token within import manipulation loop |
Date: |
Fri, 16 Aug 2024 06:58:56 -0400 (EDT) |
branch: externals/phpinspect
commit d141f8a6db96e7a72c049970f8fccea5bee979b8
Author: Hugo Thunnissen <devel@hugot.nl>
Commit: Hugo Thunnissen <devel@hugot.nl>
Infer namespace token within import manipulation loop
---
phpinspect-imports.el | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/phpinspect-imports.el b/phpinspect-imports.el
index ec5fd7658f..f2329abd61 100644
--- a/phpinspect-imports.el
+++ b/phpinspect-imports.el
@@ -131,8 +131,10 @@ NAMESPACE-META itself is returned without alterations."
(phpinspect--type= import-type (phpinspect-use-name-to-type (cadadr
token)))))))
(defun phpinspect-remove-unneeded-use-statements (types buffer imports
parent-token)
- (let ((namespace (phpinspect-meta-find-parent-matching-token parent-token
#'phpinspect-namespace-p)))
- (dolist (import imports)
+ (dolist (import imports)
+ ;; Namespace must be inferred within the loop, see comments in
+ ;; `phpinspect-add-use-statements-for-missing-types' for context.
+ (let ((namespace (phpinspect-meta-find-parent-matching-token parent-token
#'phpinspect-namespace-p)))
(unless (member (car import) types)
(when-let ((use-meta (phpinspect-find-use-statement-for-import
namespace (cdr import))))
(let ((start-point (phpinspect-meta-start use-meta))
@@ -155,12 +157,16 @@ Uses PROJECT's autoloader to determine available types
for import.
PARENT-TOKEN must be a `token-meta' object and is used to
determine the scope of the imports (global or local namespace)."
- (let* ((namespace (phpinspect-meta-find-parent-matching-token
+ (dolist (type types)
+ ;; Namespace token must be inferred within the loop, as the ancestors of
+ ;; PARENT-TOKEN may change after a buffer reparse (which happens after each
+ ;; insert)
+ (let* ((namespace (phpinspect-meta-find-parent-matching-token
parent-token #'phpinspect-namespace-p))
- (namespace-name (if namespace
+ (namespace-name (if namespace
(phpinspect-namespace-name
(phpinspect-meta-token namespace))
"")))
- (dolist (type types)
+
;; Add use statements for types that aren't imported or already
referenced
;; with a fully qualified name.
(unless (or (or (alist-get type imports))
@@ -169,8 +175,9 @@ determine the scope of the imports (global or local
namespace)."
nil namespace-name (phpinspect-name-string type)))
(phpinspect-autoloader-types
(phpinspect-project-autoload project))))
- (phpinspect-add-use-interactive type buffer project namespace)
- (phpinspect-buffer-parse buffer 'no-interrupt)))))
+ (unless (member (phpinspect-name-string type)
phpinspect-native-typenames)
+ (phpinspect-add-use-interactive type buffer project namespace)
+ (phpinspect-buffer-parse buffer 'no-interrupt))))))
(defun phpinspect-fix-imports ()
"Find types that are used in the current buffer and make sure
- [elpa] externals/phpinspect updated (3887bc58d4 -> 4ec4c40c9d), ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect d3f100388e 04/18: Resolve property types using other methods when resolving from constructor fails, ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect 3fff772d8a 03/18: Fix phpinspect-buffer-index-functions test, ELPA Syncer, 2024/08/16
- [elpa] externals/phpinspect d141f8a6db 08/18: Infer namespace token within import manipulation loop,
ELPA Syncer <=
- [elpa] externals/phpinspect 8296641ba9 07/18: Implement removal of unused imports in `phpinspect-fix-imports', ELPA Syncer, 2024/08/16
- [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