[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode e11a1fc 123/405: Fine-tuning of logic collect
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode e11a1fc 123/405: Fine-tuning of logic collecting data about inline and alternative control structures |
Date: |
Sat, 13 Jul 2019 09:59:57 -0400 (EDT) |
branch: externals/phps-mode
commit e11a1fcc847531e583a3a0079e876dfc7aaf80a6
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Fine-tuning of logic collecting data about inline and alternative control
structures
---
phps-mode-functions.el | 18 ++++++++----------
phps-mode-test-functions.el | 24 ++++++++++++++++++++++--
2 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index f6175d5..f77eb71 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -326,11 +326,6 @@
(equal token 'T_ENDFOR)
(equal token 'T_ENDFOREACH)
(equal token 'T_ENDSWITCH))
-
- ;; If this was the first token on line decrement start
- (when (and first-token-on-line
- (= first-token-on-line end-token-number))
- (setq start-alternative-control-structure-level (-
start-alternative-control-structure-level 1)))
(setq end-alternative-control-structure-level (-
end-alternative-control-structure-level 1)))
@@ -364,7 +359,8 @@
;; (message "Was colon")
;; Is token at or before line beginning?
- (when (<= token-end line-beginning)
+ (when (or (<= token-end line-beginning)
+ (= first-token-on-line end-token-number))
(setq start-alternative-control-structure-level (+
start-alternative-control-structure-level 1)))
;; Is token at or before line end?
@@ -378,6 +374,7 @@
(setq start-inline-control-structure-level (+
start-inline-control-structure-level 1))
(setq start-expecting-semi-colon t))
+
(when (<= token-start line-end)
(setq end-inline-control-structure-level (+
end-inline-control-structure-level 1))
(setq end-expecting-semi-colon t))
@@ -387,7 +384,7 @@
(setq after-special-control-structure nil))
- ;; Does the token support inline and alternative syntax?
+ ;; Does current token support inline and alternative syntax?
(when (or
(equal token 'T_IF)
(equal token 'T_WHILE)
@@ -395,12 +392,13 @@
(equal token 'T_FOREACH)
(equal token 'T_SWITCH)
(equal token 'T_ELSE)
- (equal token 'T_ELSEIF))
+ (equal token 'T_ELSEIF)
+ (equal token 'T_CASE))
;; (message "Found special control structure %s %s" token
start-round-bracket-level)
- (setq after-special-control-structure round-brace-level))
+ (setq after-special-control-structure round-brace-level)
- )))
+ ))))
(when (not found-line-tokens)
(setq start-token-number nil)
(setq end-token-number nil))
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 98101be..af79b70 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -355,7 +355,17 @@
(goto-char 55)
(should (equal (list (list t 0 0 0 0 0 0 nil) (list t 0 0 0 0 0 10 nil))
(phps-mode-functions-get-point-data))))
- ;; TODO ALTERNATIVE SYNTAX
+ (phps-mode-test-with-buffer
+ "<?php\nif ($myCondition)\n echo 'was here';\nelse\n echo 'was here
2';\n"
+ (goto-char 47)
+ (should (equal (list (list t 0 0 0 0 0 7 nil) (list t 0 0 0 0 0 8 nil))
(phps-mode-functions-get-point-data))))
+
+ (phps-mode-test-with-buffer
+ "<?php\nif ($myCondition)\n echo 'was here';\nelse\n echo 'was here
2';\n"
+ (goto-char 57)
+ (should (equal (list (list t 0 0 0 1 0 8 nil) (list t 0 0 0 0 0 11 nil))
(phps-mode-functions-get-point-data))))
+
+ ;; ALTERNATIVE SYNTAX
(phps-mode-test-with-buffer
"<?php\nif ($myCondition):\n echo 'was here';\nendif;\necho 'was here
2';\n"
@@ -365,7 +375,7 @@
(phps-mode-test-with-buffer
"<?php\nif ($myCondition):\n echo 'was here';\nendif;\necho 'was here
3';\n"
(goto-char 52)
- (should (equal (list (list t 0 0 0 0 0 8 nil) (list t 0 0 0 0 0 10 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 0 0 0 1 8 nil) (list t 0 0 0 0 0 10 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<?php\nif ($myCondition): echo 'was here';\nendif;\necho 'was here
4';\n"
@@ -376,6 +386,16 @@
"<?php\nif ($myCondition): echo 'was here'; endif; echo 'was here 5';\n"
(goto-char 35)
(should (equal (list (list t 0 0 0 0 0 0 nil) (list t 0 0 0 0 0 13 nil))
(phps-mode-functions-get-point-data))))
+
+ (phps-mode-test-with-buffer
+ "<?php\nif ($myCondition):\n echo 'was here';\nelse:\n echo 'was here
2';\nendif;\n"
+ (goto-char 44)
+ (should (equal (list (list t 0 0 0 0 1 5 nil) (list t 0 0 0 0 1 8 nil))
(phps-mode-functions-get-point-data))))
+
+ (phps-mode-test-with-buffer
+ "<?php\nif ($myCondition)\n echo 'was here';\nelse\n echo 'was here
2';\n"
+ (goto-char 55)
+ (should (equal (list (list t 0 0 0 1 0 8 nil) (list t 0 0 0 0 0 11 nil))
(phps-mode-functions-get-point-data))))
)
- [elpa] externals/phps-mode 7c6ee3e 107/405: More work on renaming, (continued)
- [elpa] externals/phps-mode 7c6ee3e 107/405: More work on renaming, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 46a8256 116/405: Starting implementation of tracking alternative control structure level, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9ac21f1 120/405: More work on inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 41ef691 112/405: Fixed lint warning of unused variables, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 12c22ee 119/405: More work on alternative and inline meta information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7e2e902 126/405: Fixed a unit test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 80da137 114/405: Preparations for adding alternative and inline syntax, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode baab77a 121/405: Unit tests for inline control structures working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f0dc652 143/405: More work on new indentation function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7dca537 105/405: Started work on renaming files, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e11a1fc 123/405: Fine-tuning of logic collecting data about inline and alternative control structures,
Stefan Monnier <=
- [elpa] externals/phps-mode e206605 115/405: Adding failing unit tests for inline and alternative syntax, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c6aa633 118/405: More work on keeping track of alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 60c7431 122/405: Unit tests for gather data about inline and alternative control structure syntax passes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 897f249 124/405: Work on alternative and inline indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode be35ed6 127/405: Added sample files for inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7279913 113/405: Improved TODOs, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a8eadfa 130/405: Improved sample files inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9996ae0 146/405: More work on indentation calculation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3776841 138/405: Added new support for tracking doc-comment, HEREDOC and NOWDOC indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 780d065 125/405: Code styling updates, Stefan Monnier, 2019/07/13