[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 1332919417 049/135: Passing another bookkeepi
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 1332919417 049/135: Passing another bookkeeping test via SDT |
Date: |
Sun, 29 Jan 2023 03:11:03 -0500 (EST) |
branch: externals/phps-mode
commit 13329194179c3947e8386ebe6b8c55641ff30ad2
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passing another bookkeeping test via SDT
---
phps-mode-parser-sdt.el | 51 ++++++++++++++++++++++++++++++++++++++++++++--
test/phps-mode-test-ast.el | 4 ++--
2 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 5720b3b4d9..585cb6857a 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -2961,6 +2961,54 @@
(puthash
300
(lambda(args terminals)
+ ;; Go through stacks and modify symbol namespaces
+ ;; - add function scope but only for non-super-global variables
+ (let ((function-name (nth 3 args))
+ (is-static-p))
+ (when-let (method-modifiers (nth 0 args))
+ (dolist (method-modifier method-modifiers)
+ (when (equal method-modifier 'static)
+ (setq is-static-p t))))
+ (unless is-static-p
+ (push
+ (list
+ "$this"
+ phps-mode-parser-sdt--bookkeeping-namespace
+ (car (cdr (car (nth 10 terminals))))
+ (cdr (cdr (car (cdr (cdr (nth 10 terminals)))))))
+ phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack))
+ (when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
+ (dolist (
+ symbol-list
+ phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack)
+ (let ((symbol-name (car symbol-list)))
+ (unless (gethash
+ symbol-name
+ phps-mode-parser-sdt--bookkeeping--superglobal-variable-p)
+ (let ((symbol-scope (car (cdr symbol-list))))
+ (push
+ (list 'function function-name)
+ symbol-scope)
+ (setcar
+ (cdr symbol-list)
+ symbol-scope))))))
+
+ (when phps-mode-parser-sdt--bookkeeping-symbol-stack
+ (dolist (
+ symbol-list
+ phps-mode-parser-sdt--bookkeeping-symbol-stack)
+ (let ((symbol-name (car symbol-list)))
+ (unless (gethash
+ symbol-name
+ phps-mode-parser-sdt--bookkeeping--superglobal-variable-p)
+ (let ((symbol-scope (car (cdr symbol-list))))
+ (push
+ (list 'function function-name)
+ symbol-scope)
+ (setcar
+ (cdr symbol-list)
+ symbol-scope)))))))
+
`(
ast-type
method
@@ -2987,8 +3035,7 @@
ast-end
,(if (nth 10 args)
(cdr (cdr (car (cdr (cdr (nth 10 terminals))))))
- nil)
- ))
+ nil)))
phps-mode-parser--table-translations)
;; 301 ((attributed_class_statement) (enum_case))
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 826b20ccbc..802b43289c 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -234,9 +234,9 @@
'(((30 35) 1) ((61 67) 1) ((93 101) 1) ((127 136) 1) ((162 171) 1) ((197
205) 1) ((231 239) 1) ((265 272) 1) ((298 303) 1) ((329 334) 1) ((360 365) 1)
((391 414) 1)))
(phps-mode-test-ast--should-bookkeep
- "<?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 [...]
+ "<?php\n\nnamespace myNamespaceA {\n $var = 123;\n class myClassA {\n
private $var2 = 123;\n public static 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 fun [...]
"Bookkeeping in maximum level with namespaces, classes and functions."
- '((" id $var" 1) ((37 41) 1) (" namespace myNamespaceA class myClassA id
$var2" 1) ((86 91) 1) (" namespace myNamespaceA class myClassA function
myFunctionA id $this" 1) (" namespace myNamespaceA class myClassA function
myFunctionA id $var3" 1) ((128 133) 1) (" namespace myNamespaceA class myClassA
function myFunctionA id $var4" 1) ((149 154) 1) ((178 182) 0) ((245 250) 0)
((313 318) 1) ((380 385) 1) (" namespace myNamespaceA class myClassA function
myFunctionB id $this" 1) (" namespa [...]
+ '((" namespace myNamespaceA id $var" ((37 41))) ((37 41) 1) (" namespace
myNamespaceA class myClassA function myFunctionB id $this" ((500 941))) ("
namespace myNamespaceA class myClassA function myFunctionB id $var6" ((514
519))) (" namespace myNamespaceA class myClassA function myFunctionA id $var4"
((163 168))) (" namespace myNamespaceA class myClassA function myFunctionA id
$var2" ((86 91))) ((881 886) 1) ((814 819) 0) ((746 751) 0) ((678 683) 0) ((610
615) 0) ((543 547) 0) ((514 5 [...]
(phps-mode-test-ast--should-bookkeep
"<?php\n\n// Conditional assignments\n\n$items = array(1, 2, 3);\nforeach
($items as $item) {\n if ($item) {\n echo 'Hit';\n }\n}\nforeach
($items as $key => $value) {\n if ($key || $value) {\n echo 'Hit';\n
}\n}\nfor ($i = 0; $i < count($items); $i++) {\n if ($i) {\n echo
'Hit';\n }\n}\nif ($a = 123) {\n if ($a) {\n echo 'Hit';\n
}\n}\nwhile ($b = 123) {\n if ($a) {\n echo 'Hit';\n }\n}\ndo {\n
echo 'Hit';\n} while ( [...]
- [elpa] externals/phps-mode b21c9f3f3a 107/135: Imenu generation via SDT all tests now passing, (continued)
- [elpa] externals/phps-mode b21c9f3f3a 107/135: Imenu generation via SDT all tests now passing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 3332b2bfa9 109/135: Fixes syntax coloring of super-globals, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode bddf800099 111/135: Added failing test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d98f6d78d8 114/135: Saving symbol-table after parse, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 1594c15e9e 117/135: More work on imenu generation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 776c818ff9 121/135: Passing some more imenu tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode c6e4844753 122/135: Some byte-compilation fixes, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 96eeff74f8 130/135: Added more todo items for bookkeeping and imenu, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 66ad034207 025/135: SDT member_modifier, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 34a595fa09 028/135: SDT class_const_list, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 1332919417 049/135: Passing another bookkeeping test via SDT,
Christian Johansson <=
- [elpa] externals/phps-mode 438ec520fc 051/135: Passing bookkeeping via SDT for conditional assignments, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7fa721a85d 060/135: More work on bookkeeping static class properties, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 0bf9b31fef 062/135: Passed bookkeeping via SDT for try catch variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 40d7d88fb8 069/135: Work on bookkeeping global variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode a10656fc34 070/135: Passing bookkeeping test for global variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 9c67facc86 075/135: Work on bookkeeping of class static properties, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 39a6fe03ae 079/135: Improved is-varadic and is-reference argument flags, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e8a5dbe153 126/135: Fix for trait and interface imenu, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 579034d1c6 127/135: Passing imenu test via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode fb9a181135 088/135: Passed more bookkeeping tsts, Christian Johansson, 2023/01/29