[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 95ac15a 245/405: Imenu index now handles clas
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 95ac15a 245/405: Imenu index now handles class extends and implements |
Date: |
Sat, 13 Jul 2019 10:00:25 -0400 (EDT) |
branch: externals/phps-mode
commit 95ac15a82b17a39d94dea98c6cb775416c47bb48
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Imenu index now handles class extends and implements
---
phps-mode-functions.el | 8 ++++++--
phps-mode-test-functions.el | 18 ++++++++++++++----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 9e405a1..c15c37b 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -667,7 +667,8 @@
((string= token-symbol ";")
(setq in-namespace-declaration nil))
- ((equal token-symbol 'T_STRING)
+ ((and (equal token-symbol 'T_STRING)
+ (not in-namespace-name))
(let ((index-name (format "\\%s"
(buffer-substring-no-properties token-start token-end)))
(index-pos token-start))
(setq in-namespace-name index-name)
@@ -680,7 +681,8 @@
(setq open-class-level nesting-level)
(setq in-class-declaration nil))
- ((equal token-symbol 'T_STRING)
+ ((and (equal token-symbol 'T_STRING)
+ (not in-class-name))
(let ((index-name (format "%s" (buffer-substring-no-properties
token-start token-end)))
(index-pos token-start))
(setq in-class-name index-name)
@@ -711,9 +713,11 @@
(cond
((equal token-symbol 'T_NAMESPACE)
+ (setq in-namespace-name nil)
(setq in-namespace-declaration t))
((equal token-symbol 'T_CLASS)
+ (setq in-class-name nil)
(setq in-class-declaration t))
((equal token-symbol 'T_FUNCTION)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 3b7e320..04100bd 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -57,7 +57,7 @@
"Round and square bracket expressions"
(should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (2 0)) (6 (1
0)) (7 (1 0)) (8 (0 0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
- (phps-mode-test-with-buffer
+ (phps-mode-test-with-buffer
"<?php\nvar_dump(array(<<<EOD\nfoobar!\nEOD\n));\n?>"
"HEREDOC in arguments example"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
@@ -272,7 +272,7 @@
"Namespace and class with doc-comments"
(should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)) (5 (0 0)) (6 (0
0)) (7 (1 0)) (8 (1 1)) (9 (1 1)) (10 (1 0)) (11 (1 0)) (12 (1 0)) (13 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
-)
+ )
(defun phps-mode-test-functions-get-lines-lindent-if ()
"Test for multi-line if expressions."
@@ -289,7 +289,7 @@
;; (message "Tokens: %s" phps-mode-lexer-tokens)
(should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (1 0)) (6 (1
0)) (7 (1 0)) (8 (0 0)) (9 (1 0)) (10 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
- (phps-mode-test-with-buffer
+ (phps-mode-test-with-buffer
"<?php\nif (true) {\n if ($configuration::load(\n
self::getParameter(self::PARAMETER_CONFIGURATION_INTERNAL_FILENAME),\n
self::getParameter(self::PARAMETER_CONFIGURATION_EXTERNAL_FILENAME),\n
self::getParameter(self::PARAMETER_STRUCTURE_INTERNAL_FILENAME),\n
self::getParameter(self::PARAMETER_STRUCTURE_EXTERNAL_FILENAME))\n ) {\n
echo 'was here';\n }\n}\n"
"If expression spanning multiple lines 3"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
@@ -605,7 +605,17 @@
"<?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-imenu-create-index-function)
'(("\\myNamespace" . 17) ("\\myNamespace\\myClass" . 36)
("\\myNamespace\\myClass->myFunctionA()" . 66)
("\\myNamespace\\myClass->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-imenu-create-index-function)
'(("\\myNamespace" . 17) ("\\myNamespace\\myClass" . 41)
("\\myNamespace\\myClass->myFunctionA()" . 94)
("\\myNamespace\\myClass->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-imenu-create-index-function)
'(("\\myNamespace" . 17) ("\\myNamespace\\myClass" . 36)
("\\myNamespace\\myClass->myFunctionA()" . 108)
("\\myNamespace\\myClass->myFunctionB()" . 148)))))
+
)
;; TODO Add tests for all examples here: https://www.php-fig.org/psr/psr-2/
- [elpa] externals/phps-mode 9031c3a 211/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, (continued)
- [elpa] externals/phps-mode 9031c3a 211/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6105e5d 226/405: Added a new failing test for indetation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5f445cd 229/405: Fixed indentation for while expressions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode eb0ee5e 236/405: Updated README with imenu-support, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 811c499 220/405: New algorithm now works for switch, case syntax, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d2e5a03 228/405: Updated indentation algorithm document and README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1aa0f90 238/405: Typo in README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode da1cfd5 231/405: Adding failing lexer test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e6a8944 241/405: Started work on a lexer bug with expressions inside double quoted strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 0c49d6d 243/405: Removed debugging output, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 95ac15a 245/405: Imenu index now handles class extends and implements,
Stefan Monnier <=
- [elpa] externals/phps-mode 67233ef 213/405: Fixed indent algorithm for multi-line strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 36a4b64 222/405: Added lost test for token-less lines again, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 70f2d46 242/405: Fixed lexer issue with multiple expressions inside double-quoted string, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 0286660 224/405: Indentation passes new tests for concatenated strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f05d40a 230/405: Tests for lexer passes again after close_tag modification, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1bc5713 227/405: New tests for concatenation passes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c71a97d 178/405: Started on refactored indentation calculation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8bb3918 249/405: Clean-up of unit test logging, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9201d1c 246/405: Imenu index now handles functions with optional arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2c3239a 187/405: Adding new failing tests for indentation, Stefan Monnier, 2019/07/13