[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode feb5724 039/405: Various debug work
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode feb5724 039/405: Various debug work |
Date: |
Sat, 13 Jul 2019 09:59:38 -0400 (EDT) |
branch: externals/phps-mode
commit feb57241345c4e55fdec6ea6ea310cecb3314215
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Various debug work
---
phps-lexer.el | 10 ++++++----
phps-test-lexer.el | 23 ++++++++++++++++++++---
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/phps-lexer.el b/phps-lexer.el
index 8c545d4..61ad818 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -891,7 +891,7 @@
;; (message "Double quoted string: %s"
double-quoted-string)
(phps-mode/RETURN_TOKEN 'T_CONSTANT_ENCAPSED_STRING
start (+ string-start 2))))
(progn
- ;; (message "Found variable after '%s'"
(buffer-substring-no-properties start (point)))
+ (message "Found variable after '%s'"
(buffer-substring-no-properties start string-start))
(phps-mode/BEGIN phps-mode/ST_DOUBLE_QUOTES)
(phps-mode/RETURN_TOKEN "\"" start (+ start 1))
(phps-mode/RETURN_TOKEN 'T_ENCAPSED_AND_WHITESPACE (+
start 1) string-start))))
@@ -1001,7 +1001,7 @@
((looking-at "[\"]")
(phps-mode/BEGIN phps-mode/ST_IN_SCRIPTING)
- ;; (message "Ended double-quote at %s" (match-beginning 0))
+ (message "Ended double-quote at %s" (match-beginning 0))
(phps-mode/RETURN_TOKEN "\"" (match-beginning 0) (match-end 0)))
((looking-at phps-mode/ANY_CHAR)
@@ -1048,7 +1048,8 @@ ANY_CHAR'
((looking-at (concat "\\$" phps-mode/LABEL "->" "[a-zA-Z_\x80-\xff]"))
(phps-mode/yy_push_state phps-mode/ST_LOOKING_FOR_PROPERTY)
- (phps-mode/RETURN_TOKEN 'T_VARIABLE (match-beginning 0) (match-end
0)))
+ (forward-char -3)
+ (phps-mode/RETURN_TOKEN 'T_VARIABLE (match-beginning 0) (-
(match-end 0) 3)))
((looking-at (concat "\\$" phps-mode/LABEL "\\["))
(phps-mode/yy_push_state phps-mode/ST_VAR_OFFSET)
@@ -1100,7 +1101,8 @@ ANY_CHAR'
((looking-at (concat "\\$" phps-mode/LABEL "->" "[a-zA-Z_\x80-\xff]"))
(phps-mode/yy_push_state phps-mode/ST_LOOKING_FOR_PROPERTY)
- (phps-mode/RETURN_TOKEN 'T_VARIABLE (match-beginning 0) (match-end 0)))
+ (forward-char -3)
+ (phps-mode/RETURN_TOKEN 'T_VARIABLE (match-beginning 0) (- (match-end 0)
3)))
((looking-at (concat "\\$" phps-mode/LABEL "\\["))
(phps-mode/yy_push_state phps-mode/ST_VAR_OFFSET)
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index eb1af34..3147afd 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -212,6 +212,25 @@
(should (equal phps-mode/lexer-tokens
'((T_OPEN_TAG 1 . 7) ("`" 7 . 8) (T_CONSTANT_ENCAPSED_STRING
8 . 20) (T_VARIABLE 20 . 29) (T_CONSTANT_ENCAPSED_STRING 29 . 33) (T_CURLY_OPEN
33 . 34) (T_VARIABLE 34 . 44) ("}" 44 . 45) (T_CONSTANT_ENCAPSED_STRING 45 .
49) (T_DOLLAR_OPEN_CURLY_BRACES 49 . 51) (T_STRING_VARNAME 51 . 60) ("}" 60 .
61) (T_CONSTANT_ENCAPSED_STRING 61 . 65) (T_VARIABLE 65 . 75) (T_STRING 75 .
80) ("]" 80 . 81) (T_CONSTANT_ENCAPSED_STRING 81 . 90) ("`" 90 . 91) (";" 91 .
92)))))
+ (phps-mode/with-test-buffer
+ "<?php $wpdb->posts; ?>"
+ (should (equal phps-mode/lexer-tokens
+ '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 12) (T_OBJECT_OPERATOR
12 . 14) (T_STRING 14 . 19) (";" 19 . 20) (";" 21 . 23) (T_CLOSE_TAG 21 .
23)))))
+
+ ;; TODO Fix this, produces invalid tokens
+ (phps-mode/with-test-buffer
+ "<?php $var = \"SELECT post_parent FROM $wpdb->posts WHERE ID =
'\".$id.\"'\"; ?>"
+ (message "Tokens 1: %s" phps-mode/lexer-tokens)
+ (should (equal phps-mode/lexer-tokens
+ '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 11) ("=" 12 . 13) ("\""
14 . 15) (T_ENCAPSED_AND_WHITESPACE 15 . 39) (T_VARIABLE 39 . 47) (T_STRING 47
. 51) (T_CONSTANT_ENCAPSED_STRING 51 . 64) ("\"" 64 . 65) ("." 65 . 66)
(T_VARIABLE 66 . 69) ("." 69 . 70) (T_CONSTANT_ENCAPSED_STRING 70 . 73) (";" 73
. 74) (";" 75 . 77) (T_CLOSE_TAG 75 . 77)))))
+
+ ;; TODO Fix this, produces invalid tokens
+ (phps-mode/with-test-buffer
+ "<?php $wpdb->get_var(\"SELECT post_parent FROM $wpdb->posts WHERE ID =
'\".$id.\"'\"); ?>"
+ (message "Tokens 2: %s" phps-mode/lexer-tokens)
+ (should (equal phps-mode/lexer-tokens
+ '((T_OPEN_TAG 1 . 7) (T_VARIABLE 7 . 12) (T_OBJECT_OPERATOR
12 . 14) (T_STRING 14 . 21) ("(" 21 . 22) ("\"" 22 . 23)
(T_ENCAPSED_AND_WHITESPACE 23 . 47) (T_VARIABLE 47 . 54) (T_OBJECT_OPERATOR 54
. 56) (T_STRING 56 . 59) (T_CONSTANT_ENCAPSED_STRING 59 . 72) ("\"" 72 . 73)
("." 73 . 74) (T_VARIABLE 74 . 77) ("." 77 . 78) (T_CONSTANT_ENCAPSED_STRING 78
. 81) (")" 81 . 82) (";" 82 . 83) (";" 84 . 86) (T_CLOSE_TAG 84 . 86)))))
+
)
(defun phps-mode/test-lexer--namespaces ()
@@ -296,12 +315,10 @@
)
-;; TODO Test this: $wpdb->get_var("SELECT post_parent FROM $wpdb->posts WHERE
ID = '".$id."'");
-
(defun phps-mode/test-lexer ()
"Run test for lexer."
;; (message "-- Running all tests for lexer... --\n")
- (setq debug-on-error t)
+ ;; (setq debug-on-error t)
(phps-mode/test-lexer--script-boundaries)
(phps-mode/test-lexer--simple-tokens)
(phps-mode/test-lexer--complex-tokens)
- [elpa] externals/phps-mode 184dfa5 034/405: Indentation outside PHP now does nothing, (continued)
- [elpa] externals/phps-mode 184dfa5 034/405: Indentation outside PHP now does nothing, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5c0568b 033/405: Added some basic unit tests for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 47440dd 036/405: Added test for decreasing indentation with letters, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9d3f644 032/405: Separated indentation tests for lexer tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d839f8a 029/405: More work on indentation support, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode efcefde 035/405: Added support for closing parenthesis and braces, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1b891ea 031/405: More work on indentation and related tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c6e5255 038/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3837d9c 001/405: My initial commit, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6776468 037/405: Started worked with adding references to tokens from point meta information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode feb5724 039/405: Various debug work,
Stefan Monnier <=
- [elpa] externals/phps-mode e36d477 045/405: token-number from point now is the same format as (nth), Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b437374 040/405: Fixed bug in parsing of object parameters inside double quoted string, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7161184 041/405: Handles stacked states better, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c625217 042/405: Added flag for PSR-2 white-space settings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b629c4b 050/405: Updated comments and TODOs, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 4b4a375 043/405: Using lexical bindings for all files, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c040358 046/405: Point lexer token information makes more sense, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 94492c4 048/405: Added changes tracking to functions from lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode be46d9c 044/405: Added lexer autoload to functions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a259292 047/405: Changed indentation function to work solely on tokens, Stefan Monnier, 2019/07/13