branch: externals/phps-mode commit 9ad46d061e098d7660d638b160178731df4a2444 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Bookkeeping via AST passing two more tests --- phps-mode-ast-bookkeeping.el | 22 ++++++++++++++++++++++ test/phps-mode-test-ast.el | 10 +++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el index 2c67e324bb..14042c6a54 100644 --- a/phps-mode-ast-bookkeeping.el +++ b/phps-mode-ast-bookkeeping.el @@ -644,6 +644,28 @@ 0 bookkeeping)))) + (t + (let ((variable-ids + (phps-mode-ast-bookkeeping--generate-variable-scope-string + scope + (plist-get subject 'name) + t)) + (predefined 0)) + ;; (message "variable-ids: %S" variable-ids) + (dolist (variable-id variable-ids) + (when (gethash + variable-id + bookkeeping) + (setq + predefined + 1))) + (puthash + (list + (plist-get subject 'start) + (plist-get subject 'end)) + predefined + bookkeeping))) + ))) ((equal type 'static-member) diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el index 72ce917c9c..43a557a682 100644 --- a/test/phps-mode-test-ast.el +++ b/test/phps-mode-test-ast.el @@ -233,7 +233,7 @@ (phps-mode-test-ast--buffer-contents "<?php\n\n$var = 'abc';\n\nif ($var2) {\n echo 'This never happens';\n}\nif ($var) {\n echo 'This happens';\n}" - "Bookkeeping in root level variable assignments #1." + "Bookkeeping in root level variable assignments #1" (lambda() (let ((parse (phps-mode-parser-parse))) (message "Left-to-right with right-most derivation:\n%S\n" parse) @@ -255,7 +255,7 @@ (phps-mode-test-ast--buffer-contents "<?php\n\n$var = 'abc';\n\nif ($var) {\n echo 'This never happens';\n}\nif ($var2) {\n echo 'This happens';\n}" - "Bookkeeping in root level variable assignments #2." + "Bookkeeping in root level variable assignments #2" (lambda() (let ((parse (phps-mode-parser-parse))) (message "Left-to-right with right-most derivation:\n%S\n" parse) @@ -277,7 +277,7 @@ (phps-mode-test-ast--buffer-contents "<?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." + "Bookkeeping in function level with variable assignments" (lambda() (let ((parse (phps-mode-parser-parse))) (message "Left-to-right with right-most derivation:\n%S\n" parse) @@ -541,7 +541,7 @@ (phps-mode-test-ast--buffer-contents "<?php\n$z = (object) array('name' => 'random');\nif ($z->name) {\n echo 'Hit';\n}" - "Bookkeeping object properties." + "Bookkeeping ignoring variable properties" (lambda() (let ((parse (phps-mode-parser-parse))) (message "Left-to-right with right-most derivation:\n%S\n" parse) @@ -585,7 +585,7 @@ (phps-mode-test-ast--buffer-contents "<?php\n\nif (isset($x)) {\n if ($x) {\n echo 'Hit';\n if (isset($i, $u)) {\n if ($i) {\n echo 'Hit';\n }\n if ($u) {\n echo 'Hit';\n }\n if ($x) {\n echo 'Hit';\n }\n }\n if ($i) {\n echo 'Miss';\n }\n if ($u) {\n echo 'Miss';\n }\n }\n}\nif ($x) {\n echo 'Miss';\n}\n\nif (!empty($y)) {\n if ( [...] - "Bookkeeping of isset() and !empty() scoped variables." + "Bookkeeping of isset() and !empty() scoped variables" (lambda() (let ((parse (phps-mode-parser-parse))) (message "Left-to-right with right-most derivation:\n%S\n" parse)