[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 776c818ff9 121/135: Passing some more imenu t
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 776c818ff9 121/135: Passing some more imenu tests |
Date: |
Sun, 29 Jan 2023 03:11:11 -0500 (EST) |
branch: externals/phps-mode
commit 776c818ff905c8e53378dabe7d209eb0e19f489c
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passing some more imenu tests
---
phps-mode-ast.el | 64 +++--
phps-mode-parser-sdt.el | 668 ++++++++++++++++++++++++---------------------
test/phps-mode-test-ast.el | 4 +-
3 files changed, 407 insertions(+), 329 deletions(-)
diff --git a/phps-mode-ast.el b/phps-mode-ast.el
index 7d4c4f18eb..3d5d4cc65c 100644
--- a/phps-mode-ast.el
+++ b/phps-mode-ast.el
@@ -75,8 +75,6 @@
(phps-mode-debug-message
(message "\nTranslation:\n%S\n\n" translation))
- (message "phps-mode-parser-sdt-symbol-imenu--table: %S"
phps-mode-parser-sdt-symbol-imenu--table)
-
;; Convert imenu index from hash-table to list structure here
(let ((imenu-index))
(maphash
@@ -91,11 +89,38 @@
(v2-index))
(maphash
(lambda (k3 v3)
- (if (symbolp k3)
- (setq v2-index v3))
- (push
- `(,k3 . ,v3)
- v2-list))
+ (if (hash-table-p v3)
+ (let ((v3-list)
+ (v3-index))
+ (maphash
+ (lambda (k4 v4)
+ (if (symbolp k4)
+ (setq v3-index v4)
+ (push `(,k4 . ,v4) v3-list)))
+ v3)
+
+ ;; Sort level 4
+ (setq
+ v3-list
+ (sort
+ v3-list
+ (lambda (a b)
+ (cond
+ ((and
+ (listp (cdr a))
+ (listp (cdr b)))
+ (< (cdr (car (car (cdr a)))) (cdr (car
(car (cdr b))))))
+ ((listp (cdr a))
+ (< (cdr (car (car (cdr a)))) (cdr b)))
+ ((listp (cdr b))
+ (< (cdr a) (cdr (car (car (cdr b))))))
+ (t
+ (< (cdr a) (cdr b)))))))
+ (push `(declaration . ,v3-index) v3-list)
+ (push `(,k3 ,v3-list) v2-list))
+ (if (symbolp k3)
+ (setq v2-index v3))
+ (push `(,k3 . ,v3) v2-list)))
v2)
;; Sort level 3
@@ -104,11 +129,21 @@
(sort
v2-list
(lambda (a b)
- (< (cdr a) (cdr b)))))
+ (cond
+ ((and
+ (listp (cdr a))
+ (listp (cdr b)))
+ (< (cdr (car (car (cdr a)))) (cdr (car (car (cdr
b))))))
+ ((listp (cdr a))
+ (< (cdr (car (car (cdr a)))) (cdr b)))
+ ((listp (cdr b))
+ (< (cdr a) (cdr (car (car (cdr b))))))
+ (t
+ (< (cdr a) (cdr b)))))))
(push `(declaration . ,v2-index) v2-list)
(push `(,k2 ,v2-list) v-list))
(if (symbolp k2)
- (setq v-index v2)
+ (setq v-index v2)
(push `(,k2 . ,v2) v-list))))
v)
@@ -152,17 +187,6 @@
(t
(< (cdr a) (cdr b)))))))
- ;; TODO sort imenu-index here
- ;; (setq
- ;; imenu-index
- ;; (sort
- ;; imenu-index
- ;; (lambda (a b)
- ;; (cond
- ;; ((and
- ;; (listp a)
- ;; (listp b))
- ;; (if ()
(setq
phps-mode-parser-sdt-symbol-imenu
imenu-index))
diff --git a/phps-mode-parser-sdt.el b/phps-mode-parser-sdt.el
index f2754a8277..804eacc724 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -877,7 +877,7 @@
;; Add imenu class, trait, interface and functions here
(when
phps-mode-parser-sdt-symbol-imenu--namespace
- (message "phps-mode-parser-sdt-symbol-imenu--namespace: %S"
phps-mode-parser-sdt-symbol-imenu--namespace)
+ ;; (message "phps-mode-parser-sdt-symbol-imenu--namespace: %S"
phps-mode-parser-sdt-symbol-imenu--namespace)
(let ((imenu-nail (format "namespace %s" (nth 0
phps-mode-parser-sdt-symbol-imenu--namespace))))
(unless
(gethash
@@ -888,252 +888,253 @@
(make-hash-table :test 'equal)
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)
- (imenu-class)
- (imenu-trait)
- (imenu-interface)
- (imenu-function))
- (dolist (imenu-scope phps-mode-parser-sdt-symbol-imenu--stack)
- (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
+ ;; (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-nail
- phps-mode-parser-sdt-symbol-imenu--table))))
+ 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-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-nail3
+ imenu-object
+ (gethash
+ imenu-nail2
+ (gethash
+ imenu-nail
+ 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
+ (gethash
+ imenu-nail3
+ (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-nail3
+ imenu-object
+ (gethash
+ imenu-nail2
+ (gethash
+ imenu-nail
+ 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
+ (gethash
+ imenu-nail3
+ (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-nail3
+ imenu-object
+ (gethash
+ imenu-nail2
+ (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 imenu-function))
+ (puthash 'declaration (nth 1 imenu-class) imenu-object)
(puthash
- imenu-nail3
+ imenu-nail
imenu-object
- (gethash
- imenu-nail2
- (gethash
- imenu-nail
- phps-mode-parser-sdt-symbol-imenu--table))))))))
+ 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-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-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 imenu-function))
+ (puthash 'declaration (nth 1 imenu-class) imenu-object)
(puthash
- imenu-nail3
+ imenu-nail
imenu-object
- (gethash
- imenu-nail2
- (gethash
- imenu-nail
- phps-mode-parser-sdt-symbol-imenu--table))))))))
+ 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-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-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 imenu-function))
+ (puthash 'declaration (nth 1 imenu-class) imenu-object)
(puthash
- imenu-nail3
+ imenu-nail
imenu-object
- (gethash
- imenu-nail2
- (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 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 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 imenu-function))
- (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))
+ 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))))))))
- (message "phps-mode-parser-sdt-symbol-imenu--table: %S"
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))
+
+ ;; (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
@@ -1168,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 "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)
;; Place symbol in imenu if not there already
(cond
@@ -1511,14 +1512,14 @@
phps-mode-parser-sdt-symbol-imenu--table))))
- (message
- "assign symbol uri: %S from %S + %S, start: %S, end: %S, object: %S"
- symbol-uri
- symbol-name
- symbol-scope
- symbol-start
- symbol-end
- symbol-uri-object)
+ ;; (message
+ ;; "assign symbol uri: %S from %S + %S, start: %S, end: %S, object:
%S"
+ ;; symbol-uri
+ ;; symbol-name
+ ;; symbol-scope
+ ;; symbol-start
+ ;; symbol-end
+ ;; symbol-uri-object)
(setq
phps-mode-parser-sdt-symbol-table-index
@@ -1625,15 +1626,15 @@
symbol-hit
phps-mode-parser-sdt-bookkeeping)
- (message
- "reference symbol uri: %S from %S + %S, start: %S, end: %S, object:
%S, hit?: %S"
- symbol-uri
- symbol-name
- symbol-scope
- symbol-start
- symbol-end
- symbol-uri-object
- symbol-hit)
+ ;; (message
+ ;; "reference symbol uri: %S from %S + %S, start: %S, end: %S,
object: %S, hit?: %S"
+ ;; symbol-uri
+ ;; symbol-name
+ ;; symbol-scope
+ ;; symbol-start
+ ;; symbol-end
+ ;; symbol-uri-object
+ ;; symbol-hit)
))
(setq
@@ -2147,13 +2148,13 @@
ast-type
namespace
ast-name
- ,name
+ ,(nth 1 args)
ast-index
- ,index
+ ,(car (cdr (nth 1 terminals)))
ast-start
- ,start
+ ,(car (cdr (nth 2 terminals)))
ast-end
- ,end
+ ,(cdr (cdr (nth 2 terminals)))
top-statement-list
,(nth 3 args)))
phps-mode-parser--table-translations)
@@ -2924,9 +2925,13 @@
(function-end (car (cdr (nth 11 terminals)))))
;; Add function to imenu stack
- (push
- (list 'function function-name function-start function-end)
- phps-mode-parser-sdt-symbol-imenu--stack)
+ (if phps-mode-parser-sdt-symbol-imenu--stack
+ (push
+ (list (list 'function function-name function-start function-end))
+ phps-mode-parser-sdt-symbol-imenu--stack)
+ (setq
+ phps-mode-parser-sdt-symbol-imenu--stack
+ (list (list (list 'function function-name function-start
function-end)))))
(when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
(dolist (
@@ -3018,20 +3023,35 @@
;; Add class scope to all functions in class
(when phps-mode-parser-sdt-symbol-imenu--stack
- (dolist (item phps-mode-parser-sdt-symbol-imenu--stack)
- (let ((item-start (nth 2 item))
- (item-end (nth 3 item)))
- (when (and
- (>= item-start class-start)
- (<= item-end class-end))
- (setcar
- item
- (list 'class class-name class-start class-end))))))
+ (let ((imenu-stack-count
+ (length phps-mode-parser-sdt-symbol-imenu--stack))
+ (imenu-stack-index 0))
+ (while (< imenu-stack-index imenu-stack-count)
+ (let* ((items (nth imenu-stack-index
phps-mode-parser-sdt-symbol-imenu--stack))
+ (item-count (length items))
+ (item-index 0))
+ (while (< item-index item-count)
+ (let* ((item (nth item-index items))
+ (item-start (nth 2 item))
+ (item-end (nth 3 item)))
+ (when (and
+ (>= item-start class-start)
+ (<= item-end class-end))
+ (push
+ (list 'class class-name class-start class-end)
+ (nth imenu-stack-index
phps-mode-parser-sdt-symbol-imenu--stack))
+ (setq item-index item-count)))
+ (setq item-index (1+ item-index))))
+ (setq imenu-stack-index (1+ imenu-stack-index)))))
;; Add class to imenu stack
- (push
- (list 'class class-name class-start class-end)
- phps-mode-parser-sdt-symbol-imenu--stack)
+ (if phps-mode-parser-sdt-symbol-imenu--stack
+ (push
+ (list (list 'class class-name class-start class-end))
+ phps-mode-parser-sdt-symbol-imenu--stack)
+ (setq
+ phps-mode-parser-sdt-symbol-imenu--stack
+ (list (list (list 'class class-name class-start class-end)))))
(when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
(dolist (
@@ -3122,20 +3142,35 @@
;; Add class scope to all functions in class
(when phps-mode-parser-sdt-symbol-imenu--stack
- (dolist (item phps-mode-parser-sdt-symbol-imenu--stack)
- (let ((item-start (nth 2 item))
- (item-end (nth 3 item)))
- (when (and
- (>= item-start class-start)
- (<= item-end class-end))
- (setcar
- item
- (list 'class class-name class-start class-end))))))
+ (let ((imenu-stack-count
+ (length phps-mode-parser-sdt-symbol-imenu--stack))
+ (imenu-stack-index 0))
+ (while (< imenu-stack-index imenu-stack-count)
+ (let* ((items (nth imenu-stack-index
phps-mode-parser-sdt-symbol-imenu--stack))
+ (item-count (length items))
+ (item-index 0))
+ (while (< item-index item-count)
+ (let* ((item (nth item-index items))
+ (item-start (nth 2 item))
+ (item-end (nth 3 item)))
+ (when (and
+ (>= item-start class-start)
+ (<= item-end class-end))
+ (push
+ (list 'class class-name class-start class-end)
+ (nth imenu-stack-index
phps-mode-parser-sdt-symbol-imenu--stack))
+ (setq item-index item-count)))
+ (setq item-index (1+ item-index))))
+ (setq imenu-stack-index (1+ imenu-stack-index)))))
;; Add class to imenu stack
- (push
- (list 'class class-name class-start class-end)
- phps-mode-parser-sdt-symbol-imenu--stack)
+ (if phps-mode-parser-sdt-symbol-imenu--stack
+ (push
+ (list (list 'class class-name class-start class-end))
+ phps-mode-parser-sdt-symbol-imenu--stack)
+ (setq
+ phps-mode-parser-sdt-symbol-imenu--stack
+ (list (list (list 'class class-name class-start class-end)))))
(when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
(dolist (
@@ -3235,20 +3270,25 @@
;; Add class scope to all functions in class
(when phps-mode-parser-sdt-symbol-imenu--stack
- (dolist (item phps-mode-parser-sdt-symbol-imenu--stack)
+ (dolist (items phps-mode-parser-sdt-symbol-imenu--stack))
+ (dolist (item items)
(let ((item-start (nth 2 item))
(item-end (nth 3 item)))
(when (and
(>= item-start class-start)
(<= item-end class-end))
- (setcar
+ (setf
item
- (list 'class class-name class-start class-end))))))
+ (append (list (list 'class class-name class-start class-end))
item))))))
;; Add class to imenu stack
- (push
- (list 'class class-name class-start class-end)
- phps-mode-parser-sdt-symbol-imenu--stack)
+ (if phps-mode-parser-sdt-symbol-imenu--stack
+ (push
+ (list (list 'class class-name class-start class-end))
+ phps-mode-parser-sdt-symbol-imenu--stack)
+ (setq
+ phps-mode-parser-sdt-symbol-imenu--stack
+ (list (list (list 'class class-name class-start class-end)))))
(when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
(dolist (
@@ -3330,20 +3370,25 @@
;; Add class scope to all functions in class
(when phps-mode-parser-sdt-symbol-imenu--stack
- (dolist (item phps-mode-parser-sdt-symbol-imenu--stack)
- (let ((item-start (nth 2 item))
- (item-end (nth 3 item)))
- (when (and
- (>= item-start class-start)
- (<= item-end class-end))
- (setcar
- item
- (list 'class class-name class-start class-end))))))
+ (dolist (items phps-mode-parser-sdt-symbol-imenu--stack)
+ (dolist (item items)
+ (let ((item-start (nth 2 item))
+ (item-end (nth 3 item)))
+ (when (and
+ (>= item-start class-start)
+ (<= item-end class-end))
+ (setf
+ item
+ (append (list (list 'class class-name class-start class-end))
item)))))))
;; Add class to imenu stack
- (push
- (list 'class class-name class-start class-end)
- phps-mode-parser-sdt-symbol-imenu--stack)
+ (if phps-mode-parser-sdt-symbol-imenu--stack
+ (push
+ (list (list 'class class-name class-start class-end))
+ phps-mode-parser-sdt-symbol-imenu--stack)
+ (setq
+ phps-mode-parser-sdt-symbol-imenu--stack
+ (list (list (list 'class class-name class-start class-end)))))
(when phps-mode-parser-sdt--bookkeeping-symbol-assignment-stack
(dolist (
@@ -4448,6 +4493,15 @@
(when (and function-start function-end)
+ ;; Add function to imenu stack
+ (if phps-mode-parser-sdt-symbol-imenu--stack
+ (push
+ (list (list 'function function-name function-start
function-end))
+ phps-mode-parser-sdt-symbol-imenu--stack)
+ (setq
+ phps-mode-parser-sdt-symbol-imenu--stack
+ (list (list (list 'function function-name function-start
function-end)))))
+
;; Add $this symbol in scope unless method is static
(unless is-static-p
(push
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 1168b5f0fb..f2c41dd112 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -161,8 +161,8 @@
(phps-mode-test-ast--should-bookkeep
"<?php\n\nnamespace myNamespaceA {\n $var = 123;\n class myClassA {\n
private $var2 = 123;\n public static function myFunctionA($var3)
{\n $var4 = 123;\n if ($var) {\n echo
'Miss';\n }\n if ($var2) {\n echo
'Miss';\n }\n if ($var3) {\n echo 'Hit';\n
}\n if ($var4) {\n echo 'Hit';\n
}\n }\n\n fun [...]
"Bookkeeping in maximum level with namespaces, classes and functions."
- '(((37 41) 2) ((485 490) 5) ((881 886) 7) ((814 819) 5) ((746 751) 0) ((678
683) 0) ((610 615) 0) ((543 547) 0) ((514 519) 7) ((142 147) 9) ((394 399) 10)
((327 332) 9) ((259 264) 0) ((192 196) 0) ((163 168) 10) ((86 91) 11) ((957
961) 2) ((999 1004) 0) ((1043 1048) 0) ((1087 1092) 0) ((1131 1136) 0) ((1175
1180) 0) ((1243 1248) 13) ((2088 2094) 16) ((2894 2900) 16) ((2826 2832) 18)
((2757 2763) 0) ((2689 2694) 0) ((2621 2626) 0) ((2553 2558) 0) ((2486 2491) 0)
((2419 2424) 0) ((2351 [...]
- '(("namespace myNamespaceA" . 18) ("namespace myNamespaceA id $var" . 37)
("namespace myNamespaceA class myClassA" . 59) ("namespace myNamespaceA class
myClassA function myFunctionB" . 500) ("namespace myNamespaceA class myClassA
function myFunctionB id $var5" . 485) ("namespace myNamespaceA class myClassA
function myFunctionB id $this" . 500) ("namespace myNamespaceA class myClassA
function myFunctionB id $var6" . 514) ("namespace myNamespaceA class myClassA
function myFunctionA" . 1 [...]
+ '(((37 41) 1) ((86 91) 2) ((142 147) 4) ((163 168) 3) ((192 196) 0) ((259
264) 0) ((327 332) 4) ((394 399) 3) ((485 490) 7) ((514 519) 5) ((543 547) 0)
((610 615) 0) ((678 683) 0) ((746 751) 0) ((814 819) 7) ((881 886) 5) ((957
961) 1) ((999 1004) 0) ((1043 1048) 0) ((1087 1092) 0) ((1131 1136) 0) ((1175
1180) 0) ((1243 1248) 8) ((1293 1298) 9) ((1335 1341) 12) ((1357 1362) 10)
((1386 1390) 0) ((1453 1458) 0) ((1521 1526) 0) ((1589 1594) 0) ((1657 1662) 0)
((1725 1730) 0) ((1793 1798) [...]
+ '(("namespace myNamespaceA" ((declaration . 18) ("$var" . 37) ("class
myClassA" ((declaration . 59) (declaration . 59) ("$var2" . 86) ("function
myFunctionA" ((declaration . 149) ("$var3" . 142) ("$var4" . 163))) ("function
myFunctionB" ((declaration . 500) ("$var5" . 485) ("$this" . 500) ("$var6" .
514))))))) ("namespace myNamespaceB" ((declaration . 1224) ("$var7" . 1243)
("class myClassB" ((declaration . 1266) (declaration . 1266) ("$var8" . 1293)
("function myFunctionA" ((declarat [...]
(phps-mode-test-ast--should-bookkeep
"<?php\n\n// Conditional assignments\n\n$items = array(1, 2, 3);\nforeach
($items as $item) {\n if ($item) {\n echo 'Hit';\n }\n}\nforeach
($items as $key => $value) {\n if ($key || $value) {\n echo 'Hit';\n
}\n}\nfor ($i = 0; $i < count($items); $i++) {\n if ($i) {\n echo
'Hit';\n }\n}\nif ($a = 123) {\n if ($a) {\n echo 'Hit';\n
}\n}\nwhile ($b = 123) {\n if ($a) {\n echo 'Hit';\n }\n}\ndo {\n
echo 'Hit';\n} while ( [...]
- [elpa] externals/phps-mode 6c6906317a 095/135: Added bookkeeping test for trait class symbols, (continued)
- [elpa] externals/phps-mode 6c6906317a 095/135: Added bookkeeping test for trait class symbols, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ada5e79291 097/135: Passing bookkeeping test for class properties in class constructor, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 8aae220c57 098/135: Started on integrating imenu generation in SDT bookkeeping, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 95f563fc70 102/135: Passing bookkeeping tests with integrated imenu generation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode ae516f9e19 105/135: Using separate imenu items for redeclared symbols, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode b21c9f3f3a 107/135: Imenu generation via SDT all tests now passing, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 3332b2bfa9 109/135: Fixes syntax coloring of super-globals, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode bddf800099 111/135: Added failing test, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode d98f6d78d8 114/135: Saving symbol-table after parse, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 1594c15e9e 117/135: More work on imenu generation, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 776c818ff9 121/135: Passing some more imenu tests,
Christian Johansson <=
- [elpa] externals/phps-mode c6e4844753 122/135: Some byte-compilation fixes, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 96eeff74f8 130/135: Added more todo items for bookkeeping and imenu, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 66ad034207 025/135: SDT member_modifier, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 34a595fa09 028/135: SDT class_const_list, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 1332919417 049/135: Passing another bookkeeping test via SDT, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 438ec520fc 051/135: Passing bookkeeping via SDT for conditional assignments, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 7fa721a85d 060/135: More work on bookkeeping static class properties, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 0bf9b31fef 062/135: Passed bookkeeping via SDT for try catch variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode 40d7d88fb8 069/135: Work on bookkeeping global variables, Christian Johansson, 2023/01/29
- [elpa] externals/phps-mode a10656fc34 070/135: Passing bookkeeping test for global variables, Christian Johansson, 2023/01/29