From: Alexandre Terrasa Date: Sat, 20 Jul 2013 15:28:43 +0000 (-0400) Subject: ni_nitdoc: display inherited virtual types and constructors in class sidebar X-Git-Tag: v0.6.1~73^2~5^2~49 X-Git-Url: http://nitlanguage.org ni_nitdoc: display inherited virtual types and constructors in class sidebar Signed-off-by: Alexandre Terrasa --- diff --git a/src/model_utils.nit b/src/model_utils.nit index 4d8d615..2591da1 100644 --- a/src/model_utils.nit +++ b/src/model_utils.nit @@ -125,6 +125,17 @@ redef class MClass return res end + # Get the set of properties introduced in 'self'. + fun intro_mproperties: Set[MProperty] do + var res = new HashSet[MProperty] + for mclassdef in mclassdefs do + for mpropdef in mclassdef.mpropdefs do + if mpropdef.is_intro then res.add(mpropdef.mproperty) + end + end + return res + end + # Get the list of locally refined methods in 'self'. fun redef_methods: Set[MMethod] do var res = new HashSet[MMethod] @@ -138,6 +149,17 @@ redef class MClass return res end + # Get the set of locally refined properties in 'self'. + fun redef_mproperties: Set[MProperty] do + var res = new HashSet[MProperty] + for mclassdef in mclassdefs do + for mpropdef in mclassdef.mpropdefs do + if not mpropdef.is_intro then res.add(mpropdef.mproperty) + end + end + return res + end + # Get the list of methods inherited by 'self'. fun inherited_methods: Set[MMethod] do var res = new HashSet[MMethod] @@ -149,6 +171,17 @@ redef class MClass return res end + # Get the set of all properties inherited by self + fun inherited_mproperties: Set[MProperty] do + var res = new HashSet[MProperty] + for s in ancestors do + for m in s.intro_mproperties do + if not self.intro_mproperties.has(m) and not self.redef_mproperties.has(m) then res.add(m) + end + end + return res + end + # Get the list of all virtual types available in 'self'. fun virtual_types: Set[MVirtualTypeProp] do var res = new HashSet[MVirtualTypeProp] diff --git a/src/ni_nitdoc.nit b/src/ni_nitdoc.nit index b6232b3..35fe406 100644 --- a/src/ni_nitdoc.nit +++ b/src/ni_nitdoc.nit @@ -639,6 +639,10 @@ class NitdocClass private var mclass: MClass private var mbuilder: ModelBuilder private var nitdoc: Nitdoc + private var vtypes = new HashSet[MVirtualTypeDef] + private var consts = new HashSet[MMethodDef] + private var meths = new HashSet[MMethodDef] + private var inherited = new HashSet[MPropDef] init(mclass: MClass, nitdoc: Nitdoc, dot_dir: nullable String, source: nullable String) do self.mclass = mclass @@ -646,6 +650,35 @@ class NitdocClass self.nitdoc = nitdoc self.dot_dir = dot_dir self.source = source + # load properties + for mclassdef in mclass.mclassdefs do + for mpropdef in mclassdef.mpropdefs do + if mpropdef.mproperty.visibility <= none_visibility then continue + if mpropdef isa MVirtualTypeDef then vtypes.add(mpropdef) + if mpropdef isa MMethodDef then + if mpropdef.mproperty.is_init then + consts.add(mpropdef) + else + meths.add(mpropdef) + end + end + end + end + # get inherited properties + for mprop in mclass.inherited_mproperties do + var mpropdef = mprop.intro + if mprop.visibility <= none_visibility then continue + if mprop.intro_mclassdef.mclass.name == "Object" then continue + if mpropdef isa MVirtualTypeDef then vtypes.add(mpropdef) + if mpropdef isa MMethodDef then + if mpropdef.mproperty.is_init then + consts.add(mpropdef) + else + meths.add(mpropdef) + end + end + inherited.add(mpropdef) + end end redef fun head do @@ -684,30 +717,6 @@ class NitdocClass var sorter = new ComparableSorter[MPropDef] append("