branch: externals/phps-mode commit 882e6f75dc03ffb5fa45cea68bfc98629515e856 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Work on SDT for interface methods --- phps-mode-ast-bookkeeping.el | 15 +++++++++++++-- phps-mode-parser-sdt.el | 19 ++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el index 35a14eb3d7..79946fbec7 100644 --- a/phps-mode-ast-bookkeeping.el +++ b/phps-mode-ast-bookkeeping.el @@ -50,7 +50,8 @@ scope-name)))) ((and - (equal scope-type 'class) + (or (equal scope-type 'class) + (equal scope-type 'interface)) scope-name) (setq scope-string @@ -131,7 +132,8 @@ scope-name)) ((and - (equal scope-type 'class) + (or (equal scope-type 'class) + (equal scope-type 'interface)) scope-name) (if namespace (setq @@ -314,6 +316,7 @@ (push `(type function name ,name) sub-scope) ;; TODO should only do this is method is not static + ;; TODO should only do this if method is not in a interface class (let ((this-ids (phps-mode-ast-bookkeeping--generate-variable-scope-string sub-scope @@ -363,6 +366,14 @@ (dolist (child children) (push `(,sub-scope ,child) bookkeeping-stack))))) + ((equal type 'interface) + (let ((name (plist-get item 'name)) + (sub-scope scope)) + (push `(type interface name ,name) sub-scope) + (when-let ((children (reverse (plist-get item 'children)))) + (dolist (child children) + (push `(,sub-scope ,child) bookkeeping-stack))))) + ((equal type 'if) (let* ((conditions (reverse (plist-get item 'condition))) (condition-stack conditions) diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el index 0a20e3414e..fc47b97d72 100644 --- a/phps-mode-parser-sdt.el +++ b/phps-mode-parser-sdt.el @@ -530,19 +530,32 @@ 'return-type (nth 8 args) 'children - (phps-mode-parser-sdt--get-list-of-object (nth 10 args)) + (if (nth 10 args) + (phps-mode-parser-sdt--get-list-of-object (nth 10 args)) + nil) 'index (car (cdr (nth 3 terminals))) 'start - (car (cdr (car (nth 10 terminals)))) + (if (nth 10 args) + (car (cdr (car (nth 10 terminals)))) + nil) 'end - (cdr (cdr (car (cdr (cdr (nth 10 terminals))))))))) + (if (nth 10 args) + (cdr (cdr (car (cdr (cdr (nth 10 terminals)))))) + nil)))) ;; (message "Method: %S" ast-object) ;; (message "args: %S" args) ;; (message "terminals: %S" terminals) ast-object)) phps-mode-parser--table-translations) +;; 301: method_body -> (";") +(puthash + 301 + (lambda(_args _terminals) + nil) + phps-mode-parser--table-translations) + ;; 302: method_body -> ("{" inner_statement_list "}") (puthash 302