package org.karaffe.compiler.phase.util;

import org.karaffe.compiler.phase.Phase;
import org.karaffe.compiler.util.CompilerContext;
import org.karaffe.compiler.util.report.Report;

public class ShowReportsPhase implements Phase {
  @Override
  public String getName() {
    return "show-reports";
  }

  @Override
  public void execute(CompilerContext context) {
    for (Report report : context.getReports()) {
      if (report.hasPosition()) {
        context.writeLine(report.getHeader() + " at " + report.getPosition());
      } else {
        context.writeLine(report.getHeader());
      }
      report.getBody().ifPresent(context::writeLine);
    }
  }
}

@@ -173,16 +173,68 @@
 .Report;
+%0Aimport org.karaffe.compiler.util.report.ReportType;
 %0A%0Apublic
@@ -454,24 +454,265 @@
 eports()) %7B%0A
+      String h;%0A      if (report.getReportType() == ReportType.ERROR) %7B%0A        h = %22ERROR %7C %22;%0A      %7D else if (report.getReportType() == ReportType.WARN) %7B%0A        h = %22WARN  %7C %22;%0A      %7D else %7B%0A        h = %22%22;%0A      %7D%0A      String title;%0A
       if (re
@@ -741,34 +741,24 @@
         
-context.writeLine(
+title = 
 report.g
@@ -799,17 +799,16 @@
 sition()
-)
 ;%0A      
@@ -828,26 +828,16 @@
     
-context.writeLine(
+title = 
 repo
@@ -850,17 +850,16 @@
 Header()
-)
 ;%0A      
@@ -856,24 +856,60 @@
 ();%0A      %7D%0A
+      context.writeLine(h + title);%0A
       report

Change report format