[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 3f4c344 056/405: Fixed detection of doc comme
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 3f4c344 056/405: Fixed detection of doc comment blocks |
Date: |
Sat, 13 Jul 2019 09:59:42 -0400 (EDT) |
branch: externals/phps-mode
commit 3f4c344fbaeb8d031afdc431b71e5f28bd32e38d
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Fixed detection of doc comment blocks
---
phps-lexer.el | 26 ++++++++++++--------------
phps-test-functions.el | 3 ++-
phps-test-lexer.el | 5 +++++
3 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/phps-lexer.el b/phps-lexer.el
index bb4c98f..3662d5e 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1271,41 +1271,39 @@ ANY_CHAR'
(start-parenthesis-level 0)
(start-inline-function-level 0)
(start-token-number nil)
- (start-in-doc-comment nil)
(end-in-scripting nil)
(end-brace-level 0)
(end-parenthesis-level 0)
(end-inline-function-level 0)
(end-token-number nil)
- (end-in-doc-comment nil)
+ (line-in-doc-comment nil)
(found-line-tokens nil))
(catch 'stop-iteration
(dolist (item phps-mode/lexer-tokens)
(let ((token (car item))
- (start (car (cdr item)))
- (end (cdr (cdr item))))
+ (token-start (car (cdr item)))
+ (token-end (cdr (cdr item))))
;; (message "Token: %s Start: %s End: %s Item: %s" token start end
item)
- (when (> start line-end)
+ (when (> token-start line-end)
;; (message "Stopping iteration at: %s %s" start position)
(throw 'stop-iteration nil))
(when (and (not found-line-tokens)
- (>= start position)
- (<= end line-end))
+ (>= token-start position)
+ (<= token-end line-end))
(setq found-line-tokens t))
;; When end of token is equal or less to current point
- (when (<= end position)
+ (when (<= token-end position)
(when (null start-token-number)
(setq start-token-number -1))
(setq start-token-number (+ start-token-number 1))
- (setq start-in-doc-comment nil)
(pcase token
('T_OPEN_TAG (setq start-in-scripting t))
('T_OPEN_TAG_WITH_ECHO (setq start-in-scripting t))
('T_CLOSE_TAG (setq start-in-scripting nil))
- ('T_DOC_COMMENT (setq start-in-doc-comment t))
+ ('T_DOC_COMMENT (setq start-in-doc-comment nil))
("}" (setq start-brace-level (- start-brace-level 1)))
("{" (setq start-brace-level (+ start-brace-level 1)))
("(" (setq start-parenthesis-level (+ start-parenthesis-level
1)))
@@ -1313,16 +1311,16 @@ ANY_CHAR'
(_)))
;; When start of token is equal or less to end of curent line
- (when (<= start line-end)
+ (when (<= token-start line-end)
(when (null end-token-number)
(setq end-token-number -1))
(setq end-token-number (+ end-token-number 1))
- (setq end-in-doc-comment nil)
+ (setq line-in-doc-comment nil)
(pcase token
('T_OPEN_TAG (setq end-in-scripting t))
('T_OPEN_TAG_WITH_ECHO (setq end-in-scripting t))
('T_CLOSE_TAG (setq end-in-scripting nil))
- ('T_DOC_COMMENT (setq end-in-doc-comment t))
+ ('T_DOC_COMMENT (setq line-in-doc-comment t))
("}" (setq end-brace-level (- end-brace-level 1)))
("{" (setq end-brace-level (+ end-brace-level 1)))
("(" (setq end-parenthesis-level (+ end-parenthesis-level 1)))
@@ -1333,7 +1331,7 @@ ANY_CHAR'
(when (not found-line-tokens)
(setq start-token-number nil)
(setq end-token-number nil))
- (let ((data (list (list start-in-scripting start-brace-level
start-parenthesis-level start-inline-function-level start-token-number
start-in-doc-comment) (list end-in-scripting end-brace-level
end-parenthesis-level end-inline-function-level end-token-number
end-in-doc-comment))))
+ (let ((data (list (list start-in-scripting start-brace-level
start-parenthesis-level start-inline-function-level start-token-number
line-in-doc-comment) (list end-in-scripting end-brace-level
end-parenthesis-level end-inline-function-level end-token-number
line-in-doc-comment))))
;; (message "data: %s" data)
data))))
diff --git a/phps-test-functions.el b/phps-test-functions.el
index c0cfd23..ae9d11d 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -38,6 +38,7 @@
(autoload 'phps-mode/with-test-buffer "phps-test")
+(autoload 'phps-mode/indent-line "phps-functions")
(autoload 'should "ert")
(defun phps-mode/test-indent-line ()
@@ -93,7 +94,7 @@
"<?php\n/**\n* My first line\n* My second line\n**/\n"
(goto-char 20)
(phps-mode/indent-line)
- (message "Tokens %s point %s" phps-mode/lexer-tokens (point))
+ ;; (message "Tokens %s point %s" phps-mode/lexer-tokens (point))
(let ((buffer-contents (buffer-substring-no-properties (point-min)
(point-max))))
(should (equal buffer-contents "<?php\n/**\n * My first line\n* My
second line\n**/\n"))))
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index 1bafd80..e359037 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -327,6 +327,11 @@
(goto-char 20)
(should (equal (list (list t 0 0 0 nil t) (list t 0 0 0 nil t))
(phps-mode/lexer-get-point-data))))
+ (phps-mode/with-test-buffer
+ "<?php /**\n * My first line\n * My second line\n **/"
+ (goto-char 10)
+ (should (equal (list (list nil 0 0 0 nil t) (list t 0 0 0 1 t))
(phps-mode/lexer-get-point-data))))
+
)
(defun phps-mode/test-lexer ()
- [elpa] externals/phps-mode 94492c4 048/405: Added changes tracking to functions from lexer, (continued)
- [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
- [elpa] externals/phps-mode 4098f46 049/405: Started with incremental lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode da1d1de 051/405: Temporary lexer after change until other work is ready, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 990d3dd 054/405: Added test for indentation of multiple-line doc comment, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode dd80d27 055/405: Started work on detecting doc comment blocks, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e1b7160 053/405: (newline-and-indent) now working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8aa1ab6 059/405: Another test for getting point data inside doc block, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 09daec3 052/405: Foundation for incremental lexer and syntax colorer completed, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3f4c344 056/405: Fixed detection of doc comment blocks,
Stefan Monnier <=
- [elpa] externals/phps-mode 3824abf 060/405: Resolved indent with trailing parenthesis, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a61cb8b 062/405: Fixed issue with doc comment indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6c597fb 065/405: Updated readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 0ca9fe8 058/405: Detection of point inside doc comment block improved, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 67f9a7a 057/405: Moved lexer-get-point-data to functions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 27cd705 069/405: Updated readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 58300fd 070/405: More updates of readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 86ec35f 066/405: Incremental lexer working somewhat, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ec71e15 074/405: Fixed bug where token-numbers are not defined, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 236f05e 071/405: Updated makefile to not use hard-coded path to emacs, Stefan Monnier, 2019/07/13