X-Git-Url: http://nitlanguage.org diff --git a/src/highlight.nit b/src/highlight.nit index 757af93..8dd1637 100644 --- a/src/highlight.nit +++ b/src/highlight.nit @@ -60,11 +60,9 @@ class HighlightVisitor # It is used to refer to some specific entities when generating links. # If `null` is returned, then no link are generated and `` elements become ``. # - # Clients are encouraged to redefine the method in a subclass to control where entities should link to. - fun hrefto(entitiy: MEntity): nullable String - do - return entitiy.href - end + # By default, `null` is returned. + # Clients are therefore encouraged to redefine the method in a subclass to control where entities should link to. + fun hrefto(entitiy: MEntity): nullable String do return null init do @@ -171,7 +169,7 @@ class HighlightVisitor var stack = new Array[Prod] var line = 0 var c: nullable Token = first_token - var hv = new HighlightVisitor + var hv = self while c != null do var starting @@ -427,9 +425,6 @@ redef class MEntity end return (new HTMLTag("a")).attr("href", href).text(text) end - - # Default link - private fun href: nullable String do return null end redef class MModule @@ -450,12 +445,6 @@ redef class MModule return res end - # The module HTML page - redef fun href: String - do - return c_name + ".html" - end - redef fun linkto(v) do return linkto_text(v, name) end @@ -474,6 +463,7 @@ redef class MClassDef if mdoc == null then mdoc = mclass.intro.mdoc if mdoc != null then mdoc.fill_infobox(res) + var in_hierarchy = self.in_hierarchy if in_hierarchy == null then return res if in_hierarchy.greaters.length > 1 then @@ -501,12 +491,6 @@ redef class MClassDef end return res end - - # The class HTML page (an anchor in the module page) - redef fun href: String - do - return mmodule.href + "#" + to_s - end end redef class MPropDef @@ -515,10 +499,13 @@ redef class MPropDef var res = new HInfoBox(v, to_s) res.href = v.hrefto(self) if self isa MMethodDef then + var msignature = self.msignature if msignature != null then res.new_field("fun").append(mproperty.name).add msignature.linkto(v) else if self isa MAttributeDef then + var static_mtype = self.static_mtype if static_mtype != null then res.new_field("fun").append(mproperty.name).add static_mtype.linkto(v) else if self isa MVirtualTypeDef then + var bound = self.bound if bound != null then res.new_field("add").append(mproperty.name).add bound.linkto(v) else res.new_field("wat?").append(mproperty.name) @@ -540,12 +527,6 @@ redef class MPropDef return res end - - # The property HTML page (an anchor in the module page) - redef fun href: String - do - return self.mclassdef.mmodule.href + "#" + self.to_s - end end redef class MClassType @@ -719,6 +700,8 @@ redef class AQclassid redef fun decorate_tag(v, res, token) do if token != n_id then return null + var parent = self.parent + if parent == null then return null return parent.decorate_tag(v, res, token) end end @@ -727,6 +710,8 @@ redef class AQid redef fun decorate_tag(v, res, token) do if token != n_id then return null + var parent = self.parent + if parent == null then return null return parent.decorate_tag(v, res, token) end end @@ -781,7 +766,7 @@ end redef class Token # Produce an HTMLTag with the correct contents and CSS classes # Subclasses can redefine it to decorate the tag - redef fun make_tag(v: HighlightVisitor): HTMLTag + redef fun make_tag(v): HTMLTag do var res = new HTMLTag("span") res.text(text) @@ -875,6 +860,7 @@ end redef class ASendExpr redef fun decorate_tag(v, res, token) do + var callsite = self.callsite if callsite == null then return null return callsite.infobox(v) end @@ -883,6 +869,7 @@ end redef class ANewExpr redef fun decorate_tag(v, res, token) do + var callsite = self.callsite if callsite == null then return null return callsite.infobox(v) end @@ -903,7 +890,9 @@ end redef class AModuleName redef fun decorate_tag(v, res, token) do - return parent.decorate_tag(v, res, token) + var p = parent + if p == null then return null + return p.decorate_tag(v, res, token) end end @@ -1016,6 +1005,7 @@ redef class AFormaldef do if not token isa TClassid then return null res.add_class("nc_vt") + var mtype = self.mtype if mtype == null then return null return mtype.infobox(v) end