branch: externals/phps-mode
commit 76ef8cceac5d2c5af03433b22c9c3a5006d0d98f
Author: Christian Johansson <christ...@cvj.se>
Commit: Christian Johansson <christ...@cvj.se>

    More fixes in code
---
 phps-mode-parser-sdt.el    | 436 ++++++++++++++++++++++-----------------------
 test/phps-mode-test-ast.el |   2 +-
 2 files changed, 219 insertions(+), 219 deletions(-)

diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index 511a51657c..89ab76a622 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -889,65 +889,65 @@
          phps-mode-parser-sdt-symbol-imenu--table))))
 
     ;; (message "\nphps-mode-parser-sdt-symbol-imenu--stack: %S" 
phps-mode-parser-sdt-symbol-imenu--stack)
-    (when phps-mode-parser-sdt-symbol-imenu--stack
-      ;; Go through imenu stack and add new items to imenu index
-      (let ((imenu-namespace
-             phps-mode-parser-sdt-symbol-imenu--namespace))
-        (dolist (imenu-scopes phps-mode-parser-sdt-symbol-imenu--stack)
-          (let ((imenu-class)
-                (imenu-trait)
-                (imenu-interface)
-                (imenu-function))
-            (dolist (imenu-scope imenu-scopes)
-              (let ((imenu-item-type (nth 0 imenu-scope))
-                    (imenu-item-name (nth 1 imenu-scope))
-                    (imenu-item-start (nth 2 imenu-scope)))
-                (cond
-                 ((equal imenu-item-type 'namespace)
-                  (setq imenu-namespace (list imenu-item-name 
imenu-item-start)))
-                 ((equal imenu-item-type 'class)
-                  (setq imenu-class (list imenu-item-name imenu-item-start)))
-                 ((equal imenu-item-type 'interface)
-                  (setq imenu-interface (list imenu-item-name 
imenu-item-start)))
-                 ((equal imenu-item-type 'trait)
-                  (setq imenu-trait (list imenu-item-name imenu-item-start)))
-                 ((equal imenu-item-type 'function)
-                  (setq imenu-function (list imenu-item-name 
imenu-item-start))))))
-            (cond
-
-             (imenu-namespace
-              (let ((imenu-nail (format "namespace %s" (nth 0 
imenu-namespace))))
-                (unless (gethash imenu-nail 
phps-mode-parser-sdt-symbol-imenu--table)
-                  (let ((imenu-object (make-hash-table :test 'equal)))
-                    (puthash 'declaration (nth 1 imenu-namespace) imenu-object)
-                    (puthash imenu-nail imenu-object 
phps-mode-parser-sdt-symbol-imenu--table)))
-                (cond
-                 (imenu-class
-                  (let ((imenu-nail2 (format "class %s" (nth 0 imenu-class))))
-                    (unless
-                        (gethash
-                         imenu-nail2
-                         (gethash
-                          imenu-nail
-                          phps-mode-parser-sdt-symbol-imenu--table))
-                      (let ((imenu-object (make-hash-table :test 'equal)))
-                        (puthash 'declaration (nth 1 imenu-class) imenu-object)
-                        (puthash
-                         imenu-nail2
-                         imenu-object
-                         (gethash
-                          imenu-nail
-                          phps-mode-parser-sdt-symbol-imenu--table))))
-                    (when imenu-function
-                      (let ((imenu-nail3 (format "function %s" (nth 0 
imenu-function))))
-                        (unless
+  (when phps-mode-parser-sdt-symbol-imenu--stack
+    ;; Go through imenu stack and add new items to imenu index
+    (let ((imenu-namespace
+           phps-mode-parser-sdt-symbol-imenu--namespace))
+      (dolist (imenu-scopes phps-mode-parser-sdt-symbol-imenu--stack)
+        (let ((imenu-class)
+              (imenu-trait)
+              (imenu-interface)
+              (imenu-function))
+          (dolist (imenu-scope imenu-scopes)
+            (let ((imenu-item-type (nth 0 imenu-scope))
+                  (imenu-item-name (nth 1 imenu-scope))
+                  (imenu-item-start (nth 2 imenu-scope)))
+              (cond
+               ((equal imenu-item-type 'namespace)
+                (setq imenu-namespace (list imenu-item-name imenu-item-start)))
+               ((equal imenu-item-type 'class)
+                (setq imenu-class (list imenu-item-name imenu-item-start)))
+               ((equal imenu-item-type 'interface)
+                (setq imenu-interface (list imenu-item-name imenu-item-start)))
+               ((equal imenu-item-type 'trait)
+                (setq imenu-trait (list imenu-item-name imenu-item-start)))
+               ((equal imenu-item-type 'function)
+                (setq imenu-function (list imenu-item-name 
imenu-item-start))))))
+          (cond
+
+           (imenu-namespace
+            (let ((imenu-nail (format "namespace %s" (nth 0 imenu-namespace))))
+              (unless (gethash imenu-nail 
phps-mode-parser-sdt-symbol-imenu--table)
+                (let ((imenu-object (make-hash-table :test 'equal)))
+                  (puthash 'declaration (nth 1 imenu-namespace) imenu-object)
+                  (puthash imenu-nail imenu-object 
phps-mode-parser-sdt-symbol-imenu--table)))
+              (cond
+               (imenu-class
+                (let ((imenu-nail2 (format "class %s" (nth 0 imenu-class))))
+                  (unless
+                      (gethash
+                       imenu-nail2
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))
+                    (let ((imenu-object (make-hash-table :test 'equal)))
+                      (puthash 'declaration (nth 1 imenu-class) imenu-object)
+                      (puthash
+                       imenu-nail2
+                       imenu-object
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))))
+                  (when imenu-function
+                    (let ((imenu-nail3 (format "function %s" (nth 0 
imenu-function))))
+                      (unless
+                          (gethash
+                           imenu-nail3
+                           (gethash
+                            imenu-nail2
                             (gethash
-                             imenu-nail3
-                             (gethash
-                              imenu-nail2
-                              (gethash
-                               imenu-nail
-                               phps-mode-parser-sdt-symbol-imenu--table))))
+                             imenu-nail
+                             phps-mode-parser-sdt-symbol-imenu--table)))
                         (let ((imenu-object (make-hash-table :test 'equal)))
                           (puthash 'declaration (nth 1 imenu-function) 
imenu-object)
                           (puthash
@@ -957,36 +957,36 @@
                             imenu-nail2
                             (gethash
                              imenu-nail
-                             phps-mode-parser-sdt-symbol-imenu--table))))))))
+                             phps-mode-parser-sdt-symbol-imenu--table)))))))))
 
-                 (imenu-trait
-                  (let ((imenu-nail2 (format "trait %s" (nth 0 imenu-trait))))
-                    (unless
-                        (gethash
-                         imenu-nail2
-                         (gethash
-                          imenu-nail
-                          phps-mode-parser-sdt-symbol-imenu--table))
-                      (let ((imenu-object (make-hash-table :test 'equal)))
-                        (puthash 'declaration (nth 1 imenu-class) imenu-object)
-                        (puthash
-                         imenu-nail2
-                         imenu-object
-                         (gethash
-                          imenu-nail
-                          phps-mode-parser-sdt-symbol-imenu--table))))
-                    (when imenu-function
-                      (let ((imenu-nail3 (format "function %s" (nth 0 
imenu-function))))
-                        (unless
+               (imenu-trait
+                (let ((imenu-nail2 (format "trait %s" (nth 0 imenu-trait))))
+                  (unless
+                      (gethash
+                       imenu-nail2
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))
+                    (let ((imenu-object (make-hash-table :test 'equal)))
+                      (puthash 'declaration (nth 1 imenu-class) imenu-object)
+                      (puthash
+                       imenu-nail2
+                       imenu-object
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))))
+                  (when imenu-function
+                    (let ((imenu-nail3 (format "function %s" (nth 0 
imenu-function))))
+                      (unless
+                          (gethash
+                           imenu-nail3
+                           (gethash
+                            imenu-nail2
                             (gethash
-                             imenu-nail3
-                             (gethash
-                              imenu-nail2
-                              (gethash
-                               imenu-nail
-                               phps-mode-parser-sdt-symbol-imenu--table))))
+                             imenu-nail
+                             phps-mode-parser-sdt-symbol-imenu--table)))
                         (let ((imenu-object (make-hash-table :test 'equal)))
-                          (puthash 'declaration (nth imenu-function))
+                          (puthash 'declaration (nth 1 imenu-function) 
imenu-object)
                           (puthash
                            imenu-nail3
                            imenu-object
@@ -994,36 +994,36 @@
                             imenu-nail2
                             (gethash
                              imenu-nail
-                             phps-mode-parser-sdt-symbol-imenu--table))))))))
+                             phps-mode-parser-sdt-symbol-imenu--table)))))))))
 
-                 (imenu-interface
-                  (let ((imenu-nail2 (format "interface %s" (nth 0 
imenu-interface))))
-                    (unless
-                        (gethash
-                         imenu-nail2
-                         (gethash
-                          imenu-nail
-                          phps-mode-parser-sdt-symbol-imenu--table))
-                      (let ((imenu-object (make-hash-table :test 'equal)))
-                        (puthash 'declaration (nth 1 imenu-class) imenu-object)
-                        (puthash
-                         imenu-nail2
-                         imenu-object
-                         (gethash
-                          imenu-nail
-                          phps-mode-parser-sdt-symbol-imenu--table))))
-                    (when imenu-function
-                      (let ((imenu-nail3 (format "function %s" (nth 0 
imenu-function))))
-                        (unless
+               (imenu-interface
+                (let ((imenu-nail2 (format "interface %s" (nth 0 
imenu-interface))))
+                  (unless
+                      (gethash
+                       imenu-nail2
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))
+                    (let ((imenu-object (make-hash-table :test 'equal)))
+                      (puthash 'declaration (nth 1 imenu-class) imenu-object)
+                      (puthash
+                       imenu-nail2
+                       imenu-object
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))))
+                  (when imenu-function
+                    (let ((imenu-nail3 (format "function %s" (nth 0 
imenu-function))))
+                      (unless
+                          (gethash
+                           imenu-nail3
+                           (gethash
+                            imenu-nail2
                             (gethash
-                             imenu-nail3
-                             (gethash
-                              imenu-nail2
-                              (gethash
-                               imenu-nail
-                               phps-mode-parser-sdt-symbol-imenu--table))))
+                             imenu-nail
+                             phps-mode-parser-sdt-symbol-imenu--table)))
                         (let ((imenu-object (make-hash-table :test 'equal)))
-                          (puthash 'declaration (nth imenu-function))
+                          (puthash 'declaration (nth 1 imenu-function) 
imenu-object)
                           (puthash
                            imenu-nail3
                            imenu-object
@@ -1031,110 +1031,110 @@
                             imenu-nail2
                             (gethash
                              imenu-nail
-                             
phps-mode-parser-sdt-symbol-imenu--table)))))))))))
+                             
phps-mode-parser-sdt-symbol-imenu--table))))))))))))
 
-             (imenu-class
-              (let ((imenu-nail (format "class %s" (nth 0 imenu-class))))
-                (unless
-                    (gethash
-                     imenu-nail
-                     phps-mode-parser-sdt-symbol-imenu--table)
-                  (let ((imenu-object (make-hash-table :test 'equal)))
-                    (puthash 'declaration (nth 1 imenu-class) imenu-object)
-                    (puthash
-                     imenu-nail
-                     imenu-object
-                     phps-mode-parser-sdt-symbol-imenu--table)
-                    (when imenu-function
-                      (let ((imenu-nail2 (format "function %s" (nth 0 
imenu-function))))
-                        (unless
-                            (gethash
-                             imenu-nail2
-                             (gethash
-                              imenu-nail
-                              phps-mode-parser-sdt-symbol-imenu--table)))
-                        (let ((imenu-object (make-hash-table :test 'equal)))
-                          (puthash 'declaration (nth imenu-function))
-                          (puthash
-                           imenu-nail2
-                           imenu-object
-                           (gethash
-                            imenu-nail
-                            phps-mode-parser-sdt-symbol-imenu--table)))))))))
+           (imenu-class
+            (let ((imenu-nail (format "class %s" (nth 0 imenu-class))))
+              (unless
+                  (gethash
+                   imenu-nail
+                   phps-mode-parser-sdt-symbol-imenu--table)
+                (let ((imenu-object (make-hash-table :test 'equal)))
+                  (puthash 'declaration (nth 1 imenu-class) imenu-object)
+                  (puthash
+                   imenu-nail
+                   imenu-object
+                   phps-mode-parser-sdt-symbol-imenu--table)))
+              (when imenu-function
+                (let ((imenu-nail2 (format "function %s" (nth 0 
imenu-function))))
+                  (unless
+                      (gethash
+                       imenu-nail2
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))
+                    (let ((imenu-object (make-hash-table :test 'equal)))
+                      (puthash 'declaration (nth 1 imenu-function) 
imenu-object)
+                      (puthash
+                       imenu-nail2
+                       imenu-object
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))))))))
 
-             (imenu-trait
-              (let ((imenu-nail (format "trait %s" (nth 0 imenu-trait))))
-                (unless
-                    (gethash
-                     imenu-nail
-                     phps-mode-parser-sdt-symbol-imenu--table)
-                  (let ((imenu-object (make-hash-table :test 'equal)))
-                    (puthash 'declaration (nth 1 imenu-class) imenu-object)
-                    (puthash
-                     imenu-nail
-                     imenu-object
-                     phps-mode-parser-sdt-symbol-imenu--table)
-                    (when imenu-function
-                      (let ((imenu-nail2 (format "function %s" (nth 0 
imenu-function))))
-                        (unless
-                            (gethash
-                             imenu-nail2
-                             (gethash
-                              imenu-nail
-                              phps-mode-parser-sdt-symbol-imenu--table)))
-                        (let ((imenu-object (make-hash-table :test 'equal)))
-                          (puthash 'declaration (nth imenu-function))
-                          (puthash
-                           imenu-nail2
-                           imenu-object
-                           (gethash
-                            imenu-nail
-                            phps-mode-parser-sdt-symbol-imenu--table)))))))))
+           (imenu-trait
+            (let ((imenu-nail (format "trait %s" (nth 0 imenu-trait))))
+              (unless
+                  (gethash
+                   imenu-nail
+                   phps-mode-parser-sdt-symbol-imenu--table)
+                (let ((imenu-object (make-hash-table :test 'equal)))
+                  (puthash 'declaration (nth 1 imenu-class) imenu-object)
+                  (puthash
+                   imenu-nail
+                   imenu-object
+                   phps-mode-parser-sdt-symbol-imenu--table)))
+              (when imenu-function
+                (let ((imenu-nail2 (format "function %s" (nth 0 
imenu-function))))
+                  (unless
+                      (gethash
+                       imenu-nail2
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))
+                    (let ((imenu-object (make-hash-table :test 'equal)))
+                      (puthash 'declaration (nth 1 imenu-function) 
imenu-object)
+                      (puthash
+                       imenu-nail2
+                       imenu-object
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))))))))
 
-             (imenu-interface
-              (let ((imenu-nail (format "interface %s" (nth 0 
imenu-interface))))
-                (unless
-                    (gethash
-                     imenu-nail
-                     phps-mode-parser-sdt-symbol-imenu--table)
-                  (let ((imenu-object (make-hash-table :test 'equal)))
-                    (puthash 'declaration (nth 1 imenu-class) imenu-object)
-                    (puthash
-                     imenu-nail
-                     imenu-object
-                     phps-mode-parser-sdt-symbol-imenu--table)
-                    (when imenu-function
-                      (let ((imenu-nail2 (format "function %s" (nth 0 
imenu-function))))
-                        (unless
-                            (gethash
-                             imenu-nail2
-                             (gethash
-                              imenu-nail
-                              phps-mode-parser-sdt-symbol-imenu--table)))
-                        (let ((imenu-object (make-hash-table :test 'equal)))
-                          (puthash 'declaration (nth imenu-function))
-                          (puthash
-                           imenu-nail2
-                           imenu-object
-                           (gethash
-                            imenu-nail
-                            phps-mode-parser-sdt-symbol-imenu--table)))))))))
+           (imenu-interface
+            (let ((imenu-nail (format "interface %s" (nth 0 imenu-interface))))
+              (unless
+                  (gethash
+                   imenu-nail
+                   phps-mode-parser-sdt-symbol-imenu--table)
+                (let ((imenu-object (make-hash-table :test 'equal)))
+                  (puthash 'declaration (nth 1 imenu-class) imenu-object)
+                  (puthash
+                   imenu-nail
+                   imenu-object
+                   phps-mode-parser-sdt-symbol-imenu--table)))
+              (when imenu-function
+                (let ((imenu-nail2 (format "function %s" (nth 0 
imenu-function))))
+                  (unless
+                      (gethash
+                       imenu-nail2
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))
+                    (let ((imenu-object (make-hash-table :test 'equal)))
+                      (puthash 'declaration (nth 1 imenu-function) 
imenu-object)
+                      (puthash
+                       imenu-nail2
+                       imenu-object
+                       (gethash
+                        imenu-nail
+                        phps-mode-parser-sdt-symbol-imenu--table))))))))
 
-             (imenu-function
-              (let ((imenu-nail (format "function %s" (nth 0 imenu-function))))
-                (unless
-                    (gethash
-                     imenu-nail
-                     phps-mode-parser-sdt-symbol-imenu--table)
-                  (let ((imenu-object (make-hash-table :test 'equal)))
-                    (puthash 'declaration (nth 1 imenu-function) imenu-object)
-                    (puthash
-                     imenu-nail
-                     imenu-object
-                     phps-mode-parser-sdt-symbol-imenu--table)))))))))
-      (setq phps-mode-parser-sdt-symbol-imenu--stack nil))
+           (imenu-function
+            (let ((imenu-nail (format "function %s" (nth 0 imenu-function))))
+              (unless
+                  (gethash
+                   imenu-nail
+                   phps-mode-parser-sdt-symbol-imenu--table)
+                (let ((imenu-object (make-hash-table :test 'equal)))
+                  (puthash 'declaration (nth 1 imenu-function) imenu-object)
+                  (puthash
+                   imenu-nail
+                   imenu-object
+                   phps-mode-parser-sdt-symbol-imenu--table)))))))))
+    (setq phps-mode-parser-sdt-symbol-imenu--stack nil))
 
-  ;; (message "phps-mode-parser-sdt-symbol-imenu--table: %S" 
phps-mode-parser-sdt-symbol-imenu--table)
+    (message "phps-mode-parser-sdt-symbol-imenu--table: %S" 
phps-mode-parser-sdt-symbol-imenu--table)
 
   ;; Parse bookkeeping writes and reads at every statement terminus
   (when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
@@ -1169,13 +1169,13 @@
         (when (nth 9 (nth 1 symbol-uri-object))
           (setq symbol-function (car (nth 9 (nth 1 symbol-uri-object)))))
 
-        ;; (message "symbol-name: %S" symbol-name)
-        ;; (message "symbol-scope: %S" symbol-scope)
-        ;; (message "symbol-namespace: %S" symbol-namespace)
-        ;; (message "symbol-class: %S" symbol-class)
-        ;; (message "symbol-trait: %S" symbol-trait)
-        ;; (message "symbol-interface: %S" symbol-interface)
-        ;; (message "symbol-function: %S" symbol-function)
+        (message "\nsymbol-name: %S" symbol-name)
+        (message "symbol-scope: %S" symbol-scope)
+        (message "symbol-namespace: %S" symbol-namespace)
+        (message "symbol-class: %S" symbol-class)
+        (message "symbol-trait: %S" symbol-trait)
+        (message "symbol-interface: %S" symbol-interface)
+        (message "symbol-function: %S" symbol-function)
 
         ;; Place symbol in imenu if not there already
         (cond
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index eacf0d2eca..45c23bf027 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -173,7 +173,7 @@
   (phps-mode-test-ast--should-bookkeep
    "<?php\n\n// Class properties\n\nclass myParent {}\n\nclass myClass extends 
myParent {\n    private $var1 = 123;\n    protected static $var2;\n    public 
$var3;\n    var $var4;\n    function __construct() {\n        if ($this) {\n    
        echo 'Hit';\n        }\n        if ($this->var1) {\n            echo 
'Hit';\n        }\n        if (self::$var1) {\n            echo 'Miss';\n       
 }\n        if (self::$var2) {\n            echo 'Hit';\n        }\n        if 
(static::$var2) {\n [...]
    "Bookkeeping of class properties"
-   '(((639 643) 0) ((632 637) 3) ((578 582) 4) ((571 576) 3) ((517 521) 5) 
((510 515) 3) ((455 460) 6) ((392 397) 6) ((330 335) 0) ((270 274) 7) ((263 
268) 3) ((208 213) 3) ((160 165) 4) ((145 150) 5) ((127 132) 6) ((93 98) 7) 
((751 756) 0))
+   '(((93 98) 1) ((127 132) 2) ((145 150) 3) ((160 165) 4) ((208 213) 5) ((263 
268) 5) ((270 274) 1) ((330 335) 0) ((392 397) 2) ((455 460) 2) ((510 515) 5) 
((517 521) 3) ((571 576) 5) ((578 582) 4) ((632 637) 5) ((639 643) 0) ((751 
756) 0))
    '(("class myClass" . 54) ("class myClass function __construct" . 194) 
("class myClass function __construct id $this" . 194) ("class myClass id $var4" 
. 160) ("class myClass id $var3" . 145) ("class myClass static id $var2" . 127) 
("class myClass id $var1" . 93)))
 
   (phps-mode-test-ast--should-bookkeep

Reply via email to