highlight: can hightlight a full source file (not a specific node)
authorJean Privat <jean@pryen.org>
Fri, 10 Jun 2016 13:46:21 +0000 (09:46 -0400)
committerJean Privat <jean@pryen.org>
Fri, 10 Jun 2016 13:46:21 +0000 (09:46 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/highlight.nit

index 59e5370..75a6a8d 100644 (file)
@@ -131,8 +131,16 @@ class HighlightVisitor
                return tag
        end
 
+       # Highlight a full lexed source file.
+       #
+       # REQUIRE `source.first_token != null`
+       fun hightlight_source(source: SourceFile)
+       do
+               htmlize(source.first_token.as(not null), null)
+       end
+
        # Produce HTML between two tokens
-       protected fun htmlize(first_token, last_token: Token)
+       protected fun htmlize(first_token: Token, last_token: nullable Token)
        do
                var stack2 = new Array[HTMLTag]
                var stack = new Array[Prod]