-# File-system location of a module (file) that is identified but not always loaded.
-class ModulePath
- # The name of the module
- # (it's the basename of the filepath)
- var name: String
+redef class MModule
+ # The path of the module source
+ var filepath: nullable String = null
+
+ # Force the parsing of the module using `modelbuilder`.
+ #
+ # If the module was already parsed, the existing ASI is returned.
+ # Else the source file is loaded, and parsed and some
+ #
+ # The importation is not done by this
+ #
+ # REQUIRE: `filepath != null`
+ # ENSURE: `modelbuilder.parsed_modules.has(self)`
+ fun parse(modelbuilder: ModelBuilder): nullable AModule
+ do
+ # Already known and loaded? then return it
+ var nmodule = modelbuilder.mmodule2nmodule.get_or_null(self)
+ if nmodule != null then return nmodule
+
+ var filepath = self.filepath
+ assert filepath != null
+ # Load it manually
+ nmodule = modelbuilder.load_module_ast(filepath)
+ if nmodule == null then return null # forward error