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

    Index used traits (juste use of type, no actual functionality outside of 
that)
---
 phpinspect-index.el | 4 ++++
 test/test-index.el  | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/phpinspect-index.el b/phpinspect-index.el
index 502b786861..a806829b82 100644
--- a/phpinspect-index.el
+++ b/phpinspect-index.el
@@ -349,6 +349,10 @@ SCOPE should be a scope token (`phpinspect-scope-p')."
              (setq comment-before token))
 
             ;; Prevent comments from sticking around too long
+            ((and (phpinspect-use-p token) (phpinspect-word-p (cadr token)))
+             ;; FIXME: Actually implement indexation of trait usage. This just
+             ;; marks the type as used for now.
+             (push (cadadr token) used-types))
             (t
              (phpinspect--log "Unsetting comment-before")
              (setq comment-before nil))))
diff --git a/test/test-index.el b/test/test-index.el
index 81abf763b6..4e9c0b5676 100644
--- a/test/test-index.el
+++ b/test/test-index.el
@@ -89,6 +89,8 @@
                   (phpinspect-parse-string
                    "<?php namespace Field; class Potato extends Cheese, Bacon 
implements Ham, Bagel {
 
+use UsedTrait;
+
 private PropertyType $property;
 
 public function makeThing(): Thing
@@ -110,7 +112,7 @@ if ($param instanceof InstanceOffed) {
                       (copy-sequence
                        '("Cheese" "Bacon" "Ham" "Bagel" "Monkey" 
"ExtendedThing"
                          "StaticThing" "Thing" "ThingFactory" "Potato" 
"OtherThing"
-                         "InnerFunctionParam" "PropertyType" "InstanceOffed" 
"NestedArray"))
+                         "InnerFunctionParam" "PropertyType" "InstanceOffed" 
"NestedArray" "UsedTrait"))
                       #'string<))
              (sort used-types (lambda (s1 s2) (string< (phpinspect-name-string 
s1) (phpinspect-name-string s2))))))))
 

Reply via email to