[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 43bf350 216/405: Added tests for token-less l
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 43bf350 216/405: Added tests for token-less lines |
Date: |
Sat, 13 Jul 2019 10:00:16 -0400 (EDT) |
branch: externals/phps-mode
commit 43bf350261e52aedc9366fac76775d459e61a332
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Added tests for token-less lines
---
phps-mode-functions.el | 41 ++++++++++++++++++++++-------------------
phps-mode-test-functions.el | 8 +++++++-
2 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index b208b65..d5bd9da 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -229,19 +229,12 @@
(when (equal after-special-control-structure-token
'T_SWITCH)
;; (message "Opening switch, increase curly brackets
to %s" curly-bracket-level)
- (push curly-bracket-level switch-curly-stack)
- (setq allow-custom-column-increment t)
- (setq curly-bracket-level (1+ curly-bracket-level)))
+ (push curly-bracket-level switch-curly-stack))
;; Is it the start of an alternative control structure?
(if (string= token ":")
(progn
-
- (when (equal after-special-control-structure-token
'T_SWITCH)
- (setq alternative-control-structure-level (1+
alternative-control-structure-level))
- (setq allow-custom-column-increment t))
-
(setq alternative-control-structure-level (1+
alternative-control-structure-level))
(when phps-mode-functions-verbose
@@ -261,9 +254,15 @@
(setq after-special-control-structure-token nil)
(setq after-special-control-structure-first-on-line nil)))
- ;; Support extra special control structures (CASE)
+ ;; Support extra special control structures (CASE:)
(when (and after-extra-special-control-structure
(string= token ":"))
+
+ (when phps-mode-functions-verbose
+ (message "Started CASE"))
+
+ (setq alternative-control-structure-level (1+
alternative-control-structure-level))
+
(setq line-contained-nesting-increase t)
(when after-extra-special-control-structure-first-on-line
(setq first-token-is-nesting-decrease t))
@@ -394,16 +393,6 @@
(setq column-level-start column-level)
- ;; Indent token-less lines here in between last tokens
if distance is more than 1 line
- (when (and (> next-token-start-line-number (1+
token-start-line-number))
- (not (equal token 'T_CLOSE_TAG)))
- (let ((token-line-number-diff (1- (-
token-start-line-number next-token-start-line-number))))
- (while (>= token-line-number-diff 0)
- (puthash (- token-start-line-number
token-line-number-diff) `(,column-level-start ,tuning-level) line-indents)
- ;; (message "Saved line %s indent %s %s" (-
token-end-line-number token-line-number-diff) column-level tuning-level)
- (setq token-line-number-diff (1-
token-line-number-diff)))))
-
-
;; Support temporarily pre-indent
(when temp-pre-indent
(setq column-level-start temp-pre-indent)
@@ -482,6 +471,20 @@
(setq tuning-level 0)))
+;; Indent token-less lines here in between last tokens if distance is more
than 1 line
+ (when (and (> next-token-start-line-number (1+
token-end-line-number))
+ (not (equal token 'T_CLOSE_TAG)))
+
+ (when phps-mode-functions-verbose
+ (message "\nDetected token-less lines between %s and
%s, should have indent: %s\n" token-end-line-number
next-token-start-line-number column-level))
+
+ (let ((token-line-number-diff (1- (-
next-token-start-line-number token-end-line-number))))
+ (while (>= token-line-number-diff 0)
+ (puthash (- next-token-start-line-number
token-line-number-diff) `(,column-level ,tuning-level) line-indents)
+ ;; (message "Saved line %s indent %s %s" (-
token-end-line-number token-line-number-diff) column-level tuning-level)
+ (setq token-line-number-diff (1-
token-line-number-diff)))))
+
+
;; ;; When nesting decreases but ends with a nesting
increase, increase indent by one
;; (when (and (< nesting-end nesting-start)
;; line-contained-nesting-increase)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index e765760..affdf09 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -123,6 +123,12 @@
;; (message "Tokens: %s" phps-mode-lexer-tokens)
(should (equal '((1 (0 0)) (2 (1 0)) (3 (0 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (phps-mode-test-with-buffer
+ "<?php\nif (true) {\n\n\n echo 'here';\n\n}"
+ "Regular if-expression white token-less lines"
+ ;; (message "Tokens: %s" phps-mode-lexer-tokens)
+ (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (1 0)) (5 (1 0)) (6 (1
0)) (7 (0 0))) (phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+
)
(defun phps-mode-test-functions-get-lines-indent-multi-line-assignments ()
@@ -276,7 +282,7 @@
"<html><head><title><?php if ($myCondition) {\n if ($mySeconCondition)
{\n echo $title2;\n\n } ?></title><body>Bla bla</body></html>"
"Mixed HTML/PHP with if expression"
;; (message "Tokens: %s" phps-mode-lexer-tokens)
- (should (equal '((1 (0 0)) (2 (1 0)) (3 (2 0)) (5 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
+ (should (equal '((1 (0 0)) (2 (1 0)) (3 (2 0)) (4 (2 0)) (5 (1 0)))
(phps-mode-test-functions--hash-to-list
(phps-mode-functions-get-lines-indent)))))
(phps-mode-test-with-buffer
"<html><head><title><?php\nif ($myCondition) {\n if ($mySecondCondition)
{\n echo $title;\n } else if ($mySecondCondition) {\n echo
$title4;\n } else {\n echo $title2;\n echo $title3;\n }\n}
?></title><body>Bla bla</body></html>"
- [elpa] externals/phps-mode 91715f6 217/405: Added another test for multi-line function arguments, (continued)
- [elpa] externals/phps-mode 91715f6 217/405: Added another test for multi-line function arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 75c4af4 214/405: Fixed indentation for lines wrapped in scripting open/close, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d754163 221/405: More work on multi-line token-less lines, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8947e6e 202/405: Conceptual work on indentation-calculation for multi-line assignment, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode fc2e8b7 212/405: Added logic to indent token-less lines as well, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8707777 237/405: Updated README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2d4646f 203/405: Work on inline control structure indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 202827b 198/405: New indentation algorithm now supports inline control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b2a5700 218/405: Fixed indentation for multi-line optional function arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f7186a1 239/405: Preparations for hierarchical imenu, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 43bf350 216/405: Added tests for token-less lines,
Stefan Monnier <=
- [elpa] externals/phps-mode 0de10fa 235/405: Passes first test for imenu, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f791cee 234/405: Started on unit tests for imenu-index generation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b56a15c 233/405: Removed debugging output, updated todo items, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 73784d0 225/405: Cleaned up tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f7e7c74 219/405: Work on indentation for switch-case, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c2af31e 240/405: Imenu support now shows hierarchical information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 55953de 232/405: Lexer now doesn't find keywords in function names, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b8e9449 247/405: Refactored Imenu to use a persistent variable per buffer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 67b8701 244/405: Decreased length of imenu items to prevent truncation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e78d8ed 248/405: Clean-up of indentation code, Stefan Monnier, 2019/07/13