branch: externals/phps-mode
commit 673a801311dfbe90dd5f1875cbadc9af4a0af9ca
Author: Christian Johansson <[email protected]>
Commit: Christian Johansson <[email protected]>
Resolved issue of parser buffer not closing
---
TODO.md | 1 -
phps-mode-lex-analyzer.el | 100 ++++++++++++++++++++++------------------------
2 files changed, 48 insertions(+), 53 deletions(-)
diff --git a/TODO.md b/TODO.md
index d229472dab..0528c33773 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,7 +1,6 @@
# TODO
* Perform buffer changes in the middle of a token will make cache reuse lex
over point and this will distort the lex at point but not at points further down
-* *PHPs Parser* buffer are not closed
## Indentation
diff --git a/phps-mode-lex-analyzer.el b/phps-mode-lex-analyzer.el
index 71927a075a..7fcf4c20a4 100644
--- a/phps-mode-lex-analyzer.el
+++ b/phps-mode-lex-analyzer.el
@@ -1001,8 +1001,7 @@ of performed operations. Optionally do it
FORCE-SYNCHRONOUS."
"Loaded from file-system cache: %S"
loaded-from-cache))
loaded-from-cache)
- (let* ((buffer (generate-new-buffer "*PHPs Parser*"))
- (cache)
+ (let* ((cache)
(tokens)
(parse-error)
(parse-trail)
@@ -1016,56 +1015,53 @@ of performed operations. Optionally do it
FORCE-SYNCHRONOUS."
cache-key))
;; Create temporary buffer and run lexer in it
- (when (get-buffer buffer)
- (with-current-buffer buffer
- (insert contents)
-
- (let* ((current-time (current-time))
- (end-time
- (+
- (car current-time)
- (car (cdr current-time))
- (* (car (cdr (cdr current-time))) 0.000001))))
- (setq
- timer-start-parser
- end-time))
-
- ;; Error-free parse here
- (condition-case conditions
- (progn
- ;; This will implicitly run the parser as well
- (phps-mode-ast--generate))
- (error
- (setq
- parse-error
- conditions)))
-
- ;; Need to copy buffer-local values before killing buffer
-
- ;; Copy variables outside of buffer
- (setq cache phps-mode-lexer--cached)
- (setq tokens (nreverse phps-mode-lexer--generated-tokens))
- (setq parse-trail phps-mode-ast--parse-trail)
- (setq ast-tree phps-mode-ast--tree)
- (setq bookkeeping phps-mode-parser-sdt-bookkeeping)
- (setq imenu phps-mode-parser-sdt-symbol-imenu)
- (setq symbol-table phps-mode-parser-sdt-symbol-table)
-
- (let* ((current-time
- (current-time))
- (end-time
- (+
- (car current-time)
- (car (cdr current-time))
- (* (car (cdr (cdr current-time))) 0.000001))))
- (setq
- timer-finished-parser
- end-time)
- (setq
- timer-elapsed-parser
- (- timer-finished-parser timer-start-parser)))
-
- (kill-buffer)))
+ (with-temp-buffer
+ (insert contents)
+
+ (let* ((current-time (current-time))
+ (end-time
+ (+
+ (car current-time)
+ (car (cdr current-time))
+ (* (car (cdr (cdr current-time))) 0.000001))))
+ (setq
+ timer-start-parser
+ end-time))
+
+ ;; Error-free parse here
+ (condition-case conditions
+ (progn
+ ;; This will implicitly run the parser as well
+ (phps-mode-ast--generate))
+ (error
+ (setq
+ parse-error
+ conditions)))
+
+ ;; Need to copy buffer-local values before killing buffer
+
+ ;; Copy variables outside of buffer
+ (setq cache phps-mode-lexer--cached)
+ (setq tokens (nreverse phps-mode-lexer--generated-tokens))
+ (setq parse-trail phps-mode-ast--parse-trail)
+ (setq ast-tree phps-mode-ast--tree)
+ (setq bookkeeping phps-mode-parser-sdt-bookkeeping)
+ (setq imenu phps-mode-parser-sdt-symbol-imenu)
+ (setq symbol-table phps-mode-parser-sdt-symbol-table)
+
+ (let* ((current-time
+ (current-time))
+ (end-time
+ (+
+ (car current-time)
+ (car (cdr current-time))
+ (* (car (cdr (cdr current-time))) 0.000001))))
+ (setq
+ timer-finished-parser
+ end-time)
+ (setq
+ timer-elapsed-parser
+ (- timer-finished-parser timer-start-parser))))
(let ((data
(list