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

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

[elpa] externals/phps-mode cc584ff4d6 061/135: Bookkeping of static clas


From: Christian Johansson
Subject: [elpa] externals/phps-mode cc584ff4d6 061/135: Bookkeping of static class properties test passing
Date: Sun, 29 Jan 2023 03:11:04 -0500 (EST)

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

    Bookkeping of static class properties test passing
---
 phps-mode-parser-sdt.el    | 66 +++++++++++++++++++++-------------------------
 test/phps-mode-test-ast.el |  2 +-
 2 files changed, 31 insertions(+), 37 deletions(-)

diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 8590d2e446..6c7fb4b525 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -596,6 +596,11 @@
   nil
   "Current bookkeeping namespace.")
 
+(defvar-local
+  phps-mode-parser-sdt--bookkeeping-namespace-stack
+  nil
+  "Current bookkeeping namespace.")
+
 (defvar-local
   phps-mode-parser-sdt--bookkeeping-symbol-stack
   nil
@@ -727,11 +732,11 @@
               (phps-mode-parser-sdt--get-symbol-uri
                symbol-name
                symbol-scope)))
-        (message
-         "assign symbol uri: %S from %S + %S"
-         symbol-uri
-         symbol-name
-         symbol-scope)
+        ;; (message
+        ;;  "assign symbol uri: %S from %S + %S"
+        ;;  symbol-uri
+        ;;  symbol-name
+        ;;  symbol-scope)
         (if (gethash symbol-uri phps-mode-parser-sdt-bookkeeping)
             (puthash
              symbol-uri
@@ -764,11 +769,11 @@
               (phps-mode-parser-sdt--get-symbol-uri
                symbol-name
                symbol-scope)))
-        (message
-         "reference symbol uri: %S from %S + %S"
-         symbol-uri
-         symbol-name
-         symbol-scope)
+        ;; (message
+        ;;  "reference symbol uri: %S from %S + %S"
+        ;;  symbol-uri
+        ;;  symbol-name
+        ;;  symbol-scope)
         (cond
 
          ;; Super-global variable
@@ -5665,29 +5670,6 @@
 (puthash
  512
  (lambda(args terminals)
-   (let ((static-member-type
-          (plist-get
-           args
-           'ast-type)))
-     (cond
-      ((equal static-member-type 'static-member-class-name)
-       (let* ((class-name (plist-get args 'class-name))
-              (class-name-type (plist-get class-name 'ast-type)))
-         (cond
-          ((equal class-name-type 'class-name-name)
-           (let* ((class-name-string (plist-get class-name 'name))
-                  (simple-variable (plist-get args 'simple-variable))
-                  (simple-variable-type (plist-get simple-variable 'ast-type)))
-             (cond
-              ((equal simple-variable-type 'simple-variable-variable)
-               (let ((simple-variable-name
-                      (plist-get simple-variable 'variable))
-                     (namespace
-                      phps-mode-parser-sdt--bookkeeping-namespace))
-                 ;; TODO Should modify stack car instead
-                 (push
-                  (list 'static-member class-name-string)
-                  (nth 1 (car 
phps-mode-parser-sdt--bookkeeping-symbol-stack)))))))))))))
    `(
      ast-type
      variable-static-member
@@ -5802,11 +5784,14 @@
          (symbol-start
           (car (cdr terminals)))
          (symbol-end
-          (cdr (cdr terminals))))
+          (cdr (cdr terminals)))
+         (namespace phps-mode-parser-sdt--bookkeeping-namespace))
+     (when phps-mode-parser-sdt--bookkeeping-namespace-stack
+       (setq namespace (pop 
phps-mode-parser-sdt--bookkeeping-namespace-stack)))
      (push
       (list
        symbol-name
-       phps-mode-parser-sdt--bookkeeping-namespace
+       namespace
        symbol-start
        symbol-end)
       phps-mode-parser-sdt--bookkeeping-symbol-stack))
@@ -5850,7 +5835,15 @@
 ;; 518 ((static_member) (class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable))
 (puthash
  518
- (lambda(args _terminals)
+ (lambda(args terminals)
+   (let* ((class-name (nth 0 args))
+          (class-name-type (plist-get class-name 'ast-type)))
+     (cond
+      ((equal class-name-type 'class-name-name)
+       (let ((class-name-string (plist-get class-name 'name))
+             (namespace phps-mode-parser-sdt--bookkeeping-namespace))
+         (push (list 'static-member class-name-string) namespace)
+         (push namespace phps-mode-parser-sdt--bookkeeping-namespace-stack)))))
    `(
      ast-type
      static-member-class-name
@@ -5864,6 +5857,7 @@
 (puthash
  519
  (lambda(args _terminals)
+   ;; TODO Add bookkeeping here
    `(
      ast-type
      static-member-variable-class-name
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 76c8e92bee..ce995c6c02 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -246,7 +246,7 @@
   (phps-mode-test-ast--should-bookkeep
    "<?php\n\n// Class properties\n\nclass myParent {}\n\nclass myClass extends 
myParent {\n    private $var1 = 123;\n    protected static $var2;\n    public 
$var3;\n    var $var4;\n    function __construct() {\n        if ($this) {\n    
        echo 'Hit';\n        }\n        if ($this->var1) {\n            echo 
'Hit';\n        }\n        if (self::$var1) {\n            echo 'Miss';\n       
 }\n        if (self::$var2) {\n            echo 'Hit';\n        }\n        if 
(static::$var2) {\n [...]
    "Bookkeeping of class properties"
-   '((" class myClass id $var1" 1) ((93 98) 1) (" class myClass static id 
$var2" 1) ((127 132) 1) (" class myClass id $var3" 1) ((145 150) 1) (" class 
myClass id $var4" 1) ((160 165) 1) (" class myClass 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)))
+   '((" class myClass function __construct id $this" ((194 743))) (" class 
myClass id $var4" ((160 165))) (" class myClass id $var3" ((145 150))) (" class 
myClass static id $var2" ((127 132))) (" class myClass id $var1" ((93 98))) 
((639 643) 0) ((632 637) 1) ((578 582) 1) ((571 576) 1) ((517 521) 1) ((510 
515) 1) ((455 460) 1) ((392 397) 1) ((330 335) 0) ((270 274) 1) ((263 268) 1) 
((208 213) 1) ((751 756) 0)))
 
   (phps-mode-test-ast--should-bookkeep
    "<?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]