Class LoadResolver
LoadResolver.LoadDirectives from the command list by recursively
parsing each referenced file and splicing its prefixed commands in place.
LoadResolver runs after ActionListProvider and before
ActionListInterpretation, so the
ExecutionEngine always receives a flat list
that contains no LoadResolver.LoadDirectives.
Algorithm for each load "path" as ns directive found in the list:
- Resolve
pathrelative to the directory of the file currently being compiled (taken from theCompilationContext.sourcePath()). Whenpathis a glob pattern it expands to every matched file instead of one; its literal prefix is resolved the same way, so a pattern may point below that directory, above it (../library/*.jd) or at an absolute location — seeanchor(Path, String). - Detect cycles: if the resolved path is already being compiled in the current call stack, report a FATAL and skip.
- Parse the referenced file up to and including
ActionListProviderusing a freshCompilationContexttied to the sub-file. - Recursively resolve any
LoadResolver.LoadDirectives found in that sub-list. - Prefix every model name in the expanded sub-list with
ns + ":"viaprefix(String, List). - Splice the prefixed commands into the result in place of the
LoadResolver.LoadDirective.
Because step 3 gives every loaded file a CompilationContext of its
own, step 1 always resolves against the file that contains the
load — never against the file that started the compilation, and never
against the process working directory. A relative path therefore denotes the
same file wherever the compiler is invoked from, and a file that is loaded
from two different places still resolves its own loads against itself.
Diagnostics produced while compiling a sub-file are always forwarded to the
parent CompilationContext, so the caller sees a unified error report.
-
Nested Class Summary
Nested classes/interfaces inherited from class Transformation
Transformation.Step<I,O> -
Constructor Summary
ConstructorsConstructorDescriptionLoadResolver(OperatorRegistry operators, UnificationEquivalenceRegistry unificationEquivalences) -
Method Summary
-
Constructor Details
-
LoadResolver
public LoadResolver(OperatorRegistry operators, UnificationEquivalenceRegistry unificationEquivalences)
-
-
Method Details
-
run
Description copied from class:TransformationBusiness logic of this step. Must not returnnull; may throw any exception. Usectxto report non-fatal diagnostics or inspect previously accumulated errors.
-