branch: externals/phps-mode commit 2d2aaad9e6b03c76cf7c75ea0b26b6c67221311b Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Added failing unit test --- README.md | 7 ++++--- phps-mode-functions.el | 13 ++++++------- phps-mode-test-functions.el | 9 +++++++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2f3bbd5..279e20c 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,17 @@ 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 (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%) -* A set of heuristics to improve large-file incremental change handling (20%) +* 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%) -* Approach flycheck about including support for this module by default (0%) * Full integration with Emacs Semantic subsystem (30%) +* Approach flycheck about including support for this module by default (0%) +* Eldoc support (0%) * Flymake support (0%) * PSR-2 auto-formatting tool based on lexer tokens (0%) * Add to MELPA (0%) diff --git a/phps-mode-functions.el b/phps-mode-functions.el index 282492a..033de69 100644 --- a/phps-mode-functions.el +++ b/phps-mode-functions.el @@ -1,6 +1,6 @@ ;;; phps-mode-functions.el --- Mode functions for PHPs -*- lexical-binding: t -*- -;; Copyright (C) 2018 Christian Johansson +;; Copyright (C) 2018-2019 Christian Johansson ;; This file is not part of GNU Emacs. @@ -46,10 +46,6 @@ (defvar phps-mode-functions-verbose nil "Verbose messaging, default nil.") - -;; NOTE Also format white-space inside the line, i.e. after function declarations? - - (defun phps-mode-functions-get-buffer-changes-start () "Get buffer change start." phps-mode-functions-buffer-changes-start) @@ -222,14 +218,17 @@ (when phps-mode-functions-verbose (message "Token '%s' pos: %s-%s lines: %s-%s" next-token next-token-start next-token-end next-token-start-line-number next-token-end-line-number))) - ;; Token logic + ;; Token logic - we have one token look-ahead at this point (when token + ;; IMENU LOGIC (cond + ((string= token "{") (setq imenu-nesting-level (1+ imenu-nesting-level))) + ((string= token "}") (when (and imenu-open-namespace-level @@ -314,6 +313,7 @@ (setq imenu-in-function-name nil) (setq imenu-in-function-declaration t))))) + ;; INDENTATION LOGIC ;; Keep track of round bracket level @@ -1054,7 +1054,6 @@ ;; Support for change detection (add-hook 'after-change-functions #'phps-mode-functions-after-change)) - (provide 'phps-mode-functions) ;;; phps-mode-functions.el ends here diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el index ced802e..4bea144 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -1,6 +1,6 @@ ;;; phps-mode-test-functions.el --- Tests for functions -*- lexical-binding: t -*- -;; Copyright (C) 2018 Christian Johansson +;; Copyright (C) 2018-2019 Christian Johansson ;; This file is not part of GNU Emacs. @@ -857,6 +857,11 @@ "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))))) + (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))))) + ) (defun phps-mode-test-functions-comment-uncomment-region () @@ -957,7 +962,7 @@ (defun phps-mode-test-functions () "Run test for functions." - (setq debug-on-error t) + ;; (setq debug-on-error t) ;; (setq phps-mode-functions-verbose t) (phps-mode-test-functions-get-lines-indent-if) (phps-mode-test-functions-get-lines-indent-classes)