[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 6776468 037/405: Started worked with adding r
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 6776468 037/405: Started worked with adding references to tokens from point meta information |
Date: |
Sat, 13 Jul 2019 09:59:35 -0400 (EDT) |
branch: externals/phps-mode
commit 6776468629623218fd69c4df6b285b6e6bf6ba2a
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Started worked with adding references to tokens from point meta information
---
phps-functions.el | 3 ++-
phps-lexer.el | 15 ++++++++++++---
phps-test-functions.el | 9 ++++++++-
phps-test-lexer.el | 18 ++++++++++--------
4 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/phps-functions.el b/phps-functions.el
index 1d26588..cc2bc7a 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -50,7 +50,8 @@
(let* ((indent-start (* (+ (nth 1 start) (nth 2 start)) 4))
(indent-end (* (+ (nth 1 end) (nth 2 end)) 4))
(indent-diff 0))
- (when (> indent-start indent-end)
+ (when (and (> indent-start indent-end)
+ (looking-at-p "^[][ \t)(}{};]+\\($\\|?>\\)"))
(setq indent-diff (- indent-start indent-end)))
(setq indent-level (- indent-start indent-diff))
(message "inside scripting, start: %s, end: %s, indenting to
column %s " start end indent-level)
diff --git a/phps-lexer.el b/phps-lexer.el
index da663ec..8c545d4 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -47,6 +47,9 @@
(defvar phps-mode/lexer-tokens nil
"Last lexer tokens.")
+(defvar phps-mode/buffer-changes--start nil
+ "Start of buffer changes, nil if none.")
+
;; SETTINGS
@@ -1268,10 +1271,12 @@ ANY_CHAR'
(start-brace-level 0)
(start-parenthesis-level 0)
(start-inline-function-level 0)
+ (start-token-number 0)
(end-in-scripting nil)
(end-brace-level 0)
(end-parenthesis-level 0)
- (end-inline-function-level 0))
+ (end-inline-function-level 0)
+ (end-token-number 0))
(catch 'stop-iteration
(dolist (item phps-mode/lexer-tokens)
(let ((token (car item))
@@ -1285,6 +1290,7 @@ ANY_CHAR'
;; When start of token is equal or less to current point
(when (< start position)
+ (setq start-token-number (+ start-token-number 1))
(pcase token
('T_OPEN_TAG (setq start-in-scripting t))
('T_OPEN_TAG_WITH_ECHO (setq start-in-scripting t))
@@ -1297,6 +1303,7 @@ ANY_CHAR'
;; When start of token is equal or less to end of curent line
(when (< start line-end)
+ (setq end-token-number (+ end-token-number 1))
(pcase token
('T_OPEN_TAG (setq end-in-scripting t))
('T_OPEN_TAG_WITH_ECHO (setq end-in-scripting t))
@@ -1308,7 +1315,7 @@ ANY_CHAR'
(_)))
)))
- (let ((data (list (list start-in-scripting start-brace-level
start-parenthesis-level start-inline-function-level) (list end-in-scripting
end-brace-level end-parenthesis-level end-inline-function-level))))
+ (let ((data (list (list start-in-scripting start-brace-level
start-parenthesis-level start-inline-function-level start-token-number) (list
end-in-scripting end-brace-level end-parenthesis-level
end-inline-function-level end-token-number))))
;; (message "data: %s" data)
data)
)))
@@ -1317,6 +1324,7 @@ ANY_CHAR'
"Just prepare other lexers for lexing region START to END."
(when (eq start 1)
;; (message "SETUP %s %s" start end)
+ (setq phps-mode/buffer-changes--start nil)
(phps-mode/BEGIN phps-mode/ST_INITIAL)))
;; TODO This function should track between what min and max region a specific
buffer has been modified and then re-run lexer for that region when editor is
idle, maybe use (buffer-name))
@@ -1324,7 +1332,8 @@ ANY_CHAR'
(defun phps-mode/after-change-functions (start stop length)
"Track buffer change from START to STOP with length LENGTH."
(when (string= major-mode "phps-mode")
- ;; (message "phps-mode/after-change-functions %s %s %s" start stop length)
+ (setq phps-mode/buffer-changes--start start)
+ (message "phps-mode/after-change-functions %s %s %s" start stop length)
))
(defun phps-mode/lex--RUN ()
diff --git a/phps-test-functions.el b/phps-test-functions.el
index f5f637f..3f6543e 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -81,13 +81,20 @@
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
(should (equal buffer-contents "<?php\n$variable = array(\n
'random'\n);\n$variable = true;\n"))))
-(phps-mode/with-test-buffer
+ (phps-mode/with-test-buffer
"<?php\n$variable = array(\n 'random'\n );\n$variable = true;\n"
(goto-char 39)
(phps-mode/indent-line)
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
(should (equal buffer-contents "<?php\n$variable = array(\n
'random'\n);\n$variable = true;\n"))))
+ (phps-mode/with-test-buffer
+ "<?php\n$variable = array(\n'random');\n$variable = true;\n"
+ (goto-char 29)
+ (phps-mode/indent-line)
+ (let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
+ (should (equal buffer-contents "<?php\n$variable = array(\n
'random');\n$variable = true;\n"))))
+
)
(defun phps-mod/test-functions ()
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 997b96b..eb1af34 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -255,47 +255,49 @@
(phps-mode/with-test-buffer
"<?php\nNAMESPACE MyNameSpace;\nCLASS MyClass {\n\tpublic function
__construct() {\n\t\texit;\n\t}\n}\n"
(goto-char 35)
- (should (equal (list (list t 0 0 0) (list t 1 0 0))
(phps-mode/lexer-get-point-data))))
+ (should (equal (list (list t 0 0 0 4) (list t 1 0 0 7))
(phps-mode/lexer-get-point-data))))
(phps-mode/with-test-buffer
"<html><head><title><?php echo $title; ?></title><body>Bla
bla</body></html>"
(goto-char 15)
- (should (equal (list (list nil 0 0 0) (list nil 0 0 0))
(phps-mode/lexer-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0) (list nil 0 0 0 6))
(phps-mode/lexer-get-point-data))))
(phps-mode/with-test-buffer
"<html><head><title><?php echo $title; ?></title><body>Bla
bla</body></html>"
(goto-char 30)
- (should (equal (list (list nil 0 0 0) (list nil 0 0 0))
(phps-mode/lexer-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0) (list nil 0 0 0 6))
(phps-mode/lexer-get-point-data))))
(phps-mode/with-test-buffer
"<html><head><title><?php echo $title; ?></title><body>Bla
bla</body></html>"
(goto-char 50)
- (should (equal (list (list nil 0 0 0) (list nil 0 0 0))
(phps-mode/lexer-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0) (list nil 0 0 0 6))
(phps-mode/lexer-get-point-data))))
(phps-mode/with-test-buffer
"<html><head><title><?php if ($myCondition) { \n if ($mySeconCondition) {
echo $title; } } ?></title><body>Bla bla</body></html>"
;; (message "Tokens: %s" phps-mode/lexer-tokens)
(goto-char 48)
- (should (equal (list (list t 1 0 0) (list nil 0 0 0))
(phps-mode/lexer-get-point-data))))
+ (should (equal (list (list t 1 0 0 6) (list nil 0 0 0 18))
(phps-mode/lexer-get-point-data))))
(phps-mode/with-test-buffer
"<html><head><title><?php if ($myCondition) { if ($mySeconCondition) {\n
echo $title;\n} } ?></title><body>Bla bla</body></html>"
(goto-char 72)
- (should (equal (list (list t 2 0 0) (list t 2 0 0))
(phps-mode/lexer-get-point-data))))
+ (should (equal (list (list t 2 0 0 11) (list t 2 0 0 14))
(phps-mode/lexer-get-point-data))))
(phps-mode/with-test-buffer
"<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition)
{\necho $title;\n}\n}\n ?></title><body>Bla bla</body></html>"
(goto-char 84)
- (should (equal (list (list t 2 0 0) (list t 1 0 0))
(phps-mode/lexer-get-point-data))))
+ (should (equal (list (list t 2 0 0 14) (list t 1 0 0 15))
(phps-mode/lexer-get-point-data))))
(phps-mode/with-test-buffer
"<html><head><title><?php if ($myCondition) { if ($mySeconCondition) { echo
$title; } } ?></title><body>Bla bla</body></html>"
(goto-char 100)
- (should (equal (list (list nil 0 0 0) (list nil 0 0 0))
(phps-mode/lexer-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0) (list nil 0 0 0 18))
(phps-mode/lexer-get-point-data))))
)
+;; 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")
- [elpa] externals/phps-mode 4fa9341 030/405: Started with unit tests for indentation, (continued)
- [elpa] externals/phps-mode 4fa9341 030/405: Started with unit tests for indentation, Stefan Monnier, 2019/07/13
- [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 <=
- [elpa] externals/phps-mode feb5724 039/405: Various debug work, Stefan Monnier, 2019/07/13
- [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