[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 781356557c 194/212: More adjustments to inden
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 781356557c 194/212: More adjustments to indent helper to find previous command |
Date: |
Wed, 26 Jan 2022 01:51:26 -0500 (EST) |
branch: externals/phps-mode
commit 781356557cb77efdea8258c047c02446735e7dea
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More adjustments to indent helper to find previous command
---
phps-mode-indent.el | 54 +++++++++++++++++++++++++------------------
test/phps-mode-test-indent.el | 12 ++++++++++
2 files changed, 44 insertions(+), 22 deletions(-)
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index 374313fa40..d9d2c4697d 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -320,6 +320,7 @@
nil
t))
(let ((match (match-string-no-properties 0)))
+ ;; (message "match: %S" match)
(cond
;; Commented out line
@@ -353,32 +354,41 @@
(line-beginning-position)
(line-end-position))))
+ ;; A closing curly bracket is indicate of a distinct command
+ ((string-match-p
+ "}[\t ]*$"
+ match)
+ (when found-semi-colon
+ (setq
+ not-found
+ nil)))
+
;; A second semi-colon is always a indicator of
;; a end of a previous command
;; Some keywords always indicate a start of command
((string-match-p
- "\\;[\t ]*$"
+ ";[\t ]*$"
match)
- (let ((is-statement
- (string-match-p
- "^[\t
]*\\(endswitch\\|endforeach\\|endwhile\\|exit\\|die\\|echo[\t ]+.*\\)[\t ]*;$"
- (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))))
- (if is-statement
- (progn
- (setq
- not-found
- nil)
- (setq
- reference-line
- (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position))))
- (if found-semi-colon
- (setq
- not-found
- nil)
+ (if found-semi-colon
+ (setq
+ not-found
+ nil)
+ (let ((is-statement
+ (string-match-p
+ "^[\t
]*\\(endswitch\\|endforeach\\|endwhile\\|exit\\|die\\|echo[\t ]+.*\\)[\t ]*;$"
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position)))))
+ (if is-statement
+ (progn
+ (setq
+ not-found
+ nil)
+ (setq
+ reference-line
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position))))
(setq
reference-line
(buffer-substring-no-properties
@@ -1080,7 +1090,7 @@
(setq
match-type
'line-after-line-that-ends-with-semicolon)
- (end-of-line)
+ (beginning-of-line)
(when-let
((reference-line
diff --git a/test/phps-mode-test-indent.el b/test/phps-mode-test-indent.el
index 33e7d39f61..fdb71bf3c6 100644
--- a/test/phps-mode-test-indent.el
+++ b/test/phps-mode-test-indent.el
@@ -149,6 +149,14 @@
(phps-mode-indent--get-previous-reference-command-line)
" endswitch;")))
+ (with-temp-buffer
+ (insert "<?php\nif (!defined('VARIABLE')) {\n
exit;\n}\n\nrequire_once(CONSTANT . 'path');\n$variable = myFunction1(\n
'argument1',\n 'argument2'\n);\n")
+ (goto-char 92)
+ (should
+ (string=
+ (phps-mode-indent--get-previous-reference-command-line)
+ "require_once(CONSTANT . 'path');")))
+
(with-temp-buffer
(insert "<?php\nif (true) {\n array(\n 8,\n );")
(goto-char (point-max))
@@ -545,6 +553,10 @@
"<?php\nif ($random) {\n if ($random) {\n if ($random) {\n
}\n }\n apply_filters(\n 'my_filter',\n $random\n );\n
return $random;\n}\n"
"Line after line that ends a multi-line function call")
+ (phps-mode-test-indent--should-equal
+ "<?php\n\nif (!defined('VARIABLE')) {\n
exit;\n}\n\nrequire_once(CONSTANT . 'path');\n$variable = myFunction1(\n
'argument1',\n 'argument2'\n);\n\nif (is_logged_in()) {\n $variable =
myFunction2(\n 'argument1',\n 'argument2'\n );\n
require_once(CONSTANT . 'string');\n}\n"
+ "Mixed expressions and statements")
+
)
(defun phps-mode-test-indent--get-lines-indent-psr-2 ()
- [elpa] externals/phps-mode 9ad46d061e 057/212: Bookkeeping via AST passing two more tests, (continued)
- [elpa] externals/phps-mode 9ad46d061e 057/212: Bookkeeping via AST passing two more tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 806bb902b3 122/212: Improved indentation for chaining objects, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode cc3bf03786 123/212: Improved indentation after ending assignment expression, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 3162dca5c4 159/212: Added two more failing indentation tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 1e44021653 163/212: Added more failing indent tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e7aff3f69d 157/212: Passed more indentation tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode db7121941c 156/212: Passing indention on line after not equals condition, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d072fe5315 136/212: Improved indentation around array elements, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f880ba2d62 164/212: Improved indentation on lines after assignment that ends with closing bracket, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode db019887af 170/212: Passed new indentation tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 781356557c 194/212: More adjustments to indent helper to find previous command,
Christian Johansson <=
- [elpa] externals/phps-mode 0735959c08 209/212: Using silent cache write, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e3bf9e8fed 059/212: SDT rules for some more infix operations, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 2bc31a0f83 065/212: Added TODO items, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d802a669c0 061/212: Bookkeeping via AST working with isset() and !empty() scoped variables, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d9115ec583 069/212: Cleaned up AST bookkeeping tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f4d2164f8b 067/212: Bookkeeping via parser SDT passing static variables in function, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e66abd00e5 064/212: Bookkeeping via AST passing nested isset() !empty() expressions, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 8b5ce22d87 072/212: Fixed issue with SDT for return statement, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 491c82a2a1 071/212: Added TODO item for bookkeeping via AST, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 5ec32f5f5a 076/212: Bookkeeping via AST passing all tests, Christian Johansson, 2022/01/26