[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode a852669 320/405: Fix bug in syntax colouring,
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode a852669 320/405: Fix bug in syntax colouring, added debug outputs for incremental lexer |
Date: |
Sat, 13 Jul 2019 10:00:40 -0400 (EDT) |
branch: externals/phps-mode
commit a85266985c898cc4bfe955c8b9a5936394da23e9
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Fix bug in syntax colouring, added debug outputs for incremental lexer
---
phps-mode-functions.el | 14 +++++---------
phps-mode-lexer.el | 27 +++++++++++++++------------
2 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index ba1ab50..b3ae09b 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -46,7 +46,6 @@
;; NOTE Also format white-space inside the line, i.e. after function
declarations?
-;; TODO Add support for automatic parenthesis, bracket, square-bracket,
single-quote and double-quote encapsulations
(defun phps-mode-functions-get-buffer-changes-start ()
"Get buffer change start."
@@ -54,6 +53,7 @@
(defun phps-mode-functions-reset-buffer-changes-start ()
"Reset buffer change start."
+ (message "Reset flag for buffer changes")
(setq phps-mode-functions-buffer-changes-start nil))
(defun phps-mode-functions-process-current-buffer ()
@@ -755,7 +755,7 @@
)))))))
-(defun phps-mode-functions-after-change (start _stop _length)
+(defun phps-mode-functions-after-change (start stop _length)
"Track buffer change from START to STOP with length LENGTH."
(when (string= major-mode "phps-mode")
@@ -763,15 +763,14 @@
(when (and (not phps-mode-functions-buffer-changes-start)
(boundp 'phps-mode-idle-interval)
phps-mode-idle-interval)
- ;; (message "Enqueued incremental lexer")
-
+ (message "Enqueued incremental lexer")
(run-with-idle-timer phps-mode-idle-interval nil
#'phps-mode-lexer-run-incremental))
;; When point of change is not set or when start of new changes precedes
old change - update the point
(when (or (not phps-mode-functions-buffer-changes-start)
(< start phps-mode-functions-buffer-changes-start))
- ;; (message "Setting start of changes from %s to %s"
phps-mode-functions-buffer-changes-start start)
- (setq phps-mode-functions-buffer-changes-start start))
+ (setq phps-mode-functions-buffer-changes-start start)
+ (message "Setting start of changes to: %s-%s"
phps-mode-functions-buffer-changes-start stop))
;; (message "phps-mode-functions-after-change %s %s %s" start stop length)
))
@@ -811,9 +810,6 @@
(set (make-local-variable 'comment-start) "/* ")
(set (make-local-variable 'comment-end) " */")
- ;; TODO Make (uncomment-region) work
- ;; TODO Make selecting region and clicking ' wrap region in single quotes
-
;; Support for change detection
(add-hook 'after-change-functions #'phps-mode-functions-after-change))
diff --git a/phps-mode-lexer.el b/phps-mode-lexer.el
index 5438252..1a52fae 100644
--- a/phps-mode-lexer.el
+++ b/phps-mode-lexer.el
@@ -211,32 +211,37 @@
(cond
((or
+ (string= token 'T_STRING)
(string= token 'T_VARIABLE)
(string= token 'T_STRING_VARNAME))
(overlay-put (make-overlay start end) 'font-lock-face
'font-lock-variable-name-face))
- ((or (string= token 'T_STRING)
- (string= token 'T_NUM_STRING))
- (overlay-put (make-overlay start end) 'font-lock-face
'font-lock-string-face))
+ ((or (string= token 'T_FUNCTION))
+ (overlay-put (make-overlay start end) 'font-lock-face
'font-lock-function-name-face))
((string= token 'T_INLINE_HTML)
- (overlay-put (make-overlay start end) 'font-lock-face
'font-lock-reference-face))
+ (overlay-put (make-overlay start end) 'font-lock-face
'font-lock-comment-delimiter-face))
((string= token 'T_COMMENT)
(overlay-put (make-overlay start end) 'font-lock-face
'font-lock-comment-face))
((string= token 'T_DOC_COMMENT)
- (overlay-put (make-overlay start end) 'font-lock-face
'font-lock-comment-delimiter-face))
+ (overlay-put (make-overlay start end) 'font-lock-face 'font-lock-doc-face))
((or
(string= token 'T_CONSTANT_ENCAPSED_STRING)
(string= token 'T_ENCAPSED_AND_WHITESPACE)
+ (string= token 'T_NUM_STRING)
(string= token 'T_DNUMBER)
(string= token 'T_LNUMBER)
)
(overlay-put (make-overlay start end) 'font-lock-face
'font-lock-string-face))
((or
+ (string= token 'T_CONST))
+ (overlay-put (make-overlay start end) 'font-lock-face
'font-lock-constant-face))
+
+ ((or
(string= token "?")
(string= token "!")
(string= token "<")
@@ -257,8 +262,6 @@
(string= token 'T_NS_SEPARATOR)
(string= token 'T_EXIT)
(string= token 'T_DIE)
- (string= token 'T_FUNCTION)
- (string= token 'T_CONST)
(string= token 'T_RETURN)
(string= token 'T_YIELD_FROM)
(string= token 'T_YIELD)
@@ -1594,7 +1597,7 @@
(defun phps-mode-lexer-setup (start end)
"Just prepare other lexers for lexing region START to END."
- ;; (message "phps-mode-lexer-setup %s %s" start end)
+ (message "phps-mode-lexer-setup %s %s" start end)
;; Flag that buffer has not been processed
(when (and (boundp 'phps-mode-functions-processed-buffer)
@@ -1612,6 +1615,7 @@
(defun phps-mode-lexer-run ()
"Run lexer."
(interactive)
+ (message "Running lexer")
(setq phps-mode-lexer-tokens (semantic-lex-buffer)))
(defun phps-mode-lexer-move-states (start diff)
@@ -1662,6 +1666,7 @@
(defun phps-mode-lexer-run-incremental ()
"Run incremental lexer based on
`(phps-mode-functions-get-buffer-changes-start)'."
+ (message "Running incremental lexer")
(when (and (phps-mode-functions-get-buffer-changes-start)
phps-mode-lexer-states)
(let ((state nil)
@@ -1718,14 +1723,12 @@
(setq phps-mode-lexer-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, buffer point max: %s" change-start states (point-max)))
- (phps-mode-lexer-run)))
- (phps-mode-functions-reset-buffer-changes-start)))
+ (phps-mode-lexer-run))))
+ (phps-mode-functions-reset-buffer-changes-start))
(define-lex phps-mode-lexer-lex
"Call lexer analyzer action."
- [elpa] externals/phps-mode a0b7695 316/405: Passes unit tests for integration with electric-pair, (continued)
- [elpa] externals/phps-mode a0b7695 316/405: Passes unit tests for integration with electric-pair, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7c3a31a 305/405: Fixed bug in indentation with stacked assignment closures, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 68422f5 301/405: Restored indentation test for PSR-2 closure, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f3766db 310/405: Fixed byte-compilation in lexer and integration-tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2ec6f6d 306/405: Fixed some compilation warnings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f2fe751 302/405: More work on trying to get PSR-2 indentation working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8eb3dc0 311/405: Fixed byte-compilation issue in lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f77edf8 308/405: Updated compile command to ignore that files that doesn't compile, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5d5ec06 313/405: Started on test for automatic quotations, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7e755e1 303/405: Fixed indentation for argument assignments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a852669 320/405: Fix bug in syntax colouring, added debug outputs for incremental lexer,
Stefan Monnier <=
- [elpa] externals/phps-mode ad94b0b 319/405: Removed some fixed TODO itemsc, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2427c7e 318/405: Improved README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6d834c1 312/405: Added support for (comment-region) and (uncomment-region), Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b1d2820 309/405: Fixed issue with indentation of square bracket arrays in assignments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3bc2411 317/405: Moved syntax-table tests to own file, using local electric-pair-mode in PHPs buffers, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c2b8a16 335/405: Passes new test for concatenated string inside function arguments, Stefan Monnier, 2019/07/13
- [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