src: misc typos, doc and warning fixes
[nit.git] / src / highlight.nit
index 6399c5e..66e1cd9 100644 (file)
@@ -25,7 +25,8 @@ class HighlightVisitor
        # The root of the HTML hierarchy
        var html = new HTMLTag("span")
 
-       # Is the HTML include a nested `<span class"{type_of_node}">` element for each `ANode` of the AST?
+       # Should the HTML include a nested `<span class"{type_of_node}">` element for each `ANode` of the AST?
+       #
        # Used to have a really huge and verbose HTML (mainly for debug)
        var with_ast = false is writable
 
@@ -62,7 +63,7 @@ class HighlightVisitor
        #
        # 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
+       fun hrefto(entity: MEntity): nullable String do return null
 
        init
        do
@@ -425,6 +426,13 @@ redef class MEntity
                end
                return (new HTMLTag("a")).attr("href", href).text(text)
        end
+
+       # Append an entry for the doc in the given infobox
+       private fun add_doc_to_infobox(res: HInfoBox)
+       do
+               var mdoc = mdoc_or_fallback
+               if mdoc != null then mdoc.fill_infobox(res)
+       end
 end
 
 redef class MModule
@@ -433,8 +441,7 @@ redef class MModule
                var res = new HInfoBox(v, "module {name}")
                res.href = v.hrefto(self)
                res.new_field("module").add(linkto(v))
-               var mdoc = self.mdoc
-               if mdoc != null then mdoc.fill_infobox(res)
+               add_doc_to_infobox(res)
                if in_importation.greaters.length > 1 then
                        var c = res.new_dropdown("imports", "{in_importation.greaters.length-1} modules")
                        for x in in_importation.greaters do
@@ -459,10 +466,9 @@ redef class MClassDef
                        res.new_field("redef class").text(mclass.name)
                        res.new_field("intro").add mclass.intro.linkto_text(v, "in {mclass.intro_mmodule.to_s}")
                end
-               var mdoc = self.mdoc
-               if mdoc == null then mdoc = mclass.intro.mdoc
-               if mdoc != null then mdoc.fill_infobox(res)
+               add_doc_to_infobox(res)
 
+               var in_hierarchy = self.in_hierarchy
                if in_hierarchy == null then return res
 
                if in_hierarchy.greaters.length > 1 then
@@ -498,10 +504,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)
@@ -511,9 +520,7 @@ redef class MPropDef
                else
                        res.new_field("intro").add mproperty.intro.linkto_text(v, "in {mproperty.intro.mclassdef}")
                end
-               var mdoc = self.mdoc
-               if mdoc == null then mdoc = mproperty.intro.mdoc
-               if mdoc != null then mdoc.fill_infobox(res)
+               add_doc_to_infobox(res)
                if mproperty.mpropdefs.length > 1 then
                        var c = res.new_dropdown("redef", "redefinitions")
                        for x in mproperty.mpropdefs do
@@ -531,9 +538,7 @@ redef class MClassType
                var res = new HInfoBox(v, to_s)
                res.href = v.hrefto(self)
                res.new_field("class").add mclass.intro.linkto(v)
-               var mdoc = mclass.mdoc
-               if mdoc == null then mdoc = mclass.intro.mdoc
-               if mdoc != null then mdoc.fill_infobox(res)
+               add_doc_to_infobox(res)
                return res
        end
        redef fun linkto(v)
@@ -547,10 +552,8 @@ redef class MVirtualType
                var res = new HInfoBox(v, to_s)
                res.href = v.hrefto(mproperty)
                var p = mproperty
-               var pd = p.intro
-               res.new_field("virtual type").add pd.linkto(v)
-               var mdoc = pd.mdoc
-               if mdoc != null then mdoc.fill_infobox(res)
+               res.new_field("virtual type").add p.intro.linkto(v)
+               add_doc_to_infobox(res)
                return res
        end
        redef fun linkto(v)
@@ -645,9 +648,7 @@ redef class CallSite
                else
                        res.new_field("intro").add mproperty.intro.linkto_text(v, "in {mproperty.intro.mclassdef}")
                end
-               var mdoc = mpropdef.mdoc
-               if mdoc == null then mdoc = mproperty.intro.mdoc
-               if mdoc != null then mdoc.fill_infobox(res)
+               add_doc_to_infobox(res)
 
                return res
        end
@@ -696,6 +697,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
@@ -704,6 +707,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
@@ -758,7 +763,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)
@@ -852,6 +857,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
@@ -860,6 +866,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
@@ -880,7 +887,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
 
@@ -993,6 +1002,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