[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 1594c15e9e 117/135: More work on imenu genera
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 1594c15e9e 117/135: More work on imenu generation |
Date: |
Sun, 29 Jan 2023 03:11:10 -0500 (EST) |
branch: externals/phps-mode
commit 1594c15e9e953d544b9951c17f6dc3e39cd48665
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More work on imenu generation
---
phps-mode-ast.el | 17 +++-
phps-mode-parser-sdt.el | 263 +++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 266 insertions(+), 14 deletions(-)
diff --git a/phps-mode-ast.el b/phps-mode-ast.el
index dbe79d0d72..a9a16bfef7 100644
--- a/phps-mode-ast.el
+++ b/phps-mode-ast.el
@@ -75,6 +75,8 @@
(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
@@ -83,7 +85,7 @@
(let ((v-list))
(maphash
(lambda (k2 v2)
- (if hash-table-p v2
+ (if (hash-table-p v2)
(let ((v2-list))
(maphash
(lambda (k3 v3)
@@ -91,6 +93,7 @@
`(,k3 . ,v3)
v2-list))
v2)
+ ;; TODO sort v2-list here
(push
`(,k2 ,v2-list)
v-list))
@@ -98,6 +101,7 @@
`(,k2 . ,v2)
v-list)))
v)
+ ;; TODO Sort by index here
(push
`(,k ,v-list)
imenu-index))
@@ -105,6 +109,17 @@
`(,k . ,v)
imenu-index)))
phps-mode-parser-sdt-symbol-imenu--table)
+ ;; 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 48f9e5ad52..079d7a89ab 100644
--- a/phps-mode-parser-sdt.el
+++ b/phps-mode-parser-sdt.el
@@ -887,8 +887,247 @@
phps-mode-parser-sdt-symbol-imenu--table))))
(when phps-mode-parser-sdt-symbol-imenu--stack
+ ;; Go through imenu stack and add new items to imenu index
(message "phps-mode-parser-sdt-symbol-imenu--stack: %S"
phps-mode-parser-sdt-symbol-imenu--stack)
- ;; TODO Go through stack and add on imenu index
+ (let ((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
+ (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-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 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))
;; Parse bookkeeping writes and reads at every statement terminus
@@ -913,18 +1152,16 @@
(symbol-function))
;; Collect namespace, class, interface, trait and function here
- (dolist (symbol-scope-item symbol-scope)
- (let ((symbol-scope-item-type (nth 0 symbol-scope))
- (symbol-scope-item-name (nth 1 symbol-scope)))
- (cond
- ((equal symbol-scope-item-type 'namespace)
- (setq symbol-namespace symbol-scope-item-name))
- ((equal symbol-scope-item-type 'class)
- (setq symbol-class symbol-scope-item-name))
- ((equal symbol-scope-item-type 'interface)
- (setq symbol-interface symbol-scope-item-name))
- ((equal symbol-scope-item-type 'function)
- (setq symbol-function symbol-scope-item-name)))))
+ (when (nth 1 (nth 1 symbol-uri-object))
+ (setq symbol-namespace (car (nth 1 (nth 1 symbol-uri-object)))))
+ (when (nth 3 (nth 1 symbol-uri-object))
+ (setq symbol-class (car (nth 3 (nth 1 symbol-uri-object)))))
+ (when (nth 5 (nth 1 symbol-uri-object))
+ (setq symbol-trait (car (nth 5 (nth 1 symbol-uri-object)))))
+ (when (nth 7 (nth 1 symbol-uri-object))
+ (setq symbol-interface (car (nth 7 (nth 1 symbol-uri-object)))))
+ (when (nth 9 (nth 1 symbol-uri-object))
+ (setq symbol-function (car (nth 9 (nth 1 symbol-uri-object)))))
;; Place symbol in imenu if not there already
(cond
- [elpa] externals/phps-mode 7609f09f04 090/135: More bookkeeping final touches, (continued)
- [elpa] externals/phps-mode 7609f09f04 090/135: More bookkeeping final touches, Christian Johansson, 2023/01/29
- [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 <=
- [elpa] externals/phps-mode 776c818ff9 121/135: Passing some more imenu tests, Christian Johansson, 2023/01/29
- [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