[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 80da137 114/405: Preparations for adding alte
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 80da137 114/405: Preparations for adding alternative and inline syntax |
Date: |
Sat, 13 Jul 2019 09:59:55 -0400 (EDT) |
branch: externals/phps-mode
commit 80da137f7a2bb47046b5c6fc8f636d0c145431a7
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Preparations for adding alternative and inline syntax
---
phps-mode-functions.el | 32 +++++++++++++++++++-------------
phps-mode-test-functions.el | 32 ++++++++++++++++----------------
2 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 788781c..2a450dd 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -50,16 +50,18 @@
(let ((start-curly-bracket-level (nth 1 start))
(start-round-bracket-level (nth 2 start))
(start-square-bracket-level (nth 3 start))
- (_start-inline-function-level (nth 4 start))
- (start-token-number (nth 5 start))
+ (start-inline-control-structure-level (nth 4 start))
+ (start-alternative-control-structure-level (nth 5 start))
+ (start-token-number (nth 6 start))
(end-curly-bracket-level (nth 1 end))
(end-round-bracket-level (nth 2 end))
(end-square-bracket-level (nth 3 end))
- (_end-inline-function-level (nth 4 end))
- (end-token-number (nth 5 end))
- (in-doc-comment (nth 6 start)))
- (let* ((indent-start (+ start-curly-bracket-level
start-round-bracket-level start-square-bracket-level))
- (indent-end (+ end-curly-bracket-level
end-round-bracket-level end-square-bracket-level))
+ (end-inline-control-structure-level (nth 4 end))
+ (end-alternative-control-structure-level (nth 5 end))
+ (end-token-number (nth 6 end))
+ (in-doc-comment (nth 7 start)))
+ (let* ((indent-start (+ start-curly-bracket-level
start-round-bracket-level start-square-bracket-level
start-inline-control-structure-level start-alternative-control-structure-level))
+ (indent-end (+ end-curly-bracket-level
end-round-bracket-level end-square-bracket-level
end-inline-control-structure-level end-alternative-control-structure-level))
(indent-level indent-start)
(indent-adjust 0))
;; (message "indent-start %s, indent-end %s" indent-start
indent-end)
@@ -194,7 +196,8 @@
;; (message "phps-mode-functions-after-change %s %s %s" start stop length)
))
-;; TODO This function needs to keep track of alternative syntax for control
structures
+;; TODO This function needs to keep track of alternative syntax for the
control structures: if, while, for, foreach, and switch
+;; TODO This function needs to keep track of inline syntax for the control
structures: if, while, for, foreach, and switch
(defun phps-mode-functions-get-point-data ()
"Return information about point in tokens."
@@ -208,16 +211,19 @@
(start-curly-bracket-level 0)
(start-round-bracket-level 0)
(start-square-bracket-level 0)
- (start-inline-function-level 0)
+ (start-inline-control-structure-level 0)
+ (start-alternative-control-structure-level 0)
(start-token-number nil)
(end-in-scripting nil)
(end-curly-bracket-level 0)
(end-round-bracket-level 0)
(end-square-bracket-level 0)
- (end-inline-function-level 0)
+ (end-inline-control-structure-level 0)
+ (end-alternative-control-structure-level 0)
(end-token-number nil)
(line-in-doc-comment nil)
- (found-line-tokens nil))
+ (found-line-tokens nil)
+ (_after-special-control-structure nil))
(catch 'stop-iteration
(dolist (item phps-mode-lexer-tokens)
(let ((token (car item))
@@ -236,7 +242,7 @@
(<= token-end line-end))
(setq found-line-tokens t))
- ;; When end of token is equal or less to current point
+ ;; When end of token is equal or less to beginning of current
line
(when (<= token-end line-beginning)
(when (null start-token-number)
(setq start-token-number -1))
@@ -284,7 +290,7 @@
(when (not found-line-tokens)
(setq start-token-number nil)
(setq end-token-number nil))
- (let ((data (list (list start-in-scripting start-curly-bracket-level
start-round-bracket-level start-square-bracket-level
start-inline-function-level start-token-number line-in-doc-comment) (list
end-in-scripting end-curly-bracket-level end-round-bracket-level
end-square-bracket-level end-inline-function-level end-token-number
line-in-doc-comment))))
+ (let ((data (list (list start-in-scripting start-curly-bracket-level
start-round-bracket-level start-square-bracket-level
start-inline-control-structure-level start-alternative-control-structure-level
start-token-number line-in-doc-comment) (list end-in-scripting
end-curly-bracket-level end-round-bracket-level end-square-bracket-level
end-inline-control-structure-level end-alternative-control-structure-level
end-token-number line-in-doc-comment))))
;; (message "data: %s" data)
data)))))
diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el
index 51e8b57..19f95a8 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -256,82 +256,82 @@
(phps-mode-test-with-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 0 3 nil) (list t 1 0 0 0 6 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 0 0 0 0 3 nil) (list t 1 0 0 0 0 6 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<html><head><title><?php echo $title; ?></title><body>Bla
bla</body></html>"
(goto-char 15)
- (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 5 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0 0 nil nil) (list nil 0 0 0 0 0 5
nil)) (phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<html><head><title><?php echo $title; ?>\n</title><body>Bla
bla</body></html>"
(goto-char 50)
- (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 nil nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0 0 nil nil) (list nil 0 0 0 0 0 nil
nil)) (phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<html><head><title></title><body>Bla bla</body></html>"
(goto-char 15)
- (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 nil nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0 0 nil nil) (list nil 0 0 0 0 0 nil
nil)) (phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<html><head><title><?php echo $title; ?></title><body>Bla
bla</body></html>"
(goto-char 30)
- (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 5 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0 0 nil nil) (list nil 0 0 0 0 0 5
nil)) (phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<html><head><title><?php echo $title; ?></title><body>Bla
bla</body></html>"
(goto-char 50)
- (should (equal (list (list nil 0 0 0 0 nil nil) (list nil 0 0 0 0 5 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0 0 nil nil) (list nil 0 0 0 0 0 5
nil)) (phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<html><head><title><?php if ($myCondition) { \n if ($mySeconCondition) {
echo $title; } } ?></title><body>Bla bla</body></html>"
(goto-char 48)
- (should (equal (list (list t 1 0 0 0 5 nil) (list nil 0 0 0 0 17 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 1 0 0 0 0 5 nil) (list nil 0 0 0 0 0 17 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-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 0 10 nil) (list t 2 0 0 0 13 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 2 0 0 0 0 10 nil) (list t 2 0 0 0 0 13 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-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 0 13 nil) (list t 1 0 0 0 14 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 2 0 0 0 0 13 nil) (list t 1 0 0 0 0 14 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-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 0 nil nil) (list nil 0 0 0 0 17 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0 0 nil nil) (list nil 0 0 0 0 0 17
nil)) (phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<?php /**\n * My first line\n * My second line\n **/"
(goto-char 20)
- (should (equal (list (list t 0 0 0 0 nil t) (list t 0 0 0 0 nil t))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 0 0 0 0 nil t) (list t 0 0 0 0 0 nil t))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<?php /**\n * My first line\n * My second line\n **/"
(goto-char 9)
- (should (equal (list (list nil 0 0 0 0 nil nil) (list t 0 0 0 0 1 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list nil 0 0 0 0 0 nil nil) (list t 0 0 0 0 0 1 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<?php /**\n * My first line\n * My second line\n **/"
(goto-char 50)
- (should (equal (list (list t 0 0 0 0 nil t) (list t 0 0 0 0 nil t))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 0 0 0 0 nil t) (list t 0 0 0 0 0 nil t))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<?php\n$variable = array(\n'random4');\n$variable = true;\n"
(goto-char 29)
- (should (equal (list (list t 0 1 0 0 4 nil) (list t 0 0 0 0 7 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 1 0 0 0 4 nil) (list t 0 0 0 0 0 7 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<?php\nif (empty(\n$this->var\n) && !empty($this->var)\n) {\n$this->var =
'abc123';\n}\n"
(goto-char 54)
- (should (equal (list (list t 0 1 0 0 16 nil) (list t 1 0 0 0 18 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 1 0 0 0 16 nil) (list t 1 0 0 0 0 18 nil))
(phps-mode-functions-get-point-data))))
(phps-mode-test-with-buffer
"<?php\n$var = [\n 'random' => [\n 'hello',\n ],\n];\n"
(goto-char 46)
- (should (equal (list (list t 0 0 2 0 6 nil) (list t 0 0 2 0 8 nil))
(phps-mode-functions-get-point-data))))
+ (should (equal (list (list t 0 0 2 0 0 6 nil) (list t 0 0 2 0 0 8 nil))
(phps-mode-functions-get-point-data))))
)
- [elpa] externals/phps-mode 529042e 109/405: More work on renaming, (continued)
- [elpa] externals/phps-mode 529042e 109/405: More work on renaming, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7688cd7 111/405: Got incremental lexer working after renaming again, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9c4a3ba 117/405: More work on alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3272991 110/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7c6ee3e 107/405: More work on renaming, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 46a8256 116/405: Starting implementation of tracking alternative control structure level, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9ac21f1 120/405: More work on inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 41ef691 112/405: Fixed lint warning of unused variables, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 12c22ee 119/405: More work on alternative and inline meta information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7e2e902 126/405: Fixed a unit test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 80da137 114/405: Preparations for adding alternative and inline syntax,
Stefan Monnier <=
- [elpa] externals/phps-mode baab77a 121/405: Unit tests for inline control structures working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f0dc652 143/405: More work on new indentation function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7dca537 105/405: Started work on renaming files, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e11a1fc 123/405: Fine-tuning of logic collecting data about inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e206605 115/405: Adding failing unit tests for inline and alternative syntax, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c6aa633 118/405: More work on keeping track of alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 60c7431 122/405: Unit tests for gather data about inline and alternative control structure syntax passes, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 897f249 124/405: Work on alternative and inline indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode be35ed6 127/405: Added sample files for inline and alternative control structures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7279913 113/405: Improved TODOs, Stefan Monnier, 2019/07/13