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

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

[elpa] externals/phps-mode 3fb73ee 37/62: Added bookkeeping support of s


From: Christian Johansson
Subject: [elpa] externals/phps-mode 3fb73ee 37/62: Added bookkeeping support of superglobals $argc, $argv and $http_response_header
Date: Tue, 20 Apr 2021 10:56:19 -0400 (EDT)

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

    Added bookkeeping support of superglobals $argc, $argv and 
$http_response_header
---
 phps-mode-lex-analyzer.el           | 29 ++++++++++++++---------------
 test/phps-mode-test-lex-analyzer.el |  4 ++--
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index 4a0dd5f..ed66b6d 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -726,21 +726,17 @@
                       ;; 1. Determine state (incremental-state) and 
state-stack (incremental-state-stack) heredoc label (incremental-heredoc-label) 
heredoc-label-stack (heredoc-label-stack) before incremental start
                       ;; 2. Build list of states before incremental start 
(head-states)
                       (catch 'quit
-                        (let ((previous-state))
-                          (dolist (state-object (nreverse old-states))
-                            (let ((end (nth 1 state-object)))
-                              (if (<= end incremental-start-new-buffer)
-                                  (progn
-                                    (setq incremental-state (nth 2 
state-object))
-                                    (setq incremental-state-stack (nth 3 
state-object))
-                                    (setq incremental-heredoc-label (nth 4 
state-object))
-                                    (setq incremental-heredoc-label-stack (nth 
5 state-object))
-                                    (setq incremental-nest-location-stack (nth 
6 state-object))
-                                    (push state-object head-states))
-                                (throw 'quit "break")))
-                            (setq
-                             previous-state
-                             state-object))))
+                        (dolist (state-object (nreverse old-states))
+                          (let ((end (nth 1 state-object)))
+                            (if (<= end incremental-start-new-buffer)
+                                (progn
+                                  (setq incremental-state (nth 2 state-object))
+                                  (setq incremental-state-stack (nth 3 
state-object))
+                                  (setq incremental-heredoc-label (nth 4 
state-object))
+                                  (setq incremental-heredoc-label-stack (nth 5 
state-object))
+                                  (setq incremental-nest-location-stack (nth 6 
state-object))
+                                  (push state-object head-states))
+                              (throw 'quit "break")))))
 
                       (phps-mode-debug-message
                        (message "Head states: %s" head-states)
@@ -1250,6 +1246,9 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
                                   (equal bookkeeping-variable-name "$_REQUEST")
                                   (equal bookkeeping-variable-name "$_SERVER")
                                   (equal bookkeeping-variable-name "$_SESSION")
+                                  (equal bookkeeping-variable-name "$argc")
+                                  (equal bookkeeping-variable-name "$argv")
+                                  (equal bookkeeping-variable-name 
"$http_​response_​header")
                                   ))
                         (setq bookkeeping-is-superglobal t))
 
diff --git a/test/phps-mode-test-lex-analyzer.el 
b/test/phps-mode-test-lex-analyzer.el
index 80d4318..75a2e2b 100644
--- a/test/phps-mode-test-lex-analyzer.el
+++ b/test/phps-mode-test-lex-analyzer.el
@@ -1404,12 +1404,12 @@
             (list (list " id $var2" 1) (list (list 8 13) 1) (list " function 
myFunction id $var" 1) (list (list 40 44) 1) (list " function myFunction id 
$var3" 1) (list (list 52 57) 1) (list (list 70 74) 1) (list (list 112 117) 0) 
(list (list 156 161) 1) (list " function myFunction2 id $abc" 1) (list (list 
215 219) 1) (list (list 231 235) 0) (list (list 274 278) 1) (list (list 315 
319) 0) (list (list 346 351) 1)))))
 
   (phps-mode-test--with-buffer
-   "<?php\n\n// Super-globals\n\nif ($_GET) {\n    echo 'Hit';\n}\nif ($_POST) 
{\n    echo 'Hit';\n}\nif ($_COOKIE) {\n    echo 'Hit';\n}\nif ($_SESSION) {\n  
  echo 'Hit';\n}\nif ($_REQUEST) {\n    echo 'Hit';\n}\nif ($GLOBALS) {\n    
echo 'Hit';\n}\nif ($_SERVER) {\n    echo 'Hit';\n}\nif ($_FILES) {\n    echo 
'Hit';\n}\nif ($_ENV) {\n    echo 'Hit';\n}"
+   "<?php\n\n// Super-globals\n\nif ($_GET) {\n    echo 'Hit';\n}\nif ($_POST) 
{\n    echo 'Hit';\n}\nif ($_COOKIE) {\n    echo 'Hit';\n}\nif ($_SESSION) {\n  
  echo 'Hit';\n}\nif ($_REQUEST) {\n    echo 'Hit';\n}\nif ($GLOBALS) {\n    
echo 'Hit';\n}\nif ($_SERVER) {\n    echo 'Hit';\n}\nif ($_FILES) {\n    echo 
'Hit';\n}\nif ($_ENV) {\n    echo 'Hit';\n}\nif ($argc) {\n    echo 
'Hit';\n}\nif ($argv) {\n    echo 'Hit';\n}\nif ($http_​response_​header) {\n   
 echo 'Hit';\n}"
    "Bookkeeping of super-globals"
    (should
     (equal
      (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t)
-     (list (list (list 30 35) 1) (list (list 61 67) 1) (list (list 93 101) 1) 
(list (list 127 136) 1) (list (list 162 171) 1) (list (list 197 205) 1) (list 
(list 231 239) 1) (list (list 265 272) 1) (list (list 298 303) 1)))))
+     (list (list (list 30 35) 1) (list (list 61 67) 1) (list (list 93 101) 1) 
(list (list 127 136) 1) (list (list 162 171) 1) (list (list 197 205) 1) (list 
(list 231 239) 1) (list (list 265 272) 1) (list (list 298 303) 1) (list (list 
329 334) 1) (list (list 360 365) 1)  (list (list 391 414) 1)))))
 
   (phps-mode-test--with-buffer
    "<?php\n\nnamespace myNamespaceA {\n    $var = 123;\n    class myClassA {\n 
       private $var2 = 123;\n        function myFunctionA($var3) {\n            
$var4 = 123;\n            if ($var) {\n                echo 'Miss';\n           
 }\n            if ($var2) {\n                echo 'Miss';\n            }\n     
       if ($var3) {\n                echo 'Hit';\n            }\n            if 
($var4) {\n                echo 'Hit';\n            }\n        }\n\n        
function myFuncti [...]



reply via email to

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