Merge: Nitsmell : Adding new code smells and print console updated
[nit.git] / lib / gen_nit.nit
index a9dc0ed..c80229b 100644 (file)
@@ -52,8 +52,15 @@ class NitModule
        # The module's name
        var name: Writable is writable
 
-       # Imports from this module
-       var imports = new Array[Writable]
+       # Annotations on the module declaration
+       var annotations = new Array[Writable]
+
+       # Importation declarations
+       #
+       # Accepts two formats:
+       # * Module name only, short or qualified: `json`, `gamnit::flat`, etc.
+       # * Full importation declaration: `import json`, `private import gamnit::flat`, etc.
+       var imports = new Set[Writable]
 
        # Main content of this module
        var content = new Array[Writable]
@@ -64,9 +71,23 @@ class NitModule
                if header != null then add header
 
                var name = name
-               add "module {name}\n\n"
+               if annotations.is_empty then
+                       add "module {name}\n\n"
+               else
+                       add "module {name} is\n"
+                       for annotation in annotations do add "\t{annotation}\n"
+                       add "end\n\n"
+               end
 
-               for i in imports do add "import {i}\n"
+               for i in imports do
+                       if i.to_s.has("import ") then
+                               add i
+                       else
+                               add "import "
+                               add i
+                       end
+                       add "\n"
+               end
                add "\n"
 
                for l in content do