[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode a5ced61 158/405: New indentation function pas
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode a5ced61 158/405: New indentation function passes all original unit tests |
Date: |
Sat, 13 Jul 2019 10:00:04 -0400 (EDT) |
branch: externals/phps-mode
commit a5ced61be668e0cf584b1184d73056a71a0a3bc2
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
New indentation function passes all original unit tests
---
phps-mode-functions.el | 6 ++++--
phps-mode-test-functions.el | 40 ++++++++++++++++++++--------------------
2 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index b0bd25c..1d142ab 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -109,7 +109,8 @@
;; Is line ending indentation equal to line beginning
indentation and did we have a change of scope?
(when (= nesting-end nesting-start)
- (when first-token-is-nesting-decrease
+ (when (and first-token-is-nesting-decrease
+ (> column-level 0))
(setq column-level (1- column-level)))
(when first-token-is-nesting-increase
(setq column-level (1+ column-level))))
@@ -331,7 +332,8 @@
;; Is line ending indentation equal to line beginning indentation
and did we have a change of scope?
(when (= nesting-end nesting-start)
- (when first-token-is-nesting-decrease
+ (when (and first-token-is-nesting-decrease
+ (> column-level 0))
(setq column-level (1- column-level)))
(when first-token-is-nesting-increase
(setq column-level (1+ column-level))))
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 53c5a7a..1f6968b 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -179,7 +179,7 @@
(phps-mode-functions-indent-line)
;; (message "Tokens %s point %s" phps-mode-lexer-tokens (point))
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
- (should (equal buffer-contents "<?php\n$variable = array(\n
'random4');\n$variable = true;\n"))))
+ (should (equal buffer-contents "<?php\n$variable =
array(\n'random4');\n$variable = true;\n"))))
(phps-mode-test-with-buffer
"<?php\nadd_filter(\n\"views_{$screen->id}\",'__return_empty_array'\n);"
@@ -192,7 +192,7 @@
(phps-mode-test-with-buffer
"<?php\nif (random_expression(\ntrue\n)) {\nsome_logic_here();\n}"
- nil
+ "Round bracket test 3"
(goto-char 36)
(phps-mode-functions-indent-line)
;; (message "Tokens %s point %s" phps-mode-lexer-tokens (point))
@@ -201,7 +201,7 @@
(phps-mode-test-with-buffer
"<?php\nif (empty(\n$this->var\n) && !empty($this->var)\n) {\n$this->var =
'abc123';\n}\n"
- nil
+ "Nested if-expression"
(goto-char 54)
(phps-mode-functions-indent-line)
;; (message "Tokens %s point %s" phps-mode-lexer-tokens (point))
@@ -210,7 +210,7 @@
(phps-mode-test-with-buffer
"<?php\nif (myFirstCondition()) {\n $this->var = 'abc123';\n } else
{\n $this->var = 'def456';\n}\n"
- nil
+ "Regular else expression"
(goto-char 68)
(phps-mode-functions-indent-line)
;; (message "Tokens %s point %s" phps-mode-lexer-tokens (point))
@@ -219,7 +219,7 @@
(phps-mode-test-with-buffer
"<?php\nif (myFirstCondition()) {\n $this->var = 'abc123';\n } else
if (mySeconCondition()) {\n $this->var = 'def456';\n}\n"
- nil
+ "Regular else if test"
(goto-char 68)
(phps-mode-functions-indent-line)
;; (message "Tokens %s point %s" phps-mode-lexer-tokens (point))
@@ -229,7 +229,7 @@
;; Square bracket
(phps-mode-test-with-buffer
"<?php\n$var = [\n 'random' => [\n 'hello',\n],\n];\n"
- nil
+ "Square bracket test 1"
(goto-char 51)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
@@ -237,7 +237,7 @@
(phps-mode-test-with-buffer
"<?php\nif (myRandomCondition()):\necho 'Something here';\n else:\n
echo 'Something else here 8';\nendif;\n"
- nil
+ "Alternative else test"
(goto-char 62)
(phps-mode-functions-indent-line)
;; (message "Tokens %s" phps-mode-lexer-tokens)
@@ -248,23 +248,23 @@
(phps-mode-test-with-buffer
"<?php\nswitch (myRandomCondition()) {\ncase 'Something here':\necho
'Something else here';\n}\n"
- nil
+ "Switch case indentation test"
(goto-char 45)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
(should (equal buffer-contents "<?php\nswitch (myRandomCondition()) {\n
case 'Something here':\necho 'Something else here';\n}\n"))))
(phps-mode-test-with-buffer
- "<?php\nswitch (myRandomCondition()) {\ncase 'Something here':\necho
'Something else here';\n}\n"
- nil
- (goto-char 65)
+ "<?php\nswitch (myRandomCondition()): \ncase 'Something here':\necho
'Something else here';\nendswitch;\n"
+ "Alternative switch case indentation test 2"
+ (goto-char 70)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
- (should (equal buffer-contents "<?php\nswitch (myRandomCondition())
{\ncase 'Something here':\n echo 'Something else here';\n}\n"))))
+ (should (equal buffer-contents "<?php\nswitch (myRandomCondition()):
\ncase 'Something here':\n echo 'Something else here';\nendswitch;\n"))))
(phps-mode-test-with-buffer
"<?php\nif (myRandomCondition())\necho 'Something here';\necho 'Something
else here';\n"
- nil
+ "Inline control structure indentation"
(goto-char 40)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
@@ -272,7 +272,7 @@
(phps-mode-test-with-buffer
"<?php\nif (myRandomCondition())\n echo 'Something here';\n echo
'Something else here';\n"
- nil
+ "Inline control structure indentation 2"
(goto-char 60)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
@@ -280,7 +280,7 @@
(phps-mode-test-with-buffer
"<?php\nif (myRandomCondition()):\necho 'Something here';\n echo
'Something else here';\nendif;\n"
- nil
+ "Alternative control structure indentation 1"
(goto-char 40)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
@@ -288,7 +288,7 @@
(phps-mode-test-with-buffer
"<?php\nmyFunction(\n array(\n 'random' => 'abc',\n ),\n
$var5\n);\n"
- nil
+ "Function arguments with associate array indentation"
(goto-char 65)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
@@ -296,7 +296,7 @@
(phps-mode-test-with-buffer
"<?php\n$var = $var2->getHead()\n->getTail();\n"
- nil
+ "Multi-line assignment indentation test 1"
(goto-char 35)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
@@ -304,7 +304,7 @@
(phps-mode-test-with-buffer
"<?php\n$var =\n'random string';\n"
- nil
+ "Single-line assignment indentation test"
(goto-char 20)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
@@ -312,7 +312,7 @@
(phps-mode-test-with-buffer
"<?php\nif (empty($this->var)):\n$this->var = 'abc123';\n endif;"
- nil
+ "Alternative control structure if expression"
(goto-char 60)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
@@ -320,7 +320,7 @@
(phps-mode-test-with-buffer
"<?php\nif (empty($this->var)):\n$this->var = 'abc123';\n endif;"
- nil
+ "Alternative control structure test"
(goto-char 30)
(phps-mode-functions-indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
- [elpa] externals/phps-mode 4a27c44 147/405: Added support for naming unit tests to better find failures, (continued)
- [elpa] externals/phps-mode 4a27c44 147/405: Added support for naming unit tests to better find failures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b852f5f 160/405: All tests for indentation passes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode dfb0427 151/405: Added unit test for round and square bracket expressions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7b8cea3 163/405: Added failing indentation test for class multiple implements, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a61ff64 134/405: Renamed function get-point-data to get-current-line-data for better semantics, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b99da6b 153/405: Starting using new indentation calculation for indentations, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6559760 166/405: Work on assignments and class declaration indentations, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2720be8 165/405: Indentation calculation for heredoc and nowdoc assignments passes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 13c4c78 164/405: More work on heredoc, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 47ffc37 179/405: More work on refactored indentation calculation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a5ced61 158/405: New indentation function passes all original unit tests,
Stefan Monnier <=
- [elpa] externals/phps-mode e3eedd7 167/405: Assignment indentation passes tests, class declaration remains, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e37c1cf 150/405: New indention calculation works with doc-comments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f789468 172/405: Took notes of new indentation tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 20e77aa 181/405: Removed debug output, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 321803a 182/405: Line indents are now cleaning on buffer changes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 38bcabb 176/405: Improved detection of assignment ends in function optional arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f1236e2 169/405: Unit tests for indentation calculation for multi-line strings passes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 105fece 149/405: New indent calculation for inline syntax passes test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 0a32b17 161/405: Improved calculation for indentation for multi-line assignments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b2eac4d 154/405: More work on switch case default, Stefan Monnier, 2019/07/13