branch: externals/phps-mode commit 4e021b8413a3731f27408183f8c8276cc11b0f9c Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Bookkeeping via AST now passing method calls --- phps-mode-ast-bookkeeping.el | 12 +++++---- phps-mode-parser-sdt.el | 63 +++++++++++++++++++++++++++++++++++++------- test/phps-mode-test-ast.el | 2 +- 3 files changed, 62 insertions(+), 15 deletions(-) diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el index 2bd8fe7f2d..bd645fafcd 100644 --- a/phps-mode-ast-bookkeeping.el +++ b/phps-mode-ast-bookkeeping.el @@ -223,8 +223,8 @@ (let ((name (plist-get item 'name)) (sub-scope scope)) (push `(type function name ,name) sub-scope) - (when-let ((parameters (reverse (plist-get item 'parameters)))) - (dolist (parameter parameters) + (when-let ((parameter-list (reverse (plist-get item 'parameter-list)))) + (dolist (parameter parameter-list) (let ((id (phps-mode-ast-bookkeeping--generate-variable-scope-string sub-scope @@ -260,8 +260,8 @@ this-id 1 bookkeeping)) - (when-let ((parameters (reverse (plist-get item 'parameters)))) - (dolist (parameter parameters) + (when-let ((parameter-list (reverse (plist-get item 'parameter-list)))) + (dolist (parameter parameter-list) (let ((id (phps-mode-ast-bookkeeping--generate-variable-scope-string sub-scope @@ -388,7 +388,9 @@ defined bookkeeping))) - ((equal type 'assign-variable) + ((and + (equal type 'assign-variable) + (plist-get (plist-get item 'key) 'name)) (let ((id (phps-mode-ast-bookkeeping--generate-variable-scope-string scope diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el index c4eb35190b..2935227814 100644 --- a/phps-mode-parser-sdt.el +++ b/phps-mode-parser-sdt.el @@ -273,7 +273,7 @@ (car (cdr (nth 11 terminals))) 'returns-reference-p (not (equal (nth 1 args) nil)) - 'parameters + 'parameter-list (nth 5 args) 'return-type (nth 7 args) @@ -412,6 +412,20 @@ ast-object)) phps-mode-parser--table-translations) +;; 262: argument_list -> ("(" ")") +(puthash + 262 + (lambda(_args _terminals) + nil) + phps-mode-parser--table-translations) + +;; 263: argument_list -> ("(" non_empty_argument_list possible_comma ")") +(puthash + 263 + (lambda(args _terminals) + (nth 1 args)) + phps-mode-parser--table-translations) + ;; class_statement_list -> (class_statement_list class_statement) (puthash 276 @@ -460,7 +474,7 @@ (not (equal (nth 2 args) nil)) 'name (nth 3 args) - 'parameters + 'parameter-list (nth 6 args) 'return-type (nth 8 args) @@ -478,6 +492,13 @@ ast-object)) phps-mode-parser--table-translations) +;; 302: method_body -> ("{" inner_statement_list "}") +(puthash + 302 + (lambda(args _terminals) + (nth 1 args)) + phps-mode-parser--table-translations) + ;; 304: variable_modifiers -> (T_VAR) (puthash 304 @@ -527,13 +548,6 @@ 'final) phps-mode-parser--table-translations) -;; 302: method_body -> ("{" inner_statement_list "}") -(puthash - 302 - (lambda(args _terminals) - (nth 1 args)) - phps-mode-parser--table-translations) - ;; property -> (T_VARIABLE backup_doc_comment) (puthash 317 @@ -669,6 +683,37 @@ ast-object)) phps-mode-parser--table-translations) +;; callable_variable -> (array_object_dereferencable "[" optional_expr "]") +(puthash + 483 + (lambda(args _terminals) + (let ((ast-object + (list + 'ast-type + 'callable-variable + 'array-object-dereferencable + 'array-index + (phps-mode-parser-sdt--get-list-of-object (nth 2 args))))) + ast-object)) + phps-mode-parser--table-translations) + +;; callable_variable -> (array_object_dereferencable T_OBJECT_OPERATOR property_name argument_list) +(puthash + 485 + (lambda(args _terminals) + (let ((ast-object + (list + 'ast-type + 'callable-variable + 'array-object-dereferencable + (nth 0 args) + 'property-name + (nth 2 args) + 'argument-list + (phps-mode-parser-sdt--get-list-of-object (nth 3 args))))) + ast-object)) + phps-mode-parser--table-translations) + ;; simple_variable -> (T_VARIABLE) (puthash 492 diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el index 6ad813295e..a4636ef861 100644 --- a/test/phps-mode-test-ast.el +++ b/test/phps-mode-test-ast.el @@ -441,7 +441,7 @@ (phps-mode-ast-bookkeeping--generate) (should (equal (phps-mode-test--hash-to-list phps-mode-ast-bookkeeping--index t) - (list (list " class myClass function __construct id $this" 1) (list (list 89 94) 1) (list (list 114 119) 1)))))) + (list (list " class myClass function random id $this" 1) (list " class myClass function __construct id $this" 1)))))) (phps-mode-test-ast--buffer-contents "<?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}"