emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode 8fa61fa1f2 063/212: Passing bookkeeping of in


From: Christian Johansson
Subject: [elpa] externals/phps-mode 8fa61fa1f2 063/212: Passing bookkeeping of interface method arguments
Date: Wed, 26 Jan 2022 01:50:44 -0500 (EST)

branch: externals/phps-mode
commit 8fa61fa1f254bc49620577aef5d3059fe9e898c9
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Passing bookkeeping of interface method arguments
---
 phps-mode-ast-bookkeeping.el | 43 +++++++++++++++++++++++++++++++------------
 phps-mode-parser-sdt.el      |  7 +++++++
 2 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
index 79946fbec7..dceac2a81f 100644
--- a/phps-mode-ast-bookkeeping.el
+++ b/phps-mode-ast-bookkeeping.el
@@ -310,22 +310,41 @@
                 (dolist (child children)
                   (push `(,sub-scope ,child) bookkeeping-stack)))))
 
+           ((equal type 'return-statement)
+            (when-let ((expr (reverse (plist-get item 'optional-expr))))
+              (dolist (e expr)
+                (push `(,scope ,e) bookkeeping-stack))))
+
            ((equal type 'method)
             (let ((name (plist-get item 'name))
-                  (sub-scope scope))
+                  (sub-scope scope)
+                  (parent-is-interface)
+                  (is-static))
               (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
-                      "$this")))
-                (dolist (this-id this-ids)
-                  (puthash
-                   this-id
-                   1
-                   bookkeeping)))
+              (when-let ((modifiers (plist-get item 'modifiers)))
+                (dolist (modifier modifiers)
+                  (when (equal modifier 'static)
+                    (setq
+                     is-static
+                     t))))
+
+              (when (equal (plist-get (car scope) 'type) 'interface)
+                (setq parent-is-interface t))
+
+              (unless (or
+                       is-static
+                       parent-is-interface)
+                (let ((this-ids
+                       
(phps-mode-ast-bookkeeping--generate-variable-scope-string
+                        sub-scope
+                        "$this")))
+                  (dolist (this-id this-ids)
+                    (puthash
+                     this-id
+                     1
+                     bookkeeping))))
+
               (when-let ((parameter-list (reverse (plist-get item 
'parameter-list))))
                 (dolist (parameter parameter-list)
                   (let ((ids
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index fc47b97d72..957ab4a76b 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -161,6 +161,13 @@
      ast-object))
  phps-mode-parser--table-translations)
 
+;; statement -> (T_RETURN optional_expr ";")
+(puthash
+ 149
+ (lambda(args _terminals)
+   `(ast-stype return-statement optional-expr 
,(phps-mode-parser-sdt--get-list-of-object (nth 1 args))))
+ phps-mode-parser--table-translations)
+
 ;; statement -> (T_GLOBAL global_var_list ";")
 (puthash
  150



reply via email to

[Prev in Thread] Current Thread [Next in Thread]