Class LoadResolver

java.lang.Object
ca.mcscert.jpipe.compiler.model.Transformation<List<Command>, List<Command>>
ca.mcscert.jpipe.compiler.steps.transformations.LoadResolver

public final class LoadResolver extends Transformation<List<Command>, List<Command>>
Eliminates all 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:

  1. Resolve path relative to the directory of the file currently being compiled (taken from the CompilationContext.sourcePath()).
  2. Detect cycles: if the resolved path is already being compiled in the current call stack, report a FATAL and skip.
  3. Parse the referenced file up to and including ActionListProvider using a fresh CompilationContext tied to the sub-file.
  4. Recursively resolve any LoadResolver.LoadDirectives found in that sub-list.
  5. Prefix every model name in the expanded sub-list with ns + ":" via prefix(String, List).
  6. Splice the prefixed commands into the result in place of the LoadResolver.LoadDirective.

Diagnostics produced while compiling a sub-file are always forwarded to the parent CompilationContext, so the caller sees a unified error report.

  • Constructor Details

  • Method Details

    • run

      protected List<Command> run(List<Command> commands, CompilationContext ctx)
      Description copied from class: Transformation
      Business logic of this step. Must not return null; may throw any exception. Use ctx to report non-fatal diagnostics or inspect previously accumulated errors.
      Specified by:
      run in class Transformation<List<Command>, List<Command>>
      Parameters:
      commands - the value produced by the previous step.
      ctx - compilation context carrying the source path and diagnostic bag.
      Returns:
      the transformed value — never null.