branch: externals/phps-mode commit 3f4c344fbaeb8d031afdc431b71e5f28bd32e38d Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
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 ()