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

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

[elpa] externals/phps-mode 41b1566c40 010/212: Imenu generation via pars


From: Christian Johansson
Subject: [elpa] externals/phps-mode 41b1566c40 010/212: Imenu generation via parser SDT passing more tests
Date: Wed, 26 Jan 2022 01:50:12 -0500 (EST)

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

    Imenu generation via parser SDT passing more tests
---
 phps-mode-ast.el | 60 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 35 insertions(+), 25 deletions(-)

diff --git a/phps-mode-ast.el b/phps-mode-ast.el
index 0efce743e1..a868d01694 100644
--- a/phps-mode-ast.el
+++ b/phps-mode-ast.el
@@ -110,9 +110,6 @@
      ;; (message "args: %S" args)
      ;; (message "terminals: %S" terminals)
      ;; (message "ast-object: %S" ast-object)
-     (push
-      ast-object
-      phps-mode-ast--tree)
      ast-object))
  phps-mode-parser--table-translations)
 
@@ -121,10 +118,6 @@
  108
  (lambda(args _terminals)
    ;; (message "T_NAMESPACE: %S" args)
-   (when (nth 2 args)
-     (setq
-      phps-mode-ast--tree
-      (append phps-mode-ast--tree (nth 2 args))))
    (nth 2 args))
  phps-mode-parser--table-translations)
 
@@ -147,10 +140,6 @@
      ;; (message "Function: %S" ast-object)
      ;; (message "args: %S" args)
      ;; (message "terminals: %S" terminals)
-     (when phps-mode-ast--current-namespace
-       (push
-        ast-object
-        phps-mode-ast--current-namespace-children))
      ast-object))
  phps-mode-parser--table-translations)
 
@@ -175,10 +164,6 @@
      ;; (message "Class %S" ast-object)
      ;; (message "args: %S" args)
      ;; (message "terminals: %S" terminals)
-     (when phps-mode-ast--current-namespace
-       (push
-        ast-object
-        phps-mode-ast--current-namespace-children))
      ast-object))
  phps-mode-parser--table-translations)
 
@@ -230,16 +215,33 @@
    phps-mode-ast--tree
    nil)
   (let ((translation (phps-mode-parser-translate)))
-    
-    (message "translation: %S" translation)
+    ;; (message "translation:\n%S\n\n" translation)
     (when translation
-      (if phps-mode-ast--tree
-          (setq
-           phps-mode-ast--tree
-           (append phps-mode-ast--tree translation))
-        (setq
-         phps-mode-ast--tree
-         translation)))
+      (dolist (item translation)
+        (when (listp item)
+          (cond
+
+           ((plist-get item 'type)
+            (if phps-mode-ast--current-namespace
+                (push
+                 item
+                 phps-mode-ast--current-namespace-children)
+              (push
+               item
+               phps-mode-ast--tree)))
+
+           ((listp (car item))
+            (dolist (sub-item item)
+              (when (and
+                     (listp sub-item)
+                     (plist-get sub-item 'type))
+                (if phps-mode-ast--current-namespace
+                    (push
+                     sub-item
+                     phps-mode-ast--current-namespace-children)
+                  (push
+                   sub-item
+                   phps-mode-ast--tree)))))))))
 
     (when phps-mode-ast--current-namespace
       (plist-put
@@ -249,6 +251,11 @@
       (push
        phps-mode-ast--current-namespace
        phps-mode-ast--tree))
+    (setq
+     phps-mode-ast--tree
+     (reverse phps-mode-ast--tree))
+
+    ;; (message "AST:\n%S\n\n" phps-mode-ast--tree)
 
     (let ((imenu-index))
       (dolist (item phps-mode-ast--tree)
@@ -292,7 +299,10 @@
              imenu-index))))
       (setq
        phps-mode-ast--imenu
-       (reverse imenu-index)))))
+       (reverse imenu-index)))
+
+    ;; (message "imenu:\n%S\n\n" phps-mode-ast--imenu)
+    ))
 
 
 (provide 'phps-mode-ast)



reply via email to

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