[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 228f212127 080/212: Starting on removing the
From: |
Christian Johansson |
Subject: |
[elpa] externals/phps-mode 228f212127 080/212: Starting on removing the old process tokens in string function |
Date: |
Wed, 26 Jan 2022 01:50:57 -0500 (EST) |
branch: externals/phps-mode
commit 228f2121277734868400bed32a44986553b24600
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Starting on removing the old process tokens in string function
---
phps-mode-ast.el | 17 +-
phps-mode-lex-analyzer.el | 418 +++++++++++++-----------------------
phps-mode-test.el | 9 +-
phps-mode.el | 1 -
test/phps-mode-test-ast.el | 2 -
test/phps-mode-test-lex-analyzer.el | 369 +------------------------------
6 files changed, 175 insertions(+), 641 deletions(-)
diff --git a/phps-mode-ast.el b/phps-mode-ast.el
index d4c411be41..ba25eac4de 100644
--- a/phps-mode-ast.el
+++ b/phps-mode-ast.el
@@ -14,6 +14,10 @@
;;; Variables:
+(defvar-local
+ phps-mode-ast--parse-trail
+ nil
+ "Parse trail for current buffer.")
(defvar-local
phps-mode-ast--tree
@@ -26,10 +30,15 @@
(defun phps-mode-ast--generate ()
"Generate AST for current buffer."
- (let ((translation (phps-mode-parser-translate))
- (namespace)
- (namespace-children)
- (ast))
+ (let* ((result (phps-mode-parser--parse t))
+ (parse-trail (nth 0 result))
+ (translation (nth 1 result))
+ (namespace)
+ (namespace-children)
+ (ast))
+ (setq
+ phps-mode-ast--parse-trail
+ parse-trail)
;; (message "\nTranslation:\n%S\n\n" translation)
diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index 6e099f47a4..91b2e2b595 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -35,8 +35,12 @@
(require 'phps-mode-lexer)
(require 'phps-mode-macros)
(require 'phps-mode-parser)
+(require 'phps-mode-parser-sdt)
(require 'phps-mode-serial)
(require 'phps-mode-syntax-color)
+(require 'phps-mode-ast)
+(require 'phps-mode-ast-bookkeeping)
+(require 'phps-mode-ast-imenu)
(require 'semantic)
(require 'semantic/lex)
@@ -64,12 +68,12 @@
(defvar-local phps-mode-lex-analyzer--idle-timer nil
"Timer object of idle timer.")
+(defvar-local phps-mode-lex-analyzer--ast nil
+ "The AST for current buffer, nil if none.")
+
(defvar-local phps-mode-lex-analyzer--imenu nil
"The Imenu alist for current buffer, nil if none.")
-(defvar-local phps-mode-lex-analyzer--lines-indent nil
- "The indentation of each line in buffer, nil if none.")
-
(defvar-local phps-mode-lex-analyzer--bookkeeping nil
"Bookkeeping of all variables in tokens.")
@@ -112,7 +116,6 @@
(setq phps-mode-lex-analyzer--heredoc-label-stack nil)
(setq phps-mode-lex-analyzer--idle-timer nil)
(setq phps-mode-lex-analyzer--imenu nil)
- (setq phps-mode-lex-analyzer--lines-indent nil)
(setq phps-mode-lex-analyzer--processed-buffer-p nil)
(setq phps-mode-lex-analyzer--state nil)
(setq phps-mode-lex-analyzer--state-stack nil)
@@ -236,77 +239,64 @@
buffer-name
(lambda()
- (let ((lex-result
- (phps-mode-lex-analyzer--lex-string
- buffer-contents)))
- (when (fboundp 'thread-yield)
- (thread-yield))
- (let ((processed-result
- (phps-mode-lex-analyzer--process-tokens-in-string
- (nth 0 lex-result)
- buffer-contents)))
- (list
- lex-result
- processed-result))))
+ (phps-mode-lex-analyzer--lex-string buffer-contents))
- (lambda(result)
+ (lambda(lex-result)
(when (get-buffer buffer-name)
(with-current-buffer buffer-name
- (let ((lex-result (nth 0 result))
- (processed-result (nth 1 result)))
-
- ;; Move variables into this buffers local variables
- (setq phps-mode-lex-analyzer--tokens (nth 0 lex-result))
- (setq phps-mode-lex-analyzer--states (nth 1 lex-result))
- (setq phps-mode-lex-analyzer--state (nth 2 lex-result))
- (setq phps-mode-lex-analyzer--state-stack (nth 3 lex-result))
- (setq phps-mode-lex-analyzer--heredoc-label (nth 4 lex-result))
- (setq phps-mode-lex-analyzer--heredoc-label-stack (nth 5
lex-result))
- (setq phps-mode-lex-analyzer--nest-location-stack (nth 6
lex-result))
- (setq phps-mode-lex-analyzer--parse-trail (nth 7 lex-result))
- (setq phps-mode-lex-analyzer--parse-error (nth 8 lex-result))
-
- ;; Save processed result
- (setq phps-mode-lex-analyzer--processed-buffer-p t)
- (setq phps-mode-lex-analyzer--imenu (nth 0 processed-result))
- (setq phps-mode-lex-analyzer--lines-indent (nth 1
processed-result))
- (setq phps-mode-lex-analyzer--bookkeeping (nth 2
processed-result))
- (phps-mode-lex-analyzer--reset-imenu)
- (when (fboundp 'thread-yield)
- (thread-yield))
-
- ;; Apply syntax color on tokens
- (dolist (token phps-mode-lex-analyzer--tokens)
- (let ((start (car (cdr token)))
- (end (cdr (cdr token))))
- (let ((token-syntax-color
(phps-mode-lex-analyzer--get-token-syntax-color token)))
- (if token-syntax-color
- (phps-mode-lex-analyzer--set-region-syntax-color start
end (list 'font-lock-face token-syntax-color))
- (phps-mode-lex-analyzer--clear-region-syntax-color start
end)))))
-
-
- ;; Signal parser error (if any)
- (when phps-mode-lex-analyzer--parse-error
-
- ;; Paint error
- (phps-mode-lex-analyzer--set-region-syntax-color
- (nth 4 phps-mode-lex-analyzer--parse-error)
- (point-max)
- (list 'font-lock-face 'font-lock-warning-face))
-
- ;; Display error
- (display-warning
- 'phps-mode
- (nth 1 phps-mode-lex-analyzer--parse-error)
- :warning
- "*PHPs Parser Errors*")
-
- ;; Signal that causes updated mode-line status
- (signal
- 'phps-parser-error
- (list
- (nth 1 phps-mode-lex-analyzer--parse-error)
- (nth 4 phps-mode-lex-analyzer--parse-error))))))))
+
+ ;; Move variables into this buffers local variables
+ (setq phps-mode-lex-analyzer--tokens (nth 0 lex-result))
+ (setq phps-mode-lex-analyzer--states (nth 1 lex-result))
+ (setq phps-mode-lex-analyzer--state (nth 2 lex-result))
+ (setq phps-mode-lex-analyzer--state-stack (nth 3 lex-result))
+ (setq phps-mode-lex-analyzer--heredoc-label (nth 4 lex-result))
+ (setq phps-mode-lex-analyzer--heredoc-label-stack (nth 5
lex-result))
+ (setq phps-mode-lex-analyzer--nest-location-stack (nth 6
lex-result))
+ (setq phps-mode-lex-analyzer--parse-trail (nth 7 lex-result))
+ (setq phps-mode-lex-analyzer--parse-error (nth 8 lex-result))
+
+ ;; Save processed result
+ (setq phps-mode-lex-analyzer--processed-buffer-p t)
+ (setq phps-mode-lex-analyzer--ast (nth 9 lex-result))
+ (setq phps-mode-lex-analyzer--imenu (nth 10 lex-result))
+ (setq phps-mode-lex-analyzer--bookkeeping (nth 11 lex-result))
+ (phps-mode-lex-analyzer--reset-imenu)
+ (when (fboundp 'thread-yield)
+ (thread-yield))
+
+ ;; Apply syntax color on tokens
+ (dolist (token phps-mode-lex-analyzer--tokens)
+ (let ((start (car (cdr token)))
+ (end (cdr (cdr token))))
+ (let ((token-syntax-color
(phps-mode-lex-analyzer--get-token-syntax-color token)))
+ (if token-syntax-color
+ (phps-mode-lex-analyzer--set-region-syntax-color start
end (list 'font-lock-face token-syntax-color))
+ (phps-mode-lex-analyzer--clear-region-syntax-color start
end)))))
+
+
+ ;; Signal parser error (if any)
+ (when phps-mode-lex-analyzer--parse-error
+
+ ;; Paint error
+ (phps-mode-lex-analyzer--set-region-syntax-color
+ (nth 4 phps-mode-lex-analyzer--parse-error)
+ (point-max)
+ (list 'font-lock-face 'font-lock-warning-face))
+
+ ;; Display error
+ (display-warning
+ 'phps-mode
+ (nth 1 phps-mode-lex-analyzer--parse-error)
+ :warning
+ "*PHPs Parser Errors*")
+
+ ;; Signal that causes updated mode-line status
+ (signal
+ 'phps-parser-error
+ (list
+ (nth 1 phps-mode-lex-analyzer--parse-error)
+ (nth 4 phps-mode-lex-analyzer--parse-error)))))))
(lambda(result)
(when (get-buffer buffer-name)
@@ -366,92 +356,80 @@
buffer-name
(lambda()
- (let ((lex-result
- (phps-mode-lex-analyzer--lex-string
- buffer-contents
- incremental-start-new-buffer
- point-max
- head-states
- incremental-state
- incremental-state-stack
- incremental-heredoc-label
- incremental-heredoc-label-stack
- incremental-nest-location-stack
- head-tokens)))
- (when (fboundp 'thread-yield)
- (thread-yield))
- (let ((processed-result
- (phps-mode-lex-analyzer--process-tokens-in-string
- (nth 0 lex-result)
- buffer-contents)))
- (list
- lex-result
- processed-result))))
-
- (lambda(result)
+ (phps-mode-lex-analyzer--lex-string
+ buffer-contents
+ incremental-start-new-buffer
+ point-max
+ head-states
+ incremental-state
+ incremental-state-stack
+ incremental-heredoc-label
+ incremental-heredoc-label-stack
+ incremental-nest-location-stack
+ head-tokens))
+
+ (lambda(lex-result)
(when (get-buffer buffer-name)
(with-current-buffer buffer-name
- (let ((lex-result (nth 0 result))
- (processed-result (nth 1 result)))
-
- (phps-mode-debug-message
- (message "Incrementally-lexed-string: %s" result))
-
- (setq phps-mode-lex-analyzer--tokens (nth 0 lex-result))
- (setq phps-mode-lex-analyzer--states (nth 1 lex-result))
- (setq phps-mode-lex-analyzer--state (nth 2 lex-result))
- (setq phps-mode-lex-analyzer--state-stack (nth 3 lex-result))
- (setq phps-mode-lex-analyzer--heredoc-label (nth 4 lex-result))
- (setq phps-mode-lex-analyzer--heredoc-label-stack (nth 5
lex-result))
- (setq phps-mode-lex-analyzer--nest-location-stack (nth 6
lex-result))
- (setq phps-mode-lex-analyzer--parse-trail (nth 7 lex-result))
- (setq phps-mode-lex-analyzer--parse-error (nth 8 lex-result))
-
- (phps-mode-debug-message
- (message "Incremental tokens: %s"
phps-mode-lex-analyzer--tokens))
-
- ;; Save processed result
- (setq phps-mode-lex-analyzer--processed-buffer-p t)
- (setq phps-mode-lex-analyzer--imenu (nth 0 processed-result))
- (setq phps-mode-lex-analyzer--lines-indent (nth 1
processed-result))
- (setq phps-mode-lex-analyzer--bookkeeping (nth 2
processed-result))
- (phps-mode-lex-analyzer--reset-imenu)
- (when (fboundp 'thread-yield)
- (thread-yield))
-
- ;; Apply syntax color on tokens
- (dolist (token phps-mode-lex-analyzer--tokens)
- (let ((start (car (cdr token)))
- (end (cdr (cdr token))))
-
- ;; Apply syntax color on token
- (let ((token-syntax-color
(phps-mode-lex-analyzer--get-token-syntax-color token)))
- (if token-syntax-color
- (phps-mode-lex-analyzer--set-region-syntax-color start
end (list 'font-lock-face token-syntax-color))
- (phps-mode-lex-analyzer--clear-region-syntax-color start
end)))))
-
- ;; Signal parser error (if any)
- (when phps-mode-lex-analyzer--parse-error
-
- ;; Paint error
- (phps-mode-lex-analyzer--set-region-syntax-color
- (nth 4 phps-mode-lex-analyzer--parse-error)
- (point-max)
- (list 'font-lock-face 'font-lock-warning-face))
-
- ;; Display error
- (display-warning
- 'phps-mode
- (nth 1 phps-mode-lex-analyzer--parse-error)
- :warning
- "*PHPs Parser Errors*")
-
- ;; Signal that causes updated mode-line status
- (signal
- 'phps-parser-error
- (list
- (nth 1 phps-mode-lex-analyzer--parse-error)
- (nth 4 phps-mode-lex-analyzer--parse-error))))))))
+
+ (phps-mode-debug-message
+ (message "Incrementally-lexed-string: %s" result))
+
+ (setq phps-mode-lex-analyzer--tokens (nth 0 lex-result))
+ (setq phps-mode-lex-analyzer--states (nth 1 lex-result))
+ (setq phps-mode-lex-analyzer--state (nth 2 lex-result))
+ (setq phps-mode-lex-analyzer--state-stack (nth 3 lex-result))
+ (setq phps-mode-lex-analyzer--heredoc-label (nth 4 lex-result))
+ (setq phps-mode-lex-analyzer--heredoc-label-stack (nth 5
lex-result))
+ (setq phps-mode-lex-analyzer--nest-location-stack (nth 6
lex-result))
+ (setq phps-mode-lex-analyzer--parse-trail (nth 7 lex-result))
+ (setq phps-mode-lex-analyzer--parse-error (nth 8 lex-result))
+
+ (phps-mode-debug-message
+ (message "Incremental tokens: %s" phps-mode-lex-analyzer--tokens))
+
+ ;; Save processed result
+ (setq phps-mode-lex-analyzer--processed-buffer-p t)
+ (setq phps-mode-lex-analyzer--ast (nth 9 lex-result))
+ (setq phps-mode-lex-analyzer--imenu (nth 10 lex-result))
+ (setq phps-mode-lex-analyzer--bookkeeping (nth 10 lex-result))
+ (phps-mode-lex-analyzer--reset-imenu)
+ (when (fboundp 'thread-yield)
+ (thread-yield))
+
+ ;; Apply syntax color on tokens
+ (dolist (token phps-mode-lex-analyzer--tokens)
+ (let ((start (car (cdr token)))
+ (end (cdr (cdr token))))
+
+ ;; Apply syntax color on token
+ (let ((token-syntax-color
(phps-mode-lex-analyzer--get-token-syntax-color token)))
+ (if token-syntax-color
+ (phps-mode-lex-analyzer--set-region-syntax-color start
end (list 'font-lock-face token-syntax-color))
+ (phps-mode-lex-analyzer--clear-region-syntax-color start
end)))))
+
+ ;; Signal parser error (if any)
+ (when phps-mode-lex-analyzer--parse-error
+
+ ;; Paint error
+ (phps-mode-lex-analyzer--set-region-syntax-color
+ (nth 4 phps-mode-lex-analyzer--parse-error)
+ (point-max)
+ (list 'font-lock-face 'font-lock-warning-face))
+
+ ;; Display error
+ (display-warning
+ 'phps-mode
+ (nth 1 phps-mode-lex-analyzer--parse-error)
+ :warning
+ "*PHPs Parser Errors*")
+
+ ;; Signal that causes updated mode-line status
+ (signal
+ 'phps-parser-error
+ (list
+ (nth 1 phps-mode-lex-analyzer--parse-error)
+ (nth 4 phps-mode-lex-analyzer--parse-error)))))))
(lambda(result)
(when (get-buffer buffer-name)
@@ -756,39 +734,6 @@
log))))
-(defun phps-mode-lex-analyzer--process-current-buffer (&optional force)
- "Process current buffer, generate indentations and Imenu, trigger
incremental lexer if we have change. FORCE processes without change."
- (interactive)
- (phps-mode-debug-message (message "Process current buffer"))
- (when phps-mode-lex-analyzer--idle-timer
- (phps-mode-debug-message
- (message "Flag buffer as not processed since changes are detected"))
- (setq phps-mode-lex-analyzer--processed-buffer-p nil))
- (if (or
- force
- (and
- (not phps-mode-lex-analyzer--processed-buffer-p)
- (not phps-mode-lex-analyzer--idle-timer)))
- (progn
- (phps-mode-debug-message (message "Buffer is not processed"))
- (let ((processed
- (phps-mode-lex-analyzer--process-tokens-in-string
- phps-mode-lex-analyzer--tokens
- (buffer-substring-no-properties
- (point-min)
- (point-max)))))
- (phps-mode-debug-message (message "Processed result: %s" processed))
- (setq phps-mode-lex-analyzer--imenu (nth 0 processed))
- (setq phps-mode-lex-analyzer--lines-indent (nth 1 processed))
- (setq phps-mode-lex-analyzer--bookkeeping (nth 2 processed)))
- (phps-mode-lex-analyzer--reset-imenu)
- (setq phps-mode-lex-analyzer--processed-buffer-p t))
- (phps-mode-debug-message
- (when phps-mode-lex-analyzer--processed-buffer-p
- (message "Buffer is already processed"))
- (when phps-mode-lex-analyzer--idle-timer
- (message "Not processing buffer since there are non-lexed changes")))))
-
(defun phps-mode-lex-analyzer--get-moved-lines-indent (old-lines-indents
start-line-number diff)
"Move OLD-LINES-INDENTS from START-LINE-NUMBER with DIFF points."
(let ((lines-indents (make-hash-table :test 'equal))
@@ -824,30 +769,12 @@
(phps-mode-lex-analyzer--get-moved-imenu
phps-mode-lex-analyzer--imenu start diff))
(phps-mode-lex-analyzer--reset-imenu)))
-(defun phps-mode-lex-analyzer--move-lines-indent (start-line-number diff)
- "Move lines indent from START-LINE-NUMBER with DIFF points."
- (when phps-mode-lex-analyzer--lines-indent
- ;; (message "Moving line-indent index from %s with %s" start-line-number
diff)
- (setq
- phps-mode-lex-analyzer--lines-indent
- (phps-mode-lex-analyzer--get-moved-lines-indent
- phps-mode-lex-analyzer--lines-indent
- start-line-number
- diff))))
-
-(defun phps-mode-lex-analyzer--get-lines-indent ()
- "Return lines indent, process buffer if not done already."
- (phps-mode-lex-analyzer--process-current-buffer)
- phps-mode-lex-analyzer--lines-indent)
-
(defun phps-mode-lex-analyzer--get-bookkeeping ()
"Return bookkeeping, process buffer if not done already."
- (phps-mode-lex-analyzer--process-current-buffer)
phps-mode-lex-analyzer--bookkeeping)
(defun phps-mode-lex-analyzer--get-imenu ()
"Return Imenu, process buffer if not done already."
- (phps-mode-lex-analyzer--process-current-buffer)
phps-mode-lex-analyzer--imenu)
(defun phps-mode-lex-analyzer--get-moved-imenu (old-index start diff)
@@ -2579,55 +2506,7 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
(defun phps-mode-lex-analyzer--indent-line ()
"Indent line."
- (phps-mode-debug-message (message "Indent line"))
- (phps-mode-lex-analyzer--process-current-buffer)
- (if phps-mode-lex-analyzer--processed-buffer-p
- (if phps-mode-lex-analyzer--lines-indent
- (let ((line-number (line-number-at-pos (point))))
- (phps-mode-debug-message (message "Found lines indent index,
indenting.."))
- (let ((indent (gethash line-number
phps-mode-lex-analyzer--lines-indent)))
- (if indent
- (progn
- (let ((indent-sum (+ (* (car indent) tab-width) (car (cdr
indent))))
- (old-indentation (current-indentation))
- (line-start (line-beginning-position)))
-
- (unless old-indentation
- (setq old-indentation 0))
-
- ;; Only continue if current indentation is wrong
- (if (not (equal indent-sum old-indentation))
- (progn
-
- (setq phps-mode-lex-analyzer--allow-after-change-p
nil)
- (indent-line-to indent-sum)
- (setq phps-mode-lex-analyzer--allow-after-change-p
t)
-
- (let ((indent-diff (- (current-indentation)
old-indentation)))
-
-
- ;; When indent is changed the trailing tokens
and states just
- ;; need to adjust their positions, this will
improve speed of indent-region a lot
- (phps-mode-lex-analyzer--move-tokens line-start
indent-diff)
- (phps-mode-lex-analyzer--move-states line-start
indent-diff)
- (phps-mode-lex-analyzer--move-imenu-index
line-start indent-diff)
-
- (phps-mode-debug-message
- (message "Lexer tokens after move: %s"
phps-mode-lex-analyzer--tokens)
- (message "Lexer states after move: %s"
phps-mode-lex-analyzer--states))
-
- ;; Reset change flag
- (phps-mode-lex-analyzer--reset-changes)
- (phps-mode-lex-analyzer--cancel-idle-timer))))))
- (phps-mode-lex-analyzer--alternative-indentation (point))
- (phps-mode-debug-message
- (message "Did not find indent for line, using alternative
indentation..")))))
- (phps-mode-lex-analyzer--alternative-indentation (point))
- (phps-mode-debug-message
- (message "Did not find lines indent index, using alternative
indentation..")))
- (phps-mode-lex-analyzer--alternative-indentation (point))
- (phps-mode-debug-message
- (message "Using alternative indentation since buffer is not processed
yet"))))
+ (phps-mode-lex-analyzer--alternative-indentation (point)))
(defun phps-mode-lex-analyzer--alternative-indentation (&optional point)
"Apply alternative indentation at POINT here."
@@ -2867,7 +2746,6 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
(defun phps-mode-lex-analyzer--imenu-create-index ()
"Get Imenu for current buffer."
- (phps-mode-lex-analyzer--process-current-buffer)
phps-mode-lex-analyzer--imenu)
(defun phps-mode-lex-analyzer--comment-region (beg end &optional _arg)
@@ -3103,9 +2981,8 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
;; Create a separate buffer, run lexer inside of it, catch errors and return
them
;; to enable nice presentation
(require 'phps-mode-macros)
- (let ((buffer (generate-new-buffer "*PHPs Lexer*"))
- (parse-trail)
- (parse-error))
+ (let* ((buffer (generate-new-buffer "*PHPs Lexer*"))
+ (parse-error))
;; Create temporary buffer and run lexer in it
(when (get-buffer buffer)
@@ -3144,8 +3021,12 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
;; Setup lexer settings
(when (boundp 'phps-mode-syntax-table)
- (setq semantic-lex-syntax-table phps-mode-syntax-table))
- (setq semantic-lex-analyzer #'phps-mode-lex-analyzer--re2c-lex)
+ (setq
+ semantic-lex-syntax-table
+ phps-mode-syntax-table))
+ (setq
+ semantic-lex-analyzer
+ #'phps-mode-lex-analyzer--re2c-lex)
;; Catch errors to kill generated buffer
(let ((got-error t))
@@ -3177,9 +3058,9 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
;; Error-free parse here
(condition-case conditions
(progn
- (setq
- parse-trail
- (phps-mode-parser-parse)))
+ (phps-mode-ast--generate)
+ (phps-mode-ast-bookkeeping--generate)
+ (phps-mode-ast-imenu--generate))
(error
(setq
parse-error
@@ -3193,8 +3074,11 @@ SQUARE-BRACKET-LEVEL and ROUND-BRACKET-LEVEL."
heredoc-label
heredoc-label-stack
nest-location-stack
- parse-trail
- parse-error)))
+ phps-mode-ast--parse-trail
+ parse-error
+ phps-mode-ast--tree
+ phps-mode-ast-imenu--index
+ phps-mode-ast-bookkeeping--index)))
(provide 'phps-mode-lex-analyzer)
diff --git a/phps-mode-test.el b/phps-mode-test.el
index 3c0ba3d85d..0c469fc5ba 100644
--- a/phps-mode-test.el
+++ b/phps-mode-test.el
@@ -44,7 +44,6 @@
(incremental-parse-error)
(incremental-tokens)
(incremental-imenu)
- (incremental-indent)
(incremental-buffer)
(incremental-bookkeeping)
(incremental-nest-location-stack)
@@ -58,7 +57,6 @@
(initial-parse-error)
(initial-tokens)
(initial-imenu)
- (initial-indent)
(initial-buffer)
(initial-bookkeeping)
(initial-nest-location-stack))
@@ -85,7 +83,6 @@
(setq incremental-states phps-mode-lex-analyzer--states)
(setq incremental-tokens phps-mode-lex-analyzer--tokens)
(setq incremental-imenu phps-mode-lex-analyzer--imenu)
- (setq incremental-indent (phps-mode-test--hash-to-list
phps-mode-lex-analyzer--lines-indent))
(setq incremental-buffer (buffer-substring (point-min) (point-max)))
(setq incremental-bookkeeping (phps-mode-test--hash-to-list
phps-mode-lex-analyzer--bookkeeping t))
(setq incremental-nest-location-stack
phps-mode-lex-analyzer--nest-location-stack)
@@ -106,14 +103,13 @@
(setq initial-parse-error phps-mode-lex-analyzer--parse-error)
(setq initial-tokens phps-mode-lex-analyzer--tokens)
(setq initial-imenu phps-mode-lex-analyzer--imenu)
- (setq initial-indent (phps-mode-test--hash-to-list
phps-mode-lex-analyzer--lines-indent))
(setq initial-buffer (buffer-substring (point-min) (point-max)))
(setq initial-bookkeeping (phps-mode-test--hash-to-list
phps-mode-lex-analyzer--bookkeeping t))
(setq initial-nest-location-stack
phps-mode-lex-analyzer--nest-location-stack)
;; Run tests
(phps-mode-debug-message
- (message "\nComparing tokens, lines indent and imenu between
buffer:\n\n'%s'\n\nand:\n\n'%s'\n" initial-buffer incremental-buffer))
+ (message "\nComparing tokens, bookkeeping and imenu between
buffer:\n\n'%s'\n\nand:\n\n'%s'\n" initial-buffer incremental-buffer))
(should (equal initial-buffer incremental-buffer))
;; (message "Initial tokens: %s\n" initial-tokens)
;; (message "Incremental tokens: %s\n" incremental-tokens)
@@ -126,9 +122,6 @@
(should (equal initial-parse-trail incremental-parse-trail))
(should (equal initial-parse-error incremental-parse-error))
(should (equal initial-nest-location-stack
incremental-nest-location-stack))
- ;; (message "Initial indent: %s\n" initial-indent)
- ;; (message "Incremental indent: %s\n" incremental-indent)
- (should (equal initial-indent incremental-indent))
(should (equal initial-imenu incremental-imenu))
(should (equal initial-bookkeeping incremental-bookkeeping))
diff --git a/phps-mode.el b/phps-mode.el
index 9d42dd647a..a1727eff7d 100644
--- a/phps-mode.el
+++ b/phps-mode.el
@@ -123,7 +123,6 @@
(phps-mode-add-trailing-newline))
(phps-mode-lex-analyzer--process-changes nil t)
- (phps-mode-lex-analyzer--process-current-buffer t)
(indent-region (point-min) (point-max)))
(let ((old-buffer-contents
(buffer-substring-no-properties (point-min) (point-max)))
diff --git a/test/phps-mode-test-ast.el b/test/phps-mode-test-ast.el
index 5a5e558630..b77e5f35a6 100644
--- a/test/phps-mode-test-ast.el
+++ b/test/phps-mode-test-ast.el
@@ -419,10 +419,8 @@
(defun phps-mode-test-ast ()
"Run test for ast."
(message "-- Running all tests for ast... --\n")
-
(phps-mode-test-ast-imenu)
(phps-mode-test-ast-bookkeeping)
-
(message "\n-- Ran all tests for ast. --"))
(phps-mode-test-ast)
diff --git a/test/phps-mode-test-lex-analyzer.el
b/test/phps-mode-test-lex-analyzer.el
index 2b4e399464..c1dfd13b2f 100644
--- a/test/phps-mode-test-lex-analyzer.el
+++ b/test/phps-mode-test-lex-analyzer.el
@@ -289,41 +289,6 @@
)
-(defun phps-mode-test-lex-analyzer--move-lines-indent ()
- "Test `phps-mode-functions-move-lines-indent'."
-
- (phps-mode-test--with-buffer
- "<?php\n/**\n * Bla\n */"
- "Move line-indents zero lines down"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)))
(phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-lines-indent))))
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)))
(phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-moved-lines-indent
(phps-mode-lex-analyzer--get-lines-indent) 2 0)))))
-
- (phps-mode-test--with-buffer
- "<?php\n/**\n * Bla\n */"
- "Move line-indents one line down"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)))
(phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-lines-indent))))
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 1)) (5 (0 1)))
(phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-moved-lines-indent
(phps-mode-lex-analyzer--get-lines-indent) 2 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n/**\n * Bla\n */"
- "Move line-indents two lines down"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)))
(phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-lines-indent))))
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 1)) (6 (0
1))) (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-moved-lines-indent
(phps-mode-lex-analyzer--get-lines-indent) 2 2)))))
-
- (phps-mode-test--with-buffer
- "<?php\n/**\n * Bla\n */"
- "Move line-indents one line up"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)))
(phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-lines-indent))))
- (should (equal '((1 (0 0)) (2 (0 1)) (3 (0 1)))
(phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-moved-lines-indent
(phps-mode-lex-analyzer--get-lines-indent) 3 -1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n/**\n * Bla\n */"
- "Move line-indents two lines up"
- (should (equal '((1 (0 0)) (2 (0 0)) (3 (0 1)) (4 (0 1)))
(phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-lines-indent))))
- (should (equal '((1 (0 1)) (2 (0 1))) (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-moved-lines-indent
(phps-mode-lex-analyzer--get-lines-indent) 3 -2)))))
-
- )
-
(defun phps-mode-test-lex-analyzer--get-lines-indent ()
"Test `phps-mode-lex-analyzer--get-lines-indent' function."
@@ -343,7 +308,6 @@
;; (message "Tokens: %s" phps-mode-lexer-tokens)
(should (equal '((1 (0 0)) (2 (0 0)) (3 (0 0)) (4 (0 0)) (5 (0 0)) (6 (0
0))) (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-lines-indent)))))
-
(phps-mode-test--with-buffer
"<?php\n$str = <<<'EOD'\nExample of string\nspanning multiple lines\nusing
nowdoc syntax.\nEOD;\n"
"Multi-line NOWDOC string"
@@ -1156,101 +1120,6 @@
)
-(defun phps-mode-test-lex-analyzer--imenu ()
- "Test for imenu."
-
- (phps-mode-test--with-buffer
- "<?php\nfunction myFunctionA() {}\nfunction myFunctionB() {}\n$var =
function () {\n echo 'here';\n};"
- "Imenu function-oriented file with anonymous function"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myFunctionA" . 16)
("myFunctionB" . 42)))))
-
- (phps-mode-test--with-buffer
- "<?php\nfunction myFunctionA() {}\nfunction myFunctionB() {}\n"
- "Imenu function-oriented file"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myFunctionA" . 16)
("myFunctionB" . 42)))))
-
- (phps-mode-test--with-buffer
- "<?php\nclass myClass {\n public function myFunctionA() {}\n
protected function myFunctionB() {}\n}\n"
- "Imenu object-oriented file"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myClass" .
(("myFunctionA" . 43) ("myFunctionB" . 83)))))))
-
- (phps-mode-test--with-buffer
- "<?php\ninterface myInterface {\n public function myFunctionA() {}\n
protected function myFunctionB() {}\n}\n"
- "Imenu object-oriented file with interface"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myInterface" .
(("myFunctionA" . 51) ("myFunctionB" . 91)))))))
-
- (phps-mode-test--with-buffer
- "<?php\nnamespace myNamespace {\n class myClass {\n public
function myFunctionA() {}\n protected function myFunctionB() {}\n
}\n}\n"
- "Imenu object-oriented file with namespace, class and function"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myNamespace"
("myClass" ("myFunctionA" . 75) ("myFunctionB" . 119)))))))
-
- (phps-mode-test--with-buffer
- "<?php\nnamespace myNamespace;\nclass myClass {\n public function
myFunctionA() {}\n protected function myFunctionB() {}\n}\n"
- "Imenu object-oriented file with bracket-less namespace, class and function"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myNamespace"
("myClass" ("myFunctionA" . 66) ("myFunctionB" . 106)))))))
-
- (phps-mode-test--with-buffer
- "<?php\nnamespace myNamespace {\n class myClass extends myAbstract {\n
public function myFunctionA() {}\n protected function myFunctionB()
{}\n }\n}\n"
- "Imenu object-oriented file with namespace, class that extends and
functions"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myNamespace"
("myClass" ("myFunctionA" . 94) ("myFunctionB" . 138)))))))
-
- (phps-mode-test--with-buffer
- "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements
myInterface {\n public function myFunctionA() {}\n protected function
myFunctionB() {}\n}\n"
- "Imenu object-oriented file with bracket-less namespace, class that extends
and implements and functions"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myNamespace"
("myClass" ("myFunctionA" . 108) ("myFunctionB" . 148)))))))
-
- (phps-mode-test--with-buffer
- "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements
myInterface {\n public function myFunctionA($myArg = null) {}\n protected
function myFunctionB($myArg = 'abc') {}\n}\n"
- "Imenu object-oriented file with bracket-less namespace, class that extends
and implements and functions with optional arguments"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myNamespace"
("myClass" ("myFunctionA" . 108) ("myFunctionB" . 161)))))))
-
- (phps-mode-test--with-buffer
- "<?php\nnamespace myNamespace\\myNamespace2;\nclass myClass extends
myAbstract implements myInterface {\n public function myFunctionA($myArg =
null) {}\n protected function myFunctionB($myArg = 'abc') {}\n}\n"
- "Imenu object-oriented file with bracket-less namespace with multiple
levels, class that extends and implements and functions with optional arguments"
- (should (equal (phps-mode-lex-analyzer--get-imenu)
'(("myNamespace\\myNamespace2" ("myClass" ("myFunctionA" . 121) ("myFunctionB"
. 174)))))))
-
- (phps-mode-test--with-buffer
- "<?php\nclass myClass\n{\n\n public function myFunction1()\n {\n
echo \"my string with variable {$variable} inside it\";\n }\n\n public
function myFunction2()\n {\n }\n\n}"
- "Imenu with double quoted string with variable inside it"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myClass"
("myFunction1" . 44) ("myFunction2" . 153))))))
-
- (phps-mode-test--with-buffer
- "<?php\n\nnamespace MyNamespace;\n\nclass MyClass\n{\n\n /**\n *\n
*/\n public function __construct()\n {\n if ($test) {\n
}\n }\n\n /**\n *\n */\n public function myFunction1()\n
{\n $this->addMessage(\"My random {$message} here\" . ($random > 1 ?
\"A\" : \"\") . \" was here.\");\n }\n \n /**\n *\n */\n
public function myFunction2()\n {\n }\n\n /**\n * It's good\n
*/\n public function my [...]
- "Imenu with double quoted string with variable inside it and concatenated
string"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("MyNamespace"
("MyClass" ("__construct" . 92) ("myFunction1" . 193) ("myFunction2" . 365)
("myFunction3" . 445) ("myFunction4" . 515)))))))
-
- (phps-mode-test--with-buffer
- "<?php\nclass myClass {}"
- "Imenu empty class"
- (should (equal (phps-mode-lex-analyzer--get-imenu) nil)))
-
- (phps-mode-test--with-buffer
- "<?php\nnamespace myNamespace {}"
- "Imenu empty bracketed namespace"
- (should (equal (phps-mode-lex-analyzer--get-imenu) nil)))
-
- (phps-mode-test--with-buffer
- "<?php\nnamespace myNamespace;"
- "Imenu empty namespace without brackets"
- (should (equal (phps-mode-lex-analyzer--get-imenu) nil)))
-
- (phps-mode-test--with-buffer
- "<?php\ninterface myInterface\n{\n function myFunction1();\n function
myFunction2($x); // NOTE Imenu not working either\n}\n"
- "Imenu in interface class with arguments in one method"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("myInterface"
("myFunction1" . 44) ("myFunction2" . 72))))))
-
- (phps-mode-test--with-buffer
- "<?php\n\nnamespace MyNamespace;\n\nfunction aFunction() {\n /**\n *
With some contents\n */\n}\n\nclass MyClass\n{\n\n /**\n *\n
*/\n public function __construct()\n {\n if ($test) {\n }\n
}\n\n /**\n *\n */\n public function myFunction1()\n {\n
$this->addMessage(\"My random {$message} here\" . ($random > 1 ? \"A\" :
\"\") . \" was here.\");\n }\n \n /**\n *\n */\n public
function myFunction2()\n [...]
- "Imenu with double quoted string with variable inside it and concatenated
string"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("MyNamespace"
("aFunction" . 41) ("MyClass" ("__construct" . 160) ("myFunction1" . 261)
("myFunction2" . 433) ("myFunction3" . 513) ("myFunction4" . 583)))))))
-
- (phps-mode-test--with-buffer
- "<?php\n\nnamespace MyNamespaceA\n{\n function aFunctionA() {\n
/**\n * With some contents\n */\n }\n class MyClass\n
{\n\n /**\n *\n */\n public function
__construct()\n {\n if ($test) {\n }\n
}\n\n /**\n *\n */\n public function
myFunction1()\n {\n $this->addMessage(\"My random {$message}
here\" . ($random > 1 ? \"A\" : \"\") . \" was he [...]
- "Imenu with double quoted string with variable inside it and concatenated
string in two namespaces"
- (should (equal (phps-mode-lex-analyzer--get-imenu) '(("MyNamespaceA"
("aFunctionA" . 46) ("MyClass" ("__construct" . 205) ("myFunction1" . 338)
("myFunction2" . 542) ("myFunction3" . 646) ("myFunction4" . 740)))
("aFunctionB" . 807) ("MyClass" ("__construct" . 925) ("myFunction1" . 1058)
("myFunction2" . 1262) ("myFunction3" . 1366) ("myFunction4" . 1460))))))
-
- )
-
(defun phps-mode-test-lex-analyzer--get-moved-imenu ()
"Test for moving imenu index."
@@ -1406,221 +1275,6 @@
)
-
-(defun phps-mode-test-lex-analyzer--bookkeeping ()
- "Test the bookkeeping."
-
- (phps-mode-test--with-buffer
- "<?php\n\n$var = 'abc';\n\nif ($var2) {\n echo 'This never
happens';\n}\nif ($var) {\n echo 'This happens';\n}"
- "Bookkeeping in root level variable assignments #1."
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $var" 1) (list (list 8 12) 1) (list (list 27 32)
0) (list (list 73 77) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\n$var = 'abc';\n\nif ($var) {\n echo 'This never
happens';\n}\nif ($var2) {\n echo 'This happens';\n}"
- "Bookkeeping in root level variable assignments #2."
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $var" 1) (list (list 8 12) 1) (list (list 27 31)
1) (list (list 72 77) 0)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\n$var2 = 4;\n\nfunction myFunction($var)\n{\n $var3 = 3;\n
if ($var) {\n echo 'Hit';\n }\n if ($var2) {\n echo
'Miss';\n }\n if ($var3) {\n echo 'Hit';\n }\n}\n\nfunction
myFunction2($abc)\n{\n if ($var) {\n echo 'Miss';\n }\n if
($abc) {\n echo 'Hit';\n }\n}\n\nif ($var) {\n echo 'Miss';\n}\nif
($var2) {\n echo 'Hit';\n}"
- "Bookkeeping in function level with variable assignments."
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" id $var2" 1) ((8 13) 1) (" function myFunction id $var" 1)
((40 44) 1) (" function myFunction id $var3" 1) ((52 57) 1) ((71 75) 1) ((113
118) 0) ((157 162) 1) (" function myFunction2 id $abc" 1) ((216 220) 1) ((232
236) 0) ((275 279) 1) ((316 320) 0) ((347 352) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\n// Super-globals\n\nif ($_GET) {\n echo 'Hit';\n}\nif ($_POST)
{\n echo 'Hit';\n}\nif ($_COOKIE) {\n echo 'Hit';\n}\nif ($_SESSION) {\n
echo 'Hit';\n}\nif ($_REQUEST) {\n echo 'Hit';\n}\nif ($GLOBALS) {\n
echo 'Hit';\n}\nif ($_SERVER) {\n echo 'Hit';\n}\nif ($_FILES) {\n echo
'Hit';\n}\nif ($_ENV) {\n echo 'Hit';\n}\nif ($argc) {\n echo
'Hit';\n}\nif ($argv) {\n echo 'Hit';\n}\nif ($http_​response_​header) {\n
echo 'Hit';\n}"
- "Bookkeeping of super-globals"
- (should
- (equal
- (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list (list 30 35) 1) (list (list 61 67) 1) (list (list 93 101) 1)
(list (list 127 136) 1) (list (list 162 171) 1) (list (list 197 205) 1) (list
(list 231 239) 1) (list (list 265 272) 1) (list (list 298 303) 1) (list (list
329 334) 1) (list (list 360 365) 1) (list (list 391 414) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\nnamespace myNamespaceA {\n $var = 123;\n class myClassA {\n
private $var2 = 123;\n function myFunctionA($var3) {\n
$var4 = 123;\n if ($var) {\n echo 'Miss';\n
}\n if ($var2) {\n echo 'Miss';\n }\n
if ($var3) {\n echo 'Hit';\n }\n if
($var4) {\n echo 'Hit';\n }\n }\n\n
function myFuncti [...]
- "Bookkeeping in maximum level with namespaces, classes and functions."
- (should
- (equal
- (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) 1)
- (list (list " id $var" 1) (list (list 37 41) 1) (list " namespace
myNamespaceA class myClassA id $var2" 1) (list (list 86 91) 1) (list "
namespace myNamespaceA class myClassA function myFunctionA id $this" 1) (list "
namespace myNamespaceA class myClassA function myFunctionA id $var3" 1) (list
(list 128 133) 1) (list " namespace myNamespaceA class myClassA function
myFunctionA id $var4" 1) (list (list 149 154) 1) (list (list 178 182) 0) (list
(list 245 250) 0) (list (list 313 318) 1 [...]
-
- (phps-mode-test--with-buffer
- "<?php\n\n// Conditional assignments\n\n$items = array(1, 2, 3);\nforeach
($items as $item) {\n if ($item) {\n echo 'Hit';\n }\n}\nforeach
($items as $key => $value) {\n if ($key || $value) {\n echo 'Hit';\n
}\n}\nfor ($i = 0; $i < count($items); $i++) {\n if ($i) {\n echo
'Hit';\n }\n}\nif ($a = 123) {\n if ($a) {\n echo 'Hit';\n
}\n}\nwhile ($b = 123) {\n if ($a) {\n echo 'Hit';\n }\n}\ndo {\n
echo 'Hit';\n} while ( [...]
- "Bookkeeping of conditional assignments"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $items" 1) (list (list 36 42) 1) (list (list 70
76) 1) (list " id $item" 1) (list (list 80 85) 1) (list (list 97 102) 1) (list
(list 143 149) 1) (list " id $key" 1) (list (list 153 157) 1) (list " id
$value" 1) (list (list 161 167) 1) (list (list 179 183) 1) (list (list 187 193)
1) (list " id $i" 1) (list (list 230 232) 1) (list (list 238 240) 1) (list
(list 249 255) 1) (list (list 258 260) 1) (list (list 274 276) 1) (list " id
$a" 1) (list (list 312 314) 1) [...]
-
- (phps-mode-test--with-buffer
- "<?php\n\n// Class properties\n\nclass myParent {}\n\nclass myClass extends
myParent {\n private $var1 = 123;\n protected static $var2;\n public
$var3;\n var $var4;\n function __construct() {\n if ($this) {\n
echo 'Hit';\n }\n if ($this->var1) {\n echo
'Hit';\n }\n if (self::$var1) {\n echo 'Miss';\n
}\n if (self::$var2) {\n echo 'Hit';\n }\n if
($this->var3) {\n [...]
- "Bookkeeping of class properties"
- ;; (message "Bookkeeping: %s" (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t))
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " class myParent id $var1" 1) (list (list 93 98) 1)
(list " class myParent static id $var2" 1) (list (list 127 132) 1) (list "
class myParent id $var3" 1) (list (list 145 150) 1) (list " class myParent id
$var4" 1) (list (list 160 165) 1) (list " class myParent function __construct
id $this" 1) (list (list 208 213) 1) (list (list 263 268) 1) (list (list 270
274) 1) (list (list 330 335) 0) (list (list 392 397) 1) (list (list 447 452) 1)
(list (list 454 458) 1) (lis [...]
-
- (phps-mode-test--with-buffer
- "<?php\n\ntry {\n \n} catch (\\Exception $e) {\n if ($e) {\n
echo 'Hit';\n }\n}\n\nif ($e) {\n echo 'Miss';\n}\n"
- "Bookkeeping of try catch variable assignment"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $e" 1) (list (list 39 41) 1) (list (list 53 55)
1) (list (list 92 94) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\n$example = function ($test) {\n if ($test) {\n echo
'Hit';\n }\n if ($example) {\n echo 'Miss';\n }\n};\n$example2
= function ($test2) use ($example) {\n if ($test2) {\n echo 'Hit';\n
}\n if ($example) {\n echo 'Hit';\n }\n if ($example2) {\n
echo 'Miss';\n }\n if ($example3) {\n echo 'Miss';\n
}\n};\nif ($test) {\n echo 'Miss';\n}\nif ($test2) {\n echo 'Miss';\n}"
- "Bookkeeping of anonymous function variable assignments"
- ;; (message "Bookkeeping: %s" (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t))
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $example" 1) (list (list 8 16) 1) (list "
anonymous function 1 id $test" 1) (list (list 29 34) 1) (list (list 46 51) 1)
(list (list 89 97) 0) (list " id $example2" 1) (list (list 131 140) 1) (list "
anonymous function 2 id $test2" 1) (list (list 153 159) 1) (list " anonymous
function 2 id $example" 1) (list (list 166 174) 1) (list (list 186 192) 1)
(list (list 230 238) 1) (list (list 276 285) 0) (list (list 324 333) 0) (list
(list 371 376) 0) (list (list 403 [...]
-
- (phps-mode-test--with-buffer
- "<?php\nclass myClass {\n function random() {}\n function
__construct()\n {\n $this->random();\n $this->random['abc'] =
123;\n }\n}"
- "Method calls should be avoided in bookkeeping"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " class myClass function __construct id $this" 1)
(list (list 89 94) 1) (list (list 114 119) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n$items = array(1, 2, 3);\nforeach ($items as &$item) {\n if
($item) {\n echo 'Hit';\n }\n}\nforeach ($items as $key => &$item2)
{\n if ($item) {\n echo 'Hit';\n }\n}"
- "Bookkeeping of foreach reference variable declaration"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $items" 1) (list (list 7 13) 1) (list (list 41
47) 1) (list " id $item" 1) (list (list 52 57) 1) (list (list 69 74) 1) (list
(list 115 121) 1) (list " id $key" 1) (list (list 125 129) 1) (list " id
$item2" 1) (list (list 134 140) 1) (list (list 152 157) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\n[$random, $bandom] = myValues();\nif ($random) {\n echo
'Hit';\n}\nif ($bandom) {\n echo 'Hit';\n}\n\n"
- "Bookkeeping of variable declarations in array"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $random" 1) (list (list 9 16) 1) (list " id
$bandom" 1) (list (list 18 25) 1) (list (list 45 52) 1) (list (list 78 85)
1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\n$var = 123;\n\nfunction test($abc) {\n global $var;\n if
($var) {\n echo 'Hit';\n }\n}"
- "Bookkeeping of global variable declaration in function"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $var" 1) (list (list 8 12) 1) (list " function
test id $abc" 1) (list (list 35 39) 1) (list " function test id $var" 1) (list
(list 54 58) 1) (list (list 68 72) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n$y = 1;\n$fn1 = fn($x) => $x + $y;\n$z = 1;\n$fn = fn($x2) =>
fn($y2) => $x2 * $y2 + $z;\nfn(array $x3) => $x3;\n$x4 = 4;\nstatic fn(): int
=> $x4;\nfn($x5 = 42) => $x5;\nfn(&$x6) => $x6;\nfn&($x7) => $x7;\nfn($x8,
...$rest) => $rest;"
- "Bookkeeping in arrow functions"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $y" 1) (list (list 7 9) 1) (list " id $fn1" 1)
(list (list 15 19) 1) (list " arrow function 1 id $x" 1) (list (list 25 27) 1)
(list (list 32 34) 1) (list (list 37 39) 1) (list " id $z" 1) (list (list 41
43) 1) (list " id $fn" 1) (list (list 49 52) 1) (list " arrow function 2 id
$x2" 1) (list (list 58 61) 1) (list " arrow function 2 id $y2" 1) (list (list
69 72) 1) (list (list 77 80) 1) (list (list 83 86) 1) (list (list 89 91) 1)
(list " arrow function 3 id $x [...]
-
- (phps-mode-test--with-buffer
- "<?php\n$z = (object) array('name' => 'random');\nif ($z->name) {\n echo
'Hit';\n}"
- "Bookkeeping object properties."
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $z" 1) (list (list 7 9) 1) (list (list 52 54)
1)))))
-
- (phps-mode-test--with-buffer
- "<?php\nif (!$var = false) {\n echo 'Hit';\n}\n"
- "Bookkeeping negative conditional assignment"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " id $var" 1) (list (list 12 16) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\nif (isset($x)) {\n if ($x) {\n echo 'Hit';\n if
(isset($i, $u)) {\n if ($i) {\n echo 'Hit';\n
}\n if ($u) {\n echo 'Hit';\n }\n
if ($x) {\n echo 'Hit';\n }\n }\n
if ($i) {\n echo 'Miss';\n }\n if ($u) {\n
echo 'Miss';\n }\n }\n}\nif ($x) {\n echo 'Miss';\n}\n\nif
(!empty($y)) {\n if ( [...]
- "Bookkeeping of isset() and !empty() scoped variables."
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " defined 1 id $x" 1) (list (list 18 20) 1) (list
(list 33 35) 1) (list " defined 2 id $i" 1) (list (list 77 79) 1) (list "
defined 2 id $u" 1) (list (list 81 83) 1) (list (list 104 106) 1) (list (list
168 170) 1) (list (list 232 234) 1) (list (list 302 304) 0) (list (list 355
357) 0) (list (list 408 410) 0) (list " defined 3 id $y" 1) (list (list 445
447) 1) (list (list 460 462) 1) (list " defined 4 id $k" 1) (list (list 505
507) 1) (list " defined 4 id $L" 1) (l [...]
-
- (phps-mode-test--with-buffer
- "<?php\ninterface myInterface\n{\n function myFunction1();\n function
myFunction2($x);\n}\n"
- "Bookkeeping variable in interface function"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- (list (list " class myInterface function myFunction2 id $x" 1)
(list (list 84 86) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\nfunction myFunction1()\n{\n return isset($a);\n}\n\nfunction
myFunction2()\n{\n $b = 2;\n if ($b) {\n echo 'Hit';\n }\n
if ($b) {\n echo 'Hit';\n }\n}\n"
- "Bookkeeping after definition condition"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '(((50 52) 0) (" function myFunction2 id $b" 1) ((87 89) 1) ((103
105) 1) ((143 145) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\n$a = array(1, 2, 3);\nforeach ($a as $uri => $page)\n{\n if
(isset($pages)) {\n if ($a) {\n echo 'Hit';\n }\n
if ($uri) {\n echo 'Hit';\n }\n if ($page) {\n
echo 'Hit';\n }\n }\n}\n"
- "Bookkeeping of foreach variable inside if (isset()) block"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" id $a" 1) ((8 10) 1) ((38 40) 1) (" id $uri" 1) ((44 48) 1)
(" id $page" 1) ((52 57) 1) (" defined 1 id $pages" 1) ((75 81) 1) ((98 100) 1)
((150 154) 1) ((204 209) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\nif (isset($b)) {\n $b = false;\n}\n$c = 2;\n\nif ($c) {\n
echo 'Hit';\n}\n"
- "Bookkeeping of variable after isset() block"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" defined 1 id $b" 2) ((17 19) 1) ((28 30) 1) (" id $c" 1) ((42
44) 1) ((55 57) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\nif (!isset($a)) {\n if ($a) {\n echo 'Miss';\n }\n}"
- "Bookkeeping for variable in negative isset() conditional"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '(((18 20) 0) ((33 35) 0)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\nfunction myFunction($a, $b, $c, $d)\n{\n global $f, $g;\n
if (isset($f)) {\n if (!empty($g)) {\n if ($a) {\n
echo 'Hit';\n }\n if ($b) {\n echo
'Hit';\n }\n if ($c) {\n echo 'Hit';\n
}\n if ($d) {\n echo 'Hit';\n }\n
}\n }\n}\n"
- "Bookkeeping variables inside nested isset() !empty() blocks"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" function myFunction id $a" 1) ((28 30) 1) (" function
myFunction id $b" 1) ((32 34) 1) (" function myFunction id $c" 1) ((36 38) 1)
(" function myFunction id $d" 1) ((40 42) 1) (" function myFunction id $f" 1)
((57 59) 1) (" function myFunction id $g" 1) ((61 63) 1) (" function myFunction
defined 1 id $f" 1) ((79 81) 1) (" function myFunction defined 2 id $g" 1)
((105 107) 1) ((128 130) 1) ((192 194) 1) ((256 258) 1) ((320 322) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\n$var = 123;\n\nfunction test($abc) {\n static $var;\n if
($var) {\n echo 'Hit';\n }\n}"
- "Bookkeeping of static variable declaration in function"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" id $var" 1) ((8 12) 1) (" function test id $abc" 1) ((35 39)
1) (" function test id $var" 1) ((54 58) 1) ((68 72) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\nglobal $a, $b;\n\nif ($a) {\n echo 'Hit';\n}\n\nfunction
myFunction($c)\n{\n global $a;\n if ($a) {\n echo 'Hit';\n }\n
if ($b) {\n echo 'Miss';\n }\n}\n"
- "Bookkeeping of global variables in functional-oriented file"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" id $a" 1) ((15 17) 1) (" id $b" 1) ((19 21) 1) ((28 30) 1) ("
function myFunction id $c" 1) ((73 75) 1) (" function myFunction id $a" 1) ((90
92) 1) ((102 104) 1) ((142 144) 0)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\nstatic $a;\n\nif ($a) {}\n\nfunction test()\n{\n static $a;\n
if ($a) {}\n}\n\nclass There\n{\n function here()\n {\n static
$a;\n if ($a) {}\n }\n}"
- "Bookkeeping of static variables in different scopes without namespaces"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" id $a" 1) ((15 17) 1) ((24 26) 1) (" function test id $a" 1)
((61 63) 1) ((73 75) 1) (" class There function here id $this" 1) (" class
There function here id $a" 1) ((138 140) 1) ((154 156) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\n\nnamespace Here\n{\n function here()\n {\n static
$a;\n if ($a) {}\n }\n class There\n {\n public function
Near()\n {\n static $a;\n if ($a) {}\n }\n
}\n}\nnamespace\n{\n static $a;\n if ($a) {}\n}\n"
- "Bookkeeping of static variables in different scopes with namespaces"
- (should (equal
- (phps-mode-test--hash-to-list
(phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" namespace Here function here id $a" 1) ((66 68) 1) ((82 84)
1) (" namespace Here class There function Near id $this" 1) (" namespace Here
class There function Near id $a" 1) ((177 179) 1) ((197 199) 1) (" id $a" 1)
((245 247) 1) ((257 259) 1)))))
-
- (phps-mode-test--with-buffer
- "<?php\nclass There\n{\n private $variable;\n private \\My\\Random
$variable2;\n private string $variable3;\n private static $variable4;\n
private static \\My\\Random $variable5;\n private static string
$variable6;\n function here()\n {\n if ($this->variable) {}\n
if ($this->variable2) {}\n if ($this->variable3) {}\n if
($this->variable4) {}\n if (self::$variable4) {}\n if
(self::$variable5) {}\n if (self::$varia [...]
- "Bookkeeping of typed class variables"
- (should
- (equal
- (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" class There id $variable" 1) ((33 42) 1) (" class There id
$variable2" 1) ((67 77) 1) (" class There id $variable3" 1) ((98 108) 1) ("
class There static id $variable4" 1) ((129 139) 1) (" class There static id
$variable5" 1) ((171 181) 1) (" class There static id $variable6" 1) ((209 219)
1) (" class There function here id $this" 1) ((259 264) 1) ((266 274) 1) ((291
296) 1) ((298 307) 1) ((324 329) 1) ((331 340) 1) ((357 362) 1) ((364 373) 0)
((396 406) 1) ((429 439) 1) ((462 [...]
-
- (phps-mode-test--with-buffer
- "<?php\n\n$a = $b = $c = 3;\n\nif ($a) {\n echo 'a=',$a;\n} else {\n
echo '$a is undefined!';\n}\nif ($b) {\n echo 'b=',$b;\n} else {\n echo
'$b is undefined!';\n}\nif ($c) {\n echo 'c=',$c;\n} else {\n echo '$c is
undefined!';\n}"
- "Bookkeeping of typed class variables"
- (should
- (equal
- (phps-mode-test--hash-to-list (phps-mode-lex-analyzer--get-bookkeeping) t)
- '((" id $a" 1) ((8 10) 1) (" id $b" 1) ((13 15) 1) (" id $c" 1) ((18 20)
1) ((31 33) 1) ((51 53) 1) ((99 101) 1) ((119 121) 1) ((167 169) 1) ((187 189)
1)))))
-
- )
-
(defun phps-mode-test-lex-analyzer--parse-string ()
"Test the parser."
@@ -1640,21 +1294,18 @@
(defun phps-mode-test-lex-analyzer ()
"Run test for functions."
;; (setq debug-on-error t)
- (phps-mode-test-lex-analyzer--bookkeeping)
(phps-mode-test-lex-analyzer--process-changes)
(phps-mode-test-lex-analyzer--alternative-indentation)
- (phps-mode-test-lex-analyzer--move-lines-indent)
- (phps-mode-test-lex-analyzer--get-inline-html-indentation)
- (phps-mode-test-lex-analyzer--get-lines-indent-if)
- (phps-mode-test-lex-analyzer--get-lines-indent-classes)
- (phps-mode-test-lex-analyzer--get-lines-indent-inline-if)
- (phps-mode-test-lex-analyzer--get-lines-indent-alternative-if)
- (phps-mode-test-lex-analyzer--get-lines-indent-multi-line-assignments)
- (phps-mode-test-lex-analyzer--get-lines-indent-switch-case)
- (phps-mode-test-lex-analyzer--get-lines-indent-psr-2)
- (phps-mode-test-lex-analyzer--get-lines-indent)
- (phps-mode-test-lex-analyzer--indent-line)
- (phps-mode-test-lex-analyzer--imenu)
+ ;; (phps-mode-test-lex-analyzer--get-inline-html-indentation)
+ ;; (phps-mode-test-lex-analyzer--get-lines-indent-if)
+ ;; (phps-mode-test-lex-analyzer--get-lines-indent-classes)
+ ;; (phps-mode-test-lex-analyzer--get-lines-indent-inline-if)
+ ;; (phps-mode-test-lex-analyzer--get-lines-indent-alternative-if)
+ ;; (phps-mode-test-lex-analyzer--get-lines-indent-multi-line-assignments)
+ ;; (phps-mode-test-lex-analyzer--get-lines-indent-switch-case)
+ ;; (phps-mode-test-lex-analyzer--get-lines-indent-psr-2)
+ ;; (phps-mode-test-lex-analyzer--get-lines-indent)
+ ;; (phps-mode-test-lex-analyzer--indent-line)
(phps-mode-test-lex-analyzer--get-moved-imenu)
(phps-mode-test-lex-analyzer--comment-uncomment-region))
- [elpa] externals/phps-mode 0735959c08 209/212: Using silent cache write, (continued)
- [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
- [elpa] externals/phps-mode f4d2164f8b 067/212: Bookkeeping via parser SDT passing static variables in function, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode e66abd00e5 064/212: Bookkeeping via AST passing nested isset() !empty() expressions, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 8b5ce22d87 072/212: Fixed issue with SDT for return statement, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 491c82a2a1 071/212: Added TODO item for bookkeeping via AST, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 5ec32f5f5a 076/212: Bookkeeping via AST passing all tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 228f212127 080/212: Starting on removing the old process tokens in string function,
Christian Johansson <=
- [elpa] externals/phps-mode 5b1f5b4774 079/212: Improved format of SDT, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 3f3a8bb0fa 081/212: Major refactor of indent tests, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode b469f0ffbb 088/212: Passing indentation for multi-line class implements, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f69df4fdf6 083/212: Moved indentation to separate file and test, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 481deb6331 082/212: More work on indentation, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode fe9cb90c44 097/212: Passing indent test for some multi-line assignments, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode c9f715a1fd 093/212: Improved comments, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode f0ab7a2cdb 095/212: Passed tests for inline control structures, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 08f57c1d36 107/212: Added TODO item for indent, Christian Johansson, 2022/01/26
- [elpa] externals/phps-mode 3853ddf32a 099/212: Passed another concatenation test for indentation, Christian Johansson, 2022/01/26