tests: error_syntax errors on `? now
[nit.git] / contrib / neo_doxygen / src / model / module_compound.nit
index 069b50b..aca8dfc 100644 (file)
@@ -17,6 +17,7 @@ module model::module_compound
 
 import graph
 import class_compound
+import namespace_members
 
 # A source file.
 #
@@ -45,17 +46,12 @@ class FileCompound
                super
        end
 
-       redef fun name_separator: String do return "/"
-
-       redef fun location=(location: nullable Location) do
+       redef fun location=(location) do
                super
-               if location != null and location.path != null then
-                       full_name = location.path.as(not null)
-               end
                for m in inner_namespaces do m.location = location
        end
 
-       redef fun name=(name: String) do
+       redef fun name=(name) do
                # Example: `MyClass.java`
                super
                var match = name.search_last(".")
@@ -69,18 +65,18 @@ class FileCompound
                for m in inner_namespaces do m.update_name
        end
 
-       redef fun declare_namespace(id: String, full_name: String) do
+       redef fun declare_namespace(id, full_name) do
                var m: Module
 
                assert not full_name.is_empty or id.is_empty else
                        sys.stderr.write "Inner mamespace declarations without name are not yet supported (except for the root namespace).\n"
                end
                m = new Module(graph, self, new NamespaceRef(id, full_name))
-               m.location = self["location"].as(nullable Location)
+               m.location = location
                inner_namespaces.add m
        end
 
-       redef fun declare_class(id: String, full_name: String) do
+       redef fun declare_class(id, name, prot) do
                assert not id.is_empty else
                        sys.stderr.write "Inner class declarations without ID are not yet supported.\n"
                end
@@ -137,25 +133,43 @@ private class Module
                update_name
        end
 
-       # Update the `full_name` and the `name`.
+       # Update the `name`.
        #
        # Update the short name of the module to the `basename` of the file that
        # declares it.
-       fun update_name do
-               name = file_compound.basename
-               parent_name = namespace.full_name
-       end
+       fun update_name do name = file_compound.basename
 
        redef fun put_edges do
                var ns_compound = namespace.seek_in(graph)
+               var self_class = ns_compound.self_class
+               var class_count = 0
+               var last_class: nullable ClassCompound = null
+
                graph.add_edge(ns_compound, "DECLARES", self)
 
                for c in file_compound.inner_classes do
                        if graph.class_to_ns[c] != ns_compound then continue
                        var class_compound = graph.by_id[c].as(ClassCompound)
+                       last_class = class_compound
+                       class_count += 1
                        graph.add_edge(self, "INTRODUCES", class_compound)
                        graph.add_edge(self, "DEFINES", class_compound.class_def)
                end
+
+               if self_class isa SelfClass then
+                       # We assume that only one file is linked to the namespace.
+                       # TODO When Doxygen will provide a way to know which file defines which member, use it.
+                       self_class.location = file_compound.location
+                       graph.add_edge(self, "INTRODUCES", self_class)
+                       graph.add_edge(self, "DEFINES", self_class.class_def)
+               end
+
+               if doc.is_empty and class_count == 1 then
+                       doc = last_class.as(not null).doc
+               end
+               if doc.is_empty then doc = file_compound.doc
+               if doc.is_empty then doc = ns_compound.doc
+               if not doc.is_empty then set_mdoc
        end
 end