[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 2efebc8 10/28: Don't colorize if there are parse errors.
From: |
Jackson Ray Hamilton |
Subject: |
[elpa] master 2efebc8 10/28: Don't colorize if there are parse errors. |
Date: |
Tue, 05 May 2015 11:10:18 +0000 |
branch: master
commit 2efebc8963a71e0455fffacb0c0f3beba3909689
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>
Don't colorize if there are parse errors.
---
context-coloring.el | 58 ++++++++++++++++++++++++++------------------------
1 files changed, 30 insertions(+), 28 deletions(-)
diff --git a/context-coloring.el b/context-coloring.el
index 853a8e8..c7caa86 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -248,34 +248,36 @@ variable."
(defun context-coloring-js2-colorize ()
"Color the current buffer using the abstract syntax tree
generated by `js2-mode'."
- ;; Reset the hash table; the old one could be obsolete.
- (setq context-coloring-js2-scope-level-hash-table (make-hash-table :test
'eq))
- (with-silent-modifications
- (js2-visit-ast
- js2-mode-ast
- (lambda (node end-p)
- (when (null end-p)
- (cond
- ((js2-scope-p node)
- (context-coloring-js2-colorize-node
- node
- (context-coloring-js2-scope-level node)))
- ((context-coloring-js2-local-name-node-p node)
- (let* ((enclosing-scope (js2-node-get-enclosing-scope node))
- (defining-scope (js2-get-defining-scope
- enclosing-scope
- (js2-name-node-name node))))
- ;; The tree seems to be walked lexically, so an entire scope will
- ;; be colored, including its name nodes, before they are reached.
- ;; Coloring the nodes defined in that scope would be redundant, so
- ;; don't do it.
- (when (not (eq defining-scope enclosing-scope))
- (context-coloring-js2-colorize-node
- node
- (context-coloring-js2-scope-level defining-scope))))))
- ;; The `t' indicates to search children.
- t)))
- (context-coloring-maybe-colorize-comments-and-strings)))
+ ;; Don't bother trying to color a mangled tree.
+ (when (= 0 (length js2-parsed-errors))
+ ;; Reset the hash table; the old one could be obsolete.
+ (setq context-coloring-js2-scope-level-hash-table (make-hash-table :test
'eq))
+ (with-silent-modifications
+ (js2-visit-ast
+ js2-mode-ast
+ (lambda (node end-p)
+ (when (null end-p)
+ (cond
+ ((js2-scope-p node)
+ (context-coloring-js2-colorize-node
+ node
+ (context-coloring-js2-scope-level node)))
+ ((context-coloring-js2-local-name-node-p node)
+ (let* ((enclosing-scope (js2-node-get-enclosing-scope node))
+ (defining-scope (js2-get-defining-scope
+ enclosing-scope
+ (js2-name-node-name node))))
+ ;; The tree seems to be walked lexically, so an entire scope
will
+ ;; be colored, including its name nodes, before they are
reached.
+ ;; Coloring the nodes defined in that scope would be redundant,
so
+ ;; don't do it.
+ (when (not (eq defining-scope enclosing-scope))
+ (context-coloring-js2-colorize-node
+ node
+ (context-coloring-js2-scope-level defining-scope))))))
+ ;; The `t' indicates to search children.
+ t)))
+ (context-coloring-maybe-colorize-comments-and-strings))))
;;; Shell command scopification / colorization
- [elpa] master updated (510f0ff -> 8a083d5), Jackson Ray Hamilton, 2015/05/05
- [elpa] master f9a6dce 03/28: Coveralls, Jackson Ray Hamilton, 2015/05/05
- [elpa] master 7a9bd8d 07/28: Add async mode startup test., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 2efebc8 10/28: Don't colorize if there are parse errors.,
Jackson Ray Hamilton <=
- [elpa] master 30f9b0a 02/28: Update Cask file., Jackson Ray Hamilton, 2015/05/05
- [elpa] master fd5b9e1 05/28: Add tests for versions and disabling., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 85ff3ef 13/28: Trailing whitespace, empty arrays, empty strings., Jackson Ray Hamilton, 2015/05/05
- [elpa] master f11f97f 09/28: Make default colors more like font-lock's., Jackson Ray Hamilton, 2015/05/05
- [elpa] master a7f5970 04/28: Remove unused function., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 9873030 08/28: Use real keywords., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 0888e06 01/28: Use Cask and Coveralls., Jackson Ray Hamilton, 2015/05/05
- [elpa] master 202ca74 15/28: Drop `subr-x' dependency., Jackson Ray Hamilton, 2015/05/05
- [elpa] master dd3fe3c 06/28: Fix badges., Jackson Ray Hamilton, 2015/05/05
- [elpa] master fb53884 17/28: Update README., Jackson Ray Hamilton, 2015/05/05