- # First, look in groups of the module
- if mmodule != null then
- var mgroup = mmodule.mgroup
- while mgroup != null do
- var dirname = mgroup.filepath
- if dirname == null then break # virtual group
- if dirname.has_suffix(".nit") then break # singleton project
-
- # Second, try the directory to find a file
- var try_file = dirname + "/" + name + ".nit"
- if try_file.file_exists then
- var res = self.load_module(try_file.simplify_path)
- if res == null then return null # Forward error
- return res.mmodule.as(not null)
- end
-
- # Third, try if the requested module is itself a group
- try_file = dirname + "/" + name + "/" + name + ".nit"
- if try_file.file_exists then
- mgroup = get_mgroup(dirname + "/" + name)
- var res = self.load_module(try_file.simplify_path)
- if res == null then return null # Forward error
- return res.mmodule.as(not null)
- end
+ # First, look in groups
+ var c = mgroup
+ while c != null do
+ var dirname = c.filepath
+ if dirname == null then break # virtual group
+ if dirname.has_suffix(".nit") then break # singleton project
+
+ # Second, try the directory to find a file
+ var try_file = dirname + "/" + name + ".nit"
+ if try_file.file_exists then
+ var res = self.identify_file(try_file.simplify_path)
+ assert res != null
+ return res
+ end