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 # Is the HTML include a nested `<span class"{type_of_node}">` element for each `ANode` of the AST?
29 # Used to have a really huge and verbose HTML (mainly for debug)
30 var with_ast
= false is writable
32 # Prefixes used in generated IDs for line `<span>` elements.
33 # Useful if more than one highlighted code is present in the same HTML document.
35 # If set to the empty string, id for lines are disabled.
37 # Is `"L"` by default.
38 var line_id_prefix
= "L" is writable
40 # The first line to generate, null if start at the first line
41 var first_line
: nullable Int = null is writable
43 # The last line to generate, null if finish at the last line
44 var last_line
: nullable Int = null is writable
46 # When highlighting a node, show its messages (errors, warnings), if any.
49 var show_messages
= true is writable
51 # When highlighting a node, attach a full popupable infobox, if any.
53 # If `false`, only a simple `title` tooltip is used.
56 var show_infobox
= true is writable
58 # A reference to an entity used in generated `<a>` elements.
60 # It is used to refer to some specific entities when generating links.
61 # If `null` is returned, then no link are generated and `<a>` elements become `<span>`.
63 # By default, `null` is returned.
64 # Clients are therefore encouraged to redefine the method in a subclass to control where entities should link to.
65 fun hrefto
(entitiy
: MEntity): nullable String do return null
69 html
.add_class
("nitcode")
72 # When highlighting a node, also consider the loose tokens around it.
74 # Loose tokens are tokens discarded from the AST but attached before
75 # or after some non-loose tokens. See `Token::is_loose`.
77 # When this flag is set to `true`, the loose tokens that are before the
78 # first token and after the last token are also highlighted.
81 var include_loose_tokens
= false is writable
83 # When highlighting a node, the first and the last lines are fully included.
85 # If the highlighted node starts (or ends) in the middle of a line,
86 # this flags forces the whole line to be highlighted.
89 var include_whole_lines
= false is writable
91 # The entry-point of the highlighting.
92 # Will fill `html` with the generated HTML content.
93 fun enter_visit
(n
: ANode)
106 if f
== null then return
108 if l
== null then return
111 if include_loose_tokens
then
112 if f
.prev_looses
.not_empty
then f
= f
.prev_looses
.first
113 if l
.next_looses
.not_empty
then l
= l
.next_looses
.last
116 if include_whole_lines
then
117 f
= f
.first_real_token_in_line
118 l
= l
.last_real_token_in_line
124 private fun full_tag
(anode
: ANode, hv
: HighlightVisitor): nullable HTMLTag
126 var tag
= anode
.make_tag
(hv
)
127 if tag
== null then return null
128 var infobox
= anode
.infobox
(hv
)
129 if infobox
== null and anode
isa Token then
130 var pa
= anode
.parent
132 infobox
= pa
.decorate_tag
(hv
, tag
, anode
)
135 if infobox
!= null and not show_infobox
then
136 tag
.attr
("title", infobox
.title
)
137 tag
.classes
.add
"titled"
140 var messages
= anode
.location
.messages
141 if messages
!= null and show_messages
then
142 tag
.css
("border-bottom", "solid 2px red")
143 if infobox
== null then
144 infobox
= new HInfoBox(hv
, "Messages")
146 var c
= infobox
.new_dropdown
("{messages.length} message(s)", "")
148 c
.open
("li").append
(m
.text
)
151 if infobox
!= null then
152 tag
.attach_infobox
(infobox
)
157 # Highlight a full lexed source file.
159 # REQUIRE `source.first_token != null`
160 fun hightlight_source
(source
: SourceFile)
162 htmlize
(source
.first_token
.as(not null), null)
165 # Produce HTML between two tokens
166 protected fun htmlize
(first_token
: Token, last_token
: nullable Token)
168 var stack2
= new Array[HTMLTag]
169 var stack
= new Array[Prod]
171 var c
: nullable Token = first_token
176 # Handle start of line
177 var cline
= c
.location
.line_start
178 if cline
!= line
then
179 # Handle starting block productions,
180 # Because c could be a detached token, get prods in
181 # the first AST token
182 var c0
= c
.first_token_in_line
184 if c0
!= null then starting
= c0
.starting_prods
185 if starting
!= null then for p
in starting
do
186 if not p
.is_block
then continue
187 var tag
= full_tag
(p
, hv
)
188 if tag
== null then continue
189 tag
.add_class
("foldable")
196 # Add a div for the whole line
197 var tag
= new HTMLTag("span")
198 var p
= line_id_prefix
199 if p
!= "" then tag
.attrs
["id"] = "{p}{cline}"
200 tag
.classes
.add
"line"
207 # Add the blank, verbatim
208 html
.add_raw_html c
.blank_before
210 # Handle starting span production
211 starting
= c
.starting_prods
212 if starting
!= null then for p
in starting
do
213 if not p
.is_span
then continue
214 var tag
= full_tag
(p
, hv
)
215 if tag
== null then continue
226 var tag
= full_tag
(c
, hv
)
227 if tag
!= null then html
.add tag
230 # Handle ending span productions
231 var ending
= c
.ending_prods
232 if ending
!= null then for p
in ending
do
233 if not p
.is_span
then continue
234 if stack
.is_empty
or p
!= stack
.last
then continue
239 # Handle end of line and end of file
241 if c
== last_token
then n
= null
242 if n
== null or n
.location
.line_start
!= line
then
243 # closes the line div
246 # close the block production divs
247 var c0
= c
.last_token_in_line
249 if c0
!= null then ending
= c0
.ending_prods
250 if ending
!= null then for p
in ending
do
251 if not p
.is_block
then continue
252 if stack
.is_empty
or p
!= stack
.last
then continue
260 #assert stack.is_empty
261 #assert stack2.is_empty
264 # Return a default CSS content related to CSS classes used in the `html` tree.
265 # Could be inlined in the `.html` file of saved as a specific `.css` file.
266 fun css_content
: String
269 .nitcode a { color: inherit; cursor:pointer; }
270 .nitcode .titled:hover { text-decoration: underline; } /* underline titles */
271 .nitcode .popupable:hover { text-decoration: underline; cursor:help; } /* underline titles */
272 .nitcode .foldable { display: block } /* for block productions*/
273 .nitcode .line{ display: block } /* for lines */
274 .nitcode .line:hover{ background-color: #FFFFE0; } /* current line */
275 .nitcode :target { background-color: #FFF3C2 } /* target highlight*/
276 /* lexical raw tokens. independent of usage or semantic: */
277 .nitcode .nc_c { color: gray; font-style: italic; } /* comment */
278 .nitcode .nc_d { color: #3D8127; font-style: italic; } /* documentation comments */
279 .nitcode .nc_k { font-weight: bold; } /* keyword */
280 .nitcode .nc_o {} /* operator */
281 .nitcode .nc_i {} /* standard identifier */
282 .nitcode .nc_t { color: #445588; font-weight: bold; } /* type/class identifier */
283 .nitcode .nc_a { color: #445588; font-style: italic; } /* old style attribute identifier */
284 .nitcode .nc_l { color: #009999; } /* char and number literal */
285 .nitcode .nc_s { color: #8F1546; } /* string literal */
286 /* syntactic token usage. added because of their position in the AST */
287 .nitcode .nc_ast { color: blue; } /* assert label */
288 .nitcode .nc_la { color: blue; } /* break/continue label */
289 .nitcode .nc_m { color: #445588; } /* module name */
290 /* syntactic groups */
291 .nitcode .nc_def { font-weight: bold; color: blue; } /* name used in a definition */
292 .nitcode .nc_def.nc_a { color: blue; } /* name used in a attribute definition */
293 .nitcode .nc_def.nc_t { color: blue; } /* name used in a class or vt definition */
294 .nitcode .nc_ss { color: #9E6BEB; } /* superstrings */
295 .nitcode .nc_cdef {} /* A whole class definition */
296 .nitcode .nc_pdef {} /* A whole property definition */
297 /* semantic token usage */
298 .nitcode .nc_v { font-style: italic; } /* local variable or parameter */
299 .nitcode .nc_vt { font-style: italic; } /* virtual type or formal type */
301 .nitcode .nc_error { border: 1px red solid;} /* not used */
302 .popover { max-width: 800px !important; }
306 # Additional content to inject in the <head> tag
307 # Note: does not include `css_content`; handle it yourself.
308 fun head_content
: String
310 return """<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">\n"""
313 # Additional content to inject just before the closing </body> tag
314 fun foot_content
: String
317 <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
318 <script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
319 <script>$(".popupable").popover({html:true, placement:'top'})/*initialize bootstrap popover*/</script>"""
324 # Attach the infobox to the node by using BootStrap popover
325 fun attach_infobox
(infobox
: HInfoBox)
327 classes
.add
("popupable")
328 attrs
["title"] = infobox
.title
329 var href
= infobox
.href
331 attrs
["data-title"] = """<a href="{{{href}}}">{{{infobox.title}}}</a>"""
333 attrs
["data-content"] = infobox
.content
.write_to_string
334 attrs
["data-toggle"] = "popover"
339 # A generic information container that can be used to decorate AST entities
341 # The visitor used for contextualisation, if needed
342 var visitor
: HighlightVisitor
344 # A short title for the AST element
347 # The primary link where the entity points
349 var href
: nullable String = null
351 # The content of the popuped infobox
352 var content
= new HTMLTag("div")
354 # Append a new field in the popuped infobox
355 fun new_field
(title
: String): HTMLTag
357 content
.open
("b").text
(title
)
359 var res
= content
.open
("span")
364 # Append a new dropdown in the popuped content
365 fun new_dropdown
(title
, text
: String): HTMLTag
367 content
.add_raw_html
"""<div class="dropdown"> <a data-toggle="dropdown" href="#"><b>"""
368 content
.append
(title
)
369 content
.add_raw_html
"</b> "
371 content
.add_raw_html
"""<span class="caret"></span></a>"""
372 var res
= content
.open
("ul").add_class
("dropdown-menu").attr
("role", "menu").attr
("aria-labelledby", "dLabel")
373 content
.add_raw_html
"</div>"
380 # Model entity or whatever that can produce an infobox
381 interface HInfoBoxable
382 # An new infobox documenting the entity
383 fun infobox
(v
: HighlightVisitor): HInfoBox is abstract
387 # Append an entry for the doc in the given infobox
388 fun fill_infobox
(res
: HInfoBox)
390 if content
.length
< 2 then
391 res
.new_field
("doc").text
(content
.first
)
394 var c
= res
.new_dropdown
("doc", content
.first
)
395 for x
in content
.iterator
.skip_head
(1) do
397 c
.add_raw_html
"<br>"
405 # A HTML version of `to_s` with hyper-links.
407 # By default, `linkto_text(v, to_s)` is used, c.f. see `linkto_text`.
409 # For some complex entities, like generic types, multiple `<a>` and `<span>` elements can be generated.
410 # E.g. `Array[Int]` might become `<a>Array</a>[<a>Int</a>]` with the correct `href` attributes
411 # provided by `v.hrefto`.
412 fun linkto
(v
: HighlightVisitor): HTMLTag do return linkto_text
(v
, to_s
)
414 # Link to the `self` with a specific text.
416 # The whole text is linked with a single `<a>` element.
418 # The `href` used is provided by `v.hrefto`.
419 # If `href` is null then a `<span>` element is used instead of `<a>`.
420 fun linkto_text
(v
: HighlightVisitor, text
: String): HTMLTag
422 var href
= v
.hrefto
(self)
424 return (new HTMLTag("span")).text
(text
)
426 return (new HTMLTag("a")).attr
("href", href
).text
(text
)
433 var res
= new HInfoBox(v
, "module {name}")
434 res
.href
= v
.hrefto
(self)
435 res
.new_field
("module").add
(linkto
(v
))
437 if mdoc
!= null then mdoc
.fill_infobox
(res
)
438 if in_importation
.greaters
.length
> 1 then
439 var c
= res
.new_dropdown
("imports", "{in_importation.greaters.length-1} modules")
440 for x
in in_importation
.greaters
do
441 if x
== self then continue
442 c
.open
("li").add x
.linkto
(v
)
448 redef fun linkto
(v
) do return linkto_text
(v
, name
)
451 redef class MClassDef
454 var res
= new HInfoBox(v
, "class {mclass.name}")
455 res
.href
= v
.hrefto
(self)
457 res
.new_field
("class").text
(mclass
.name
)
459 res
.new_field
("redef class").text
(mclass
.name
)
460 res
.new_field
("intro").add mclass
.intro
.linkto_text
(v
, "in {mclass.intro_mmodule.to_s}")
463 if mdoc
== null then mdoc
= mclass
.intro
.mdoc
464 if mdoc
!= null then mdoc
.fill_infobox
(res
)
466 if in_hierarchy
== null then return res
468 if in_hierarchy
.greaters
.length
> 1 then
469 var c
= res
.new_dropdown
("hier", "super-classes")
470 for x
in in_hierarchy
.greaters
do
471 if x
== self then continue
472 if not x
.is_intro
then continue
473 c
.open
("li").add x
.linkto
(v
)
476 if in_hierarchy
.smallers
.length
> 1 then
477 var c
= res
.new_dropdown
("hier", "sub-classes")
478 for x
in in_hierarchy
.smallers
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 mclass
.mclassdefs
.length
> 1 then
485 var c
= res
.new_dropdown
("redefs", "refinements")
486 for x
in mclass
.mclassdefs
do
487 if x
== self then continue
488 c
.open
("li").add x
.linkto_text
(v
, "in {x.mmodule}")
498 var res
= new HInfoBox(v
, to_s
)
499 res
.href
= v
.hrefto
(self)
500 if self isa MMethodDef then
501 if msignature
!= null then res
.new_field
("fun").append
(mproperty
.name
).add msignature
.linkto
(v
)
502 else if self isa MAttributeDef then
503 if static_mtype
!= null then res
.new_field
("fun").append
(mproperty
.name
).add static_mtype
.linkto
(v
)
504 else if self isa MVirtualTypeDef then
505 if bound
!= null then res
.new_field
("add").append
(mproperty
.name
).add bound
.linkto
(v
)
507 res
.new_field
("wat?").append
(mproperty
.name
)
512 res
.new_field
("intro").add mproperty
.intro
.linkto_text
(v
, "in {mproperty.intro.mclassdef}")
515 if mdoc
== null then mdoc
= mproperty
.intro
.mdoc
516 if mdoc
!= null then mdoc
.fill_infobox
(res
)
517 if mproperty
.mpropdefs
.length
> 1 then
518 var c
= res
.new_dropdown
("redef", "redefinitions")
519 for x
in mproperty
.mpropdefs
do
520 c
.open
("li").add x
.linkto_text
(v
, "in {x.mclassdef}")
528 redef class MClassType
531 var res
= new HInfoBox(v
, to_s
)
532 res
.href
= v
.hrefto
(self)
533 res
.new_field
("class").add mclass
.intro
.linkto
(v
)
534 var mdoc
= mclass
.mdoc
535 if mdoc
== null then mdoc
= mclass
.intro
.mdoc
536 if mdoc
!= null then mdoc
.fill_infobox
(res
)
541 return mclass
.intro
.linkto
(v
)
544 redef class MVirtualType
547 var res
= new HInfoBox(v
, to_s
)
548 res
.href
= v
.hrefto
(mproperty
)
551 res
.new_field
("virtual type").add pd
.linkto
(v
)
553 if mdoc
!= null then mdoc
.fill_infobox
(res
)
558 return mproperty
.intro
.linkto
(v
)
561 redef class MParameterType
564 var res
= new HInfoBox(v
, to_s
)
565 res
.new_field
("parameter type").append
("{name} from class ").add mclass
.intro
.linkto
(v
)
570 redef class MNullableType
573 return mtype
.infobox
(v
)
577 var res
= new HTMLTag("span")
578 res
.append
("nullable ").add
(mtype
.linkto
(v
))
583 redef class MNotNullType
586 return mtype
.infobox
(v
)
590 var res
= new HTMLTag("span")
591 res
.append
("not null ").add
(mtype
.linkto
(v
))
596 redef class MNullType
599 var res
= new HInfoBox(v
, to_s
)
604 var res
= new HTMLTag("span")
610 redef class MSignature
613 var res
= new HTMLTag("span")
615 if not mparameters
.is_empty
then
617 for p
in mparameters
do
625 res
.add p
.mtype
.linkto
(v
)
629 var ret
= return_mtype
632 res
.add ret
.linkto
(v
)
641 var res
= new HInfoBox(v
, "call {mpropdef}")
642 res
.href
= v
.hrefto
(mpropdef
)
643 res
.new_field
("call").add
(mpropdef
.linkto
(v
)).add
(msignature
.linkto
(v
))
644 if mpropdef
.is_intro
then
646 res
.new_field
("intro").add mproperty
.intro
.linkto_text
(v
, "in {mproperty.intro.mclassdef}")
648 var mdoc
= mpropdef
.mdoc
649 if mdoc
== null then mdoc
= mproperty
.intro
.mdoc
650 if mdoc
!= null then mdoc
.fill_infobox
(res
)
656 return mpropdef
.linkto
(v
)
664 var declared_type
= self.declared_type
665 if declared_type
== null then
666 var res
= new HInfoBox(v
, "{name}")
667 res
.new_field
("local var").append
("{name}")
670 var res
= new HInfoBox(v
, "{name}: {declared_type}")
671 res
.new_field
("local var").append
("{name}:").add
(declared_type
.linkto
(v
))
680 # Optionally creates a tag that encapsulate the AST element on HTML rendering
681 protected fun make_tag
(v
: HighlightVisitor): nullable HTMLTag do return null
683 # Add aditionnal information on a child-token and return an additionnal HInfoBox on it
684 protected fun decorate_tag
(v
: HighlightVisitor, res
: HTMLTag, token
: Token): nullable HInfoBox
686 #debug("no decoration for {token.inspect}")
687 #res.add_class("nc_error")
691 # Return a optional infobox
692 fun infobox
(v
: HighlightVisitor): nullable HInfoBox do return null
695 redef class AQclassid
696 redef fun decorate_tag
(v
, res
, token
)
698 if token
!= n_id
then return null
699 return parent
.decorate_tag
(v
, res
, token
)
704 redef fun decorate_tag
(v
, res
, token
)
706 if token
!= n_id
then return null
707 return parent
.decorate_tag
(v
, res
, token
)
711 redef class AStdClassdef
712 redef fun make_tag
(v
)
714 var res
= new HTMLTag("span")
715 res
.add_class
("nc_cdef")
717 if md
!= null then res
.attr
("id", md
.to_s
)
720 redef fun decorate_tag
(v
, res
, token
)
722 if not token
isa TClassid then return null
723 res
.add_class
("nc_def")
726 if md
== null then return null
731 redef fun make_tag
(v
)
733 var res
= new HTMLTag("span")
734 res
.add_class
("nc_pdef")
739 res
.attr
("id", mpd
.to_s
)
741 if self isa AAttrPropdef then
743 if mpd
!= null then res
.add
(tag
(mpd
))
745 if mpd
!= null then res
.add
(tag
(mpd
))
750 private fun tag
(mpd
: MPropDef): HTMLTag
752 var a
= new HTMLTag("a")
753 a
.attr
("id", mpd
.to_s
)
759 # Produce an HTMLTag with the correct contents and CSS classes
760 # Subclasses can redefine it to decorate the tag
761 redef fun make_tag
(v
: HighlightVisitor): HTMLTag
763 var res
= new HTMLTag("span")
769 redef class TokenKeyword
770 redef fun make_tag
(v
)
773 res
.add_class
("nc_k")
777 redef class TokenOperator
778 redef fun make_tag
(v
)
781 res
.add_class
("nc_o")
786 redef class AVarFormExpr
787 redef fun decorate_tag
(v
, res
, token
)
789 if token
!= n_id
then return null
790 var variable
= self.variable
791 if variable
== null then return null
792 res
.add_class
("nc_v")
793 return variable
.infobox
(v
)
797 redef class AVardeclExpr
798 redef fun decorate_tag
(v
, res
, token
)
800 if token
!= n_id
then return null
801 var variable
= self.variable
802 if variable
== null then return null
803 res
.add_class
("nc_v")
804 return variable
.infobox
(v
)
808 redef class AForGroup
809 redef fun decorate_tag
(v
, res
, token
)
811 if not token
isa TId then return null
813 if vs
== null then return null
814 res
.add_class
("nc_v")
815 var idx
= n_ids
.index_of
(token
)
816 var variable
= vs
[idx
]
817 return variable
.infobox
(v
)
822 redef fun decorate_tag
(v
, res
, token
)
824 if token
!= n_id
then return null
826 if mp
== null then return null
827 var variable
= self.variable
828 if variable
== null then return null
829 res
.add_class
("nc_v")
830 return variable
.infobox
(v
)
834 redef class AAssertExpr
835 redef fun decorate_tag
(v
, res
, token
)
837 if not token
isa TId then return null
838 res
.add_class
("nc_ast")
844 redef fun decorate_tag
(v
, res
, token
)
846 if not token
isa TId then return null
847 res
.add_class
("nc_la")
852 redef class ASendExpr
853 redef fun decorate_tag
(v
, res
, token
)
855 if callsite
== null then return null
856 return callsite
.infobox
(v
)
861 redef fun decorate_tag
(v
, res
, token
)
863 if callsite
== null then return null
864 return callsite
.infobox
(v
)
868 redef class AAssignOp
869 redef fun decorate_tag
(v
, res
, token
)
872 assert p
isa AReassignFormExpr
874 var callsite
= p
.reassign_callsite
875 if callsite
== null then return null
876 return callsite
.infobox
(v
)
880 redef class AModuleName
881 redef fun decorate_tag
(v
, res
, token
)
883 return parent
.decorate_tag
(v
, res
, token
)
887 redef class AModuledecl
888 redef fun decorate_tag
(v
, res
, token
)
890 if not token
isa TId then return null
891 res
.add_class
("nc_def")
892 res
.add_class
("nc_m")
896 if mm
== null then return null
901 redef class AStdImport
902 redef fun decorate_tag
(v
, res
, token
)
904 if not token
isa TId then return null
905 res
.add_class
("nc_m")
907 if mm
== null then return null
911 redef class AAttrPropdef
912 redef fun decorate_tag
(v
, res
, token
)
914 if not token
isa TId then return null
915 res
.add_class
("nc_def")
916 var mpd
: nullable MPropDef
918 if mpd
== null then mpd
= mpropdef
919 if mpd
== null then return null
920 return mpd
.infobox
(v
)
925 redef fun make_tag
(v
)
928 res
.add_class
("nc_i")
933 redef fun make_tag
(v
)
935 var res
= new HTMLTag("span")
936 res
.add_class
("nc_def")
939 redef fun decorate_tag
(v
, res
, token
)
942 # nothing to decorate
947 if not p
isa AMethPropdef then return null
949 if mpd
== null then return null
950 return mpd
.infobox
(v
)
954 redef fun make_tag
(v
)
957 res
.add_class
("nc_a")
961 redef class AAttrFormExpr
962 redef fun decorate_tag
(v
, res
, token
)
964 if not token
isa TAttrid then return null
966 if p
== null then return null
967 return p
.intro
.infobox
(v
)
971 redef fun make_tag
(v
)
974 res
.add_class
("nc_t")
979 redef fun decorate_tag
(v
, res
, token
)
981 if not token
isa TClassid then return null
983 if mt
== null then return null
985 if mt
isa MFormalType then
986 res
.add_class
("nc_vt")
991 redef class AFormaldef
992 redef fun decorate_tag
(v
, res
, token
)
994 if not token
isa TClassid then return null
995 res
.add_class
("nc_vt")
996 if mtype
== null then return null
997 return mtype
.infobox
(v
)
1000 redef class ATypePropdef
1001 redef fun decorate_tag
(v
, res
, token
)
1003 if not token
isa TClassid then return null
1004 res
.add_class
("nc_def")
1006 if md
== null then return null
1007 return md
.infobox
(v
)
1010 redef class TComment
1011 redef fun make_tag
(v
)
1015 res
.add_class
("nc_c")
1021 redef fun make_tag
(v
)
1023 var res
= new HTMLTag("span")
1024 res
.add_class
("nc_d")
1028 redef class TokenLiteral
1029 redef fun make_tag
(v
)
1032 res
.add_class
("nc_l")
1036 redef class ASuperstringExpr
1037 redef fun make_tag
(v
)
1039 var res
= new HTMLTag("span")
1040 res
.add_class
("nc_ss")
1044 redef class AStringFormExpr
1045 redef fun decorate_tag
(v
, res
, token
)
1047 # Workaround to tag strings
1048 res
.classes
.remove
("nc_l")
1049 res
.add_class
("nc_s")
1054 redef fun decorate_tag
(v
, res
, token
)
1057 if t
== null then return null