X-Git-Url: http://nitlanguage.org diff --git a/src/loader.nit b/src/loader.nit index 6149ffa..6caaf79 100644 --- a/src/loader.nit +++ b/src/loader.nit @@ -330,8 +330,21 @@ redef class ModelBuilder # Return the mgroup associated to a directory path. # If the directory is not a group null is returned. + # + # Note: `paths` is also used to look for mgroups fun get_mgroup(dirpath: String): nullable MGroup do + if not dirpath.file_exists then do + for p in paths do + var try = p / dirpath + if try.file_exists then + dirpath = try + break label + end + end + return null + end label + var rdp = module_absolute_path(dirpath) if mgroups.has_key(rdp) then return mgroups[rdp] @@ -508,6 +521,19 @@ redef class ModelBuilder end end + # Check for conflicting module names in the project + if mgroup != null then + var others = model.get_mmodules_by_name(mod_name) + if others != null then for other in others do + if other.mgroup!= null and other.mgroup.mproject == mgroup.mproject then + var node: ANode + if decl == null then node = nmodule else node = decl.n_name + error(node, "Error: A module named `{other.full_name}` already exists at {other.location}") + break + end + end + end + # Create the module var mmodule = new MModule(model, mgroup, mod_name, nmodule.location) nmodule.mmodule = mmodule @@ -515,6 +541,7 @@ redef class ModelBuilder self.mmodule2nmodule[mmodule] = nmodule if decl != null then + # Extract documentation var ndoc = decl.n_doc if ndoc != null then var mdoc = ndoc.to_mdoc @@ -523,6 +550,8 @@ redef class ModelBuilder else advice(decl, "missing-doc", "Documentation warning: Undocumented module `{mmodule}`") end + # Is the module a test suite? + mmodule.is_test_suite = not decl.get_annotations("test_suite").is_empty end return mmodule