branch: externals/phps-mode commit 696d66d7e76b37d968b226e9c892c42cb584ab77 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Bookkeeping of static variable inside function --- phps-mode-parser-sdt.el | 15 +++++++++++++++ test/phps-mode-test-ast.el | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el index a328e6d803..ddb9bea944 100644 --- a/phps-mode-parser-sdt.el +++ b/phps-mode-parser-sdt.el @@ -1786,6 +1786,21 @@ (puthash 156 (lambda(args _terminals) + (let ((static-var-list (nth 1 args))) + (dolist (static-var static-var-list) + (let ((static-var-type (plist-get static-var 'ast-type))) + (cond + ((equal static-var-type 'variable) + (let* ((variable-name (plist-get static-var 'ast-name)) + (variable-start (plist-get static-var 'ast-start)) + (variable-end (plist-get static-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))))))) `( ast-type static-statement diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el index 9619250711..4dde441bb1 100644 --- a/test/phps-mode-test-ast.el +++ b/test/phps-mode-test-ast.el @@ -331,7 +331,7 @@ (phps-mode-test-ast--should-bookkeep "<?php\n\n$var = 123;\n\nfunction test($abc) {\n static $var;\n if ($var) {\n echo 'Hit';\n }\n}" "Bookkeeping of static 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 $var" ((54 58))) ((35 39) 1) ((68 72) 1))) (phps-mode-test-ast--should-bookkeep "<?php\n\nglobal $a, $b;\n\nif ($a) {\n echo 'Hit';\n}\n\nfunction myFunction($c)\n{\n global $a;\n if ($a) {\n echo 'Hit';\n }\n if ($b) {\n echo 'Miss';\n }\n}\n"