X-Git-Url: http://nitlanguage.org diff --git a/contrib/neo_doxygen/src/model/member.nit b/contrib/neo_doxygen/src/model/member.nit index f29892e..05b82cb 100644 --- a/contrib/neo_doxygen/src/model/member.nit +++ b/contrib/neo_doxygen/src/model/member.nit @@ -18,55 +18,36 @@ module model::member import graph import type_entity -# A member. -abstract class Member +# A member or an inner class. +abstract class MemberOrInner super CodeBlock + # The type of the introducer. + type INTRODUCER_TYPE: MemberIntroducer + # The node used to represent the `MProperty` node. # # Only defined if `self` is at the root of a reimplementation graph, and # only once `put_in_graph` is called. - var introducer: nullable MemberIntroducer = null - - # Members that this member redefines/reimplements. - var reimplemented: SimpleCollection[String] = new Array[String] + var introducer: nullable INTRODUCER_TYPE = null init do super self.labels.add("MPropDef") end - # Set the static type. - fun static_type=(static_type: nullable TypeEntity) is abstract - - # Get the static type. - fun static_type: nullable TypeEntity is abstract - - # Append the specified parameter to the signature. - fun add_parameter(parameter: MemberParameter) do end - - # Append a member that is reimplemeneted by `self`. - fun reimplement(parent: String) do - reimplemented.add(parent) - end - # Does this member introduce the property? - fun is_intro: Bool do - return reimplemented.length <= 0 - end + fun is_intro: Bool is abstract redef fun put_in_graph do super self["is_intro"] = is_intro if is_intro then var visibility = self["visibility"] - var full_name = self["full_name"] var name = self["name"] introducer = create_introducer - if full_name isa String then - introducer.full_name = full_name - else if name isa String then + if name isa String then introducer.name = name end if visibility isa String then @@ -92,6 +73,15 @@ abstract class Member end end + # Get the visibility. + # + # Return `""` by default. + fun visibility: String do + var visibility = self["visibility"] + if visibility isa String then return visibility + return "" + end + redef fun name=(name: String) do super if introducer != null then @@ -99,28 +89,41 @@ abstract class Member end end - redef fun full_name=(full_name: String) do - super - if introducer != null then - introducer.as(not null).full_name = full_name - end - end + # Create an instance of `MemberIntroducer` that will be linked to `self`. + protected fun create_introducer: INTRODUCER_TYPE is abstract - redef fun parent_name=(parent_name: String) do - super - if introducer != null then - introducer.as(not null).parent_name = parent_name - end + # Find the nearest reimplementation root. + fun resolve_introducer: nullable INTRODUCER_TYPE is abstract +end + +# A member. +abstract class Member + super MemberOrInner + + # Members that this member redefines/reimplements. + var reimplemented: SimpleCollection[String] = new Array[String] + + # Set the static type. + fun static_type=(static_type: nullable TypeEntity) is abstract + + # Get the static type. + fun static_type: nullable TypeEntity is abstract + + # Append the specified parameter to the signature. + fun add_parameter(parameter: MemberParameter) do end + + # Append a member that is reimplemeneted by `self`. + fun reimplement(parent: String) do + reimplemented.add(parent) end + redef fun is_intro do return reimplemented.length <= 0 + # Is the member abstract? fun is_abstract=(is_abstract: Bool) do self["is_abstract"] = is_abstract end - # Create an instance of `MemberIntroducer` that will be linked to `self`. - protected fun create_introducer: MemberIntroducer is abstract - # Find the nearest reimplementation root. # # var g = new ProjectGraph("foo") @@ -139,7 +142,7 @@ abstract class Member # m3.reimplement("3") # m3.put_in_graph # assert m3.resolve_introducer == null - fun resolve_introducer: nullable MemberIntroducer do + redef fun resolve_introducer do if introducer == null then var member_queue = new List[String] var visited = new HashSet[Member] @@ -174,9 +177,12 @@ class UnknownMember redef fun put_edges do end end +# A local definition of a method. class Method super Member + redef type INTRODUCER_TYPE: MethodIntroducer + # The method’s signature. var signature: Signature is noinit, writable @@ -201,9 +207,7 @@ class Method signature.parameters.add(parameter) end - redef fun create_introducer: MemberIntroducer do - return new MethodIntroducer(graph) - end + redef fun create_introducer do return new MethodIntroducer(graph) redef fun put_in_graph do super @@ -216,9 +220,12 @@ class Method end end +# A local definition of an attribute. class Attribute super Member + redef type INTRODUCER_TYPE: AttributeIntroducer + # The declared type. redef var static_type: nullable TypeEntity = null is writable @@ -227,9 +234,7 @@ class Attribute self.labels.add("MAttributeDef") end - redef fun create_introducer: MemberIntroducer do - return new AttributeIntroducer(graph) - end + redef fun create_introducer do return new AttributeIntroducer(graph) redef fun put_in_graph do super @@ -256,9 +261,19 @@ abstract class MemberIntroducer self["visibility"] = "public" end + # Set the visibility. fun visibility=(visibility: String) do self["visibility"] = visibility end + + # Get the visibility. + # + # Return `""` by default. + fun visibility: String do + var visibility = self["visibility"] + if visibility isa String then return visibility + return "" + end end # A `MProperty` node for a method.