mmodule: Added support of package importation
authorFlorian Deljarry <deljarry.florian@gmail.com>
Sat, 17 Aug 2019 17:40:54 +0000 (13:40 -0400)
committerFlorian Deljarry <deljarry.florian@gmail.com>
Tue, 27 Aug 2019 21:27:07 +0000 (17:27 -0400)
Now when the imported `mmodules` is added to the `mmodule_importation_hierarchy`,
the `mmodules` package it's also added to `mpackage_importation_hierarchy`.

Signed-off-by: Florian Deljarry <deljarry.florian@gmail.com>

src/model/mmodule.nit

index a410236..ab71dce 100644 (file)
@@ -185,12 +185,19 @@ class MModule
                self.in_importation = model.mmodule_importation_hierarchy.add_node(self)
        end
 
-       # Register the imported modules (ie "import some_module")
+       # Register the imported modules (ie "import some_module") and packages importation graph
+       # In the same time it register the imported package
        # The visibility must be set with `set_visibility_for`.
        fun set_imported_mmodules(imported_mmodules: Array[MModule])
        do
                for m in imported_mmodules do
                        self.model.mmodule_importation_hierarchy.add_edge(self, m)
+                       var actual_mpackage = self.mpackage
+                       var imported_mpackage = m.mpackage
+                       if actual_mpackage != null and imported_mpackage != null then
+                               # Register the imported package
+                               self.model.mpackage_importation_graph.add_arc(actual_mpackage, imported_mpackage)
+                       end
                end
        end