X-Git-Url: http://nitlanguage.org diff --git a/src/highlight.nit b/src/highlight.nit index 35d7d2e..3005aa7 100644 --- a/src/highlight.nit +++ b/src/highlight.nit @@ -122,7 +122,8 @@ class HighlightVisitor # The root of the HTML hierarchy var html = new HTMLTag("span") - # Is the HTML include a nested `` element for each `ANode` of the AST? + # Should the HTML include a nested `` element for each `ANode` of the AST? + # # Used to have a really huge and verbose HTML (mainly for debug) var with_ast = false is writable @@ -159,7 +160,7 @@ class HighlightVisitor # # By default, `null` is returned. # Clients are therefore encouraged to redefine the method in a subclass to control where entities should link to. - fun hrefto(entitiy: MEntity): nullable String do return null + fun hrefto(entity: MEntity): nullable String do return null init do @@ -210,6 +211,22 @@ class HighlightVisitor if l.next_looses.not_empty then l = l.next_looses.last end + var line = first_line + if line != null then + while f.location.line_start < line do + f = f.next_token + if f == null then return + end + end + + line = last_line + if line != null then + while l.location.line_end > line do + l = l.prev_token + if l == null then return + end + end + if include_whole_lines then f = f.first_real_token_in_line l = l.last_real_token_in_line @@ -317,7 +334,7 @@ class HighlightVisitor end # Add the token - if c isa TEol then + if c isa TEol then html.append "\n" else var tag = full_tag(c, hv) @@ -354,8 +371,7 @@ class HighlightVisitor c = n end - #assert stack.is_empty - #assert stack2.is_empty + if not stack2.is_empty then html = stack2.first end # Return a default CSS content related to CSS classes used in the `html` tree. @@ -459,12 +475,14 @@ class HInfoBox end # Append a new dropdown in the popuped content - fun new_dropdown(title, text: String): HTMLTag + fun new_dropdown(title, text: String, text_is_html: nullable Bool): HTMLTag do content.add_raw_html """" @@ -648,8 +666,8 @@ redef class MVirtualType var res = new HInfoBox(v, to_s) res.href = v.hrefto(mproperty) var p = mproperty + res.new_field("virtual type").add p.intro.linkto(v) add_doc_to_infobox(res) - if mdoc != null then mdoc.fill_infobox(res) return res end redef fun linkto(v)