66e1cd932010984a63f39ea4355cc39c034a2abf
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): 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> "
372 content
.add_raw_html
"""<span class="caret"></span></a>"""
373 var res
= content
.open
("ul").add_class
("dropdown-menu").attr
("role", "menu").attr
("aria-labelledby", "dLabel")
374 content
.add_raw_html
"</div>"
381 # Model entity or whatever that can produce an infobox
382 interface HInfoBoxable
383 # An new infobox documenting the entity
384 fun infobox
(v
: HighlightVisitor): HInfoBox is abstract
388 # Append an entry for the doc in the given infobox
389 fun fill_infobox
(res
: HInfoBox)
391 if content
.length
< 2 then
392 res
.new_field
("doc").text
(content
.first
)
395 var c
= res
.new_dropdown
("doc", content
.first
)
396 for x
in content
.iterator
.skip_head
(1) do
398 c
.add_raw_html
"<br>"
406 # A HTML version of `to_s` with hyper-links.
408 # By default, `linkto_text(v, to_s)` is used, c.f. see `linkto_text`.
410 # For some complex entities, like generic types, multiple `<a>` and `<span>` elements can be generated.
411 # E.g. `Array[Int]` might become `<a>Array</a>[<a>Int</a>]` with the correct `href` attributes
412 # provided by `v.hrefto`.
413 fun linkto
(v
: HighlightVisitor): HTMLTag do return linkto_text
(v
, to_s
)
415 # Link to the `self` with a specific text.
417 # The whole text is linked with a single `<a>` element.
419 # The `href` used is provided by `v.hrefto`.
420 # If `href` is null then a `<span>` element is used instead of `<a>`.
421 fun linkto_text
(v
: HighlightVisitor, text
: String): HTMLTag
423 var href
= v
.hrefto
(self)
425 return (new HTMLTag("span")).text
(text
)
427 return (new HTMLTag("a")).attr
("href", href
).text
(text
)
430 # Append an entry for the doc in the given infobox
431 private fun add_doc_to_infobox
(res
: HInfoBox)
433 var mdoc
= mdoc_or_fallback
434 if mdoc
!= null then mdoc
.fill_infobox
(res
)
441 var res
= new HInfoBox(v
, "module {name}")
442 res
.href
= v
.hrefto
(self)
443 res
.new_field
("module").add
(linkto
(v
))
444 add_doc_to_infobox
(res
)
445 if in_importation
.greaters
.length
> 1 then
446 var c
= res
.new_dropdown
("imports", "{in_importation.greaters.length-1} modules")
447 for x
in in_importation
.greaters
do
448 if x
== self then continue
449 c
.open
("li").add x
.linkto
(v
)
455 redef fun linkto
(v
) do return linkto_text
(v
, name
)
458 redef class MClassDef
461 var res
= new HInfoBox(v
, "class {mclass.name}")
462 res
.href
= v
.hrefto
(self)
464 res
.new_field
("class").text
(mclass
.name
)
466 res
.new_field
("redef class").text
(mclass
.name
)
467 res
.new_field
("intro").add mclass
.intro
.linkto_text
(v
, "in {mclass.intro_mmodule.to_s}")
469 add_doc_to_infobox
(res
)
471 var in_hierarchy
= self.in_hierarchy
472 if in_hierarchy
== null then return res
474 if in_hierarchy
.greaters
.length
> 1 then
475 var c
= res
.new_dropdown
("hier", "super-classes")
476 for x
in in_hierarchy
.greaters
do
477 if x
== self then continue
478 if not x
.is_intro
then continue
479 c
.open
("li").add x
.linkto
(v
)
482 if in_hierarchy
.smallers
.length
> 1 then
483 var c
= res
.new_dropdown
("hier", "sub-classes")
484 for x
in in_hierarchy
.smallers
do
485 if x
== self then continue
486 if not x
.is_intro
then continue
487 c
.open
("li").add x
.linkto
(v
)
490 if mclass
.mclassdefs
.length
> 1 then
491 var c
= res
.new_dropdown
("redefs", "refinements")
492 for x
in mclass
.mclassdefs
do
493 if x
== self then continue
494 c
.open
("li").add x
.linkto_text
(v
, "in {x.mmodule}")
504 var res
= new HInfoBox(v
, to_s
)
505 res
.href
= v
.hrefto
(self)
506 if self isa MMethodDef then
507 var msignature
= self.msignature
508 if msignature
!= null then res
.new_field
("fun").append
(mproperty
.name
).add msignature
.linkto
(v
)
509 else if self isa MAttributeDef then
510 var static_mtype
= self.static_mtype
511 if static_mtype
!= null then res
.new_field
("fun").append
(mproperty
.name
).add static_mtype
.linkto
(v
)
512 else if self isa MVirtualTypeDef then
513 var bound
= self.bound
514 if bound
!= null then res
.new_field
("add").append
(mproperty
.name
).add bound
.linkto
(v
)
516 res
.new_field
("wat?").append
(mproperty
.name
)
521 res
.new_field
("intro").add mproperty
.intro
.linkto_text
(v
, "in {mproperty.intro.mclassdef}")
523 add_doc_to_infobox
(res
)
524 if mproperty
.mpropdefs
.length
> 1 then
525 var c
= res
.new_dropdown
("redef", "redefinitions")
526 for x
in mproperty
.mpropdefs
do
527 c
.open
("li").add x
.linkto_text
(v
, "in {x.mclassdef}")
535 redef class MClassType
538 var res
= new HInfoBox(v
, to_s
)
539 res
.href
= v
.hrefto
(self)
540 res
.new_field
("class").add mclass
.intro
.linkto
(v
)
541 add_doc_to_infobox
(res
)
546 return mclass
.intro
.linkto
(v
)
549 redef class MVirtualType
552 var res
= new HInfoBox(v
, to_s
)
553 res
.href
= v
.hrefto
(mproperty
)
555 res
.new_field
("virtual type").add p
.intro
.linkto
(v
)
556 add_doc_to_infobox
(res
)
561 return mproperty
.intro
.linkto
(v
)
564 redef class MParameterType
567 var res
= new HInfoBox(v
, to_s
)
568 res
.new_field
("parameter type").append
("{name} from class ").add mclass
.intro
.linkto
(v
)
573 redef class MNullableType
576 return mtype
.infobox
(v
)
580 var res
= new HTMLTag("span")
581 res
.append
("nullable ").add
(mtype
.linkto
(v
))
586 redef class MNotNullType
589 return mtype
.infobox
(v
)
593 var res
= new HTMLTag("span")
594 res
.append
("not null ").add
(mtype
.linkto
(v
))
599 redef class MNullType
602 var res
= new HInfoBox(v
, to_s
)
607 var res
= new HTMLTag("span")
613 redef class MSignature
616 var res
= new HTMLTag("span")
618 if not mparameters
.is_empty
then
620 for p
in mparameters
do
628 res
.add p
.mtype
.linkto
(v
)
632 var ret
= return_mtype
635 res
.add ret
.linkto
(v
)
644 var res
= new HInfoBox(v
, "call {mpropdef}")
645 res
.href
= v
.hrefto
(mpropdef
)
646 res
.new_field
("call").add
(mpropdef
.linkto
(v
)).add
(msignature
.linkto
(v
))
647 if mpropdef
.is_intro
then
649 res
.new_field
("intro").add mproperty
.intro
.linkto_text
(v
, "in {mproperty.intro.mclassdef}")
651 add_doc_to_infobox
(res
)
657 return mpropdef
.linkto
(v
)
665 var declared_type
= self.declared_type
666 if declared_type
== null then
667 var res
= new HInfoBox(v
, "{name}")
668 res
.new_field
("local var").append
("{name}")
671 var res
= new HInfoBox(v
, "{name}: {declared_type}")
672 res
.new_field
("local var").append
("{name}:").add
(declared_type
.linkto
(v
))
681 # Optionally creates a tag that encapsulate the AST element on HTML rendering
682 protected fun make_tag
(v
: HighlightVisitor): nullable HTMLTag do return null
684 # Add aditionnal information on a child-token and return an additionnal HInfoBox on it
685 protected fun decorate_tag
(v
: HighlightVisitor, res
: HTMLTag, token
: Token): nullable HInfoBox
687 #debug("no decoration for {token.inspect}")
688 #res.add_class("nc_error")
692 # Return a optional infobox
693 fun infobox
(v
: HighlightVisitor): nullable HInfoBox do return null
696 redef class AQclassid
697 redef fun decorate_tag
(v
, res
, token
)
699 if token
!= n_id
then return null
700 var parent
= self.parent
701 if parent
== null then return null
702 return parent
.decorate_tag
(v
, res
, token
)
707 redef fun decorate_tag
(v
, res
, token
)
709 if token
!= n_id
then return null
710 var parent
= self.parent
711 if parent
== null then return null
712 return parent
.decorate_tag
(v
, res
, token
)
716 redef class AStdClassdef
717 redef fun make_tag
(v
)
719 var res
= new HTMLTag("span")
720 res
.add_class
("nc_cdef")
722 if md
!= null then res
.attr
("id", md
.to_s
)
725 redef fun decorate_tag
(v
, res
, token
)
727 if not token
isa TClassid then return null
728 res
.add_class
("nc_def")
731 if md
== null then return null
736 redef fun make_tag
(v
)
738 var res
= new HTMLTag("span")
739 res
.add_class
("nc_pdef")
744 res
.attr
("id", mpd
.to_s
)
746 if self isa AAttrPropdef then
748 if mpd
!= null then res
.add
(tag
(mpd
))
750 if mpd
!= null then res
.add
(tag
(mpd
))
755 private fun tag
(mpd
: MPropDef): HTMLTag
757 var a
= new HTMLTag("a")
758 a
.attr
("id", mpd
.to_s
)
764 # Produce an HTMLTag with the correct contents and CSS classes
765 # Subclasses can redefine it to decorate the tag
766 redef fun make_tag
(v
): HTMLTag
768 var res
= new HTMLTag("span")
774 redef class TokenKeyword
775 redef fun make_tag
(v
)
778 res
.add_class
("nc_k")
782 redef class TokenOperator
783 redef fun make_tag
(v
)
786 res
.add_class
("nc_o")
791 redef class AVarFormExpr
792 redef fun decorate_tag
(v
, res
, token
)
794 if token
!= n_id
then return null
795 var variable
= self.variable
796 if variable
== null then return null
797 res
.add_class
("nc_v")
798 return variable
.infobox
(v
)
802 redef class AVardeclExpr
803 redef fun decorate_tag
(v
, res
, token
)
805 if token
!= n_id
then return null
806 var variable
= self.variable
807 if variable
== null then return null
808 res
.add_class
("nc_v")
809 return variable
.infobox
(v
)
813 redef class AForGroup
814 redef fun decorate_tag
(v
, res
, token
)
816 if not token
isa TId then return null
818 if vs
== null then return null
819 res
.add_class
("nc_v")
820 var idx
= n_ids
.index_of
(token
)
821 var variable
= vs
[idx
]
822 return variable
.infobox
(v
)
827 redef fun decorate_tag
(v
, res
, token
)
829 if token
!= n_id
then return null
831 if mp
== null then return null
832 var variable
= self.variable
833 if variable
== null then return null
834 res
.add_class
("nc_v")
835 return variable
.infobox
(v
)
839 redef class AAssertExpr
840 redef fun decorate_tag
(v
, res
, token
)
842 if not token
isa TId then return null
843 res
.add_class
("nc_ast")
849 redef fun decorate_tag
(v
, res
, token
)
851 if not token
isa TId then return null
852 res
.add_class
("nc_la")
857 redef class ASendExpr
858 redef fun decorate_tag
(v
, res
, token
)
860 var callsite
= self.callsite
861 if callsite
== null then return null
862 return callsite
.infobox
(v
)
867 redef fun decorate_tag
(v
, res
, token
)
869 var callsite
= self.callsite
870 if callsite
== null then return null
871 return callsite
.infobox
(v
)
875 redef class AAssignOp
876 redef fun decorate_tag
(v
, res
, token
)
879 assert p
isa AReassignFormExpr
881 var callsite
= p
.reassign_callsite
882 if callsite
== null then return null
883 return callsite
.infobox
(v
)
887 redef class AModuleName
888 redef fun decorate_tag
(v
, res
, token
)
891 if p
== null then return null
892 return p
.decorate_tag
(v
, res
, token
)
896 redef class AModuledecl
897 redef fun decorate_tag
(v
, res
, token
)
899 if not token
isa TId then return null
900 res
.add_class
("nc_def")
901 res
.add_class
("nc_m")
905 if mm
== null then return null
910 redef class AStdImport
911 redef fun decorate_tag
(v
, res
, token
)
913 if not token
isa TId then return null
914 res
.add_class
("nc_m")
916 if mm
== null then return null
920 redef class AAttrPropdef
921 redef fun decorate_tag
(v
, res
, token
)
923 if not token
isa TId then return null
924 res
.add_class
("nc_def")
925 var mpd
: nullable MPropDef
927 if mpd
== null then mpd
= mpropdef
928 if mpd
== null then return null
929 return mpd
.infobox
(v
)
934 redef fun make_tag
(v
)
937 res
.add_class
("nc_i")
942 redef fun make_tag
(v
)
944 var res
= new HTMLTag("span")
945 res
.add_class
("nc_def")
948 redef fun decorate_tag
(v
, res
, token
)
951 # nothing to decorate
956 if not p
isa AMethPropdef then return null
958 if mpd
== null then return null
959 return mpd
.infobox
(v
)
963 redef fun make_tag
(v
)
966 res
.add_class
("nc_a")
970 redef class AAttrFormExpr
971 redef fun decorate_tag
(v
, res
, token
)
973 if not token
isa TAttrid then return null
975 if p
== null then return null
976 return p
.intro
.infobox
(v
)
980 redef fun make_tag
(v
)
983 res
.add_class
("nc_t")
988 redef fun decorate_tag
(v
, res
, token
)
990 if not token
isa TClassid then return null
992 if mt
== null then return null
994 if mt
isa MFormalType then
995 res
.add_class
("nc_vt")
1000 redef class AFormaldef
1001 redef fun decorate_tag
(v
, res
, token
)
1003 if not token
isa TClassid then return null
1004 res
.add_class
("nc_vt")
1005 var mtype
= self.mtype
1006 if mtype
== null then return null
1007 return mtype
.infobox
(v
)
1010 redef class ATypePropdef
1011 redef fun decorate_tag
(v
, res
, token
)
1013 if not token
isa TClassid then return null
1014 res
.add_class
("nc_def")
1016 if md
== null then return null
1017 return md
.infobox
(v
)
1020 redef class TComment
1021 redef fun make_tag
(v
)
1025 res
.add_class
("nc_c")
1031 redef fun make_tag
(v
)
1033 var res
= new HTMLTag("span")
1034 res
.add_class
("nc_d")
1038 redef class TokenLiteral
1039 redef fun make_tag
(v
)
1042 res
.add_class
("nc_l")
1046 redef class ASuperstringExpr
1047 redef fun make_tag
(v
)
1049 var res
= new HTMLTag("span")
1050 res
.add_class
("nc_ss")
1054 redef class AStringFormExpr
1055 redef fun decorate_tag
(v
, res
, token
)
1057 # Workaround to tag strings
1058 res
.classes
.remove
("nc_l")
1059 res
.add_class
("nc_s")
1064 redef fun decorate_tag
(v
, res
, token
)
1067 if t
== null then return null