[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode f7186a1 239/405: Preparations for hierarchica
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode f7186a1 239/405: Preparations for hierarchical imenu |
Date: |
Sat, 13 Jul 2019 10:00:23 -0400 (EDT) |
branch: externals/phps-mode
commit f7186a116a270eca77c4154def800827e878f48a
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Preparations for hierarchical imenu
---
phps-mode-functions.el | 48 ++++++++++++++++++++++++++++++++++++++++-----
phps-mode-test-functions.el | 11 +++++++++++
2 files changed, 54 insertions(+), 5 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 798aee0..08b8604 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -626,47 +626,85 @@
(when (boundp 'phps-mode-lexer-tokens)
(let ((tokens phps-mode-lexer-tokens)
(in-namespace-declaration nil)
+ (in-namespace-name nil)
+ (open-namespace-level nil)
(in-class-declaration nil)
- (in-function-declaration nil))
+ (open-class-level nil)
+ (in-class-name nil)
+ (in-function-declaration nil)
+ (open-function-level nil)
+ (nesting-level 0))
(dolist (token tokens)
(let ((token-symbol (car token))
(token-start (car (cdr token)))
(token-end (cdr (cdr token))))
+
+ (cond
+ ((string= token-symbol "{")
+ (setq nesting-level (1+ nesting-level)))
+ ((string= token-symbol "}")
+
+ (when (and open-namespace-level
+ (= open-namespace-level nesting-level)
+ in-namespace-name)
+ (setq in-namespace-name nil))
+
+ (when (and open-class-level
+ (= open-class-level nesting-level)
+ in-class-name)
+ (setq in-class-name nil))
+
+ (setq nesting-level (1- nesting-level))))
+
(cond
(in-namespace-declaration
(cond
- ((or (string= token-symbol "{")
- (string= token-symbol ";"))
+ ((string= token-symbol "{")
+ (setq open-namespace-level nesting-level))
+
+ ((string= token-symbol ";")
(setq in-namespace-declaration nil))
((equal token-symbol 'T_STRING)
(let ((index-name (format "namespace %s"
(buffer-substring-no-properties token-start token-end)))
(index-pos token-start))
+ (setq in-namespace-name index-name)
(push `(,index-name . ,index-pos) index)))))
(in-class-declaration
(cond
((string= token-symbol "{")
+ (setq open-class-level nesting-level)
(setq in-class-declaration nil))
((equal token-symbol 'T_STRING)
(let ((index-name (format "class %s"
(buffer-substring-no-properties token-start token-end)))
(index-pos token-start))
+ (setq in-class-name index-name)
+ (when in-namespace-name
+ (setq index-name (concat in-namespace-name " | "
index-name)))
(push `(,index-name . ,index-pos) index)))))
(in-function-declaration
(cond
- ((or (string= token-symbol "{")
- (string= token-symbol ";"))
+ ((string= token-symbol "{")
+ (setq open-function-level nesting-level)
+ (setq in-function-declaration nil))
+
+ ((string= token-symbol ";")
(setq in-function-declaration nil))
((equal token-symbol 'T_STRING)
(let ((index-name (format "function %s"
(buffer-substring-no-properties token-start token-end)))
(index-pos token-start))
+ (when in-class-name
+ (setq index-name (concat in-class-name " | " index-name)))
+ (when in-namespace-name
+ (setq index-name (concat in-namespace-name " | "
index-name)))
(push `(,index-name . ,index-pos) index)))))
(t
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index c889176..aca76ad 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -590,6 +590,17 @@
"<?php\nfunction myFunctionA() {}\nfunction myFunctionB() {}\n"
"Imenu function-oriented file"
(should (equal (phps-mode-functions-imenu-create-index-function)
'(("function myFunctionA" . 16) ("function 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-imenu-create-index-function) '(("class
myClass" . 13) ("class myClass | function myFunctionA" . 43) ("class myClass |
function 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"
+ (should (equal (phps-mode-functions-imenu-create-index-function) '(("class
myClass" . 13) ("class myClass | function myFunctionA" . 43) ("class myClass |
function myFunctionB" . 83)))))
+
)
- [elpa] externals/phps-mode 8b4c188 188/405: Now able to detect indent change of scope with same nesting level, (continued)
- [elpa] externals/phps-mode 8b4c188 188/405: Now able to detect indent change of scope with same nesting level, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 91715f6 217/405: Added another test for multi-line function arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 75c4af4 214/405: Fixed indentation for lines wrapped in scripting open/close, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d754163 221/405: More work on multi-line token-less lines, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8947e6e 202/405: Conceptual work on indentation-calculation for multi-line assignment, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode fc2e8b7 212/405: Added logic to indent token-less lines as well, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8707777 237/405: Updated README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2d4646f 203/405: Work on inline control structure indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 202827b 198/405: New indentation algorithm now supports inline control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b2a5700 218/405: Fixed indentation for multi-line optional function arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f7186a1 239/405: Preparations for hierarchical imenu,
Stefan Monnier <=
- [elpa] externals/phps-mode 43bf350 216/405: Added tests for token-less lines, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 0de10fa 235/405: Passes first test for imenu, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f791cee 234/405: Started on unit tests for imenu-index generation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b56a15c 233/405: Removed debugging output, updated todo items, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 73784d0 225/405: Cleaned up tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f7e7c74 219/405: Work on indentation for switch-case, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c2af31e 240/405: Imenu support now shows hierarchical information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 55953de 232/405: Lexer now doesn't find keywords in function names, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b8e9449 247/405: Refactored Imenu to use a persistent variable per buffer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 67b8701 244/405: Decreased length of imenu items to prevent truncation, Stefan Monnier, 2019/07/13