[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 52c502c 139/405: Improved logic for doc-comme
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 52c502c 139/405: Improved logic for doc-comment tracking |
Date: |
Sat, 13 Jul 2019 10:00:00 -0400 (EDT) |
branch: externals/phps-mode
commit 52c502c5ec73c9df0437294b1edf0ac027ea1337
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Improved logic for doc-comment tracking
---
phps-mode-functions.el | 43 ++++++++++++++++++++++++-------------------
phps-mode-test-functions.el | 24 +++++++++++++++++++++---
2 files changed, 45 insertions(+), 22 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 69d413e..f5a6985 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -135,25 +135,30 @@
(equal token 'T_ELSEIF))
(setq after-special-control-structure round-bracket-level))
- ;; Keep track of in scripting
- (when (or (equal token 'T_OPEN_TAG)
- (equal token 'T_OPEN_TAG_WITH_ECHO))
- (setq in-scripting t))
- (when (equal token 'T_CLOSE_TAG)
- (setq in-scripting nil))
-
- ;; Keep track of whether we are inside a doc-comment
- (when (equal token 'T_DOC_COMMENT)
- (setq in-doc-comment token-end))
- (when (and in-doc-comment
- (> token-start in-doc-comment))
- (setq in-doc-comment nil))
-
- ;; Keep track of whether we are inside a HEREDOC or NOWDOC
- (when (equal token 'T_START_HEREDOC)
- (setq in-heredoc t))
- (when (equal token 'T_END_HEREDOC)
- (setq in-heredoc nil))
+ ;; Does token end before current line begins?
+ (when (< token-start line-beginning)
+
+ ;; Keep track of in scripting
+ (when (or (equal token 'T_OPEN_TAG)
+ (equal token 'T_OPEN_TAG_WITH_ECHO))
+ (setq in-scripting t))
+ (when (equal token 'T_CLOSE_TAG)
+ (setq in-scripting nil))
+
+ ;; Keep track of whether we are inside a doc-comment
+ (when (equal token 'T_DOC_COMMENT)
+ (setq in-doc-comment token-end))
+ (when (and in-doc-comment
+ (> token-start in-doc-comment))
+ (setq in-doc-comment nil))
+
+ ;; Keep track of whether we are inside a HEREDOC or NOWDOC
+ (when (equal token 'T_START_HEREDOC)
+ (setq in-heredoc t))
+ (when (equal token 'T_END_HEREDOC)
+ (setq in-heredoc nil))
+
+ )
;; Are we on a new line?
(when (> token-line-number last-line-number)
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index e5b89b1..7a91214 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -37,26 +37,44 @@
(defun phps-mode-test-functions-get-current-line-indent ()
"Test `phps-mode-functions-get-current-line-indent' function."
+ ;; Mixed HTML/PHP
+
(phps-mode-test-with-buffer
- "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition)
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
+ "<html><head><title><?php\nif ($myCondition) {\nif ($mySeconCondition)
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
+ (goto-char 15)
+ (should (equal nil (phps-mode-functions-get-current-line-indent))))
+
+ (phps-mode-test-with-buffer
+ "<html><head><title><?php\nif ($myCondition) {\nif ($mySeconCondition)
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
(goto-char 69)
(should (equal '(1 0) (phps-mode-functions-get-current-line-indent))))
(phps-mode-test-with-buffer
- "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition)
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
+ "<html><head><title><?php\nif ($myCondition) {\nif ($mySeconCondition)
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
(goto-char 40)
(should (equal '(0 0) (phps-mode-functions-get-current-line-indent))))
(phps-mode-test-with-buffer
- "<html><head><title><?php if ($myCondition) {\nif ($mySeconCondition)
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
+ "<html><head><title><?php\nif ($myCondition) {\nif ($mySeconCondition)
{\necho $title;\n\n} ?></title><body>Bla bla</body></html>"
(goto-char 75)
(should (equal '(2 0) (phps-mode-functions-get-current-line-indent))))
+ ;; DOC-COMMENT
+
(phps-mode-test-with-buffer
"<?php\n/**\n* Bla\n*/"
(goto-char 13)
(should (equal '(0 1) (phps-mode-functions-get-current-line-indent))))
+ (phps-mode-test-with-buffer
+ "<?php\n/**\n* Bla\n*/"
+ (goto-char 8)
+ (should (equal '(0 0) (phps-mode-functions-get-current-line-indent))))
+
+ (phps-mode-test-with-buffer
+ "<?php\n/**\n* Bla\n*/"
+ (goto-char 17)
+ (should (equal '(0 1) (phps-mode-functions-get-current-line-indent))))
)
- [elpa] externals/phps-mode 7279913 113/405: Improved TODOs, (continued)
- [elpa] externals/phps-mode 7279913 113/405: Improved TODOs, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a8eadfa 130/405: Improved sample files inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9996ae0 146/405: More work on indentation calculation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3776841 138/405: Added new support for tracking doc-comment, HEREDOC and NOWDOC indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 780d065 125/405: Code styling updates, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 314dba1 135/405: Improved articulation of what information get-current-line-data should return, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f0523b7 137/405: More work on new function to calculate indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 16d8056 144/405: Foundation for new indentation tests completed, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d380cd4 129/405: Updated readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3f08b86 128/405: Updated tracking of alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 52c502c 139/405: Improved logic for doc-comment tracking,
Stefan Monnier <=
- [elpa] externals/phps-mode 1472273 136/405: Begun working on new approach to indentation calculation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9792f70 133/405: Cleaning up code gather point meta information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode cc947a9 140/405: Added more tests for new indentation function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d3e00f2 141/405: Starting on new function for indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c68c7a0 131/405: Fixed issue were first-token-on-line was nil, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c4ee0c3 132/405: Added more failing tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 0b3ced4 145/405: First test for new indentation function passes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 96588b5 142/405: More work on new indentation calculation functions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9d6af11 157/405: More work on indentations, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e249124 152/405: Prevent negative indent, Stefan Monnier, 2019/07/13