ModuleNameResolver

class ModuleNameResolver(val moduleRoots: ModuleRoots)

A ModuleNameResolver resolves fully-qualified references to Avail modules to absolutefile references.

Assuming that the Avail module path comprises four module roots listed in the order S, P,Q, R, then the following algorithm is used for resolution of a fully-qualified reference R/X/Y/Z/M:

  1. Obtain the canonical name /R'/A/B/C/M' by applying an existing renaming rule for /R/X/Y/Z/M.

  2. If package /R'/A/B/C contains a module M', then capture its file reference F.

  3. If package /R'/A/B contains a module M', then capture its file reference F.

  4. If package /R'/A contains a module M', then capture its file reference F.

  5. If module root /R contains a module M', then capture its file reference F.

  6. If module root /S contains a module M', then capture its file reference F.

  7. If module root /P contains a module M', then capture its file reference F.

  8. If module root /Q contains a module M', then capture its file reference F.

  9. If the resolution succeeded and F specifies a directory, then replace the resolution with F/M'.avail. Verify that the resolution specifies an existing regular file.

  10. Otherwise, resolution failed.

An instance is obtained via RenamesFileParser.parse.

Author

Todd L Smith

Leslie Schultz

Richard Arriaga

Parameters

moduleRoots

The Avail module roots.

Constructors

Link copied to clipboard
fun ModuleNameResolver(moduleRoots: ModuleRoots)

Construct a new ModuleNameResolver.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class ModuleNameResolutionResult

This class was created so that, upon an UnresolvedDependencyException, the ModuleNameResolver could bundle information about the different paths checked for the missing file into the exception itself.

Functions

Link copied to clipboard
fun addRenameRule(modulePath: String, substitutePath: String)

Add a rule to translate the specified fully-qualified module name.

Link copied to clipboard
fun clearCache()

Clear all cached module resolutions. Also release all file locks on repositories and close them.

Link copied to clipboard
fun clearRenameRules()

Remove all rename rules.

Link copied to clipboard
fun commitRepositories()

Commit all dirty repositories.

Link copied to clipboard
fun destroy()

Release all external locks and handles associated with this resolver. It must not be used again.

Link copied to clipboard
fun resolve(qualifiedName: ModuleName, dependent: ResolvedModuleName? = null): ResolvedModuleName

Resolve a fully-qualified module name (as a reference to the local name made from within the package).

Properties

Link copied to clipboard
val moduleRoots: ModuleRoots
Link copied to clipboard
val renameRules: Map<String, String>

An immutable Map of all the module path renames.

Link copied to clipboard
val renameRulesInverted: Map<String, List<String>>

An immutable Map from module rename targets to sources.