branch: externals/phps-mode
commit 74ab2a71b62df8b1d742a510d63afeb58c344953
Author: Christian Johansson <christ...@cvj.se>
Commit: Christian Johansson <christ...@cvj.se>

    Work on incremental lexer and failing test for indent
---
 phps-mode-lexer.el          | 11 +++++++----
 phps-mode-test-functions.el | 13 ++++++++++---
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index 95ce874..87a824e 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -399,8 +399,7 @@
   ;; Push token start, end, lexer state and state stack to variable
   (push (list start end phps-mode-lexer-STATE phps-mode-lexer-state_stack) 
phps-mode-lexer-states)
 
-  (semantic-lex-push-token
-   (semantic-lex-token token start end)))
+  (semantic-lex-push-token (semantic-lex-token token start end)))
 
 ;; TODO Figure out what this does
 (defun phps-mode-lexer-SKIP_TOKEN (_token _start _end)
@@ -1691,9 +1690,12 @@
             ;; Build new list of tokens before point of change
             (catch 'stop-iteration
               (dolist (token tokens)
-                (let ((start (car (cdr token))))
+                (let ((start (car (cdr token)))
+                      (end (cdr (cdr token))))
                   (if (< start previous-token-end)
-                      (push token old-tokens)
+                      (progn
+                        (semantic-lex-push-token (semantic-lex-token token 
start end))
+                        (push token old-tokens))
                     (throw 'stop-iteration nil)))))
             (setq old-tokens (nreverse old-tokens))
 
@@ -1731,6 +1733,7 @@
   (when (boundp 'semantic-lex-analyzer)
     (setq semantic-lex-analyzer 'phps-mode-lexer-lex))
   (add-hook 'semantic-lex-reset-functions #'phps-mode-lexer-setup)
+  (set (make-local-variable 'phps-mode-lexer-tokens) nil)
   (phps-mode-lexer-run))
 
 (provide 'phps-mode-lexer)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 792ab9f..7f18ae7 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -164,13 +164,22 @@
 
   ;; TODO Fix below
 
-  
+  (phps-mode-test-with-buffer
+   "<?php\n$myVar = 'blaha'\n    . 'ijeije' . __(\n        'okeoke'\n    ) . 
'okeoke';\n?>"
+   "Concatenated assignment string with function call"
+   (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (1 0)) (6 (0 
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
+
   (phps-mode-test-with-buffer
    "<?php\n$myVar = 'blaha'\n    . 'ijeije' . __(\n        'okeoke'\n    )\n   
 . 'okeoke';\n?>"
    "Concatenated assignment string with function call"
    (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (1 0)) (6 (1 
0)) (7 (0 0))) (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))))
 
   (phps-mode-test-with-buffer
+   "<?php\necho 'blaha'\n    . 'ijeije' . __(\n        'okeoke'\n    ) . 
'okeoke';\n?>"
+   "Concatenated echo string with function call"
+   (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (1 0)) (6 (0 
0))) (phps-mode-test-hash-to-list (phps-mode-functions-get-lines-indent)))))
+
+  (phps-mode-test-with-buffer
    "<?php\necho 'blaha'\n    . 'ijeije' . __(\n        'okeoke'\n    )\n    . 
'okeoke';\n?>"
    "Concatenated echo string with function call"
    (should (equal '((1 (0 0)) (2 (0 0)) (3 (1 0)) (4 (2 0)) (5 (1 0)) (6 (1 
0)) (7 (0 0))) (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))))
@@ -222,8 +231,6 @@
    ;; (message "Indent: %s" (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))
    (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (1 
0)) (7 (1 0)) (8 (2 0)) (9 (1 0)) (10 (0 0))) (phps-mode-test-hash-to-list 
(phps-mode-functions-get-lines-indent)))))
 
-  ;; TODO Fix this below
-
   (phps-mode-test-with-buffer
    "<?php\nnamespace Vendor\\Package;\n\nclass ClassName\n{\n    public 
function aVeryLongMethodName(\n        ClassTypeHint $arg1,\n        &$arg2,\n  
      array $arg3 = []\n    ) {\n        // method body\n    }\n}"
    "PSR-2 : 4.4. Method Arguments : Example 2"

Reply via email to