[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode e7aff3f69d 157/212: Passed more indentation t
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode e7aff3f69d 157/212: Passed more indentation tests |
Date: |
Wed, 26 Jan 2022 01:51:19 -0500 (EST) |
branch: externals/phps-mode
commit e7aff3f69dc7756b818b7a1fff8e4dc5d6529bb9
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Passed more indentation tests
---
phps-mode-indent.el | 499 ++++++++++++++++++++++++++++------------------------
1 file changed, 267 insertions(+), 232 deletions(-)
diff --git a/phps-mode-indent.el b/phps-mode-indent.el
index c08a5d9386..f501591519 100644
--- a/phps-mode-indent.el
+++ b/phps-mode-indent.el
@@ -313,76 +313,6 @@
new-indentation
(- new-indentation tab-width)))
- ;; function myFunction($key,
- ;; $value)
- ;; {
- ((and
- current-line-starts-with-opening-bracket
- (string= current-line-starts-with-opening-bracket "{")
- previous-line-ends-with-closing-bracket)
- ;; Backtrack to line were bracket started
- ;; and use indentation from that line for this line
- (forward-line (* -1 move-length1))
- (end-of-line)
- (let ((not-found t)
- (reference-line)
- (reference-indentation)
- (parenthesis-level 0))
- (while
- (and
- not-found
- (search-backward-regexp
- "[][(){}]"
- nil
- t))
- (let ((match (match-string-no-properties 0)))
- (cond
-
- ((or
- (string= "(" match)
- (string= "[" match)
- (string= "{" match))
- (setq
- parenthesis-level
- (1+ parenthesis-level))
- (when (= parenthesis-level 0)
- (setq
- not-found
- nil)))
-
- ((or
- (string= ")" match)
- (string= "]" match)
- (string= "}" match))
- (setq
- parenthesis-level
- (1- parenthesis-level))
- (when (= parenthesis-level 0)
- (setq
- not-found
- nil)))
-
- )))
- (unless not-found
- (setq
- reference-line
- (buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)))
- (setq
- reference-indentation
- (phps-mode-indent--string-indentation
- reference-line)))
-
- (goto-char point)
-
- (when reference-indentation
- (setq
- new-indentation
- reference-indentation)))
-
- )
-
;; if (true)
;; echo 'Something';
;; or
@@ -409,68 +339,6 @@
(setq new-indentation
(+ new-indentation tab-width)))
- ;; echo <<<VAR
- ;; abc
- ;; or
- ;; echo <<<'VAR'
- ;; abc
- ;; or
- ;; echo <<<"VAR"
- ;; abc
- ((string-match-p
- "<<<'?\"?[a-zA-Z0-9_]+'?\"?$"
- previous-line-string)
- (setq
- new-indentation
- 0))
-
- ;; $var = 'A line' .
- ;; 'something';
- ;; or
- ;; $var .= 'A line' .
- ;; 'something'
- ;; or
- ;; $var += 35 +
- ;; 77
- ;; but ignore
- ;; $var === true
- ;; or
- ;; $var == 3
- ;; or
- ;; $argument1 = 3,
- ;; $argument2 = 4
- ;; or
- ;; function myFunction(
- ;; $abc = 3
- ;; ) {
- ;; or
- ;; $abc != 3
- ((and
- (string-match-p
- "^[\t ]*$[a-zA-Z0-9_]+[\t ]*[^=!]*=\\($\\|[\t ]+.*[^,;]$\\)"
- previous-line-string)
- (not
- current-line-starts-with-closing-bracket))
- (setq
- new-indentation
- (+ new-indentation tab-width)))
-
- ;; echo 'Something' .
- ;; 'something';
- ;; but ignore
- ;; print_r($object)
- ((and
- (string-match-p
- "^[\t ]*\\(echo\\|print$\\|print[\t ]+\\|return\\|die\\)"
- previous-line-string)
- (not
- (string-match-p
- ";[\t ]*$"
- previous-line-string)))
- (setq
- new-indentation
- (+ new-indentation tab-width)))
-
;; else
;; echo 'Something';
;; or
@@ -576,6 +444,273 @@
new-indentation
tab-width)))
+ ;; $myObject->myFunction()
+ ;; ->myFunction2()
+ ;; but ignore
+ ;; $myObject->test(
+ ;; 'here'
+ ((and
+ (not previous-line-ends-with-opening-bracket)
+ (string-match-p
+ "->"
+ previous-line-string)
+ (string-match-p
+ "^[\t ]*->"
+ current-line-string))
+ (let ((not-found t)
+ (started-chaining-on-this-line t)
+ (is-assignment)
+ (is-string-concatenation)
+ (is-bracket-less-command)
+ (is-same-line-p t))
+ (while
+ (and
+ not-found
+ (search-backward-regexp
+ "\\(;\\|{\\|(\\|)\\|=\\|->\\|echo[\t ]+\\|print[\t
]+\\|\n\\|^[\t ]*\\.\\|\\.[\t ]*$\\)"
+ nil
+ t))
+ (let ((match (match-string-no-properties 0)))
+ (cond
+
+ ((string=
+ "->"
+ match)
+ (setq
+ started-chaining-on-this-line
+ is-same-line-p))
+
+ ((string=
+ "\n"
+ match)
+ (setq
+ is-same-line-p
+ nil))
+
+ ((or
+ (string=
+ "echo"
+ match)
+ (string=
+ "print"
+ match))
+ (setq
+ is-bracket-less-command
+ t)
+ (setq
+ not-found
+ nil))
+
+ ((or
+ (string=
+ ";"
+ match)
+ (string=
+ "}"
+ match))
+ (setq
+ not-found
+ nil))
+
+ ((string=
+ "="
+ match)
+ (setq
+ is-assignment
+ t)
+ (setq
+ not-found
+ nil))
+
+ ((string-match-p
+ "\\(^[\t ]*\\.\\|\\.[\t ]*\\)$"
+ match)
+ (setq
+ is-string-concatenation
+ t)
+ (setq
+ not-found
+ nil))
+
+ )))
+
+ (when (and
+ (not is-assignment)
+ (not is-string-concatenation)
+ (not started-chaining-on-this-line)
+ (not is-bracket-less-command))
+ (setq
+ new-indentation
+ (+ new-indentation tab-width))))
+ (goto-char point))
+
+ ;; function myFunction($key,
+ ;; $value)
+ ;; {
+ ;; or
+ ;; (is_array($data)
+ ;; && !empty($data['index'])
+ ;; && (is_a($data['index'], 'Index')
+ ;; || is_a($data['Index'], 'Index2')))
+ ;; || is_a($data, 'WC_Index')
+ (previous-line-ends-with-closing-bracket
+
+ ;; Backtrack to line were bracket started
+ ;; and use indentation from that line for this line
+ (forward-line (* -1 move-length1))
+ (end-of-line)
+ (let ((not-found t)
+ (reference-line)
+ (reference-line2)
+ (reference-indentation)
+ (parenthesis-level 0))
+ (while
+ (and
+ not-found
+ (search-backward-regexp
+ "[][(){}]"
+ nil
+ t))
+ (let ((match (match-string-no-properties 0)))
+ (cond
+
+ ((or
+ (string= "(" match)
+ (string= "[" match)
+ (string= "{" match))
+ (setq
+ parenthesis-level
+ (1+ parenthesis-level))
+ (when (= parenthesis-level 0)
+ (setq
+ not-found
+ nil)))
+
+ ((or
+ (string= ")" match)
+ (string= "]" match)
+ (string= "}" match))
+ (setq
+ parenthesis-level
+ (1- parenthesis-level))
+ (when (= parenthesis-level 0)
+ (setq
+ not-found
+ nil)))
+
+ )))
+ (unless not-found
+ (setq
+ reference-line
+ (buffer-substring-no-properties
+ (line-beginning-position)
+ (line-end-position)))
+ (setq
+ reference-line2
+ (buffer-substring-no-properties
+ (point)
+ (line-end-position)))
+ (setq
+ reference-indentation
+ (phps-mode-indent--string-indentation
+ reference-line))
+ (setq
+ new-indentation
+ reference-indentation)
+ (let ((reference-bracket-level
+ (phps-mode-indent--get-string-brackets-count
+ reference-line))
+ (reference-bracket-level2
+ (phps-mode-indent--get-string-brackets-count
+ reference-line2)))
+ ;; if (
+ ;; (is_array($data)
+ ;; && !empty($data['index'])
+ ;; && (is_a($data['index'], 'Index')
+ ;; || is_a($data['Index'], 'Index2')))
+ ;; || is_a($data, 'WC_Index')
+ ;; (message "reference-bracket-level: %S"
reference-bracket-level)
+ ;; (message "reference-bracket-level2: %S"
reference-bracket-level2)
+ (when (and
+ (> reference-bracket-level 0)
+ (> reference-bracket-level
reference-bracket-level2))
+ (setq
+ new-indentation
+ (+ new-indentation tab-width))))
+
+ (when current-line-starts-with-closing-bracket
+ (setq
+ new-indentation
+ (- new-indentation tab-width)))
+
+ )
+
+ (goto-char point))
+
+ )
+
+ ;; echo <<<VAR
+ ;; abc
+ ;; or
+ ;; echo <<<'VAR'
+ ;; abc
+ ;; or
+ ;; echo <<<"VAR"
+ ;; abc
+ ((string-match-p
+ "<<<'?\"?[a-zA-Z0-9_]+'?\"?$"
+ previous-line-string)
+ (setq
+ new-indentation
+ 0))
+
+ ;; $var = 'A line' .
+ ;; 'something';
+ ;; or
+ ;; $var .= 'A line' .
+ ;; 'something'
+ ;; or
+ ;; $var += 35 +
+ ;; 77
+ ;; but ignore
+ ;; $var === true
+ ;; or
+ ;; $var == 3
+ ;; or
+ ;; $argument1 = 3,
+ ;; $argument2 = 4
+ ;; or
+ ;; function myFunction(
+ ;; $abc = 3
+ ;; ) {
+ ;; or
+ ;; $abc != 3
+ ((and
+ (string-match-p
+ "^[\t ]*$[a-zA-Z0-9_]+[\t ]*[^=!]*=\\($\\|[\t ]+.*[^,;]$\\)"
+ previous-line-string)
+ (not
+ current-line-starts-with-closing-bracket))
+ (setq
+ new-indentation
+ (+ new-indentation tab-width)))
+
+ ;; echo 'Something' .
+ ;; 'something';
+ ;; but ignore
+ ;; print_r($object)
+ ((and
+ (string-match-p
+ "^[\t ]*\\(echo\\|print$\\|print[\t ]+\\|return\\|die\\)"
+ previous-line-string)
+ (not
+ (string-match-p
+ ";[\t ]*$"
+ previous-line-string)))
+ (setq
+ new-indentation
+ (+ new-indentation tab-width)))
+
;; $variable = array(
;; 'random' =>
;; 'hello'
@@ -1380,106 +1515,6 @@
new-indentation
(+ new-indentation tab-width)))
- ;; $myObject->myFunction()
- ;; ->myFunction2()
- ;; but ignore
- ;; $myObject->test(
- ;; 'here'
- ((and
- (not previous-line-ends-with-opening-bracket)
- (string-match-p
- "->"
- previous-line-string)
- (string-match-p
- "^[\t ]*->"
- current-line-string))
- (let ((not-found t)
- (started-chaining-on-this-line t)
- (is-assignment)
- (is-string-concatenation)
- (is-bracket-less-command)
- (is-same-line-p t))
- (while
- (and
- not-found
- (search-backward-regexp
- "\\(;\\|{\\|(\\|)\\|=\\|->\\|echo[\t ]+\\|print[\t
]+\\|\n\\|^[\t ]*\\.\\|\\.[\t ]*$\\)"
- nil
- t))
- (let ((match (match-string-no-properties 0)))
- (cond
-
- ((string=
- "->"
- match)
- (setq
- started-chaining-on-this-line
- is-same-line-p))
-
- ((string=
- "\n"
- match)
- (setq
- is-same-line-p
- nil))
-
- ((or
- (string=
- "echo"
- match)
- (string=
- "print"
- match))
- (setq
- is-bracket-less-command
- t)
- (setq
- not-found
- nil))
-
- ((or
- (string=
- ";"
- match)
- (string=
- "}"
- match))
- (setq
- not-found
- nil))
-
- ((string=
- "="
- match)
- (setq
- is-assignment
- t)
- (setq
- not-found
- nil))
-
- ((string-match-p
- "\\(^[\t ]*\\.\\|\\.[\t ]*\\)$"
- match)
- (setq
- is-string-concatenation
- t)
- (setq
- not-found
- nil))
-
- )))
-
- (when (and
- (not is-assignment)
- (not is-string-concatenation)
- (not started-chaining-on-this-line)
- (not is-bracket-less-command))
- (setq
- new-indentation
- (+ new-indentation tab-width))))
- (goto-char point))
-
;; /**
;; *
;; */
- [elpa] externals/phps-mode e8a47de694 052/212: Work on supported arrow functions for bookkeeping via AST, (continued)
- [elpa] externals/phps-mode e8a47de694 052/212: Work on supported arrow functions for bookkeeping via AST, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 5686703a6b 074/212: Passing bookkeeping via AST for $this inside arrow function body inside class method, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a9d0e941df 066/212: Started on SDT for static variables statement, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode a8fecdfd68 055/212: Bookkeeping of variables inside arrow functions now working, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e42646dc3a 058/212: Added SDT for isset() and empty(), Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 9ad46d061e 057/212: Bookkeeping via AST passing two more tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 806bb902b3 122/212: Improved indentation for chaining objects, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode cc3bf03786 123/212: Improved indentation after ending assignment expression, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 3162dca5c4 159/212: Added two more failing indentation tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 1e44021653 163/212: Added more failing indent tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e7aff3f69d 157/212: Passed more indentation tests,
Christian Johansson <=
- [elpa] externals/phps-mode db7121941c 156/212: Passing indention on line after not equals condition, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d072fe5315 136/212: Improved indentation around array elements, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f880ba2d62 164/212: Improved indentation on lines after assignment that ends with closing bracket, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode db019887af 170/212: Passed new indentation tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 781356557c 194/212: More adjustments to indent helper to find previous command, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 0735959c08 209/212: Using silent cache write, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e3bf9e8fed 059/212: SDT rules for some more infix operations, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 2bc31a0f83 065/212: Added TODO items, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d802a669c0 061/212: Bookkeeping via AST working with isset() and !empty() scoped variables, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode d9115ec583 069/212: Cleaned up AST bookkeeping tests, Christian Johansson, 2022/01/26