highlight: only highlight the given node, not the whole AST
authorJean Privat <jean@pryen.org>
Sat, 17 Oct 2015 02:30:31 +0000 (22:30 -0400)
committerJean Privat <jean@pryen.org>
Sat, 17 Oct 2015 02:30:31 +0000 (22:30 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/highlight.nit

index 2a139ee..7bce52d 100644 (file)
@@ -53,8 +53,22 @@ class HighlightVisitor
        fun enter_visit(n: ANode)
        do
                n.parentize_tokens
-               var s = n.location.file
-               htmlize(s.first_token.as(not null), s.last_token.as(not null))
+
+               var f
+               var l
+
+               if n isa Token then
+                       f = n
+                       l = n
+               else
+                       assert n isa Prod
+                       f = n.first_token
+                       if f == null then return
+                       l = n.last_token
+                       if l == null then return
+               end
+
+               htmlize(f, l)
        end
 
        private fun full_tag(anode: ANode, hv: HighlightVisitor): nullable HTMLTag