src/astbuilder: Add new nodes makers
[nit.git] / contrib / neo_doxygen / src / doxml / entitydef.nit
index fd9ae68..aa6968c 100644 (file)
@@ -15,7 +15,7 @@
 # Common SAX listeners for entity definitions.
 module doxml::entitydef
 
-import doc
+import doc_listener
 
 # Processes the content of an entity definition.
 abstract class EntityDefListener
@@ -40,7 +40,7 @@ abstract class EntityDefListener
        # The current entity.
        protected fun entity: Entity is abstract
 
-       redef fun start_dox_element(local_name: String, atts: Attributes) do
+       redef fun start_dox_element(local_name, atts) do
                if ["briefdescription", "detaileddescription", "inbodydescription"].has(local_name) then
                        doc.doc = entity.doc
                        doc.listen_until(dox_uri, local_name)
@@ -57,8 +57,8 @@ abstract class EntityDefListener
        end
 
        # Parse the attributes of a `location` element.
-       protected fun get_location(atts: Attributes): Location do
-               var location = new Location
+       protected fun get_location(atts: Attributes): neo_doxygen::Location do
+               var location = new neo_doxygen::Location
 
                location.path = atts.value_ns("", "bodyfile") or else atts.value_ns("", "file")
                # Doxygen may indicate `[generated]`.
@@ -75,3 +75,55 @@ abstract class EntityDefListener
                return location
        end
 end
+
+# Processes the content of a `<param>` element.
+abstract class ParamListener[T: Parameter]
+       super EntityDefListener
+
+       # The current parameter.
+       var parameter: T is noinit
+
+       private var type_listener: TypeListener is noinit
+
+       init do
+               super
+               type_listener = new TypeListener(reader, self)
+       end
+
+       redef fun entity do return parameter
+
+       redef fun listen_until(uri, local_name) do
+               super
+               parameter = create_parameter
+       end
+
+       # Create a new parameter.
+       protected fun create_parameter: T is abstract
+
+       redef fun start_dox_element(local_name, atts) do
+               if "declname" == local_name then
+                       text.listen_until(dox_uri, local_name)
+               else if "type" == local_name then
+                       type_listener.listen_until(dox_uri, local_name)
+               else
+                       super
+               end
+       end
+
+       redef fun end_dox_element(local_name) do
+               if "declname" == local_name then
+                       parameter.name = text.to_s
+               else if "type" == local_name then
+                       source_language.apply_parameter_type(parameter, type_listener.linked_text)
+               else
+                       super
+               end
+       end
+end
+
+# Processes the content of a `<param>` element in a `<templateparamlist>` element.
+class TypeParamListener
+       super ParamListener[TypeParameter]
+
+       redef fun create_parameter do return new TypeParameter(graph)
+end