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

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

[elpa] externals/phps-mode 4dc07c9041 050/212: Bookkeeping via AST worki


From: Christian Johansson
Subject: [elpa] externals/phps-mode 4dc07c9041 050/212: Bookkeeping via AST working with assigned variables from array
Date: Wed, 26 Jan 2022 01:50:40 -0500 (EST)

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

    Bookkeeping via AST working with assigned variables from array
---
 phps-mode-ast-bookkeeping.el | 13 +++++++++++++
 phps-mode-parser-sdt.el      | 28 +++++++++++++++++++++++-----
 test/phps-mode-test-ast.el   |  2 +-
 3 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
index 53a5e8d6f4..0655bf0091 100644
--- a/phps-mode-ast-bookkeeping.el
+++ b/phps-mode-ast-bookkeeping.el
@@ -398,6 +398,19 @@
                defined
                bookkeeping)))
 
+           ((equal type 'assign-variables-from-array)
+            (when-let ((keys (reverse (plist-get item 'keys))))
+              (dolist (key keys)
+                (push
+                 (list
+                  scope
+                  (list
+                   'ast-type
+                   'assign-variable
+                   'key
+                   key))
+                 bookkeeping-stack))))
+
            ((and
              (equal type 'assign-variable)
              (plist-get (plist-get item 'key) 'name))
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index a82a32bcba..b2e391d749 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -585,16 +585,21 @@
      ast-object))
  phps-mode-parser--table-translations)
 
-;; expr -> (variable T_INC)
+;; expr -> ("[" array_pair_list "]" "=" expr)
 (puthash
- 353
+ 336
  (lambda(args _terminals)
    (let ((ast-object
           (list
            'ast-type
-           'increment-variable
-           'variable
-           (nth 0 args))))
+           'assign-variables-from-array
+           'keys
+           (nth 1 args)
+           'values
+           (phps-mode-parser-sdt--get-list-of-object (nth 4 args)))))
+     ;; (message "Method: %S" ast-object)
+     ;; (message "args: %S" args)
+     ;; (message "terminals: %S" terminals)
      ast-object))
  phps-mode-parser--table-translations)
 
@@ -623,6 +628,19 @@
      ast-object))
  phps-mode-parser--table-translations)
 
+;; expr -> (variable T_INC)
+(puthash
+ 353
+ (lambda(args _terminals)
+   (let ((ast-object
+          (list
+           'ast-type
+           'increment-variable
+           'variable
+           (nth 0 args))))
+     ast-object))
+ phps-mode-parser--table-translations)
+
 ;; inline_function -> (function returns_ref backup_doc_comment "(" 
parameter_list ")" lexical_vars return_type backup_fn_flags "{" 
inner_statement_list "}" backup_fn_flags)
 (puthash
  416
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 569802af74..0ab8142928 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -483,7 +483,7 @@
      (phps-mode-ast-bookkeeping--generate)
      (should (equal
               (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
-              (list (list " id $random" 1) (list (list 9 16) 1) (list " id 
$bandom" 1) (list (list 18 25) 1) (list (list 45 52) 1) (list (list 78 85) 
1))))))
+              '((" id $random" 1) ((9 16) 1) (" id $bandom" 1) ((18 25) 1) 
((45 52) 1) ((78 85) 1))))))
 
   (phps-mode-test-ast--buffer-contents
    "<?php\n\n$var = 123;\n\nfunction test($abc) {\n    global $var;\n    if 
($var) {\n        echo 'Hit';\n    }\n}"



reply via email to

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