branch: externals/phps-mode commit 38bcabb0a6ae1a14db762086c84fc60ea22ce90b Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Improved detection of assignment ends in function optional arguments --- phps-mode-functions.el | 5 +++-- phps-mode-test-functions.el | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/phps-mode-functions.el b/phps-mode-functions.el index f475749..4f45d5b 100644 --- a/phps-mode-functions.el +++ b/phps-mode-functions.el @@ -317,7 +317,8 @@ ;; Keep track of assignments (if in-assignment - (if (string= token ";") + (if (or (string= token ";") + (< round-bracket-level in-assignment)) (progn (setq in-assignment nil) (when in-assignment-started-this-line @@ -332,7 +333,7 @@ (when (and (not after-special-control-structure) (string= token "=")) ;; (message "Started assignment") - (setq in-assignment t) + (setq in-assignment round-bracket-level) (setq in-assignment-started-this-line t) (setq in-assignment-level 1))) diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el index bcc74b4..2e8bbed 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -181,12 +181,12 @@ (phps-mode-test-with-buffer "<?php\nfunction myFunction($parameters = null)\n{\n echo 'statement';\n}\n" - "Statement after one-lined function declaration" + "Statement after one-lined function declaration with optional argument" ;; (message "Tokens: %s" phps-mode-lexer-tokens) (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (1 0)) (5 (0 0))) (phps-mode-test-functions--hash-to-list (phps-mode-functions-get-lines-indent))))) (phps-mode-test-with-buffer - "<?php\n// Can we load configuration?\nif ($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" + "<?php\n// Can we load configuration?\nif ($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" "If expression spanning multiple lines" ;; (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)))))