[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode a30c3f6 177/405: More work on indentation tes
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode a30c3f6 177/405: More work on indentation tests |
Date: |
Sat, 13 Jul 2019 10:00:08 -0400 (EDT) |
branch: externals/phps-mode
commit a30c3f6e7b0c80cc3f4125d39320ae6430d9a668
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
More work on indentation tests
---
phps-mode-functions.el | 30 ++++++++++++++++++++++--------
phps-mode-test-functions.el | 4 ++--
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 4f45d5b..d1d7036 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -107,15 +107,18 @@
(setq nesting-end (+ round-bracket-level
square-bracket-level curly-bracket-level alternative-control-structure-level
inline-control-structure-level in-assignment-level in-class-declaration-level))
;; Is line ending indentation lesser than line beginning
indentation?
- (when (and (< nesting-end nesting-start)
- (> column-level 0))
+ (when (< nesting-end nesting-start)
;; Decrement column
(if allow-custom-column-decrement
(progn
(setq column-level (- column-level (-
nesting-start nesting-end)))
(setq allow-custom-column-increment nil))
- (setq column-level (1- column-level))))
+ (setq column-level (1- column-level)))
+
+ ;; Prevent negative column-values
+ (when (< column-level 0)
+ (setq column-level 0)))
;; Is line ending indentation equal to line beginning
indentation and did we have a change of scope?
(when (and (= nesting-end nesting-start)
@@ -127,7 +130,7 @@
(when first-token-is-nesting-increase
(setq column-level (1+ column-level))))
- ;; (message "new line %s or last token at %s, %s %s.%s (%s
- %s) = %s %s %s %s %s [%s %s] %s %s %s" token-start-line-number token
last-token column-level tuning-level nesting-start nesting-end
round-bracket-level square-bracket-level curly-bracket-level
alternative-control-structure-level inline-control-structure-level
first-token-is-nesting-decrease first-token-is-nesting-increase in-assignment
in-assignment-level in-class-declaration-level)
+ (message "new line %s or last token at %s, %s %s.%s (%s -
%s) = %s %s %s %s %s [%s %s] %s %s %s" token-start-line-number token last-token
column-level tuning-level nesting-start nesting-end round-bracket-level
square-bracket-level curly-bracket-level alternative-control-structure-level
inline-control-structure-level first-token-is-nesting-decrease
first-token-is-nesting-increase in-assignment in-assignment-level
in-class-declaration-level)
;; Put indent-level to hash-table
(when (> last-line-number 0)
@@ -387,15 +390,26 @@
(setq nesting-end (+ round-bracket-level square-bracket-level
curly-bracket-level alternative-control-structure-level
inline-control-structure-level in-assignment-level in-class-declaration-level))
;; Is line ending indentation lesser than line beginning
indentation?
- (when (and (< nesting-end nesting-start)
- (> column-level 0))
+ (when (< nesting-end nesting-start)
;; Decrement column
(if allow-custom-column-decrement
(progn
(setq column-level (- column-level (- nesting-start
nesting-end)))
(setq allow-custom-column-increment nil))
- (setq column-level (1- column-level))))
+ (setq column-level (1- column-level)))
+
+ ;; Positive nesting should set positive column
+ (when (and (<= column-level 0)
+ (> nesting-end 0))
+ (message "Setting column-level to 1")
+ (setq column-level 1))
+
+ ;; Prevent negative column-values
+ (when (< column-level 0)
+ (setq column-level 0))
+
+ )
;; Is line ending indentation equal to line beginning indentation
and did we have a change of scope?
(when (= nesting-end nesting-start)
@@ -405,7 +419,7 @@
(when first-token-is-nesting-increase
(setq column-level (1+ column-level))))
- ;; (message "last token at %s %s.%s (%s - %s) = %s %s %s %s %s [%s
%s] %s %s" last-token column-level tuning-level nesting-start nesting-end
round-bracket-level square-bracket-level curly-bracket-level
alternative-control-structure-level inline-control-structure-level
first-token-is-nesting-decrease first-token-is-nesting-increase
in-assignment-level in-class-declaration-level)
+ (message "last token at %s %s.%s (%s - %s) = %s %s %s %s %s [%s
%s] %s %s" last-token column-level tuning-level nesting-start nesting-end
round-bracket-level square-bracket-level curly-bracket-level
alternative-control-structure-level inline-control-structure-level
first-token-is-nesting-decrease first-token-is-nesting-increase
in-assignment-level in-class-declaration-level)
;; Put indent-level to hash-table
(puthash last-line-number `(,column-level ,tuning-level)
line-indents)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 2e8bbed..8512b2c 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -80,7 +80,7 @@
(should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
- "<?php\nmyFunction(array(\n 23,\n [\n 25\n ]\n)\n);"
+ "<?php\nmyFunction(array(\n 23,\n [\n 25\n ]\n )\n);"
"Round and square bracket expressions"
(should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (2 0)) (6 (1
0)) (7 (0 0)) (8 (0 0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
@@ -186,7 +186,7 @@
(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)))))
- [elpa] externals/phps-mode 8bb3918 249/405: Clean-up of unit test logging, (continued)
- [elpa] externals/phps-mode 8bb3918 249/405: Clean-up of unit test logging, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9201d1c 246/405: Imenu index now handles functions with optional arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2c3239a 187/405: Adding new failing tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d9a0119 183/405: Optimized indentation code by removing unused variables, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a0cbcd1 186/405: More work on indentation of multi-line IF-expressions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d7c5f67 190/405: More work on nesting-stack, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 253839f 170/405: Added indentation unit tests for concatenated strings outside assignments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e38794b0 197/405: More conceptual work on algorithm for inline control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9db28d9 185/405: Added verbose flag for unit tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2a1ed52 196/405: Optimized algorithm for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a30c3f6 177/405: More work on indentation tests,
Stefan Monnier <=
- [elpa] externals/phps-mode e8a8d41 204/405: Merged remote changes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode faa4e00 201/405: Started on conceptually describing algorithm for multi-line assignment indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 874701d 195/405: Work on alternative and inline control structure syntax with new algorithm, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ec69d07 193/405: Added a failing class declaration indentation case, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 164b77e 205/405: Unit test for alternative control syntax passes with new algorithm, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e8658c8 192/405: New indentation algorithm now passes class unit tests, started on indentation document, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ba9d8a0 199/405: More organization of tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 86404c8 207/405: New algorithm now passes tests for alternative control structure, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8b4c188 188/405: Now able to detect indent change of scope with same nesting level, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 91715f6 217/405: Added another test for multi-line function arguments, Stefan Monnier, 2019/07/13