rascal icon indicating copy to clipboard operation
rascal copied to clipboard

TODO: create a library function that can compute a root location from a module name

Open jurgenvinju opened this issue 2 years ago • 2 comments

It's hard to refer to resources in Rascal in a consistent manner.

  • For source projects the project scheme works, but that is different from after deployment.
  • For deployed projects the lib scheme works, but it can be ambiguous due to different versions of the same library at run-time

Proposal:

  • add to util::Reflective:
    • loc getModuleRoot("my::module::Name") - produces the result of looking for /my/module/Name.rsc in the interpreter's search path and returns the root src folder. For the compiler it will return getClass("my.module.Name").getResource("/")
    • loc getModuleResource("my::module::Name", myPath) will use the child location of getModuleRoot with myPath appended to it.

The idea would be that the behavior of this function would abstract from a project source or a deployed situation. In either situation the output loc is different (one is a project source directory, the other is inside a jar file), but the same files would be found.

The user must make sure that resources end up in the target folder in the right place to make the above true.

jurgenvinju avatar Jun 28 '23 14:06 jurgenvinju

I really don't know how to make this yet, without digging deep into interpreter specific dependency.

jurgenvinju avatar Jun 28 '23 14:06 jurgenvinju

It could be that an answer to #1827 makes this a lot easier. There could be several instances of the URIResolverRegistry singleton, each for an application in which module://moduleName would indeed resolve to a unique module path. Or getModuleRoot would have a unique resolution within that layer.

jurgenvinju avatar Jun 28 '23 14:06 jurgenvinju