highlight: rename enter_visit and htmlize (and fix spell of hightlight)
authorJean Privat <jean@pryen.org>
Wed, 29 Nov 2017 18:44:16 +0000 (13:44 -0500)
committerJean Privat <jean@pryen.org>
Wed, 29 Nov 2017 19:26:34 +0000 (14:26 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/highlight.nit
src/nitlight.nit
src/test_highlight.nit

index f654c3e..da18cce 100644 (file)
@@ -188,9 +188,8 @@ class HighlightVisitor
        # Default: false
        var include_whole_lines = false is writable
 
-       # The entry-point of the highlighting.
-       # Will fill `html` with the generated HTML content.
-       fun enter_visit(n: ANode)
+       # Highlight a AST element.
+       fun highlight_node(n: ANode)
        do
                n.parentize_tokens
 
@@ -234,7 +233,7 @@ class HighlightVisitor
                        l = l.last_real_token_in_line
                end
 
-               htmlize(f, l)
+               do_highlight(f, l)
        end
 
        private fun full_tag(anode: ANode, hv: HighlightVisitor): nullable HTMLTag
@@ -273,13 +272,13 @@ class HighlightVisitor
        # Highlight a full lexed source file.
        #
        # REQUIRE `source.first_token != null`
-       fun hightlight_source(source: SourceFile)
+       fun highlight_source(source: SourceFile)
        do
-               htmlize(source.first_token.as(not null), null)
+               do_highlight(source.first_token.as(not null), null)
        end
 
-       # Produce HTML between two tokens
-       protected fun htmlize(first_token: Token, last_token: nullable Token)
+       # Low-level highlighting between 2 tokens
+       protected fun do_highlight(first_token: Token, last_token: nullable Token)
        do
                var stack2 = new Array[HTMLTag]
                var stack = new Array[Prod]
index 2c66ce7..269d0c2 100644 (file)
@@ -150,7 +150,7 @@ for mm in mmodules do
                page.add_raw_html v.head_content
                page.add_raw_html "</head><body><pre class='nit_code'>"
        end
-       v.enter_visit(m)
+       v.highlight_node(m)
        if not opt_fragment.value then
                page.add(v.html)
                page.add_raw_html "</pre>"
index 13384f6..8c66462 100644 (file)
@@ -41,7 +41,7 @@ do
                var n = mb.mpropdef2node(pd)
                if not n isa APropdef then continue
                var hl = new TestHighlightVisitor
-               hl.enter_visit(n)
+               hl.highlight_node(n)
                print "<h1 id=\"{pd.c_name}\">{pd.full_name}</h1>"
                printn "<pre><code>"
                hl.html.write_to(stdout)
@@ -69,7 +69,7 @@ class THLVisitor
                        seen.add cn
 
                        var hl = new TestHighlightVisitor
-                       hl.enter_visit(n)
+                       hl.highlight_node(n)
                        print "<h2>AST node: {cn} at {n.location}</h2>"
                        printn "<pre><code>"
                        hl.html.write_to(stdout)