1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Highlighting of Nit AST
23 # Visitor used to produce a HTML tree based on a AST on a `Source`
24 class HighlightVisitor
25 # The root of the HTML hierarchy
26 var html
= new HTMLTag("span")
28 # Should the HTML include a nested `<span class"{type_of_node}">` element for each `ANode` of the AST?
30 # Used to have a really huge and verbose HTML (mainly for debug)
31 var with_ast
= false is writable
33 # Prefixes used in generated IDs for line `<span>` elements.
34 # Useful if more than one highlighted code is present in the same HTML document.
36 # If set to the empty string, id for lines are disabled.
38 # Is `"L"` by default.
39 var line_id_prefix
= "L" is writable
41 # The first line to generate, null if start at the first line
42 var first_line
: nullable Int = null is writable
44 # The last line to generate, null if finish at the last line
45 var last_line
: nullable Int = null is writable
47 # When highlighting a node, show its messages (errors, warnings), if any.
50 var show_messages
= true is writable
52 # When highlighting a node, attach a full popupable infobox, if any.
54 # If `false`, only a simple `title` tooltip is used.
57 var show_infobox
= true is writable
59 # A reference to an entity used in generated `<a>` elements.
61 # It is used to refer to some specific entities when generating links.
62 # If `null` is returned, then no link are generated and `<a>` elements become `<span>`.
64 # By default, `null` is returned.
65 # Clients are therefore encouraged to redefine the method in a subclass to control where entities should link to.
66 fun hrefto
(entity
: MEntity): nullable String do return null
70 html
.add_class
("nitcode")
73 # When highlighting a node, also consider the loose tokens around it.
75 # Loose tokens are tokens discarded from the AST but attached before
76 # or after some non-loose tokens. See `Token::is_loose`.
78 # When this flag is set to `true`, the loose tokens that are before the
79 # first token and after the last token are also highlighted.
82 var include_loose_tokens
= false is writable
84 # When highlighting a node, the first and the last lines are fully included.
86 # If the highlighted node starts (or ends) in the middle of a line,
87 # this flags forces the whole line to be highlighted.
90 var include_whole_lines
= false is writable
92 # The entry-point of the highlighting.
93 # Will fill `html` with the generated HTML content.
94 fun enter_visit
(n
: ANode)
107 if f
== null then return
109 if l
== null then return
112 if include_loose_tokens
then
113 if f
.prev_looses
.not_empty
then f
= f
.prev_looses
.first
114 if l
.next_looses
.not_empty
then l
= l
.next_looses
.last
117 if include_whole_lines
then
118 f
= f
.first_real_token_in_line
119 l
= l
.last_real_token_in_line
125 private fun full_tag
(anode
: ANode, hv
: HighlightVisitor): nullable HTMLTag
127 var tag
= anode
.make_tag
(hv
)
128 if tag
== null then return null
129 var infobox
= anode
.infobox
(hv
)
130 if infobox
== null and anode
isa Token then
131 var pa
= anode
.parent
133 infobox
= pa
.decorate_tag
(hv
, tag
, anode
)
136 if infobox
!= null and not show_infobox
then
137 tag
.attr
("title", infobox
.title
)
138 tag
.classes
.add
"titled"
141 var messages
= anode
.location
.messages
142 if messages
!= null and show_messages
then
143 tag
.css
("border-bottom", "solid 2px red")
144 if infobox
== null then
145 infobox
= new HInfoBox(hv
, "Messages")
147 var c
= infobox
.new_dropdown
("{messages.length} message(s)", "")
149 c
.open
("li").append
(m
.text
)
152 if infobox
!= null then
153 tag
.attach_infobox
(infobox
)
158 # Highlight a full lexed source file.
160 # REQUIRE `source.first_token != null`
161 fun hightlight_source
(source
: SourceFile)
163 htmlize
(source
.first_token
.as(not null), null)
166 # Produce HTML between two tokens
167 protected fun htmlize
(first_token
: Token, last_token
: nullable Token)
169 var stack2
= new Array[HTMLTag]
170 var stack
= new Array[Prod]
172 var c
: nullable Token = first_token
177 # Handle start of line
178 var cline
= c
.location
.line_start
179 if cline
!= line
then
180 # Handle starting block productions,
181 # Because c could be a detached token, get prods in
182 # the first AST token
183 var c0
= c
.first_token_in_line
185 if c0
!= null then starting
= c0
.starting_prods
186 if starting
!= null then for p
in starting
do
187 if not p
.is_block
then continue
188 var tag
= full_tag
(p
, hv
)
189 if tag
== null then continue
190 tag
.add_class
("foldable")
197 # Add a div for the whole line
198 var tag
= new HTMLTag("span")
199 var p
= line_id_prefix
200 if p
!= "" then tag
.attrs
["id"] = "{p}{cline}"
201 tag
.classes
.add
"line"
208 # Add the blank, verbatim
209 html
.add_raw_html c
.blank_before
211 # Handle starting span production
212 starting
= c
.starting_prods
213 if starting
!= null then for p
in starting
do
214 if not p
.is_span
then continue
215 var tag
= full_tag
(p
, hv
)
216 if tag
== null then continue
227 var tag
= full_tag
(c
, hv
)
228 if tag
!= null then html
.add tag
231 # Handle ending span productions
232 var ending
= c
.ending_prods
233 if ending
!= null then for p
in ending
do
234 if not p
.is_span
then continue
235 if stack
.is_empty
or p
!= stack
.last
then continue
240 # Handle end of line and end of file
242 if c
== last_token
then n
= null
243 if n
== null or n
.location
.line_start
!= line
then
244 # closes the line div
247 # close the block production divs
248 var c0
= c
.last_token_in_line
250 if c0
!= null then ending
= c0
.ending_prods
251 if ending
!= null then for p
in ending
do
252 if not p
.is_block
then continue
253 if stack
.is_empty
or p
!= stack
.last
then continue
261 #assert stack.is_empty
262 #assert stack2.is_empty
265 # Return a default CSS content related to CSS classes used in the `html` tree.
266 # Could be inlined in the `.html` file of saved as a specific `.css` file.
267 fun css_content
: String
270 .nitcode a { color: inherit; cursor:pointer; }
271 .nitcode .titled:hover { text-decoration: underline; } /* underline titles */
272 .nitcode .popupable:hover { text-decoration: underline; cursor:help; } /* underline titles */
273 .nitcode .foldable { display: block } /* for block productions*/
274 .nitcode .line{ display: block } /* for lines */
275 .nitcode .line:hover{ background-color: #FFFFE0; } /* current line */
276 .nitcode :target { background-color: #FFF3C2 } /* target highlight*/
277 /* lexical raw tokens. independent of usage or semantic: */
278 .nitcode .nc_c { color: gray; font-style: italic; } /* comment */
279 .nitcode .nc_d { color: #3D8127; font-style: italic; } /* documentation comments */
280 .nitcode .nc_k { font-weight: bold; } /* keyword */
281 .nitcode .nc_o {} /* operator */
282 .nitcode .nc_i {} /* standard identifier */
283 .nitcode .nc_t { color: #445588; font-weight: bold; } /* type/class identifier */
284 .nitcode .nc_a { color: #445588; font-style: italic; } /* old style attribute identifier */
285 .nitcode .nc_l { color: #009999; } /* char and number literal */
286 .nitcode .nc_s { color: #8F1546; } /* string literal */
287 /* syntactic token usage. added because of their position in the AST */
288 .nitcode .nc_ast { color: blue; } /* assert label */
289 .nitcode .nc_la { color: blue; } /* break/continue label */
290 .nitcode .nc_m { color: #445588; } /* module name */
291 /* syntactic groups */
292 .nitcode .nc_def { font-weight: bold; color: blue; } /* name used in a definition */
293 .nitcode .nc_def.nc_a { color: blue; } /* name used in a attribute definition */
294 .nitcode .nc_def.nc_t { color: blue; } /* name used in a class or vt definition */
295 .nitcode .nc_ss { color: #9E6BEB; } /* superstrings */
296 .nitcode .nc_cdef {} /* A whole class definition */
297 .nitcode .nc_pdef {} /* A whole property definition */
298 /* semantic token usage */
299 .nitcode .nc_v { font-style: italic; } /* local variable or parameter */
300 .nitcode .nc_vt { font-style: italic; } /* virtual type or formal type */
302 .nitcode .nc_error { border: 1px red solid;} /* not used */
303 .popover { max-width: 800px !important; }
307 # Additional content to inject in the <head> tag
308 # Note: does not include `css_content`; handle it yourself.
309 fun head_content
: String
311 return """<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">\n"""
314 # Additional content to inject just before the closing </body> tag
315 fun foot_content
: String
318 <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
319 <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
320 <script>$(".popupable").popover({html:true, placement:'top'})/*initialize bootstrap popover*/</script>"""
325 # Attach the infobox to the node by using BootStrap popover
326 fun attach_infobox
(infobox
: HInfoBox)
328 classes
.add
("popupable")
329 attrs
["title"] = infobox
.title
330 var href
= infobox
.href
332 attrs
["data-title"] = """<a href="{{{href}}}">{{{infobox.title}}}</a>"""
334 attrs
["data-content"] = infobox
.content
.write_to_string
335 attrs
["data-toggle"] = "popover"
340 # A generic information container that can be used to decorate AST entities
342 # The visitor used for contextualisation, if needed
343 var visitor
: HighlightVisitor
345 # A short title for the AST element
348 # The primary link where the entity points
350 var href
: nullable String = null
352 # The content of the popuped infobox
353 var content
= new HTMLTag("div")
355 # Append a new field in the popuped infobox
356 fun new_field
(title
: String): HTMLTag
358 content
.open
("b").text
(title
)
360 var res
= content
.open
("span")
365 # Append a new dropdown in the popuped content
366 fun new_dropdown
(title
, text
: String, text_is_html
: nullable Bool): HTMLTag
368 content
.add_raw_html
"""<div class="dropdown"> <a data-toggle="dropdown" href="#"><b>"""
369 content
.append
(title
)
370 content
.add_raw_html
"</b> "
371 if text_is_html
== true then
372 content
.add_raw_html
(text
)
373 else content
.append
(text
)
374 content
.add_raw_html
"""<span class="caret"></span></a>"""
375 var res
= content
.open
("ul").add_class
("dropdown-menu").attr
("role", "menu").attr
("aria-labelledby", "dLabel")
376 content
.add_raw_html
"</div>"
383 # Model entity or whatever that can produce an infobox
384 interface HInfoBoxable
385 # An new infobox documenting the entity
386 fun infobox
(v
: HighlightVisitor): HInfoBox is abstract
390 # Append an entry for the doc in the given infobox
391 fun fill_infobox
(res
: HInfoBox)
393 if content
.length
< 2 then
394 res
.new_field
("doc").text
(content
.first
)
397 var c
= res
.new_dropdown
("doc", content
.first
)
398 for x
in content
.iterator
.skip_head
(1) do
400 c
.add_raw_html
"<br>"
408 # A HTML version of `to_s` with hyper-links.
410 # By default, `linkto_text(v, to_s)` is used, c.f. see `linkto_text`.
412 # For some complex entities, like generic types, multiple `<a>` and `<span>` elements can be generated.
413 # E.g. `Array[Int]` might become `<a>Array</a>[<a>Int</a>]` with the correct `href` attributes
414 # provided by `v.hrefto`.
415 fun linkto
(v
: HighlightVisitor): HTMLTag do return linkto_text
(v
, to_s
)
417 # Link to the `self` with a specific text.
419 # The whole text is linked with a single `<a>` element.
421 # The `href` used is provided by `v.hrefto`.
422 # If `href` is null then a `<span>` element is used instead of `<a>`.
423 fun linkto_text
(v
: HighlightVisitor, text
: String): HTMLTag
425 var href
= v
.hrefto
(self)
427 return (new HTMLTag("span")).text
(text
)
429 return (new HTMLTag("a")).attr
("href", href
).text
(text
)
432 # Append an entry for the doc in the given infobox
433 private fun add_doc_to_infobox
(res
: HInfoBox)
435 var mdoc
= mdoc_or_fallback
436 if mdoc
!= null then mdoc
.fill_infobox
(res
)
443 var res
= new HInfoBox(v
, "module {name}")
444 res
.href
= v
.hrefto
(self)
445 res
.new_field
("module").add
(linkto
(v
))
446 add_doc_to_infobox
(res
)
447 if in_importation
.greaters
.length
> 1 then
448 var c
= res
.new_dropdown
("imports", "{in_importation.greaters.length-1} modules")
449 for x
in in_importation
.greaters
do
450 if x
== self then continue
451 c
.open
("li").add x
.linkto
(v
)
457 redef fun linkto
(v
) do return linkto_text
(v
, name
)
460 redef class MClassDef
463 var res
= new HInfoBox(v
, "class {mclass.name}")
464 res
.href
= v
.hrefto
(self)
466 res
.new_field
("class").text
(mclass
.name
)
468 res
.new_field
("redef class").text
(mclass
.name
)
469 res
.new_field
("intro").add mclass
.intro
.linkto_text
(v
, "in {mclass.intro_mmodule.to_s}")
471 add_doc_to_infobox
(res
)
473 var in_hierarchy
= self.in_hierarchy
474 if in_hierarchy
== null then return res
476 if in_hierarchy
.greaters
.length
> 1 then
477 var c
= res
.new_dropdown
("hier", "super-classes")
478 for x
in in_hierarchy
.greaters
do
479 if x
== self then continue
480 if not x
.is_intro
then continue
481 c
.open
("li").add x
.linkto
(v
)
484 if in_hierarchy
.smallers
.length
> 1 then
485 var c
= res
.new_dropdown
("hier", "sub-classes")
486 for x
in in_hierarchy
.smallers
do
487 if x
== self then continue
488 if not x
.is_intro
then continue
489 c
.open
("li").add x
.linkto
(v
)
492 if mclass
.mclassdefs
.length
> 1 then
493 var c
= res
.new_dropdown
("redefs", "refinements")
494 for x
in mclass
.mclassdefs
do
495 if x
== self then continue
496 c
.open
("li").add x
.linkto_text
(v
, "in {x.mmodule}")
506 var res
= new HInfoBox(v
, to_s
)
507 res
.href
= v
.hrefto
(self)
508 if self isa MMethodDef then
509 var msignature
= self.msignature
510 if msignature
!= null then res
.new_field
("fun").append
(mproperty
.name
).add msignature
.linkto
(v
)
511 else if self isa MAttributeDef then
512 var static_mtype
= self.static_mtype
513 if static_mtype
!= null then res
.new_field
("fun").append
(mproperty
.name
).add static_mtype
.linkto
(v
)
514 else if self isa MVirtualTypeDef then
515 var bound
= self.bound
516 if bound
!= null then res
.new_field
("add").append
(mproperty
.name
).add bound
.linkto
(v
)
518 res
.new_field
("wat?").append
(mproperty
.name
)
523 res
.new_field
("intro").add mproperty
.intro
.linkto_text
(v
, "in {mproperty.intro.mclassdef}")
525 add_doc_to_infobox
(res
)
526 if mproperty
.mpropdefs
.length
> 1 then
527 var c
= res
.new_dropdown
("redef", "redefinitions")
528 for x
in mproperty
.mpropdefs
do
529 c
.open
("li").add x
.linkto_text
(v
, "in {x.mclassdef}")
537 redef class MClassType
540 var res
= new HInfoBox(v
, to_s
)
541 res
.href
= v
.hrefto
(self)
542 res
.new_field
("class").add mclass
.intro
.linkto
(v
)
543 add_doc_to_infobox
(res
)
548 return mclass
.intro
.linkto
(v
)
551 redef class MVirtualType
554 var res
= new HInfoBox(v
, to_s
)
555 res
.href
= v
.hrefto
(mproperty
)
557 res
.new_field
("virtual type").add p
.intro
.linkto
(v
)
558 add_doc_to_infobox
(res
)
563 return mproperty
.intro
.linkto
(v
)
566 redef class MParameterType
569 var res
= new HInfoBox(v
, to_s
)
570 res
.new_field
("parameter type").append
("{name} from class ").add mclass
.intro
.linkto
(v
)
575 redef class MNullableType
578 return mtype
.infobox
(v
)
582 var res
= new HTMLTag("span")
583 res
.append
("nullable ").add
(mtype
.linkto
(v
))
588 redef class MNotNullType
591 return mtype
.infobox
(v
)
595 var res
= new HTMLTag("span")
596 res
.append
("not null ").add
(mtype
.linkto
(v
))
601 redef class MNullType
604 var res
= new HInfoBox(v
, to_s
)
609 var res
= new HTMLTag("span")
615 redef class MSignature
618 var res
= new HTMLTag("span")
620 if not mparameters
.is_empty
then
622 for p
in mparameters
do
630 res
.add p
.mtype
.linkto
(v
)
634 var ret
= return_mtype
637 res
.add ret
.linkto
(v
)
646 var res
= new HInfoBox(v
, "call {mpropdef}")
647 res
.href
= v
.hrefto
(mpropdef
)
648 res
.new_field
("call").add
(mpropdef
.linkto
(v
)).add
(msignature
.linkto
(v
))
649 if mpropdef
.is_intro
then
651 res
.new_field
("intro").add mproperty
.intro
.linkto_text
(v
, "in {mproperty.intro.mclassdef}")
653 add_doc_to_infobox
(res
)
659 return mpropdef
.linkto
(v
)
667 var declared_type
= self.declared_type
668 if declared_type
== null then
669 var res
= new HInfoBox(v
, "{name}")
670 res
.new_field
("local var").append
("{name}")
673 var res
= new HInfoBox(v
, "{name}: {declared_type}")
674 res
.new_field
("local var").append
("{name}:").add
(declared_type
.linkto
(v
))
683 # Optionally creates a tag that encapsulate the AST element on HTML rendering
684 protected fun make_tag
(v
: HighlightVisitor): nullable HTMLTag do return null
686 # Add aditionnal information on a child-token and return an additionnal HInfoBox on it
687 protected fun decorate_tag
(v
: HighlightVisitor, res
: HTMLTag, token
: Token): nullable HInfoBox
689 #debug("no decoration for {token.inspect}")
690 #res.add_class("nc_error")
694 # Return a optional infobox
695 fun infobox
(v
: HighlightVisitor): nullable HInfoBox do return null
698 redef class AQclassid
699 redef fun decorate_tag
(v
, res
, token
)
701 if token
!= n_id
then return null
702 var parent
= self.parent
703 if parent
== null then return null
704 return parent
.decorate_tag
(v
, res
, token
)
709 redef fun decorate_tag
(v
, res
, token
)
711 if token
!= n_id
then return null
712 var parent
= self.parent
713 if parent
== null then return null
714 return parent
.decorate_tag
(v
, res
, token
)
718 redef class AStdClassdef
719 redef fun make_tag
(v
)
721 var res
= new HTMLTag("span")
722 res
.add_class
("nc_cdef")
724 if md
!= null then res
.attr
("id", md
.to_s
)
727 redef fun decorate_tag
(v
, res
, token
)
729 if not token
isa TClassid then return null
730 res
.add_class
("nc_def")
733 if md
== null then return null
738 redef fun make_tag
(v
)
740 var res
= new HTMLTag("span")
741 res
.add_class
("nc_pdef")
746 res
.attr
("id", mpd
.to_s
)
748 if self isa AAttrPropdef then
750 if mpd
!= null then res
.add
(tag
(mpd
))
752 if mpd
!= null then res
.add
(tag
(mpd
))
757 private fun tag
(mpd
: MPropDef): HTMLTag
759 var a
= new HTMLTag("a")
760 a
.attr
("id", mpd
.to_s
)
766 # Produce an HTMLTag with the correct contents and CSS classes
767 # Subclasses can redefine it to decorate the tag
768 redef fun make_tag
(v
): HTMLTag
770 var res
= new HTMLTag("span")
776 redef class TokenKeyword
777 redef fun make_tag
(v
)
780 res
.add_class
("nc_k")
784 redef class TokenOperator
785 redef fun make_tag
(v
)
788 res
.add_class
("nc_o")
793 redef class AVarFormExpr
794 redef fun decorate_tag
(v
, res
, token
)
796 if token
!= n_id
then return null
797 var variable
= self.variable
798 if variable
== null then return null
799 res
.add_class
("nc_v")
800 return variable
.infobox
(v
)
804 redef class AVardeclExpr
805 redef fun decorate_tag
(v
, res
, token
)
807 if token
!= n_id
then return null
808 var variable
= self.variable
809 if variable
== null then return null
810 res
.add_class
("nc_v")
811 return variable
.infobox
(v
)
815 redef class AForGroup
816 redef fun decorate_tag
(v
, res
, token
)
818 if not token
isa TId then return null
820 if vs
== null then return null
821 res
.add_class
("nc_v")
822 var idx
= n_ids
.index_of
(token
)
823 var variable
= vs
[idx
]
824 return variable
.infobox
(v
)
829 redef fun decorate_tag
(v
, res
, token
)
831 if token
!= n_id
then return null
833 if mp
== null then return null
834 var variable
= self.variable
835 if variable
== null then return null
836 res
.add_class
("nc_v")
837 return variable
.infobox
(v
)
841 redef class AAssertExpr
842 redef fun decorate_tag
(v
, res
, token
)
844 if not token
isa TId then return null
845 res
.add_class
("nc_ast")
851 redef fun decorate_tag
(v
, res
, token
)
853 if not token
isa TId then return null
854 res
.add_class
("nc_la")
859 redef class ASendExpr
860 redef fun decorate_tag
(v
, res
, token
)
862 var callsite
= self.callsite
863 if callsite
== null then return null
864 return callsite
.infobox
(v
)
869 redef fun decorate_tag
(v
, res
, token
)
871 var callsite
= self.callsite
872 if callsite
== null then return null
873 return callsite
.infobox
(v
)
877 redef class AAssignOp
878 redef fun decorate_tag
(v
, res
, token
)
881 assert p
isa AReassignFormExpr
883 var callsite
= p
.reassign_callsite
884 if callsite
== null then return null
885 return callsite
.infobox
(v
)
889 redef class AModuleName
890 redef fun decorate_tag
(v
, res
, token
)
893 if p
== null then return null
894 return p
.decorate_tag
(v
, res
, token
)
898 redef class AModuledecl
899 redef fun decorate_tag
(v
, res
, token
)
901 if not token
isa TId then return null
902 res
.add_class
("nc_def")
903 res
.add_class
("nc_m")
907 if mm
== null then return null
912 redef class AStdImport
913 redef fun decorate_tag
(v
, res
, token
)
915 if not token
isa TId then return null
916 res
.add_class
("nc_m")
918 if mm
== null then return null
922 redef class AAttrPropdef
923 redef fun decorate_tag
(v
, res
, token
)
925 if not token
isa TId then return null
926 res
.add_class
("nc_def")
927 var mpd
: nullable MPropDef
929 if mpd
== null then mpd
= mpropdef
930 if mpd
== null then return null
931 return mpd
.infobox
(v
)
936 redef fun make_tag
(v
)
939 res
.add_class
("nc_i")
944 redef fun make_tag
(v
)
946 var res
= new HTMLTag("span")
947 res
.add_class
("nc_def")
950 redef fun decorate_tag
(v
, res
, token
)
953 # nothing to decorate
958 if not p
isa AMethPropdef then return null
960 if mpd
== null then return null
961 return mpd
.infobox
(v
)
965 redef fun make_tag
(v
)
968 res
.add_class
("nc_a")
972 redef class AAttrFormExpr
973 redef fun decorate_tag
(v
, res
, token
)
975 if not token
isa TAttrid then return null
977 if p
== null then return null
978 return p
.intro
.infobox
(v
)
982 redef fun make_tag
(v
)
985 res
.add_class
("nc_t")
990 redef fun decorate_tag
(v
, res
, token
)
992 if not token
isa TClassid then return null
994 if mt
== null then return null
996 if mt
isa MFormalType then
997 res
.add_class
("nc_vt")
1002 redef class AFormaldef
1003 redef fun decorate_tag
(v
, res
, token
)
1005 if not token
isa TClassid then return null
1006 res
.add_class
("nc_vt")
1007 var mtype
= self.mtype
1008 if mtype
== null then return null
1009 return mtype
.infobox
(v
)
1012 redef class ATypePropdef
1013 redef fun decorate_tag
(v
, res
, token
)
1015 if not token
isa TClassid then return null
1016 res
.add_class
("nc_def")
1018 if md
== null then return null
1019 return md
.infobox
(v
)
1022 redef class TComment
1023 redef fun make_tag
(v
)
1027 res
.add_class
("nc_c")
1033 redef fun make_tag
(v
)
1035 var res
= new HTMLTag("span")
1036 res
.add_class
("nc_d")
1040 redef class TokenLiteral
1041 redef fun make_tag
(v
)
1044 res
.add_class
("nc_l")
1048 redef class ASuperstringExpr
1049 redef fun make_tag
(v
)
1051 var res
= new HTMLTag("span")
1052 res
.add_class
("nc_ss")
1056 redef class AStringFormExpr
1057 redef fun decorate_tag
(v
, res
, token
)
1059 # Workaround to tag strings
1060 res
.classes
.remove
("nc_l")
1061 res
.add_class
("nc_s")
1066 redef fun decorate_tag
(v
, res
, token
)
1069 if t
== null then return null