emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode a1af5b11fb 040/212: More work on bookkeeping


From: Christian Johansson
Subject: [elpa] externals/phps-mode a1af5b11fb 040/212: More work on bookkeeping of class properties via AST
Date: Wed, 26 Jan 2022 01:50:24 -0500 (EST)

branch: externals/phps-mode
commit a1af5b11fb798f22b2cda39ea182d0947e1bbf6c
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    More work on bookkeeping of class properties via AST
---
 phps-mode-ast-bookkeeping.el | 54 +++++++++++++++++++++++++++++++++++++++-----
 test/phps-mode-test-ast.el   |  2 +-
 2 files changed, 49 insertions(+), 7 deletions(-)

diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
index b695406d00..7daf64317b 100644
--- a/phps-mode-ast-bookkeeping.el
+++ b/phps-mode-ast-bookkeeping.el
@@ -566,8 +566,8 @@
                 (let* ((sub-variable-namespace
                         (phps-mode-ast-bookkeeping--generate-variable-namespace
                          namespace
-                         nil
-                         function))
+                         class
+                         nil))
                        (variable-id
                         (format
                          "%s id $%s"
@@ -576,8 +576,8 @@
                        (sub-symbol-namespace
                         (phps-mode-ast-bookkeeping--generate-variable-namespace
                          namespace
-                         nil
-                         function))
+                         class
+                         nil))
                        (symbol-id
                         (format
                          "%s id %s"
@@ -587,20 +587,62 @@
                         (list
                          (plist-get item 'property-start)
                          (plist-get item 'property-end))))
+                  ;; (message "dereferenced: %S %S" variable-id symbol-id)
                   (if (or
                        (gethash variable-id bookkeeping)
                        (gethash symbol-id bookkeeping))
                       (puthash
                        bookkeeping-object
-                       t
+                       1
                        bookkeeping)
                     (puthash
                      bookkeeping-object
-                     nil
+                     0
                      bookkeeping))))
 
                )))
 
+           ((equal type 'static-member)
+            (let* ((parent-class (plist-get item 'class))
+                   (downcased-parent-class (downcase parent-class))
+                   (member (plist-get item 'member))
+                   (member-type (plist-get member 'ast-type)))
+
+              (cond
+
+               ((string= downcased-parent-class "self")
+
+                (cond
+
+                 ((equal member-type 'simple-variable)
+                  (let* ((sub-variable-namespace
+                          
(phps-mode-ast-bookkeeping--generate-variable-namespace
+                           namespace
+                           class
+                           nil))
+                         (variable-id
+                          (format
+                           "%s static id %s"
+                           sub-variable-namespace
+                           (plist-get member 'name)))
+                         (bookkeeping-object
+                          (list
+                           (plist-get member 'start)
+                           (plist-get member 'end))))
+                    (if (gethash variable-id bookkeeping)
+                        (puthash
+                         bookkeeping-object
+                         1
+                         bookkeeping)
+                      (puthash
+                       bookkeeping-object
+                       0
+                       bookkeeping))))
+
+                 )
+
+                ))))
+
            ))))
     (setq
      phps-mode-ast-bookkeeping--index
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index c57b9420f8..ba863c74cf 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -378,7 +378,7 @@
      (phps-mode-ast-bookkeeping--generate)
      (should (equal
               (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " class myParent id $var1" 1) (list (list 93 98) 1) 
(list " class myParent static id $var2" 1) (list (list 127 132) 1) (list " 
class myParent id $var3" 1) (list (list 145 150) 1) (list " class myParent id 
$var4" 1) (list (list 160 165) 1) (list " class myParent function __construct 
id $this" 1) (list (list 208 213) 1) (list (list 263 268) 1) (list (list 270 
274) 1) (list (list 330 335) 0) (list (list 392 397) 1) (list (list 447 452) 1) 
(list (list 454 458) 1) (l [...]
+              '((" class myParent id $var1" 1) ((93 98) 1) (" class myParent 
static id $var2" 1) ((127 132) 1) (" class myParent id $var3" 1) ((145 150) 1) 
(" class myParent id $var4" 1) ((160 165) 1) (" class myParent function 
__construct id $this" 1) ((208 213) 1) ((263 268) 1) ((270 274) 1) ((330 335) 
0) ((392 397) 1) ((447 452) 1) ((454 458) 1) ((508 513) 1) ((515 519) 1) ((569 
574) 1) ((576 580) 0) ((688 693) 0))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\ntry {\n    \n} catch (\\Exception $e) {\n    if ($e) {\n        
echo 'Hit';\n    }\n}\n\nif ($e) {\n    echo 'Miss';\n}\n"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]