branch: externals/phps-mode commit a10656fc343a2298004d699fcc5576135e83c15b Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Passing bookkeeping test for global variables --- phps-mode-parser-sdt.el | 38 +++++++++++++++++++++++--------------- test/phps-mode-test-ast.el | 4 ++-- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el index 6fe350a325..1b19999470 100644 --- a/phps-mode-parser-sdt.el +++ b/phps-mode-parser-sdt.el @@ -752,11 +752,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 @@ -811,14 +811,15 @@ symbol-hit phps-mode-parser-sdt-bookkeeping) - (message - "reference symbol uri: %S from %S + %S, start: %S, end: %S, hit?: %S" - symbol-uri - symbol-name - symbol-scope - symbol-start - symbol-end - symbol-hit))) + ;; (message + ;; "reference symbol uri: %S from %S + %S, start: %S, end: %S, hit?: %S" + ;; symbol-uri + ;; symbol-name + ;; symbol-scope + ;; symbol-start + ;; symbol-end + ;; symbol-hit) + )) (setq phps-mode-parser-sdt--bookkeeping-symbol-stack nil))) @@ -1976,7 +1977,7 @@ (puthash 179 (lambda(args terminals) - ;; (message "parameter_list-args: %S" (nth 5 args)) + ;; (message "179-parameter_list-args: %S" (nth 5 args)) ;; (message "parameter_list-terminals: %S" (nth 5 terminals)) ;; Iterate optional parameters are declare them as new variable declarations @@ -2005,7 +2006,14 @@ symbol-scope symbol-start symbol-end) - phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack))))))) + phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack) + (push + (list + symbol-name + symbol-scope + symbol-start + symbol-end) + phps-mode-parser-sdt--bookkeeping-symbol-stack))))))) ;; (message "before:") ;; (message diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el index e21aff41eb..6248d3ae05 100644 --- a/test/phps-mode-test-ast.el +++ b/test/phps-mode-test-ast.el @@ -226,7 +226,7 @@ (phps-mode-test-ast--should-bookkeep "<?php\n\n$var2 = 4;\n\nfunction myFunction($var)\n{\n $var3 = 3;\n if ($var) {\n echo 'Hit';\n }\n if ($var2) {\n echo 'Miss';\n }\n if ($var3) {\n echo 'Hit';\n }\n}\n\nfunction myFunction2($abc)\n{\n if ($var) {\n echo 'Miss';\n }\n if ($abc) {\n echo 'Hit';\n }\n}\n\nif ($var) {\n echo 'Miss';\n}\nif ($var2) {\n echo 'Hit';\n}" "Bookkeeping in function level with variable assignments" - '((" id $var2" ((8 13))) ((8 13) 1) (" function myFunction id $var" ((40 44))) (" function myFunction id $var3" ((52 57))) ((157 162) 1) ((113 118) 0) ((71 75) 1) ((52 57) 1) (" function myFunction2 id $abc" ((216 220))) ((275 279) 1) ((232 236) 0) ((316 320) 0) ((347 352) 1))) + '((" id $var2" ((8 13))) ((8 13) 1) (" function myFunction id $var" ((40 44))) (" function myFunction id $var3" ((52 57))) ((40 44) 1) ((157 162) 1) ((113 118) 0) ((71 75) 1) ((52 57) 1) (" function myFunction2 id $abc" ((216 220))) ((216 220) 1) ((275 279) 1) ((232 236) 0) ((316 320) 0) ((347 352) 1))) (phps-mode-test-ast--should-bookkeep "<?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}" @@ -276,7 +276,7 @@ (phps-mode-test-ast--should-bookkeep "<?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))) + '((" id $var" ((8 12))) ((8 12) 1) (" function test id $abc" ((35 39))) (" function test id $var2" ((60 65))) (" function test id $var" ((54 58))) ((35 39) 1) ((117 122) 1) ((75 79) 1) ((60 65) 0) ((54 58) 1))) (phps-mode-test-ast--should-bookkeep "<?php\n$y = 1;\n$fn1 = fn($x) => $x + $y;\n$z = 1;\n$fn = fn($x2) => fn($y2) => $x2 * $y2 + $z;\nfn(array $x3) => $x3;\n$x4 = 4;\nstatic fn(): int => $x4;\nfn($x5 = 42) => $x5;\nfn(&$x6) => $x6;\nfn&($x7) => $x7;\nfn($x8, ...$rest) => $rest;"