Merge: hightlight: improve infrastructure
[nit.git] / src / highlight.nit
index 4a2166c..d11b6f7 100644 (file)
@@ -145,8 +145,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]
@@ -702,6 +710,22 @@ redef class ANode
        fun infobox(v: HighlightVisitor): nullable HInfoBox do return null
 end
 
+redef class AQclassid
+       redef fun decorate_tag(v, res, token)
+       do
+               if token != n_id then return null
+               return parent.decorate_tag(v, res, token)
+       end
+end
+
+redef class AQid
+       redef fun decorate_tag(v, res, token)
+       do
+               if token != n_id then return null
+               return parent.decorate_tag(v, res, token)
+       end
+end
+
 redef class AStdClassdef
        redef fun make_tag(v)
        do