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

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

[elpa] externals/phps-mode 1dc3b453c9 043/212: Passed bookkeeping via AS


From: Christian Johansson
Subject: [elpa] externals/phps-mode 1dc3b453c9 043/212: Passed bookkeeping via AST for try catch blocks
Date: Wed, 26 Jan 2022 01:50:38 -0500 (EST)

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

    Passed bookkeeping via AST for try catch blocks
---
 phps-mode-ast-bookkeeping.el | 60 ++++++++++++++++++++++++++++++++++++++++++++
 phps-mode-parser-sdt.el      | 38 ++++++++++++++++++++++++++++
 2 files changed, 98 insertions(+)

diff --git a/phps-mode-ast-bookkeeping.el b/phps-mode-ast-bookkeeping.el
index fc20aea951..bc05f9deed 100644
--- a/phps-mode-ast-bookkeeping.el
+++ b/phps-mode-ast-bookkeeping.el
@@ -554,6 +554,66 @@
               (plist-get item 'variable))
              bookkeeping-stack))
 
+           ((equal type 'try)
+            (when-let ((children (reverse (plist-get item 
'inner-statement-list))))
+              (dolist (child children)
+                (push
+                 (list
+                  (list
+                   class
+                   function
+                   namespace)
+                  child)
+                 bookkeeping-stack)))
+            (when-let ((children (reverse (plist-get item 'catch-list))))
+              (dolist (child children)
+                (push
+                 (list
+                  (list
+                   class
+                   function
+                   namespace)
+                  child)
+                 bookkeeping-stack)))
+            (when-let ((children (reverse (plist-get item 
'finally-statement))))
+              (dolist (child children)
+                (push
+                 (list
+                  (list
+                   class
+                   function
+                   namespace)
+                  child)
+                 bookkeeping-stack))))
+
+           ((equal type 'catch)
+            (when-let ((optional-variable (plist-get item 'optional-variable)))
+              (let ((id
+                     (format
+                      "%s id %s"
+                      variable-namespace
+                      optional-variable)))
+                (puthash
+                 id
+                 1
+                 bookkeeping)
+                (puthash
+                 (list
+                  (plist-get item 'optional-variable-start)
+                  (plist-get item 'optional-variable-end))
+                 1
+                 bookkeeping)))
+            (when-let ((children (reverse (plist-get item 'children))))
+              (dolist (child children)
+                (push
+                 (list
+                  (list
+                   class
+                   function
+                   namespace)
+                  child)
+                 bookkeeping-stack))))
+
            ((equal type 'array-object-dereferencable)
             (let* ((subject (plist-get item 'subject))
                    (property-name (plist-get item 'property))
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 7d883851d4..f61ab9a926 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -217,6 +217,44 @@
      ast-object))
  phps-mode-parser--table-translations)
 
+;; statement -> (T_TRY "{" inner_statement_list "}" catch_list 
finally_statement)
+(puthash
+ 160
+ (lambda(args _terminals)
+   (let ((ast-object
+          (list
+           'ast-type
+           'try
+           'inner-statement-list
+           (phps-mode-parser-sdt--get-list-of-object (nth 2 args))
+           'catch-list
+           (phps-mode-parser-sdt--get-list-of-object (nth 4 args))
+           'finally-statement
+           (nth 5 args))))
+     ast-object))
+ phps-mode-parser--table-translations)
+
+;; catch_list -> (catch_list T_CATCH "(" catch_name_list optional_variable ")" 
"{" inner_statement_list "}")
+(puthash
+ 164
+ (lambda(args terminals)
+   (let ((ast-object
+          (list
+           'ast-type
+           'catch
+           'catch-name-list
+           (phps-mode-parser-sdt--get-list-of-object (nth 3 args))
+           'optional-variable
+           (nth 4 args)
+           'optional-variable-start
+           (car (cdr (nth 4 terminals)))
+           'optional-variable-end
+           (cdr (cdr (nth 4 terminals)))
+           'children
+           (nth 7 args))))
+     ast-object))
+ phps-mode-parser--table-translations)
+
 ;; function_declaration_statement -> (function returns_ref T_STRING 
backup_doc_comment "(" parameter_list ")" return_type backup_fn_flags "{" 
inner_statement_list "}" backup_fn_flags)
 (puthash
  174



reply via email to

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