Class DiagnosticRenderer

java.lang.Object
ca.mcscert.jpipe.compiler.model.Transformation<DiagnosticSnapshot, String>
ca.mcscert.jpipe.compiler.steps.transformations.DiagnosticRenderer
Direct Known Subclasses:
DiagnosticReport, JsonDiagnosticReport

public abstract class DiagnosticRenderer extends Transformation<DiagnosticSnapshot, String>
Common base of the diagnostic command's renderers.

Rendering is exposed as render(DiagnosticSnapshot), callable directly and not only as a pipeline step. That is what lets a compilation which aborted still be reported on: a fatal diagnostic stops the pipeline at the next Transformation.fire(I, CompilationContext) boundary (ADR-0016), so a report that could only be produced as a step could never describe the very failures it exists to report.

See Also:
  • Constructor Details

    • DiagnosticRenderer

      public DiagnosticRenderer()
  • Method Details

    • render

      public abstract String render(DiagnosticSnapshot snapshot)
      Renders a snapshot into the report text.
      Parameters:
      snapshot - what the compilation produced and reported.
      Returns:
      the rendered report.
    • run

      protected final String run(DiagnosticSnapshot 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<DiagnosticSnapshot, String>
      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.