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

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

[elpa] externals/phps-mode e6bc401d0b 068/135: Work on improving test fo


From: Christian Johansson
Subject: [elpa] externals/phps-mode e6bc401d0b 068/135: Work on improving test for global variable bookkeeping
Date: Sun, 29 Jan 2023 03:11:05 -0500 (EST)

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

    Work on improving test for global variable bookkeeping
---
 phps-mode-parser-sdt.el    | 30 ++++++++++++++++++++++++++++--
 test/phps-mode-test-ast.el |  2 +-
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 9d4866167a..c79fdef75a 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -647,6 +647,11 @@
             (setq function space-name))
            ((equal space-type 'anonymous-function)
             (setq anonymous-function space-name))
+           ((equal space-type 'global)
+            (setq namespace nil)
+            (setq class nil)
+            (setq function nil)
+            (setq anonymous-function nil))
            ((equal space-type 'object-operator)
             (let ((downcased-space-name
                    (downcase space-name)))
@@ -1694,12 +1699,33 @@
 (puthash
  155
  (lambda(args _terminals)
+   (let ((global-var-list (nth 1 args)))
+     (dolist (global-var global-var-list)
+       (let ((global-var-type (plist-get global-var 'ast-type)))
+         (cond
+          ((equal global-var-type 'simple-variable-variable)
+           (let ((variable-name (plist-get global-var 'variable))
+                 (variable-start (plist-get global-var 'ast-start))
+                 (variable-end (plist-get global-var 'ast-end)))
+             (push
+              (list
+               variable-name
+               phps-mode-parser-sdt--bookkeeping-namespace
+               variable-start
+               variable-end)
+              phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack)
+             (push
+              (list
+               variable-name
+               '((global))
+               variable-start
+               variable-end)
+              phps-mode-parser-sdt--bookkeeping-symbol-stack)))))))
    `(
      ast-type
      global-statement
      global-var-list
-     ,(nth 1 args)
-     ))
+     ,(nth 1 args)))
  phps-mode-parser--table-translations)
 
 ;; 156 ((statement) (T_STATIC static_var_list ";"))
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 15621b146a..e21aff41eb 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -274,7 +274,7 @@
    '((" id $bandom" ((18 25))) (" id $random" ((9 16))) ((18 25) 1) ((9 16) 1) 
((45 52) 1) ((78 85) 1)))
 
   (phps-mode-test-ast--should-bookkeep
-   "<?php\n\n$var = 123;\n\nfunction test($abc) {\n    global $var;\n    if 
($var) {\n        echo 'Hit';\n    }\n}"
+   "<?php\n\n$var = 123;\n\nfunction test($abc) {\n    global $var, $var2;\n   
 if ($var) {\n        echo 'Hit';\n    }\n    if ($var2) {\n        echo 
'Hit';\n    }\n}"
    "Bookkeeping of global variable declaration in function"
    '((" id $var" 1) ((8 12) 1) (" function test id $abc" 1) ((35 39) 1) (" 
function test id $var" 1) ((54 58) 1) ((68 72) 1)))
 



reply via email to

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