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

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

[elpa] externals/phps-mode e3a060a 026/405: Handles script breaking sing


From: Stefan Monnier
Subject: [elpa] externals/phps-mode e3a060a 026/405: Handles script breaking single-line comments
Date: Sat, 13 Jul 2019 09:59:33 -0400 (EDT)

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

    Handles script breaking single-line comments
---
 phps-lexer.el      | 6 ++++--
 phps-test-lexer.el | 7 +++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/phps-lexer.el b/phps-lexer.el
index 1529dd7..52c2a5a 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -779,13 +779,15 @@
     (let* ((start (match-beginning 0))
            (end (match-end 0))
            (data (buffer-substring-no-properties start end))
-           (line (buffer-substring-no-properties (line-beginning-position) 
(line-end-position))))
+           (line (buffer-substring-no-properties end (line-end-position))))
       (if (string-match "\\?>" line)
           (progn
-            (phps-mode/RETURN_TOKEN 'T_COMMENT start (match-end 0))
+            ;; (message "Found comment 1 from %s to %s %s in %s" end (+ end 
(match-beginning 0)) (match-beginning 0) line)
+            (phps-mode/RETURN_TOKEN 'T_COMMENT start (+ end (match-beginning 
0)))
             )
         (progn
           ;; TODO Handle expecting values here
+          ;; (message "Found comment 2 from %s to %s" start 
(line-end-position))
           (phps-mode/RETURN_TOKEN 'T_COMMENT start (line-end-position))
           ))))
 
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 62bbe0d..95d592c 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -134,6 +134,13 @@
                   '((T_OPEN_TAG 1 . 7) (T_STRING 7 . 17) ("(" 17 . 18) (")" 18 
. 19) (";" 19 . 20)))))
 
   (phps-mode/with-test-buffer
+   "<?php // echo 'random';?><!--</div>-->"
+   (should (equal phps-mode/lexer-tokens
+                  '((T_OPEN_TAG 1 . 7) (T_COMMENT 7 . 24) (";" 24 . 26) 
(T_CLOSE_TAG 24 . 26)))))
+
+
+
+  (phps-mode/with-test-buffer
    "<?php echo isset($backtrace[1]['file']) ? 'yes' : 'no';\n//a random 
comment\n// another random comment\n/**\n * More comments\n* More\n **/\necho 
$backtrace; ?>"
    (should (equal phps-mode/lexer-tokens
                   '((T_OPEN_TAG 1 . 7) (T_ECHO 7 . 11) (T_ISSET 12 . 17) ("(" 
17 . 18) (T_VARIABLE 18 . 28) ("[" 28 . 29) (T_LNUMBER 29 . 30) ("]" 30 . 31) 
("[" 31 . 32) (T_CONSTANT_ENCAPSED_STRING 32 . 38) ("]" 38 . 39) (")" 39 . 40) 
("?" 41 . 42) (T_CONSTANT_ENCAPSED_STRING 43 . 48) (":" 49 . 50) 
(T_CONSTANT_ENCAPSED_STRING 51 . 55) (";" 55 . 56) (T_COMMENT 57 . 75) 
(T_COMMENT 76 . 101) (T_DOC_COMMENT 102 . 134) (T_ECHO 135 . 139) (T_VARIABLE 
140 . 150) (";" 150 . 151) (";" 152 . 154)  [...]



reply via email to

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