emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 1c0155f 203/271: Don't color name nodes in their own scope


From: Jackson Ray Hamilton
Subject: [elpa] master 1c0155f 203/271: Don't color name nodes in their own scope.
Date: Thu, 05 Feb 2015 18:31:13 +0000

branch: master
commit 1c0155f575ae8733980c3449938102bde2f72fb5
Author: Jackson Ray Hamilton <address@hidden>
Commit: Jackson Ray Hamilton <address@hidden>

    Don't color name nodes in their own scope.
---
 context-coloring.el |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index ac941db..56e3e28 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -250,15 +250,6 @@ END (exclusive) with the face corresponding to LEVEL."
              (setq current-scope enclosing-scope))
            (puthash scope level 
context-coloring-js2-scope-level-hash-table)))))
 
-(defsubst context-coloring-js2-name-node-level (node)
-  (cond ((js2-node-top-level-decl-p node)
-         0)
-        (t
-         (context-coloring-js2-scope-level
-          (js2-get-defining-scope
-           (js2-node-get-enclosing-scope node)
-           (js2-name-node-name node))))))
-
 (defsubst context-coloring-js2-local-name-node-p (node)
   "Determines if NODE is a js2-name-node representing a local
 variable."
@@ -298,9 +289,18 @@ generated by js2-mode."
             node
             (context-coloring-js2-scope-level node)))
           ((context-coloring-js2-local-name-node-p node)
-           (context-coloring-js2-colorize-node
-            node
-            (context-coloring-js2-name-node-level 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)))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]