emacs-elpa-diffs
[Top][All Lists]
Advanced

[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))))
   
   )
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]