[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode fa47a17 390/405: Changed imenu index to a hie
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode fa47a17 390/405: Changed imenu index to a hierarchical structure |
Date: |
Sat, 13 Jul 2019 10:00:59 -0400 (EDT) |
branch: externals/phps-mode
commit fa47a17e920e89b7de84cf10fb7d8c2b3461661e
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Changed imenu index to a hierarchical structure
---
phps-mode-functions.el | 72 +++++++++++++++++++++++++++------------------
phps-mode-test-functions.el | 16 +++++-----
2 files changed, 52 insertions(+), 36 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index c85e366..6c55ec4 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -182,14 +182,20 @@
(temp-pre-indent nil)
(temp-post-indent nil)
(imenu-index '())
+ (imenu-namespace-index '())
+ (imenu-class-index '())
(imenu-in-namespace-declaration nil)
(imenu-in-namespace-name nil)
+ (imenu-in-namespace-index nil)
+ (imenu-in-namespace-with-brackets nil)
(imenu-open-namespace-level nil)
(imenu-in-class-declaration nil)
(imenu-open-class-level nil)
(imenu-in-class-name nil)
+ (imenu-in-class-index nil)
(imenu-in-function-declaration nil)
(imenu-in-function-name nil)
+ (imenu-in-function-index nil)
(imenu-nesting-level 0)
(incremental-line-number 1))
@@ -234,69 +240,79 @@
(when (and imenu-open-namespace-level
(= imenu-open-namespace-level imenu-nesting-level)
imenu-in-namespace-name)
+ (let ((imenu-add-list (nreverse imenu-namespace-index)))
+ (push `(,imenu-in-namespace-name . ,imenu-add-list)
imenu-index))
(setq imenu-in-namespace-name nil))
(when (and imenu-open-class-level
(= imenu-open-class-level imenu-nesting-level)
imenu-in-class-name)
+ (let ((imenu-add-list (nreverse imenu-class-index)))
+ (if imenu-in-namespace-name
+ (push `(,imenu-in-class-name . ,imenu-add-list)
imenu-namespace-index)
+ (push `(,imenu-in-class-name . ,imenu-add-list)
imenu-index)))
(setq imenu-in-class-name nil))
(setq imenu-nesting-level (1- imenu-nesting-level))))
+
+ (when (and (equal next-token 'END_PARSE)
+ imenu-in-namespace-name
+ (not imenu-in-namespace-with-brackets))
+ (let ((imenu-add-list (nreverse imenu-namespace-index)))
+ (push `(,imenu-in-namespace-name . ,imenu-add-list)
imenu-index))
+ (setq imenu-in-namespace-name nil))
(cond
(imenu-in-namespace-declaration
(cond
- ((string= token "{")
+ ((or (string= token "{")
+ (string= token ";"))
+ (setq imenu-in-namespace-with-brackets (string= token "{"))
(setq imenu-open-namespace-level imenu-nesting-level)
+ (setq imenu-namespace-index '())
(setq imenu-in-namespace-declaration nil)
- (push `(,imenu-in-namespace-name . ,token-start)
imenu-index))
-
- ((string= token ";")
- (setq imenu-in-namespace-declaration nil)
- (push `(,imenu-in-namespace-name . ,token-start)
imenu-index))
+ (let ((imenu-label (format "namespace %s"
imenu-in-namespace-name)))
+ (push `(,imenu-label . ,imenu-in-namespace-index)
imenu-index)))
- ((and (or (equal token 'T_STRING)
- (equal token 'T_NS_SEPARATOR))
- (setq imenu-in-namespace-name (concat
imenu-in-namespace-name (buffer-substring-no-properties token-start
token-end)))))))
+ ((and (or (equal token 'T_STRING)
+ (equal token 'T_NS_SEPARATOR))
+ (setq imenu-in-namespace-index token-start)
+ (setq imenu-in-namespace-name (concat
imenu-in-namespace-name (buffer-substring-no-properties token-start
token-end)))))))
(imenu-in-class-declaration
(cond
((string= token "{")
(setq imenu-open-class-level imenu-nesting-level)
- (setq imenu-in-class-declaration nil))
+ (setq imenu-in-class-declaration nil)
+ (setq imenu-class-index '())
+ (let ((imenu-label (format "class %s"
imenu-in-class-name)))
+ (if imenu-in-namespace-name
+ (push `(,imenu-label . ,imenu-in-class-index)
imenu-namespace-index)
+ (push `(,imenu-label . ,imenu-in-class-index)
imenu-index))))
((and (equal token 'T_STRING)
(not imenu-in-class-name))
- (let ((imenu-index-name (format "%s"
(buffer-substring-no-properties token-start token-end)))
- (imenu-index-pos token-start))
- (setq imenu-in-class-name imenu-index-name)
- (when imenu-in-namespace-name
- (setq imenu-index-name (concat imenu-in-namespace-name
"\\" imenu-index-name)))
- (push `(,imenu-index-name . ,imenu-index-pos)
imenu-index)))))
+ (setq imenu-in-class-name (buffer-substring-no-properties
token-start token-end))
+ (setq imenu-in-class-index token-start))))
(imenu-in-function-declaration
(cond
- ((string= token "{")
+ ((or (string= token "{")
+ (string= token ";"))
+ (if imenu-in-class-name
+ (push `(,imenu-in-function-name .
,imenu-in-function-index) imenu-class-index)
+ (push `(,imenu-in-function-name .
,imenu-in-function-index) imenu-index))
(setq imenu-in-function-name nil)
(setq imenu-in-function-declaration nil))
- ((string= token ";")
- (setq imenu-in-function-declaration nil))
-
((and (equal token 'T_STRING)
(not imenu-in-function-name))
- (let ((imenu-index-name (format "%s()"
(buffer-substring-no-properties token-start token-end)))
- (imenu-index-pos token-start))
- (setq imenu-in-function-name imenu-index-name)
- (when imenu-in-class-name
- (setq imenu-index-name (concat imenu-in-class-name
"->" imenu-index-name)))
- (when imenu-in-namespace-name
- (setq imenu-index-name (concat imenu-in-namespace-name
"\\" imenu-index-name)))
- (push `(,imenu-index-name . ,imenu-index-pos)
imenu-index)))))
+ (setq imenu-in-function-name
(buffer-substring-no-properties token-start token-end))
+ (setq imenu-in-function-index token-start))))
(t (cond
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index d613710..2550c92 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -825,42 +825,42 @@
(phps-mode-test-with-buffer
"<?php\nfunction myFunctionA() {}\nfunction myFunctionB() {}\n"
"Imenu function-oriented file"
- (should (equal (phps-mode-functions-get-imenu) '(("myFunctionA()" . 16)
("myFunctionB()" . 42)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myFunctionA" . 16)
("myFunctionB" . 42)))))
(phps-mode-test-with-buffer
"<?php\nclass myClass {\n public function myFunctionA() {}\n
protected function myFunctionB() {}\n}\n"
"Imenu object-oriented file"
- (should (equal (phps-mode-functions-get-imenu) '(("myClass" . 13)
("myClass->myFunctionA()" . 43) ("myClass->myFunctionB()" . 83)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("class myClass" . 13)
("myClass" ("myFunctionA" . 43) ("myFunctionB" . 83))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace {\n class myClass {\n public
function myFunctionA() {}\n protected function myFunctionB() {}\n
}\n}\n"
"Imenu object-oriented file with namespace, class and function"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" . 29)
("myNamespace\\myClass" . 41) ("myNamespace\\myClass->myFunctionA()" . 75)
("myNamespace\\myClass->myFunctionB()" . 119)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("namespace myNamespace" .
17) ("myNamespace" ("class myClass" . 41) ("myClass" ("myFunctionA" . 75)
("myFunctionB" . 119)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace;\nclass myClass {\n public function
myFunctionA() {}\n protected function myFunctionB() {}\n}\n"
"Imenu object-oriented file with bracket-less namespace, class and function"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" . 28)
("myNamespace\\myClass" . 36) ("myNamespace\\myClass->myFunctionA()" . 66)
("myNamespace\\myClass->myFunctionB()" . 106)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("namespace myNamespace" .
17) ("myNamespace" ("class myClass" . 36) ("myClass" ("myFunctionA" . 66)
("myFunctionB" . 106)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace {\n class myClass extends myAbstract {\n
public function myFunctionA() {}\n protected function myFunctionB()
{}\n }\n}\n"
"Imenu object-oriented file with namespace, class that extends and
functions"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" . 29)
("myNamespace\\myClass" . 41) ("myNamespace\\myClass->myFunctionA()" . 94)
("myNamespace\\myClass->myFunctionB()" . 138)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("namespace myNamespace" .
17) ("myNamespace" ("class myClass" . 41) ("myClass" ("myFunctionA" . 94)
("myFunctionB" . 138)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements
myInterface {\n public function myFunctionA() {}\n protected function
myFunctionB() {}\n}\n"
"Imenu object-oriented file with bracket-less namespace, class that extends
and implements and functions"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" . 28)
("myNamespace\\myClass" . 36) ("myNamespace\\myClass->myFunctionA()" . 108)
("myNamespace\\myClass->myFunctionB()" . 148)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("namespace myNamespace" .
17) ("myNamespace" ("class myClass" . 36) ("myClass" ("myFunctionA" . 108)
("myFunctionB" . 148)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements
myInterface {\n public function myFunctionA($myArg = null) {}\n protected
function myFunctionB($myArg = 'abc') {}\n}\n"
"Imenu object-oriented file with bracket-less namespace, class that extends
and implements and functions with optional arguments"
- (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" . 28)
("myNamespace\\myClass" . 36) ("myNamespace\\myClass->myFunctionA()" . 108)
("myNamespace\\myClass->myFunctionB()" . 161)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("namespace myNamespace" .
17) ("myNamespace" ("class myClass" . 36) ("myClass" ("myFunctionA" . 108)
("myFunctionB" . 161)))))))
(phps-mode-test-with-buffer
"<?php\nnamespace myNamespace\\myNamespace2;\nclass myClass extends
myAbstract implements myInterface {\n public function myFunctionA($myArg =
null) {}\n protected function myFunctionB($myArg = 'abc') {}\n}\n"
"Imenu object-oriented file with bracket-less namespace with multiple
levels, class that extends and implements and functions with optional arguments"
- (should (equal (phps-mode-functions-get-imenu)
'(("myNamespace\\myNamespace2" . 41) ("myNamespace\\myNamespace2\\myClass" .
49) ("myNamespace\\myNamespace2\\myClass->myFunctionA()" . 121)
("myNamespace\\myNamespace2\\myClass->myFunctionB()" . 174)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("namespace
myNamespace\\myNamespace2" . 29) ("myNamespace\\myNamespace2" ("class myClass"
. 49) ("myClass" ("myFunctionA" . 121) ("myFunctionB" . 174)))))))
)
- [elpa] externals/phps-mode a4b2f37 375/405: Added new TODO item, (continued)
- [elpa] externals/phps-mode a4b2f37 375/405: Added new TODO item, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7deefdc 383/405: Fixed use-package config example in README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 65f79c8 397/405: Added map shortcuts for comment / uncomment region, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode dbd2825 389/405: Added unit test for multiple level namespaces and added support for it, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5f52f54 395/405: Fixed compilation warning after new imenu structure, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 192f9ae 391/405: Fix issues with test list structure, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 21f883e 396/405: Updated README and copyright date, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f0912ee 398/405: Removed TODO and changed syntax color to be based on tokens only, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 47793f7 402/405: Updated README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2d2aaad 388/405: Added failing unit test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode fa47a17 390/405: Changed imenu index to a hierarchical structure,
Stefan Monnier <=
- [elpa] externals/phps-mode d05601b 387/405: Updated documents, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 07d9176 403/405: Improved flycheck support, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1d58896 400/405: Minimal mode map is now loaded, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 11e151a 382/405: Fixed linting issues in flycheck file, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 808f679 401/405: Moved TODO to separate doc and improved syntax coloring, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f5c2072 405/405: Updated copyright for inclusion in ELPA, Stefan Monnier, 2019/07/13