branch: externals/phps-mode
commit e66abd00e52fd52c35aad0902017d1ff0dd5ddde
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>
Bookkeeping via AST passing nested isset() !empty() expressions
---
phps-mode-ast-bookkeeping.el | 4 ++--
phps-mode-parser-sdt.el | 17 +++++++++++------
test/phps-mode-test-ast.el | 6 +++---
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
index dceac2a81f..f372160d7e 100644
--- a/phps-mode-ast-bookkeeping.el
+++ b/phps-mode-ast-bookkeeping.el
@@ -286,7 +286,7 @@
(let ((name (plist-get item 'name))
(sub-scope scope))
(push `(type function name ,name) sub-scope)
- (when-let ((parameter-list (reverse (plist-get item
'parameter-list))))
+ (when-let ((parameter-list (plist-get item 'parameter-list)))
(dolist (parameter parameter-list)
(let ((ids
(phps-mode-ast-bookkeeping--generate-variable-scope-string
@@ -345,7 +345,7 @@
1
bookkeeping))))
- (when-let ((parameter-list (reverse (plist-get item
'parameter-list))))
+ (when-let ((parameter-list (plist-get item 'parameter-list)))
(dolist (parameter parameter-list)
(let ((ids
(phps-mode-ast-bookkeeping--generate-variable-scope-string
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 957ab4a76b..bb651cf501 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -402,16 +402,21 @@
(puthash
231
(lambda(args _terminals)
- (if (listp (car (nth 0 args)))
- (nth 0 args)
- (list (nth 0 args))))
+ (nth 0 args))
+ phps-mode-parser--table-translations)
+
+; 233: non_empty_parameter_list -> (attributed_parameter)
+(puthash
+ 233
+ (lambda(args _terminals)
+ (list args))
phps-mode-parser--table-translations)
; 234: non_empty_parameter_list -> (non_empty_parameter_list ","
attributed_parameter)
(puthash
234
(lambda(args _terminals)
- (list (nth 0 args) (nth 2 args)))
+ (append (nth 0 args) (list (nth 2 args))))
phps-mode-parser--table-translations)
;; 241: parameter -> (optional_visibility_modifier
optional_type_without_static is_reference is_variadic T_VARIABLE
backup_doc_comment)
@@ -825,7 +830,7 @@
'backup-doc-comment
(nth 2 args)
'parameter-list
- (phps-mode-parser-sdt--get-list-of-object (nth 4 args))
+ (nth 4 args)
'lexical-vars
(phps-mode-parser-sdt--get-list-of-object (nth 6 args))
'return-type
@@ -856,7 +861,7 @@
'backup-doc-comment
(nth 2 args)
'parameter-list
- (phps-mode-parser-sdt--get-list-of-object (nth 4 args))
+ (nth 4 args)
'return-type
(nth 6 args)
'backup-fn-flags-1
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index bf4fa56eef..9d1d02283f 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -647,7 +647,7 @@
(should
(equal
(phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
- '(((50 52) 0) (" function myFunction2 id $b" 1) ((87 89) 1) ((103 105)
1) ((143 145) 1))))))
+ '((" function myFunction2 id $b" 1) ((87 89) 1) ((103 105) 1) ((143
145) 1))))))
(phps-mode-test-ast--buffer-contents
"<?php\n\n$a = array(1, 2, 3);\nforeach ($a as $uri => $page)\n{\n if
(isset($pages)) {\n if ($a) {\n echo 'Hit';\n }\n
if ($uri) {\n echo 'Hit';\n }\n if ($page) {\n
echo 'Hit';\n }\n }\n}\n"
@@ -691,7 +691,7 @@
(should
(equal
(phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
- '((" defined 1 id $b" 2) ((17 19) 1) ((28 30) 1) (" id $c" 1) ((42 44)
1) ((55 57) 1))))))
+ '((" defined 1 id $b" 2) ((17 19) 1) ((28 30) 2) (" id $c" 1) ((42 44)
1) ((55 57) 1))))))
(phps-mode-test-ast--buffer-contents
"<?php\nif (!isset($a)) {\n if ($a) {\n echo 'Miss';\n }\n}"
@@ -735,7 +735,7 @@
(should
(equal
(phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t)
- '((" function myFunction id $a" 1) ((28 30) 1) (" function myFunction
id $b" 1) ((32 34) 1) (" function myFunction id $c" 1) ((36 38) 1) (" function
myFunction id $d" 1) ((40 42) 1) (" function myFunction id $f" 1) ((57 59) 1)
(" function myFunction id $g" 1) ((61 63) 1) (" function myFunction defined 1
id $f" 1) ((79 81) 1) (" function myFunction defined 2 id $g" 1) ((105 107) 1)
((128 130) 1) ((192 194) 1) ((256 258) 1) ((320 322) 1))))))
+ '((" function myFunction id $a" 1) ((28 30) 1) (" function myFunction
id $b" 1) ((32 34) 1) (" function myFunction id $c" 1) ((36 38) 1) (" function
myFunction id $d" 1) ((40 42) 1) (" function myFunction id $f" 1) ((57 59) 1)
(" function myFunction id $g" 1) ((61 63) 1) (" function myFunction defined 1
id $f" 1) ((79 81) 1) (" function myFunction defined 1 defined 2 id $g" 1)
((105 107) 1) ((128 130) 1) ((192 194) 1) ((256 258) 1) ((320 322) 1))))))
(phps-mode-test-ast--buffer-contents
"<?php\n\n$var = 123;\n\nfunction test($abc) {\n static $var;\n if
($var) {\n echo 'Hit';\n }\n}"