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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode 419a812 298/405: More work on debugging inden


From: Stefan Monnier
Subject: [elpa] externals/phps-mode 419a812 298/405: More work on debugging indentation with assignment
Date: Sat, 13 Jul 2019 10:00:36 -0400 (EDT)

branch: externals/phps-mode
commit 419a812a2a877261899e6556ae3b74972fb33cdc
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>

    More work on debugging indentation with assignment
---
 phps-mode-functions.el      | 43 +++++++++++++++++++++++++------------------
 phps-mode-test-functions.el |  2 +-
 2 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index a70d184..315894d 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -404,15 +404,18 @@
                 (if in-concatenation
                     (when (or (string= token ";")
                               (and (string= token ")")
-                                   (<= round-bracket-level 
in-concatenation-round-bracket-level))
+                                   (< round-bracket-level 
in-concatenation-round-bracket-level))
                               (and (string= token"]")
-                                   (<= square-bracket-level 
in-concatenation-square-bracket-level)))
+                                   (< square-bracket-level 
in-concatenation-square-bracket-level)))
+                      (when phps-mode-functions-verbose
+                        (message "Ended concatenation"))
                       (setq in-concatenation nil)
                       (setq in-concatenation-level 0))
                   (when (and (> next-token-start-line-number 
token-end-line-number)
                              (or (string= token ".")
                                  (string= next-token ".")))
-                    ;; (message "Started assignment")
+                    (when phps-mode-functions-verbose
+                      (message "Started concatenation"))
                     (setq in-concatenation t)
                     (setq in-concatenation-round-bracket-level 
round-bracket-level)
                     (setq in-concatenation-square-bracket-level 
square-bracket-level)
@@ -454,28 +457,32 @@
 
                 ;; Keep track of assignments
                 (if in-assignment
-                    (if (or (string= token ";")
-                            (and (string= token ")")
-                                 (<= round-bracket-level 
in-assignment-round-bracket-level))
-                            (and (string= token ",")
-                                 (<= round-bracket-level 
in-assignment-round-bracket-level))
-                            (and (string= token"]")
-                                 (<= square-bracket-level 
in-assignment-square-bracket-level)))
-                        (progn
-                          (setq in-assignment nil)
-                          (setq in-assignment-level 0))
-                      (when first-token-on-line
-                        (setq in-assignment-level 1)
-                        ;; (message "In assignment on new-line at %s" token)
-                        ))
+                    (when (or (string= token ";")
+                              (and (string= token ")")
+                                   (<= round-bracket-level 
in-assignment-round-bracket-level))
+                              (and (string= token ",")
+                                   (<= round-bracket-level 
in-assignment-round-bracket-level))
+                              (and (string= token"]")
+                                   (<= square-bracket-level 
in-assignment-square-bracket-level)))
+                      (when phps-mode-functions-verbose
+                        (message "Ended assignment"))
+                      (setq in-assignment nil)
+                      (setq in-assignment-level 0))
                   (when (and (not after-special-control-structure)
                              (string= token "="))
-                    (message "Started assignment")
+                    (when phps-mode-functions-verbose
+                      (message "Started assignment"))
                     (setq in-assignment t)
                     (setq in-assignment-round-bracket-level 
round-bracket-level)
                     (setq in-assignment-square-bracket-level 
square-bracket-level)
                     (setq in-assignment-level 1)))
 
+                ;; TODO Fix issue with indentation for assignments with 
chained object operators
+
+                ;; Keep track of object operators
+                (when (and (equal token 'T_OBJECT_OPERATOR)
+                           first-token-on-line))
+
                 ;; Did we encounter a token that supports extra special 
alternative control structures?
                 (when (equal token 'T_CASE)
                   (setq after-extra-special-control-structure t)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 738ad79..95a1cf0 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -332,7 +332,7 @@
    "<?php\n$var =\n    500 .\n    \"200\" .\n    100.0 .\n    '200' .\n    
$this->getTail()\n    ->getBottom();"
    "Multi-line assignments"
    ;; (message "Tokens: %s" phps-mode-lexer-tokens)
-   (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (2 
0)) (7 (2 0)) (8 (1 0))) (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))))
+   (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (2 0)) (6 (2 
0)) (7 (2 0)) (8 (2 0))) (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))))
 
   )
 



reply via email to

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