--- /dev/null
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Common SAX listeners for entity definitions.
+module doxml::entitydef
+
+import doc
+
+# Processes the content of an entity definition.
+abstract class EntityDefListener
+ super StackableListener
+
+ # The inner `TextListener`.
+ protected var text: TextListener is noinit
+
+ # The inner `DocListener`.
+ protected var doc: DocListener is noinit
+
+ # The inner `NoopListener`.
+ protected var noop: NoopListener is noinit
+
+ init do
+ super
+ text = new TextListener(reader, self)
+ doc = new DocListener(reader, self)
+ noop = new NoopListener(reader, self)
+ end
+
+ # The current entity.
+ protected fun entity: Entity is abstract
+
+ redef fun start_dox_element(local_name: String, atts: Attributes) do
+ if ["briefdescription", "detaileddescription", "inbodydescription"].has(local_name) then
+ doc.doc = entity.doc
+ doc.listen_until(dox_uri, local_name)
+ else if "location" == local_name then
+ entity.location = get_location(atts)
+ else
+ noop.listen_until(dox_uri, local_name)
+ end
+ end
+
+ redef fun end_listening do
+ super
+ entity.put_in_graph
+ end
+
+ # Parse the attributes of a `location` element.
+ protected fun get_location(atts: Attributes): Location do
+ var location = new Location
+
+ location.path = atts.value_ns("", "bodyfile") or else atts.value_ns("", "file")
+ # Doxygen may indicate `[generated]`.
+ if "[generated]" == location.path then location.path = null
+ var line_start = atts.value_ns("", "bodystart") or else atts.value_ns("", "line") or else null
+ if line_start != null then location.line_start = line_start.to_i
+ var line_end = atts.value_ns("", "bodyend")
+ if line_end != null then location.line_end = line_end.to_i
+ var column_start = atts.value_ns("", "column")
+ if column_start != null then location.column_start = column_start.to_i
+ if location.line_start == location.line_end then
+ location.column_end = location.column_start
+ end
+ return location
+ end
+end