Merge: introduce nit_env.sh to setup the shell environement
[nit.git] / src / loader.nit
index 0ae8ff0..c80b6dc 100644 (file)
@@ -42,13 +42,13 @@ import ini
 
 redef class ToolContext
        # Option --path
-       var opt_path = new OptionArray("Set include path for loaders (may be used more than once)", "-I", "--path")
+       var opt_path = new OptionArray("Add an additional include path (may be used more than once)", "-I", "--path")
 
        # Option --only-metamodel
        var opt_only_metamodel = new OptionBool("Stop after meta-model processing", "--only-metamodel")
 
        # Option --only-parse
-       var opt_only_parse = new OptionBool("Only proceed to parse step of loaders", "--only-parse")
+       var opt_only_parse = new OptionBool("Only proceed to parse files", "--only-parse")
 
        redef init
        do
@@ -130,6 +130,7 @@ redef class ModelBuilder
                        if stat != null and stat.is_dir then
                                self.toolcontext.info("look in directory {a}", 2)
                                var fs = a.files
+                               alpha_comparator.sort(fs)
                                # Try each entry as a group or a module
                                for f in fs do
                                        var af = a/f
@@ -151,6 +152,11 @@ redef class ModelBuilder
 
                        var mmodule = identify_module(a)
                        if mmodule == null then
+                               if a.file_exists then
+                                       toolcontext.error(null, "Error: `{a}` is not a Nit source file.")
+                               else
+                                       toolcontext.error(null, "Error: cannot find module `{a}`.")
+                               end
                                continue
                        end
 
@@ -237,7 +243,9 @@ redef class ModelBuilder
                        end
                end
 
-               var candidate = search_module_in_paths(anode.hot_location, name, lookpaths)
+               var loc = null
+               if anode != null then loc = anode.hot_location
+               var candidate = search_module_in_paths(loc, name, lookpaths)
 
                if candidate == null then
                        if mgroup != null then
@@ -539,7 +547,9 @@ redef class ModelBuilder
                var p = mgroup.filepath
                # a virtual group has nothing to scan
                if p == null then return
-               for f in p.files do
+               var files = p.files
+               alpha_comparator.sort(files)
+               for f in files do
                        var fp = p/f
                        var g = identify_group(fp)
                        # Recursively scan for groups of the same package
@@ -647,6 +657,7 @@ redef class ModelBuilder
                var mmodule = new MModule(model, mgroup, mod_name, nmodule.location)
                nmodule.mmodule = mmodule
                nmodules.add(nmodule)
+               parsed_modules.add mmodule
                self.mmodule2nmodule[mmodule] = nmodule
 
                if parent!= null then