[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 55b3087 333/405: Optimized lexer calling, do
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 55b3087 333/405: Optimized lexer calling, do not call when using (indent-line) |
Date: |
Sat, 13 Jul 2019 10:00:43 -0400 (EDT) |
branch: externals/phps-mode
commit 55b3087d118d8b07eca0c19109bef6b1f34a8bc6
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Optimized lexer calling, do not call when using (indent-line)
---
phps-mode-functions.el | 3 +-
phps-mode-lexer.el | 120 ++++++++++++++++++++++++-------------------------
2 files changed, 62 insertions(+), 61 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index cc80145..6fee6d1 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -756,7 +756,8 @@
(phps-mode-lexer-move-tokens line-start indent-diff)
(phps-mode-lexer-move-states line-start indent-diff)
- )))))))
+ ;; Reset change flag
+ (phps-mode-functions-reset-buffer-changes-start))))))))
(defun phps-mode-functions-after-change (start _stop _length)
"Track buffer change from START to STOP with length LENGTH."
diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index a47daca..abfd6ba 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -1685,67 +1685,67 @@
"Run incremental lexer based on
`(phps-mode-functions-get-buffer-changes-start)'."
;; (message "Running incremental lexer")
(let ((change-start (phps-mode-functions-get-buffer-changes-start)))
- (when (and change-start
- (> change-start 1)
- phps-mode-lexer-states)
- (let ((state nil)
- (state-stack nil)
- (new-states '())
- (states (nreverse phps-mode-lexer-states))
- (previous-token-start nil)
- (previous-token-end nil)
- (tokens phps-mode-lexer-tokens))
-
- ;; 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))
- (end (nth 1 state-object)))
- (when (< end change-start)
- (setq state (nth 2 state-object))
- (setq state-stack (nth 3 state-object))
- (setq previous-token-start start)
- (setq previous-token-end end)
- (push state-object new-states))
- (when (> start change-start)
- (throw 'stop-iteration nil)))))
-
- (if (and state
- state-stack)
- (let ((old-tokens '()))
-
- ;; Build new list of tokens before point of change
- (catch 'stop-iteration
- (dolist (token tokens)
- (let ((_start (car (cdr token)))
- (end (cdr (cdr token))))
- (if (< end previous-token-end)
- (progn
- ;; NOTE Does following line make any difference?
- ;; (semantic-lex-push-token (semantic-lex-token
token _start end))
- (push token old-tokens))
- (throw 'stop-iteration nil)))))
- (setq old-tokens (nreverse old-tokens))
-
- ;; Delete all overlays from point of change to end of buffer
- (dolist (overlay (overlays-in previous-token-end (point-max)))
- (delete-overlay overlay))
-
- (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-lexer-STATE state)
- (setq phps-mode-lexer-state_stack state-stack)
- (setq phps-mode-lexer-states new-states)
+ (when change-start
+ (when (and (> change-start 1)
+ phps-mode-lexer-states)
+ (let ((state nil)
+ (state-stack nil)
+ (new-states '())
+ (states (nreverse phps-mode-lexer-states))
+ (previous-token-start nil)
+ (previous-token-end nil)
+ (tokens phps-mode-lexer-tokens))
+
+ ;; 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))
+ (end (nth 1 state-object)))
+ (when (< end change-start)
+ (setq state (nth 2 state-object))
+ (setq state-stack (nth 3 state-object))
+ (setq previous-token-start start)
+ (setq previous-token-end end)
+ (push state-object new-states))
+ (when (> start change-start)
+ (throw 'stop-iteration nil)))))
+
+ (if (and state
+ state-stack)
+ (let ((old-tokens '()))
+
+ ;; Build new list of tokens before point of change
+ (catch 'stop-iteration
+ (dolist (token tokens)
+ (let ((_start (car (cdr token)))
+ (end (cdr (cdr token))))
+ (if (< end previous-token-end)
+ (progn
+ ;; NOTE Does following line make any difference?
+ ;; (semantic-lex-push-token (semantic-lex-token
token _start end))
+ (push token old-tokens))
+ (throw 'stop-iteration nil)))))
+ (setq old-tokens (nreverse old-tokens))
+
+ ;; Delete all overlays from point of change to end of buffer
+ (dolist (overlay (overlays-in previous-token-end (point-max)))
+ (delete-overlay overlay))
- ;; (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)
-
- ))
- ;; (display-warning "phps-mode" (format "Found no state to rewind to
for %s in stack %s, buffer point max: %s" change-start states (point-max)))
- ))))
- (phps-mode-lexer-run)
+ (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-lexer-STATE state)
+ (setq phps-mode-lexer-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 old tokens: %s" state state-stack new-states
previous-token-start old-tokens)
+
+ ))
+ ;; (display-warning "phps-mode" (format "Found no state to rewind
to for %s in stack %s, buffer point max: %s" change-start states (point-max)))
+ )))
+ (phps-mode-lexer-run)))
(phps-mode-functions-reset-buffer-changes-start))
(define-lex phps-mode-lexer-lex
- [elpa] externals/phps-mode b4e416a 336/405: (comment-region) tests working with custom function, (continued)
- [elpa] externals/phps-mode b4e416a 336/405: (comment-region) tests working with custom function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ad53b6c 330/405: Fixed warning when expected integer was nil, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c8c5b62 337/405: Made custom functions for (comment-region) and (uncomment-region), Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7e22fdb 323/405: Added failing incremental indentation test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a45b39a 339/405: Added two failing indentation tests for concatenated equal assignment and double arrow multi-line array declaration, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3e1ff06 332/405: Added integration-tests for syntax colouring and update goals, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ced201d 322/405: Updated syntax colouring for namespace, class, function and constant names, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8298a6a 325/405: Colorized strings after namespace separator, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a30e5ff 331/405: Run incremental lexer when processing file if buffer change, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e9475f7 321/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 55b3087 333/405: Optimized lexer calling, do not call when using (indent-line),
Stefan Monnier <=
- [elpa] externals/phps-mode a309998 326/405: Integration tests passes with new function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c37b234 334/405: Added failing test for indent in concatenated string inside function arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8109c1a 328/405: (uncomment-region) working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 9e62157 338/405: (comment-region) and (uncomment-region) now handles part of lines as well as full lines, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 091ab21 340/405: Passes new unit test for indentation of concatenated equal and multiplication equal assignments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode d27af61 327/405: Fixed bug with incremental lexer were states are missing, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 32f9808 329/405: indent and imenu now triggers incremental lexer if buffer changed, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 365d739 324/405: Changed structure of integration tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2807902 343/405: Added syntax coloring for %, =, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1bac28a 352/405: Updated readme with decreased percent for indent, Stefan Monnier, 2019/07/13