///|
pub fn diagnostic_json_line(diagnostic : Diagnostic) -> String {
  let source = @source.SourceFile::new(diagnostic.file, "")
  render_report_json([diagnostic], source, diagnostic.file)
  .trim_end()
  .to_owned()
}

///|
pub fn DiagnosticReport::json(
  self : DiagnosticReport,
  source : @source.SourceFile,
) -> String {
  render_report_json(self.diagnostics, source, source.name())
}

///|
pub fn DiagnosticReport::sarif(
  self : DiagnosticReport,
  source : @source.SourceFile,
) -> String {
  render_sarif(self.diagnostics, source)
}

///|
pub fn DiagnosticReport::text(
  self : DiagnosticReport,
  source : @source.SourceFile,
) -> String {
  render_text(self.diagnostics, source)
}

///|
pub fn DiagnosticReport::has_warnings(self : DiagnosticReport) -> Bool {
  self.warnings > 0
}

///|
pub fn DiagnosticReport::has_infos(self : DiagnosticReport) -> Bool {
  self.infos > 0
}

///|
pub fn DiagnosticReport::highest_severity(self : DiagnosticReport) -> Severity? {
  if self.errors > 0 {
    Some(Error)
  } else if self.warnings > 0 {
    Some(Warning)
  } else if self.infos > 0 {
    Some(Info)
  } else {
    None
  }
}

///|
pub fn DiagnosticReport::filter(
  self : DiagnosticReport,
  minimum : Severity,
) -> DiagnosticReport {
  DiagnosticReport::new(filter_severity(self.diagnostics, minimum))
}

///|
pub fn DiagnosticReport::deduplicated(
  self : DiagnosticReport,
) -> DiagnosticReport {
  DiagnosticReport::new(deduplicate(self.diagnostics))
}