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
)
429 # Append an entry for the doc in the given infobox
430 private fun add_doc_to_infobox
(res
: HInfoBox)
432 var mdoc
= mdoc_or_fallback
433 if mdoc
!= null then mdoc
.fill_infobox
(res
)
440 var res
= new HInfoBox(v
, "module {name}")
441 res
.href
= v
.hrefto
(self)
442 res
.new_field
("module").add
(linkto
(v
))
443 add_doc_to_infobox
(res
)
444 if in_importation
.greaters
.length
> 1 then
445 var c
= res
.new_dropdown
("imports", "{in_importation.greaters.length-1} modules")
446 for x
in in_importation
.greaters
do
447 if x
== self then continue
448 c
.open
("li").add x
.linkto
(v
)
454 redef fun linkto
(v
) do return linkto_text
(v
, name
)
457 redef class MClassDef
460 var res
= new HInfoBox(v
, "class {mclass.name}")
461 res
.href
= v
.hrefto
(self)
463 res
.new_field
("class").text
(mclass
.name
)
465 res
.new_field
("redef class").text
(mclass
.name
)
466 res
.new_field
("intro").add mclass
.intro
.linkto_text
(v
, "in {mclass.intro_mmodule.to_s}")
468 add_doc_to_infobox
(res
)
470 var in_hierarchy
= self.in_hierarchy
471 if in_hierarchy
== null then return res
473 if in_hierarchy
.greaters
.length
> 1 then
474 var c
= res
.new_dropdown
("hier", "super-classes")
475 for x
in in_hierarchy
.greaters
do
476 if x
== self then continue
477 if not x
.is_intro
then continue
478 c
.open
("li").add x
.linkto
(v
)
481 if in_hierarchy
.smallers
.length
> 1 then
482 var c
= res
.new_dropdown
("hier", "sub-classes")
483 for x
in in_hierarchy
.smallers
do
484 if x
== self then continue
485 if not x
.is_intro
then continue
486 c
.open
("li").add x
.linkto
(v
)
489 if mclass
.mclassdefs
.length
> 1 then
490 var c
= res
.new_dropdown
("redefs", "refinements")
491 for x
in mclass
.mclassdefs
do
492 if x
== self then continue
493 c
.open
("li").add x
.linkto_text
(v
, "in {x.mmodule}")
503 var res
= new HInfoBox(v
, to_s
)
504 res
.href
= v
.hrefto
(self)
505 if self isa MMethodDef then
506 var msignature
= self.msignature
507 if msignature
!= null then res
.new_field
("fun").append
(mproperty
.name
).add msignature
.linkto
(v
)
508 else if self isa MAttributeDef then
509 var static_mtype
= self.static_mtype
510 if static_mtype
!= null then res
.new_field
("fun").append
(mproperty
.name
).add static_mtype
.linkto
(v
)
511 else if self isa MVirtualTypeDef then
512 var bound
= self.bound
513 if bound
!= null then res
.new_field
("add").append
(mproperty
.name
).add bound
.linkto
(v
)
515 res
.new_field
("wat?").append
(mproperty
.name
)
520 res
.new_field
("intro").add mproperty
.intro
.linkto_text
(v
, "in {mproperty.intro.mclassdef}")
522 add_doc_to_infobox
(res
)
523 if mproperty
.mpropdefs
.length
> 1 then
524 var c
= res
.new_dropdown
("redef", "redefinitions")
525 for x
in mproperty
.mpropdefs
do
526 c
.open
("li").add x
.linkto_text
(v
, "in {x.mclassdef}")
534 redef class MClassType
537 var res
= new HInfoBox(v
, to_s
)
538 res
.href
= v
.hrefto
(self)
539 res
.new_field
("class").add mclass
.intro
.linkto
(v
)
540 add_doc_to_infobox
(res
)
545 return mclass
.intro
.linkto
(v
)
548 redef class MVirtualType
551 var res
= new HInfoBox(v
, to_s
)
552 res
.href
= v
.hrefto
(mproperty
)
554 add_doc_to_infobox
(res
)
555 if mdoc
!= null then mdoc
.fill_infobox
(res
)
560 return mproperty
.intro
.linkto
(v
)
563 redef class MParameterType
566 var res
= new HInfoBox(v
, to_s
)
567 res
.new_field
("parameter type").append
("{name} from class ").add mclass
.intro
.linkto
(v
)
572 redef class MNullableType
575 return mtype
.infobox
(v
)
579 var res
= new HTMLTag("span")
580 res
.append
("nullable ").add
(mtype
.linkto
(v
))
585 redef class MNotNullType
588 return mtype
.infobox
(v
)
592 var res
= new HTMLTag("span")
593 res
.append
("not null ").add
(mtype
.linkto
(v
))
598 redef class MNullType
601 var res
= new HInfoBox(v
, to_s
)
606 var res
= new HTMLTag("span")
612 redef class MSignature
615 var res
= new HTMLTag("span")
617 if not mparameters
.is_empty
then
619 for p
in mparameters
do
627 res
.add p
.mtype
.linkto
(v
)
631 var ret
= return_mtype
634 res
.add ret
.linkto
(v
)
643 var res
= new HInfoBox(v
, "call {mpropdef}")
644 res
.href
= v
.hrefto
(mpropdef
)
645 res
.new_field
("call").add
(mpropdef
.linkto
(v
)).add
(msignature
.linkto
(v
))
646 if mpropdef
.is_intro
then
648 res
.new_field
("intro").add mproperty
.intro
.linkto_text
(v
, "in {mproperty.intro.mclassdef}")
650 add_doc_to_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 var parent
= self.parent
700 if parent
== null then return null
701 return parent
.decorate_tag
(v
, res
, token
)
706 redef fun decorate_tag
(v
, res
, token
)
708 if token
!= n_id
then return null
709 var parent
= self.parent
710 if parent
== null then return null
711 return parent
.decorate_tag
(v
, res
, token
)
715 redef class AStdClassdef
716 redef fun make_tag
(v
)
718 var res
= new HTMLTag("span")
719 res
.add_class
("nc_cdef")
721 if md
!= null then res
.attr
("id", md
.to_s
)
724 redef fun decorate_tag
(v
, res
, token
)
726 if not token
isa TClassid then return null
727 res
.add_class
("nc_def")
730 if md
== null then return null
735 redef fun make_tag
(v
)
737 var res
= new HTMLTag("span")
738 res
.add_class
("nc_pdef")
743 res
.attr
("id", mpd
.to_s
)
745 if self isa AAttrPropdef then
747 if mpd
!= null then res
.add
(tag
(mpd
))
749 if mpd
!= null then res
.add
(tag
(mpd
))
754 private fun tag
(mpd
: MPropDef): HTMLTag
756 var a
= new HTMLTag("a")
757 a
.attr
("id", mpd
.to_s
)
763 # Produce an HTMLTag with the correct contents and CSS classes
764 # Subclasses can redefine it to decorate the tag
765 redef fun make_tag
(v
): HTMLTag
767 var res
= new HTMLTag("span")
773 redef class TokenKeyword
774 redef fun make_tag
(v
)
777 res
.add_class
("nc_k")
781 redef class TokenOperator
782 redef fun make_tag
(v
)
785 res
.add_class
("nc_o")
790 redef class AVarFormExpr
791 redef fun decorate_tag
(v
, res
, token
)
793 if token
!= n_id
then return null
794 var variable
= self.variable
795 if variable
== null then return null
796 res
.add_class
("nc_v")
797 return variable
.infobox
(v
)
801 redef class AVardeclExpr
802 redef fun decorate_tag
(v
, res
, token
)
804 if token
!= n_id
then return null
805 var variable
= self.variable
806 if variable
== null then return null
807 res
.add_class
("nc_v")
808 return variable
.infobox
(v
)
812 redef class AForGroup
813 redef fun decorate_tag
(v
, res
, token
)
815 if not token
isa TId then return null
817 if vs
== null then return null
818 res
.add_class
("nc_v")
819 var idx
= n_ids
.index_of
(token
)
820 var variable
= vs
[idx
]
821 return variable
.infobox
(v
)
826 redef fun decorate_tag
(v
, res
, token
)
828 if token
!= n_id
then return null
830 if mp
== null then return null
831 var variable
= self.variable
832 if variable
== null then return null
833 res
.add_class
("nc_v")
834 return variable
.infobox
(v
)
838 redef class AAssertExpr
839 redef fun decorate_tag
(v
, res
, token
)
841 if not token
isa TId then return null
842 res
.add_class
("nc_ast")
848 redef fun decorate_tag
(v
, res
, token
)
850 if not token
isa TId then return null
851 res
.add_class
("nc_la")
856 redef class ASendExpr
857 redef fun decorate_tag
(v
, res
, token
)
859 var callsite
= self.callsite
860 if callsite
== null then return null
861 return callsite
.infobox
(v
)
866 redef fun decorate_tag
(v
, res
, token
)
868 var callsite
= self.callsite
869 if callsite
== null then return null
870 return callsite
.infobox
(v
)
874 redef class AAssignOp
875 redef fun decorate_tag
(v
, res
, token
)
878 assert p
isa AReassignFormExpr
880 var callsite
= p
.reassign_callsite
881 if callsite
== null then return null
882 return callsite
.infobox
(v
)
886 redef class AModuleName
887 redef fun decorate_tag
(v
, res
, token
)
890 if p
== null then return null
891 return p
.decorate_tag
(v
, res
, token
)
895 redef class AModuledecl
896 redef fun decorate_tag
(v
, res
, token
)
898 if not token
isa TId then return null
899 res
.add_class
("nc_def")
900 res
.add_class
("nc_m")
904 if mm
== null then return null
909 redef class AStdImport
910 redef fun decorate_tag
(v
, res
, token
)
912 if not token
isa TId then return null
913 res
.add_class
("nc_m")
915 if mm
== null then return null
919 redef class AAttrPropdef
920 redef fun decorate_tag
(v
, res
, token
)
922 if not token
isa TId then return null
923 res
.add_class
("nc_def")
924 var mpd
: nullable MPropDef
926 if mpd
== null then mpd
= mpropdef
927 if mpd
== null then return null
928 return mpd
.infobox
(v
)
933 redef fun make_tag
(v
)
936 res
.add_class
("nc_i")
941 redef fun make_tag
(v
)
943 var res
= new HTMLTag("span")
944 res
.add_class
("nc_def")
947 redef fun decorate_tag
(v
, res
, token
)
950 # nothing to decorate
955 if not p
isa AMethPropdef then return null
957 if mpd
== null then return null
958 return mpd
.infobox
(v
)
962 redef fun make_tag
(v
)
965 res
.add_class
("nc_a")
969 redef class AAttrFormExpr
970 redef fun decorate_tag
(v
, res
, token
)
972 if not token
isa TAttrid then return null
974 if p
== null then return null
975 return p
.intro
.infobox
(v
)
979 redef fun make_tag
(v
)
982 res
.add_class
("nc_t")
987 redef fun decorate_tag
(v
, res
, token
)
989 if not token
isa TClassid then return null
991 if mt
== null then return null
993 if mt
isa MFormalType then
994 res
.add_class
("nc_vt")
999 redef class AFormaldef
1000 redef fun decorate_tag
(v
, res
, token
)
1002 if not token
isa TClassid then return null
1003 res
.add_class
("nc_vt")
1004 var mtype
= self.mtype
1005 if mtype
== null then return null
1006 return mtype
.infobox
(v
)
1009 redef class ATypePropdef
1010 redef fun decorate_tag
(v
, res
, token
)
1012 if not token
isa TClassid then return null
1013 res
.add_class
("nc_def")
1015 if md
== null then return null
1016 return md
.infobox
(v
)
1019 redef class TComment
1020 redef fun make_tag
(v
)
1024 res
.add_class
("nc_c")
1030 redef fun make_tag
(v
)
1032 var res
= new HTMLTag("span")
1033 res
.add_class
("nc_d")
1037 redef class TokenLiteral
1038 redef fun make_tag
(v
)
1041 res
.add_class
("nc_l")
1045 redef class ASuperstringExpr
1046 redef fun make_tag
(v
)
1048 var res
= new HTMLTag("span")
1049 res
.add_class
("nc_ss")
1053 redef class AStringFormExpr
1054 redef fun decorate_tag
(v
, res
, token
)
1056 # Workaround to tag strings
1057 res
.classes
.remove
("nc_l")
1058 res
.add_class
("nc_s")
1063 redef fun decorate_tag
(v
, res
, token
)
1066 if t
== null then return null