[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode e614a20ada 066/135: Added bookkeeping for ref
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode e614a20ada 066/135: Added bookkeeping for referenced foreach variables |
Date: |
Sun, 29 Jan 2023 03:11:04 -0500 (EST) |
branch: externals/phps-mode
commit e614a20ada15e5c1ddec8710a0ceb6e4cef0443b
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Added bookkeeping for referenced foreach variables
---
phps-mode-parser-sdt.el | 49 +++++++++++++++++++++++++++++++++++++++++-----
test/phps-mode-test-ast.el | 2 +-
2 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index a626eb02a5..a2bd37905b 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -2375,8 +2375,46 @@
;; 205 ((foreach_variable) (ampersand variable))
(puthash
205
- (lambda(args _terminals)
- ;; TODO Declare variable here
+ (lambda(args terminals)
+ ;; Save variable declaration in bookkeeping buffer
+ (let* ((variable (nth 1 args))
+ (variable-type (plist-get variable 'ast-type)))
+ (cond
+ ((equal variable-type 'variable-callable-variable)
+ (let* ((callable-variable (plist-get variable 'callable-variable))
+ (callable-variable-type (plist-get callable-variable 'ast-type)))
+ (cond
+ ((equal callable-variable-type 'callable-variable-simple-variable)
+ (let ((callable-variable-simple-variable
+ (plist-get callable-variable 'simple-variable)))
+ (let ((callable-variable-simple-variable-type
+ (plist-get
+ callable-variable-simple-variable
+ 'ast-type)))
+ (cond
+ ((equal
+ callable-variable-simple-variable-type
+ 'simple-variable-variable)
+ (let* ((variable-name
+ (plist-get
+ callable-variable-simple-variable
+ 'variable))
+ (symbol-name
+ variable-name)
+ (symbol-start
+ (car (cdr (nth 1 terminals))))
+ (symbol-end
+ (cdr (cdr (nth 1 terminals))))
+ (symbol-scope
+ phps-mode-parser-sdt--bookkeeping-namespace))
+ ;; (message "declared foreach variable from terminals: %S"
(nth 1 terminals))
+ (push
+ (list
+ symbol-name
+ symbol-scope
+ symbol-start
+ symbol-end)
+
phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack))))))))))))
`(
ast-type
@@ -2444,8 +2482,7 @@
ast-type
foreach-statement
statement
- ,args
- ))
+ ,args))
phps-mode-parser--table-translations)
;; 211 ((foreach_statement) (":" inner_statement_list T_ENDFOREACH ";"))
@@ -5937,7 +5974,9 @@
(cdr (cdr terminals)))
(namespace phps-mode-parser-sdt--bookkeeping-namespace))
(when phps-mode-parser-sdt--bookkeeping-namespace-stack
- (setq namespace (pop
phps-mode-parser-sdt--bookkeeping-namespace-stack)))
+ (setq
+ namespace
+ (pop phps-mode-parser-sdt--bookkeeping-namespace-stack)))
(push
(list
symbol-name
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 7883ec8207..b6485e2ecc 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -266,7 +266,7 @@
(phps-mode-test-ast--should-bookkeep
"<?php\n$items = array(1, 2, 3);\nforeach ($items as &$item) {\n if
($item) {\n echo 'Hit';\n }\n}\nforeach ($items as $key => &$item2)
{\n if ($item) {\n echo 'Hit';\n }\n}"
"Bookkeeping of foreach reference variable declaration"
- '((" id $items" 1) ((7 13) 1) ((41 47) 1) (" id $item" 1) ((52 57) 1) ((69
74) 1) ((115 121) 1) (" id $key" 1) ((125 129) 1) (" id $item2" 1) ((134 140)
1) ((152 157) 1)))
+ '((" id $items" ((7 13))) ((7 13) 1) (" id $item" ((52 57))) ((69 74) 1)
((52 57) 1) ((41 47) 1) (" id $item2" ((134 140))) (" id $key" ((125 129)))
((152 157) 1) ((134 140) 1) ((125 129) 1) ((115 121) 1)))
(phps-mode-test-ast--should-bookkeep
"<?php\n\n[$random, $bandom] = myValues();\nif ($random) {\n echo
'Hit';\n}\nif ($bandom) {\n echo 'Hit';\n}\n"
- [elpa] externals/phps-mode 911abb044e 024/135: SDT method_body, (continued)
- [elpa] externals/phps-mode 911abb044e 024/135: SDT method_body, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 75743d0c25 022/135: Merge branch 'master' into feature/full-sdt, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 610358e2ef 026/135: SDT for property, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 4981a1eb45 032/135: SDT rules up to 520, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode b2454f1967 058/135: Bookkeeping of static class property, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 962b905ca0 057/135: Bookkeeping working for class non-static properties, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7b9f8011f1 056/135: More testing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e2f2c86e18 059/135: Improved class properties bookkeeping test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode eac10d63e6 063/135: Started on bookkeeping of variables inside anonymous functions, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e924ac83b6 065/135: Improved bookkeeping test for anonymous function, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode e614a20ada 066/135: Added bookkeeping for referenced foreach variables,
Christian Johansson <=
- [elpa] externals/phps-mode d33625bb1a 067/135: Bookkeeping for array assignment passing test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode a646676781 084/135: Passing more bookkeeping tests, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7609f09f04 090/135: More bookkeeping final touches, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 6c6906317a 095/135: Added bookkeeping test for trait class symbols, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ada5e79291 097/135: Passing bookkeeping test for class properties in class constructor, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 8aae220c57 098/135: Started on integrating imenu generation in SDT bookkeeping, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 95f563fc70 102/135: Passing bookkeeping tests with integrated imenu generation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ae516f9e19 105/135: Using separate imenu items for redeclared symbols, Christian Johansson, 2023/01/29
- [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