Search a module name from path lookpaths.

If found, the module is returned.

Property definitions

nitc :: loader $ ModelBuilder :: search_module_in_paths
	# Search a module `name` from path `lookpaths`.
	# If found, the module is returned.
	private fun search_module_in_paths(location: nullable Location, name: String, lookpaths: Collection[String]): nullable MModule
	do
		var name_no_version
		if name.has('=') then
			name_no_version = name.split('=').first
		else name_no_version = name

		var res = new ArraySet[MModule]
		for dirname in lookpaths do
			# Try a single module file
			var mp = identify_module((dirname/"{name}.nit").simplify_path)
			if mp != null then res.add mp
			# Try the default module of a group
			var g = identify_group((dirname/name).simplify_path)
			if g != null then
				scan_group(g)
				res.add_all g.mmodules_by_name(name_no_version)
			end
		end
		if res.is_empty then return null
		if res.length > 1 then
			toolcontext.error(location, "Error: conflicting module files for `{name}`: `{[for x in res do x.filepath or else x.full_name].join("`, `")}`")
		end
		return res.first
	end
src/loader.nit:291,2--317,4