[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 86ec35f 066/405: Incremental lexer working so
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 86ec35f 066/405: Incremental lexer working somewhat |
Date: |
Sat, 13 Jul 2019 09:59:44 -0400 (EDT) |
branch: externals/phps-mode
commit 86ec35fb8b7b9e301e702d13c792ba6c4bed107d
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Incremental lexer working somewhat
---
phps-functions.el | 14 ++++++++++----
phps-lexer.el | 39 +++++++++++++++++++++++++++++++--------
2 files changed, 41 insertions(+), 12 deletions(-)
diff --git a/phps-functions.el b/phps-functions.el
index fe7ded9..6c4a67b 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -40,6 +40,7 @@
"Start of buffer changes, nil if none.")
;; TODO Also format white-space inside the line, i.e. after function
declarations?
+;; TODO Support inline function indentation
(defun phps-mode/indent-line ()
"Indent line."
(let ((data (phps-mode/get-point-data)))
@@ -101,7 +102,12 @@
;; (message "Indenting to %s" indent-sum)
;; (message "inside scripting, start: %s, end: %s, indenting to
column %s " start end indent-level)
(indent-line-to indent-sum)
- (phps-mode/run-incremental-lex))))))))
+ (let ((line-start (line-beginning-position)))
+ (when (or (not phps-mode/buffer-changes--start)
+ (< line-start phps-mode/buffer-changes--start))
+ ;; (message "Setting changes start from %s to %s"
phps-mode/buffer-changes--start start)
+ (setq phps-mode/buffer-changes--start line-start))
+ (phps-mode/run-incremental-lex)))))))))
;; TODO Implement this?
(defun phps-mode/indent-region ()
@@ -114,13 +120,13 @@
(when (string= major-mode "phps-mode")
(when (and (not phps-mode/buffer-changes--start)
(boundp 'phps-mode/idle-interval))
- (run-with-idle-timer phps-mode/idle-interval nil #'phps-mode/lex--RUN)
+ ;; (run-with-idle-timer phps-mode/idle-interval nil #'phps-mode/lex--RUN)
;; TODO Maybe use incremental lexer once it's working
- ;; (run-with-idle-timer phps-mode/idle-interval nil
#'phps-mode/run-incremental-lex)
+ (run-with-idle-timer phps-mode/idle-interval nil
#'phps-mode/run-incremental-lex)
)
(when (or (not phps-mode/buffer-changes--start)
(< start phps-mode/buffer-changes--start))
- ;; (message "Setting %s to %s" phps-mode/buffer-changes--start start)
+ ;; (message "Setting start of changes from %s to %s"
phps-mode/buffer-changes--start start)
(setq phps-mode/buffer-changes--start start))
;; (message "phps-mode/after-change-functions %s %s %s" start stop length)
))
diff --git a/phps-lexer.el b/phps-lexer.el
index dfca7c2..bd0a586 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1262,9 +1262,9 @@ ANY_CHAR'
;; TODO Need to store lexer state and stack at each changing point of buffer
to be able to rewind lexer
(defun phps-mode/lex--SETUP (start end)
"Just prepare other lexers for lexing region START to END."
+ (message "phps-mode/lex--SETUP %s %s" start end)
(when (and (eq start 1)
end)
- ;; (message "SETUP %s %s" start end)
(delete-all-overlays)
(when (boundp 'phps-mode/buffer-changes--start)
(setq phps-mode/buffer-changes--start nil))
@@ -1288,8 +1288,12 @@ ANY_CHAR'
(new-states '())
(states (nreverse phps-mode/lexer-states))
(change-start phps-mode/buffer-changes--start)
- (previous-token-start nil))
+ (previous-token-start nil)
+ (tokens phps-mode/lexer-tokens))
;; (message "Looking for state to rewind to for %s in stack %s"
change-start states)
+
+ ;; Find state and state stack before point of change
+ ;; also determine were previous token to change starts
(catch 'stop-iteration
(dolist (state-object states)
(let ((start (nth 0 state-object))
@@ -1301,14 +1305,33 @@ ANY_CHAR'
(push state-object new-states))
(when (> start change-start)
(throw 'stop-iteration nil)))))
+
(if (and state
state-stack)
- (progn
- (setq phps-mode/STATE state)
- (setq phps-mode/state_stack state-stack)
- (setq phps-mode/lexer-states new-states)
- ;; (message "Rewinding lex to state: %s and stack: %s and states:
%s and start: %s" state state-stack new-states previous-token-start)
- (setq phps-mode/lexer-tokens (semantic-lex previous-token-start
(point-max))))
+ (let ((old-tokens '()))
+
+ ;; Build new list of tokens before point of change
+ (catch 'stop-iteration
+ (dolist (token tokens)
+ (let ((start (car (cdr token))))
+ (if (< start previous-token-start)
+ (push token old-tokens)
+ (throw 'stop-iteration nil)
+ ))))
+ (setq old-tokens (nreverse old-tokens))
+
+ (let* ((new-tokens (semantic-lex previous-token-start (point-max)))
+ (appended-tokens (append old-tokens new-tokens)))
+ ;; (message "old-tokens: %s, new-tokens: %s" old-tokens
new-tokens)
+ (setq phps-mode/lexer-tokens appended-tokens)
+ (setq phps-mode/STATE state)
+ (setq phps-mode/state_stack state-stack)
+ (setq phps-mode/lexer-states new-states)
+ ;; TODO Should clear overlays after point of change here
+ ;; (message "Rewinding lex to state: %s and stack: %s and
states: %s and start: %s old tokens: %s" state state-stack new-states
previous-token-start old-tokens)
+
+ ;; TODO Here clear all tokens after previous-token-start and add
new tokens to stack
+ ))
(display-warning "phps-mode" (format "Found no state to rewind to for
%s in stack %s" change-start states))
(phps-mode/lex--RUN)))
(setq phps-mode/buffer-changes--start nil)))
- [elpa] externals/phps-mode 8aa1ab6 059/405: Another test for getting point data inside doc block, (continued)
- [elpa] externals/phps-mode 8aa1ab6 059/405: Another test for getting point data inside doc block, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 09daec3 052/405: Foundation for incremental lexer and syntax colorer completed, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3f4c344 056/405: Fixed detection of doc comment blocks, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3824abf 060/405: Resolved indent with trailing parenthesis, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a61cb8b 062/405: Fixed issue with doc comment indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6c597fb 065/405: Updated readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 0ca9fe8 058/405: Detection of point inside doc comment block improved, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 67f9a7a 057/405: Moved lexer-get-point-data to functions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 27cd705 069/405: Updated readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 58300fd 070/405: More updates of readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 86ec35f 066/405: Incremental lexer working somewhat,
Stefan Monnier <=
- [elpa] externals/phps-mode ec71e15 074/405: Fixed bug where token-numbers are not defined, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 236f05e 071/405: Updated makefile to not use hard-coded path to emacs, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode bf633d2 061/405: Added test for indent of final line of doc comment block, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ba8165a 063/405: Fixed bug with brace count not including braces inside double quoted strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 99dfc68 067/405: Incremental-lexer deletes affected overlays, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 90d059c 064/405: Fixed bug in incremental lexer logic, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1be9270 068/405: Updated README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e57f1e1 075/405: Skipping indentation if it's already correct, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c57fb5b 073/405: Improved indentation of trailing opening brace, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5e30a65 076/405: Added TODO items, Stefan Monnier, 2019/07/13