[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode dbd2825 389/405: Added unit test for multiple
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode dbd2825 389/405: Added unit test for multiple level namespaces and added support for it |
Date: |
Sat, 13 Jul 2019 10:00:59 -0400 (EDT) |
branch: externals/phps-mode
commit dbd2825dffdd773f8ca3b4fbd07d3eab781a80bb
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Added unit test for multiple level namespaces and added support for it
---
README.md | 2 +-
phps-mode-functions.el | 15 +++++++--------
phps-mode-test-functions.el | 14 +++++++-------
phps-mode.el | 4 ++--
4 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/README.md b/README.md
index 279e20c..cc4b280 100644
--- a/README.md
+++ b/README.md
@@ -16,12 +16,12 @@ This mode does not require PHP installed on your computer
because it has a built
* Lexer based on official PHP re2c lexer (100%)
* Syntax coloring based on lexer tokens (100%)
* PSR-1 and PSR-2 indentation based on lexer tokens (100%)
-* Imenu support (90%)
* Integration with `(electric-pair)` (100%)
* Incremental lexer and syntax coloring after buffer changes (100%)
* Incremental indentation and imenu calculation after buffer changes (100%)
* Supports `(comment-region)` and `(uncomment-region)` (100%)
* Travis support (100%)
+* Imenu support (90%)
* A set of heuristics to improve large-file incremental change handling (50%)
* Wisent LALR parser based on official PHP yacc parser automatically converted
grammar (50%)
* Full integration with Emacs Semantic subsystem (30%)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 033de69..c85e366 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -250,17 +250,16 @@
((string= token "{")
(setq imenu-open-namespace-level imenu-nesting-level)
- (setq imenu-in-namespace-declaration nil))
+ (setq imenu-in-namespace-declaration nil)
+ (push `(,imenu-in-namespace-name . ,token-start)
imenu-index))
((string= token ";")
- (setq imenu-in-namespace-declaration nil))
+ (setq imenu-in-namespace-declaration nil)
+ (push `(,imenu-in-namespace-name . ,token-start)
imenu-index))
- ((and (equal token 'T_STRING)
- (not imenu-in-namespace-name))
- (let ((imenu-index-name (format "\\%s"
(buffer-substring-no-properties token-start token-end)))
- (imenu-index-pos token-start))
- (setq imenu-in-namespace-name imenu-index-name)
- (push `(,imenu-index-name . ,imenu-index-pos)
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)))))))
(imenu-in-class-declaration
(cond
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 4bea144..d613710 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -835,32 +835,32 @@
(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" . 17)
("\\myNamespace\\myClass" . 41) ("\\myNamespace\\myClass->myFunctionA()" . 75)
("\\myNamespace\\myClass->myFunctionB()" . 119)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" . 29)
("myNamespace\\myClass" . 41) ("myNamespace\\myClass->myFunctionA()" . 75)
("myNamespace\\myClass->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" . 17)
("\\myNamespace\\myClass" . 36) ("\\myNamespace\\myClass->myFunctionA()" . 66)
("\\myNamespace\\myClass->myFunctionB()" . 106)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" . 28)
("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-get-imenu) '(("\\myNamespace" . 17)
("\\myNamespace\\myClass" . 41) ("\\myNamespace\\myClass->myFunctionA()" . 94)
("\\myNamespace\\myClass->myFunctionB()" . 138)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" . 29)
("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-get-imenu) '(("\\myNamespace" . 17)
("\\myNamespace\\myClass" . 36) ("\\myNamespace\\myClass->myFunctionA()" . 108)
("\\myNamespace\\myClass->myFunctionB()" . 148)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" . 28)
("myNamespace\\myClass" . 36) ("myNamespace\\myClass->myFunctionA()" . 108)
("myNamespace\\myClass->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" . 17)
("\\myNamespace\\myClass" . 36) ("\\myNamespace\\myClass->myFunctionA()" . 108)
("\\myNamespace\\myClass->myFunctionB()" . 161)))))
+ (should (equal (phps-mode-functions-get-imenu) '(("myNamespace" . 28)
("myNamespace\\myClass" . 36) ("myNamespace\\myClass->myFunctionA()" . 108)
("myNamespace\\myClass->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, class that extends
and implements and functions with optional arguments"
- (should (equal (phps-mode-functions-get-imenu)
'(("\\myNamespace\\myNamespace2" . 17) ("\\myNamespace\\myClass" . 50)
("\\myNamespace\\myClass->myFunctionA()" . 122)
("\\myNamespace\\myClass->myFunctionB()" . 175)))))
+ "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)))))
)
diff --git a/phps-mode.el b/phps-mode.el
index d41b57f..ddd08ac 100644
--- a/phps-mode.el
+++ b/phps-mode.el
@@ -3,8 +3,8 @@
;; Author: Christian Johansson <github.com/cjohansson>
;; Maintainer: Christian Johansson <github.com/cjohansson>
;; Created: 3 Mar 2018
-;; Modified: 20 Apr 2019
-;; Version: 0.2
+;; Modified: 4 May 2019
+;; Version: 0.2.1
;; Keywords: tools, convenience
;; URL: https://github.com/cjohansson/emacs-phps-mode
- [elpa] externals/phps-mode 3f20bd2 394/405: Updated tests and structure of hierarchical imenu, (continued)
- [elpa] externals/phps-mode 3f20bd2 394/405: Updated tests and structure of hierarchical imenu, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ba7a3dc 381/405: Updated TODO list with travis integration completed, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3c959d3 404/405: Improved README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 895105d 384/405: Updated emacs version requirement and travis build, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b7b778b 379/405: Updated Travis CI build script, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3d3003f 364/405: Started on test for newline-and-indent before white-space, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 09a2123 372/405: Passes all tests for moving line-indent index, Stefan Monnier, 2019/07/13
- [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 <=
- [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, 2019/07/13
- [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