Class CollectDiagnostics

java.lang.Object
ca.mcscert.jpipe.compiler.model.Transformation<Unit, DiagnosticSnapshot>
ca.mcscert.jpipe.compiler.steps.transformations.CollectDiagnostics

public final class CollectDiagnostics extends Transformation<Unit, DiagnosticSnapshot>
Gathers everything a diagnostic report shows into a single DiagnosticSnapshot.

This is the one place that walks the Unit for reporting purposes. The renderers downstream (DiagnosticReport for text, JsonDiagnosticReport for JSON) consume the snapshot and never touch the model, which is what guarantees the two formats describe the same thing.

  • Constructor Details

    • CollectDiagnostics

      public CollectDiagnostics()
  • Method Details

    • run

      protected DiagnosticSnapshot run(Unit input, 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<Unit, DiagnosticSnapshot>
      Parameters:
      input - the value produced by the previous step.
      ctx - compilation context carrying the source path and diagnostic bag.
      Returns:
      the transformed value — never null.
    • snapshot

      public DiagnosticSnapshot snapshot(Unit input, CompilationContext ctx)
      Describes what a compilation produced and reported.

      Callable directly, and not only as a pipeline step, so that a compilation which aborted on a fatal diagnostic can still be reported on — pass an empty Unit for the models it never got to build.

      Parameters:
      input - the compiled unit; empty, never null, when the pipeline aborted.
      ctx - the context carrying diagnostics, statistics and actions.
      Returns:
      the render-agnostic report payload.